akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;




int main(){
    string s; cin >> s;
    int sum=0;
    for(int i=0;i<(int)s.length();i++) sum+=s[i]-'0';
    if(sum%9==0) cout << "Yes";
    else cout << "No";
    cout << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,d,x;
    int sum = 0;
    int coe=0;
    cin >> n >> d >> x;
    int a[n];
    rep(i,n)cin >> a[i];
    rep(i,n){
        coe = 0;
        while(coe*a[i]+1<=d){
            sum++;
            coe++;
        }
    }
    
    cout << sum + x;
    
	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
const ll infty = 1000000007;

int N;
ll x[200010];
ll y[200010];

typedef pair<ll, int> state;

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> x[i] >> y[i];
    if (x[i] < y[i]) swap(x[i], y[i]);
  }
  ll maxi = 0;
  int maxi_ind;
  ll mini = infty;
  int mini_ind;
  for (auto i = 0; i < N; ++i) {
    if (maxi < x[i]) {
      maxi = x[i];
      maxi_ind = i;
    }
    if (mini > y[i]) {
      mini = y[i];
      mini_ind = i;
    }
  }
  ll x_mini = infty;
  ll y_maxi = 0;
  for (auto i = 0; i < N; ++i) {
    x_mini = min(x_mini, x[i]);
    y_maxi = max(y_maxi, y[i]); 
  }
  ll ans = (maxi - x_mini) * (y_maxi - mini);
  for (auto i = 0; i < N; ++i) {
    if (i == maxi_ind) continue;
    if (mini == y[i]) {
      mini_ind = i;
    }
  }
  if (maxi_ind != mini_ind) {
    set<state> hako;
    ll ub = x[mini_ind];
    ll lb = y[maxi_ind];
    if (ub < lb) swap(ub, lb);
    for (auto i = 0; i < N; ++i) {
      if (i != maxi_ind && i != mini_ind) {
        hako.insert(state(y[i], i));
      }
    }
    hako.insert(state(ub, -1));
    hako.insert(state(lb, -1));
    ll under = infty;
    while (true) {
      auto last = hako.end();
      last--;
      under = min(under, (*last).first - (*hako.begin()).first);
      int ind = (*hako.begin()).second;
      if (ind != -1) {
        hako.erase(hako.begin());
        hako.insert(state(x[ind], -1));
      } else {
        break;
      }
    }
    ans = min(ans, under * (maxi - mini));
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 4005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}

int64 N;
void Solve() {
	read(N);
	for(int64 i = 1 ; i <= 3500 ; ++i) {
		for(int64 j = 1 ; j <= 3500 ; ++j) {
			int64 t = 4 * i * j - N * j - N * i;
			if(t <= 0) {continue;}
			int64 s = N * i * j;
			if(s % t == 0) {
				out(s / t);space;out(i);space;out(j);enter;
				return ;
			}
		}
	}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

int main()
{
  int q;
  while (~scanf("%d", &q)) {
    if (q == -1)
      break;

    double x = q / 2.0;
    while (std::abs(x*x*x-q) >= 0.00001*q)
      x = x - ((x*x*x-q) / (3*x*x));
    printf("%f\n", x);
  }
  return 0;
}

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


#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define for(i, m, n) for(int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl;
typedef long long ll;

constexpr ll INF = 1'010'000'000'000'000'017LL;\
constexpr ll MOD = 1'000'000'007LL;\
constexpr double EPS = 1e-12;\
constexpr double PI = 3.14159265358979323846;

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

Measured memory_bytes: 256
//Bismillahir rahmanir Rahim
//sajeedreefy
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long int n,x,s,i,count=0;
    cin >> n;
    vector <long long int> vec(n);
    for(i=0;i<n;i++)
    {
        cin >> vec[i];
    }
    for(i=1;i<n;i++)
    {
        if(vec[i]<vec[i-1])
        {
            x=vec[i-1]-vec[i];
            count=count+x;
            vec[i]=vec[i]+x;
        }
    }
    cout << count << "\n";
    return 0;

}



Measured memory_bytes: 4784
from math import sqrt, cos
a, b, h, m = map(int, input().split())

pi = 3.141592653589793238
tmp = abs(m*6-(h*30+m/2))
arg = min(tmp, 360-tmp)

print(sqrt(a**2+b**2-2*a*b*cos(arg*pi/180)))

Measured memory_bytes: 62432
#include <iostream>
#include <map>
#include <string>

using namespace std;

map<string, int> cnt;
string ans[2];
int num_max;
int main() {
    string str;
    while (cin >> str) {
        cnt[str]++;
    }

    for (auto e : cnt) {
        if (num_max < e.second) {
            ans[0] = e.first;
            num_max = e.second;
        }
        if (ans[1].size() < e.first.size()) {
            ans[1] = e.first;
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
}

Measured memory_bytes: 3012
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, const char * argv[]) {
 
 
 
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    /////////////////////
    long long int n,i,sum = 0;
    
    cin >>n;
    
    for(i = 1;i <= n;i++){
        if(i%3==0 || i%5 == 0){
            
        }
        else
            sum = sum+ i;
        
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC084A
{
    class Program
    {
        static void Main(string[] args)
        {
            int M,x,a;
            M = int.Parse(Console.ReadLine());
            a = 24 - M;
            x = 24 + a;
            Console.WriteLine(x);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092
# 定数
INF = 10e3

include Math
# 2D平面の点の構造体
# 原点からの距離を計算するメソッドを持つ
P = Struct.new(:x,:y) do
  def dist
    Math.sqrt(x*x+y*y)
  end
end

# 入力
N = gets.to_i
red = []
blue = []
a = []
b = []
N.times do |i|
  a[i], b[i] = gets.split.map(&:to_i)
  red[i] = P.new(a[i], b[i])
end
c = []
d = []
N.times do |i|
  c[i], d[i] = gets.split.map(&:to_i)
  blue[i] = P.new(c[i], d[i])
end

# 赤点をy座標で降順ソート
red = red.sort{
  |p1,p2| p2.y <=> p1.y
}

partner = {}
# redの各点をy座標の降順で見ていく
red.each do |r|
  pair_di = INF
  blue.each do |b|
    # ペアの条件を満たすならば
    if r.x < b.x && r.y < b.y
      # rとの距離が最小のbをマッチさせる
      if b.x < pair_di
        pair_di = b.x
        partner[r] = b
      end
    end
  end
  # puts "#{r} #{partner[r]}"
  if partner[r] != nil
    blue.delete_at(blue.find_index(partner[r]))
  end
end

# puts "#{partner}"
puts partner.size

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

using namespace std;

typedef long long ll;

const ll INF = ll(1e18) + 1;




int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll l = -INF, r = INF;
    while(l+1<r)
    {
        ll mid = (l + r) / 2;//半分
        bool ok = [&] {
            ll total = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i]<0)
                {
                    int ok = n,
                        ng = -1;
                    while(ok-ng>1)
                    {
                        int c = (ok + ng) / 2;
                        if (a[c] * a[i] < mid)
                        {
                            ok = c;
                        }
                        else
                        {
                            ng = c;
                        }
                    }
                    total += n-ok;
                }
                else
                {
                    int ok = -1,
                        ng = n;
                    while(ng-ok>1)
                    {
                        int c = (ok + ng) / 2;
                        if (a[c] * a[i] < mid)
                        {
                            ok = c;
                        }
                        else
                        {
                            ng = c;
                        }
                    }
                    total += ok + 1;//0-originなので
                }
                if(a[i]*a[i]<mid)
                {
                    total--;
                }
            }
            total /= 2;
            return total < k;
        }();
        if(ok)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
ll a[105];
int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0,x=0,y=0,z=0;
    cin>>n;
    for(l=2; l<=n; l++)
    {
        r=l;
        for(i=2; i<=(r/i); i++)
        {
            while(r%i==0)
            {
                r/=i;
                a[i]++;
            }
        }
        if(r>1)
        {
            a[r]++;
        }
    }
    l=0,r=0;
    for(i=2; i<=n; i++)
    {
        if(a[i]>=74)
        {
            z++;
        }
        if(a[i]>=24)
        {
            x++;
        }
        if(a[i]>=14)
        {
            y++;
        }
        if(a[i]>3)
        {
            r++;
        }
        if(a[i]>1)
        {
            l++;
        }
    }
    s=z+x*(l-1)+y*(r-1)+(r*(r-1)*(l-2))/2;
    cout<<s<<"\n";
    return 0;
}

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

Measured memory_bytes: 576
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
int n,m,used[100005],f;
vector <int> ve[100005];
void dfs(int x,int v){
	used[x]=v;
	for (int i=0;i<ve[x].size();i++){
		if (used[ve[x][i]]==v){
			f=true;
		}
		if (!used[ve[x][i]]){
			if (v==1){
				dfs(ve[x][i],2);
			}else{
				dfs(ve[x][i],1);
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		ve[a].push_back(b);
		ve[b].push_back(a);  
	}
	dfs(1,1);
	if (f){
		cout<<ll(ll(ll(ll(n)*ll((n-1)))/2)-m);
	}else{
		int b=0,w=0;
		for (int i=1;i<=n;i++){
			if (used[i]==1){
				b++;
			}else{
				w++;
			}
		}
		cout<<ll(ll(w)*ll(b)-m);
	}
}

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

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	if((a+b)<=2*c){
		cout <<(a*x+b*y) <<endl;
	}
	else if(x==y){
		cout <<(2*(x*c)) <<endl;
	}
	else if(x>y){
		if(a>=2*c){
			cout << (2*(x*c)) << endl;
		}
		else{
			cout << (2*(y*c)+(x-y)*a) << endl;
		}
	}
	else{
		if(b>=2*c){
			cout << (2*(y*c)) << endl;
		}
		else{
			cout << (2*(x*c)+(y-x)*b) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[3005][3005];

int main(){
  int n,s;
  cin >> n >> s;
  int a[n];
  rep(i,n)cin >> a[i];
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=s;j++){
      if(j==0){
        dp[i][j]=i+1;
        continue;
      }
      dp[i][j]+=dp[i-1][j];
      if(j-a[i-1]>=0)dp[i][j]+=dp[i-1][j-a[i-1]];
    }
  }
  mint ans = 0;
  rep(i,n+1)ans += dp[i][s];
  // rep(i,n+1){
  //   rep(j,s+1){
  //     cout << dp[i][j];
  //   }
  //   cout << endl;
  // }
  cout << ans << endl;
}

Measured memory_bytes: 70784
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);

	int A[100001];
	for (int i = 0; i < N+1; i++){
		scanf("%d", A + i);
	}

	int carry = 0;
	long long int ret = 0;
	for (int i = 0; i < N; i++){
		int B; scanf("%d", &B);
		ret += (long long int)min(A[i], B + carry);
		carry = min(B,max(0, B - (A[i]-carry)));
	}
	ret += (long long int)min(A[N], carry);

	printf("%lld", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

#define deb(a)    cout<<__LINE__<<"# "<<#a<<" -> "<<a<<endl;
#define pb push_back
#define OO 2e9+10

#define ConPnt(a)   {for(auto it: a){cout<<it<<", ";}cout<<endl;}
#define MapPnt(a)   {for(auto it: a){cout<<it.first<<": "<<it.second<<", ";}cout<<endl;}

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

template<class T> T abs(T x){
    if(x<0) return -x;
    return x;
}
template<class T>T sqr(T a){
    return a*a;
}

const double pi = acos(-1.0);
const double eps = 1e-8;


int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,k,ans,x;
    while(2==scanf("%d%d",&n,&k))
    {
        for(i=0;i<n;i++)
            scanf("%d",&x);
        int ans = 1;
        if(k==n)
        {
            printf("%d\n",ans);
            continue;
        }
        n-=k;
        ans += (n+k-2)/(k-1);

        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e12;
int main()
{
 ll n,p;
 cin>>n>>p;
 ll sum=1;
  for(ll i=2;i*i<=p;i++)
  {
      if(p%i==0){
        ll cnt=0;
        while(p%i==0){
            cnt++;
            p/=i;
        }
        for(ll j=1;j<=cnt/n;j++) sum*=i;

      }
  }

if(n==1)sum*=p;
 cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    for(int i=0; i<int(s.length()); i++){
        if(i%2==0){
            if(s[i]=='L'){
                ans = "No";
            }
        }else{
            if(s[i]=='R'){
                ans = "No";
            }
        }
    }
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
    
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
    
using namespace std;
    
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;
    

    
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);
    
    string S, T;
    cin>>S;
    cin>>T;

    vector<int> subsequencias;

    for(int i = 0; i<S.size(); ++i){
        if(i+T.size() > S.size()) break;
        int cont_equal = 0;
        for(int j = 0; j<T.size(); ++j){
            if(S[i+j] != T[j]) cont_equal++;
        }
        subsequencias.push_back(cont_equal);
    }

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

    cout<<subsequencias[0]<<endl;

    return 0;   
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef double long db;
ll a[200005],n,k;
bool check(ll x){
    ll sum=0;
    for(ll i=1;i<=n;i++){
        sum+=(a[i]+x-1)/x-1;
    }
    return sum<=k;
}
int main(){
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    ll l=1,r=2e9;
    while(r>=l){
        ll mid=(l+r)/2;
        if(check(mid)) r=mid-1;
        else l=mid+1;
    }
    cout<<r+1<<endl;
}

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


void solve(long long N, long long K, std::vector<long long> h){
  vector<long long> dp(N);

  for(long long i = 1; i < N; i++) {
    long long mymin = INT_MAX;

    for(long long j = min(K, i); j >= 1; j--) {
      mymin = min(mymin, dp[i-j]+abs(h[i]-h[i-j]));
    }

    dp[i] = mymin;
  }

  cout << dp[N-1] << endl;
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int vis[MAXN], an[MAXN], dis[MAXN];
vector<vector<int> > adj(MAXN);

int main(){
  fio();
  int n,m; cin>>n>>m;
  forn(i,m){
  	int u,v; cin>>u>>v;
  	adj[u].pb(v);
  	adj[v].pb(u);
  }
  for1(i,n) dis[i] = 1e9;
  queue <pair<int,int>> q;
  q.push({1,0});
  dis[1] = 0;
  while(!q.empty()){
  	auto y = q.front();
  	q.pop();
  	int x = y.fi;
  	if(vis[x]) continue;
  	vis[x] = 1;
  	an[x] = y.se;
  	for(auto i:adj[x]){
  		if(!vis[i]){
  			q.push({i,x});
  		}
  	}
  }
  int chk = 1;
  for(int i=2;i<=n;i++) chk&=(an[i]>=1);
  if(chk){
  	cout<<"Yes"<<endl;
  	for(int i=2;i<=n;i++) cout<<an[i]<<endl;
  }
  else cout<<"No"<<endl;
  return 0;
}

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

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
ll knap(ll W,ll wt[],ll val[],ll n){
    ll i, w; 
    ll K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
    return K[n][W];
}


int main(){
    boost();
    ll n,w;
    cin >> n >> w;
    ll arr1[n],arr2[n];
    ll i;
    for(i=0;i<n;i++)
    cin >> arr1[i] >> arr2[i];
    
    cout << knap(w,arr1,arr2,n);
    
    
}

Measured memory_bytes: 82488
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

string GetString(int a, int b) {
  string S;
  char ch = '0' + b;
  for (int i = 0; i < a; ++i) {
    S += ch;
  }
  return S;
}

int main() {
  int a, b;
  cin >> a >> b;
  string S = GetString(a, b);
  string T = GetString(b, a);
  cout << min(S, T) << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int a;
	long long int b[100000],c[100000],d[100000];
	cin>>a;
	long int counter=0;
	for(int i=0;i<a;i++)
	{
		cin>>b[i]>>c[i];
		counter-=c[i];
		d[i]=b[i]+c[i];
	}
	sort(d,d+a);
	for(int i=0;i<(a+1)/2;i++)
	{
		counter+=d[a-1-2*i];
	}
	cout<<counter;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,k; cin >> n >> k;
  cout << min(n%k,k-n%k) << endl;
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
  	string s; cin>>s;
  	if(n % 2 != 0) cout << "No" << endl;
  	else{
      int mid = n/2;
      string s1 = s.substr(0, n/2);
      string s2 = s.substr(mid, n/2);
      if(s1==s2) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#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);
    rep(i, n) cin >> a[i];
    set<int> odd;
    rep(i, n) if (i%2==0) odd.insert(a[i]);
    VSORT(a);
    int cnt = 0;
    rep(i, n) if (i%2==0) if (odd.find(a[i])==odd.end()) ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5964
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    
    
    int n = 0;
    cin >> n;
    
    priority_queue< double, vector<double>, greater<double> > pq;
    for(int i=0;i<n;i++)
    {
        double tmp = 0;
        cin >> tmp;
        pq.push(tmp);
    }
    
    while(pq.size() >= 2)
    {
        //最小値２つを取得
        double v1 = pq.top();
        pq.pop();
        double v2 = pq.top();
        pq.pop();
        
        //平均値を計算してキューへ戻す
        pq.push((v1 + v2)/2);
    }
    
    //キューの最小値が答え
    cout << fixed;
    cout << setprecision(5) << pq.top() << endl;
    
    return 0;
}


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

int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    double x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%lf",&x[i][j]);
        }
    }
    int count=0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double sum=0;
            for(int k=0;k<d;k++){
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(sqrt(sum)==floor(sqrt(sum))) count++;
        }
    }

    printf("%d\n",count);
}

Measured memory_bytes: 256
/*  ex2_3
	UMAboogie */

#include <stdio.h>

int main(void){
  int side, white;
  //次の入力でマス目の一辺の長さを変数sideに受け取る
  scanf("%d\n",&side);
  //次の入力で白く塗るマスの数を変数whiteに受け取る
  scanf("%d\n",&white);
  //マス目の総数を計算し、変数pixelに代入する
  int pixel = side*side;
  //黒く塗るマスの数を計算し、変数blackに代入し、表示する
  int black = pixel - white;
  printf("%d\n",black);
  return 0;
}


Measured memory_bytes: 128
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
W = LI()
ans = math.inf
for i in range(n):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)

Measured memory_bytes: 74348
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int k,n;
   cin>>k>>n;
   vector<int> a(n);
   rep(i,n)cin>>a.at(i);
   vector<int> b(n);
   rep(i,n-1)b.at(i)=a.at(i+1)-a.at(i);
   b.at(n-1)=k+a.at(0)-a.at(n-1);
   sort(b.begin(),b.end());
   cout<<k-b.at(n-1)<<endl;
   

}


Measured memory_bytes: 1792
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,a,b = LI()
    if (b-a)&1 == 0:
        print((b-a)>>1)
    else:
        c,d = a,b
        k = a-1
        b -= a-1
        a = 1
        k += 1
        b -= 1
        k += (b-1) >> 1
        a,b = c,d
        l = n-b
        a += n-b
        b = n
        l += 1
        a += 1
        l += (n-a) >> 1
        print(min(k,l))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39152
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

S = sInLH()

if S[0] < S[1]:
  ans = '<'
elif S[0] > S[1]:
  ans = '>'
else:
  ans = '='
  
print(ans)
  

Measured memory_bytes: 62280
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll power(ll a,ll n)
{
	if(n==0)
	return 1;
	if(n%2==0)
	return power((a*a)%mod,n/2)%mod;
	return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
}
ll divisors[10000001];
void totalDivisors()
{
  rep(i,1,10000001)
  {
    for(ll j=i;j<10000001;j+=i)
      divisors[j]++;
  }
}
int main()
{
	ll n;
  	lscf(n);
  ll ans=0;
    totalDivisors();
    for(ll i=1;i<=n;i++)
      ans+=(i*divisors[i]);
  lpri(ans);
return 0;
}

Measured memory_bytes: 81948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		Integer x = sc.nextInt();
		Integer[] a = new Integer[n + 1];
		Integer[][] b = new Integer[n + 1][n];
		Long result;
		Long cost = 0L;
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
			b[i][0] = a[i];
			cost += b[i][0];
		}
		result = cost;
		for (int k = 1; k < n; k++) {
			cost = (long) k * x;
			for (int i = 1; i <= n; i++) {
				if (i > k) {
					b[i][k] = Math.min(b[i][k - 1], a[i - k]);
				} else {
					b[i][k] = Math.min(b[i][k - 1], a[i - k + n]);
				}
				cost += b[i][k];
			}
			if (cost < result) {
				result = cost;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 111140
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/10/ALDS1_10_A
# やるだけ


n = int(input())
# dpテーブルの用意
dp = [-1]*(n+1)
# dpの初期値
dp[0], dp[1] = 1, 1

for i in range(2, n+1):
    dp[i] = dp[i-1]+dp[i-2]
print(dp[-1])



Measured memory_bytes: 5600
import sys
# sys.setrecursionlimit(100000)
import heapq


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    from collections import Counter
    # 計算量 O(n*log_n + m*log_m)

    # 入力
    n, m = input_int_list()
    hq = list(Counter(input_int_list()).items())  # O(n)
    # 最小値管理にPriorityQueueを使う

    heapq.heapify(hq)  # O(n*log_n)

    queries = []
    for _ in range(m):
        queries.append(input_int_list())

    queries.sort(key=lambda x: x[1], reverse=True)  # O(m * log_m)

    # cが大きい数字から処理したほうが効率的になる
    for b, c in queries:
        while b > 0:
            k, v = heapq.heappop(hq)
            if k >= c:
                heapq.heappush(hq, (k, v))
                break
            else:
                if v == b:
                    heapq.heappush(hq, (c, b))
                    b = 0
                elif v > b:
                    heapq.heappush(hq, (c, b))
                    heapq.heappush(hq, (k, v - b))
                    b = 0
                elif b > v:
                    heapq.heappush(hq, (c, v))
                    b -= v
    ans = 0
    for k, v in hq:
        ans += k * v

    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 107340
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef pair<string, pair<int, int> > P;

int w, h;
char c[80][80];

int dy[2] = {1, 0};
int dx[2] = {0, 1};
bool f[70][70];

bool is_digit(char c){
    return ('0' <= c && c <= '9');
}

bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

vector<string> res;

void dfs(int y, int x, string s){
    // cout << y << " " << x << " " <<s << endl;
    if(!contain(y, x) || !is_digit(c[y][x])){
        res.push_back(s);
        return;
    }
    f[y][x] = true;
    rep(i, 0, 2){
        int ny = y + dy[i];
        int nx = x + dx[i];
        dfs(ny, nx, s + c[y][x]);
    }
    return;
}

//s1 < s2?
bool comp(string s1, string s2){
    if(s1.size() == s2.size()) return s1 < s2;
    return s1.size() < s2.size();
}

int main(){
    while(1){
        cin >> w >> h;
        if(w + h == 0) break;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> c[i][j];
            }
        }
        string d[70][70];
        rep(i, 0, h){
            rep(j, 0, w){
                d[i][j] = "";
                if(is_digit(c[i][j]) && c[i][j] != '0'){
                    d[i][j] += c[i][j];
                }
            }
        }
        rep(i, 0, h){
            rep(j, 0, w){
                string t = "", t1 = "";
                if(i != 0){
                    if(is_digit(c[i][j]) && d[i - 1][j] != ""){
                        t = d[i - 1][j] + c[i][j];
                    }
                }
                if(j != 0){
                    if(is_digit(c[i][j]) && d[i][j - 1] != ""){
                        t1 = d[i][j - 1] + c[i][j];
                    }
                }
                // cout << d[i][j] << " ";
                if(comp(d[i][j], t)) d[i][j] = t;
                if(comp(d[i][j], t1)) d[i][j] = t1;
                // cout << i << " " << j << " " << d[i][j] << endl;
            }
        }
        string ans = "";
        rep(i, 0, h){
            rep(j, 0, w){
                if(comp(ans, d[i][j])) ans = d[i][j];
            }
        }
        cout << ans << endl;
        // res.clear();
        // rep(i, 0, h) rep(j, 0, w) f[i][j] = false;
        // rep(i, 0, h){
        //     rep(j, 0, w){
        //         if(f[i][j] == false && is_digit(c[i][j]) && c[i][j] != '0'){
        //             string tmp = "";
        //             dfs(i, j, tmp);
        //         }
        //     }
        // }
        // // rep(i, 0, res.size()){
        // //     cout << res[i] << endl;
        // // }     
        // int sz = 0;
        // rep(i, 0, res.size()){
        //     sz = max(sz, (int)res[i].size());
        // }
        // string ans = "";
        // rep(i, 0, res.size()){
        //     if(res[i].size() == sz && ans < res[i]) ans = res[i];
        // }
        // cout << ans << endl;
    }
}

Measured memory_bytes: 3384
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N,D = map(int, input().split())
  Xn = [list(map(int, input().split())) for _ in range(N)]

  sqrtset = [i**2 for i in range(1000)]

  ans = 0
  for i in range(N):
    for j in range(i+1,N):
      sm = 0
      for d in range(D):
        sm += (Xn[i][d]-Xn[j][d])**2
      if sm in sqrtset:
        ans += 1

  print(ans)


if __name__ == "__main__":
  main()

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
YPC = []
for c in range(M):
    p, y = MAP()
    p -= 1
    YPC.append((y, p, c))

YPC.sort()
ans = [()] * M
pcnt = [0] * N
for _, p, c in YPC:
    ans[c] = (p + 1, pcnt[p] + 1)
    pcnt[p] += 1

for p, c in ans:
    print(str(p).zfill(6) + str(c).zfill(6))


Measured memory_bytes: 36088
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  map<int,bool> A;
  REP(i,m){
    int tmp;
    cin >> tmp;
    A[tmp] = true;
  }
  int dp[n+10];
  REP(i,n+10) dp[i] = 0;
  dp[0] = 1;
  FOR(i,1,n+1){
    if(!A[i]){
      dp[i] += dp[i-1];
      if (i > 1) dp[i] += dp[i-2];
      dp[i] %= MOD;
    }
  } 
  OUT(dp[n]);
}

Measured memory_bytes: 7296
def solve():
    N, *a_l = map(int, open(0).read().split())
    a_l = [0] + a_l

    for i in range(N//2, 0, -1):
        a_l[i] = sum(a_l[i::i]) % 2

    b_l = [i for i, x in enumerate(a_l) if x]

    print(len(b_l))
    if len(b_l) != 0:
        print(' '.join(map(str, b_l)))


if __name__ == '__main__':
    solve()


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2020;
const int LEN = 30;
const int MSK = (1<<LEN) - 1;

const int MAX2 = MAX * MAX / LEN;

int M[MAX2];

int get(int x)
{
	int ind = x / LEN;
	int pos = x % LEN;

	return (M[ind] & (1<<pos)) > 0;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);

	M[0] = 1;

	int sum = 0;

	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);
		sum += x;

		RFOR(i, MAX2, 0)
		{
			if (M[i] == 0) continue;

			int to = (i * LEN + x) / LEN;
			if (to >= MAX2) continue;
			int sh = (x) % LEN;

			if (to + 1 < MAX2)
			{
				M[to+1] |= M[i] >> (LEN - sh);
				M[to+1] &= MSK;
			}

			M[to] |= M[i] << sh;
			M[to] &= MSK;

		}
	}

	PII res = MP(INF, INF);

	FOR (i, 0, sum + 1)
	{
		if (!get(i)) continue;

		if (abs(i * 2 - sum) <= res.first)
		{
			res = MP(abs(i*2-sum), i);
		}
	}

	cout<<res.second<<endl;
}


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

using ll=long long;

int main() {
  int A,B,C,K; cin >>A >>B >>C >>K;
  string ans="No";
  rep(i,0,K+1) {
    if (B>=C) {C*=2;}
    else if (A>=B) {B*=2;}
    else {ans="Yes";}
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3612
using System;

class Program{
    static int Merge(int[] A, int left, int mid, int right){
        var n1=mid-left;
        var n2=right-mid;
        var L=new int[n1+1];
        var R=new int[n2+1];
        for(var i=0; i<n1; i++){
            L[i]=A[left+i];
        }
        for(var i=0; i<n2; i++){
            R[i]=A[mid+i];
        }
        L[n1]=1000*1000*1000+1;
        R[n2]=1000*1000*1000+1;
        var l=0;
        var j=0;
        var cnt=0;
        for(var k=left; k<right; k++){
            if(L[l]<=R[j]){
                A[k]=L[l];
                l++;
            } else{
                A[k]=R[j];
                j++;
            }
            cnt++;
        }
        return cnt;
    }

    static int MergeSort(int[] A, int left, int right){
        if(left+1<right){
            var mid=(left+right)/2;
            var a=MergeSort(A, left, mid);
            var b=MergeSort(A, mid, right);
            var c=Merge(A, left, mid, right);
            return a+b+c;
        } else{
            return 0;
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var S=new int[n];
        for(var i=0; i<n; i++){
            S[i]=int.Parse(s[i]);
        }

        var result=MergeSort(S, 0, n);

        for(var i=0; i<n; i++){
            Console.Write(S[i]);
            if(i>=n-1){
                Console.WriteLine();
            } else{
                Console.Write(" ");
            }
        }
        Console.WriteLine(result);
    }
}

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

void search(vector<vector<int>>& map, int x, int y)
{
	if (map[x][y] < 0)
		return;

	if (map[x][y] == 1) {
		map[x][y] = 0;
		search(map, x - 1, y);
		search(map, x + 1, y);
		search(map, x, y - 1);
		search(map, x, y + 1);
		search(map, x - 1, y - 1);
		search(map, x + 1, y + 1); 
		search(map, x + 1, y - 1);
		search(map, x - 1, y + 1);
	}
}
int main()
{
	int w, h;
	while (1) {
		cin >> w >> h;
		if (w == 0 && h == 0)
			break;

		vector<vector<int>> map;
		map = vector<vector<int>>(h+2, vector<int>(w+2, -1));

		for (int i = 1; i < h+1; i++) {
			for (int j = 1; j < w+1; j++)
				cin >> map[i][j];
		}
		int island_n = 0;
		for (int i = 1; i < h + 1; i++) {
			for (int j = 1; j < w + 1; j++) {
				if (map[i][j] == 1) {
					island_n++;
					search(map,i, j);
				}
			}
		}
		cout << island_n << endl;
	}
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;
cin>>s;
    REP(i,2)if(s[i]!=s[2])
{cout <<"Yes"  <<"\n";return 0;}
    cout <<"No"  <<"\n";
    return 0;
}


Measured memory_bytes: 256