akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
#include<regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N; cin >> N;
	int ans = 0;
	if (N / 1000 == 2) ans++;
	N %= 1000;
	if (N / 100 == 2) ans++;
	N %= 100;
	if (N / 10 == 2) ans++;
	N %= 10;
	if (N == 2) ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>T operator()(T&& lhs, T&& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min(); 
}

void Main()
{
	std::size_t N, M;
	std::cin >> N >> M;
	std::vector<int> height(N);
	for (auto& h : height)
	{
		std::cin >> h;
	}
	std::unordered_set<index_t> bad;
	for (auto i : boost::irange(M))
	{
		index_t a, b;
		std::cin >> a >> b;
		--a; --b;
		if (height[a] <= height[b])
		{
			bad.emplace(a);
		}
		if (height[b] <= height[a])
		{
			bad.emplace(b);
		}
	}
	std::cout << N - bad.size() << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans=LINF,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[505][505];
bool fl;
struct edge{int to,cost;};
ll gyou[505];//縦にありますか？

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)rep(j,n)cin>>s[i][j];
    //横を全部一つ埋める　縦で全部埋まってないやつを足す
    int ok=0;
    rep(i,n){
        rep(j,n){
            if(s[i][j]=='#')ok=1;
        }
    }
    if(!ok)Cout(-1);
    else{
        rep(i,n){//横
            rep(j,n){//縦
                if(s[j][i]=='#')gyou[i]=1;
            }
        }
        rep(i,n){
            int flags1=0;
            int flags2=0;
            cnt=0;
            rep(j,n){
                if(s[i][j]=='.'){
                    if(gyou[i]!=0)flags1=1;//どっかから一回の操作でもってこれそう
                    cnt++;
                    flags2=1;
                }
            }
            if(flags1==0)cnt++;
            if(flags2==0)cnt=0;
            ans=min(ans,cnt);
            //cerr<<i<<" "<<cnt<<"\n";
        }
        //Cout(ans);
        rep(i,n){//横
            int add=0;
            rep(j,n){//縦
                if(s[j][i]=='.')add=1;
            }
            if(add)ans++;
        }
        Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=0;
		if(a==0) {
			c=1;
		}
		else if(a==1) {
			c=100;
		}
		else if(a==2) {
			c=10000;
		}

		if(b!=100) {
			System.out.println(c*b);
		}

		else {
			System.out.println(101*c);
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

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

	int N, K; cin >> N >> K;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int _k = 0; _k < K; _k++) {
		vector<int> B(N, 0);
		for (int i = 0; i < N; i++) {
			int left = i - A[i];
			int right = i + A[i] + 1;
			if (left < 0) { left = 0; }
			B[left]++;
			if (right < N) {
				B[right]--;
			}
		}
		bool end = true;
		int ans = 0;
		for (int i = 0; i < N; i++) {
			ans += B[i];
			A[i] = ans;
			if (A[i] != N) {
				end = false;
			}
		}
		if (end) { break; }
	}

	for (int i = 0; i < N; i++) {
		cout << A[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 5256
#include<iostream>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a;
	while (getline(cin,a)&&a != "END OF INPUT") {
		string h="";
		string g= "";
		a += " ";
		for (int i = 0; i < a.length(); i++) {
			if (a[i] == ' ') {
				g+=to_string(h.length());
				h = "";
			}
			else
				h += a[i];
		}
		cout <<g<< endl;
	}
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

int main(){
	ll n,a,b; cin >> n >> a >> b;
	ll c = a+b;
	ll q = n / c;
	ll r = n % c;
	ll ans = q * a + min(r,a);
	cout << ans << endl;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<string> v(2);
    rep(i, 2) cin >> v[i];

    string s = "";
    rep(i, n-1){
        if(v[0][i] != v[0][i+1]) s += "0";
        else {
            s += "1";
            i++;
        }
    }
    if(n == 1) s = "0";
    if(n >= 2 && v[0][n-1] != v[0][n-2]) s += "0";
    
    const ll mod = 1e9 + 7;
    ll ans;
    if(s[0] == '0') ans = 3;
    else ans = 6;
    for(int i=1; i<n; i++){
        if(s[i] == '0'){
            if(s[i-1] == '0') ans *= 2;
            else ans *= 1;
        }
        else if(s[i] == '1'){
            if(s[i-1] == '0') ans *= 2;
            else ans *= 3;
        }
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

/** ビッグボーナスの回数 */
static int b;
/** レギュラーボーナスの回数 */
static int r;
/** 通常ゲーム中でのブドウの回数 */
static int g;
/** チェリーの回数 */
static int c;
/** スターの回数 */
static int s;
/** 総ゲーム数 */
static int t;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  for ( ; ; )
  {
    scanf ( "%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t );
    if ( !( b | r | g | c | s | t ) ) break ;

    printf ( "%d\n"
      , 100                     /*< 元金 */
      - t * 3                   /*< スロットコスト */
      + ( b * 5 + r * 3 ) * 16  /*< ボーナス利益+スロットコスト差分 */
      + b * 15                  /*< 777 利益 */
      + r * 15                  /*< BAR 利益 */
      + g * 7                   /*< グレープ利益 */
      + c * 2                   /*< チェリー利益 */
      + s * 3 );                /*< スタースロットコスト差分 */
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
int main()
{
    int a;
    while(cin>>a){
        int dp[200005]={};
        
        int A[200005]={};
        for(int i=0;i<a;i++)
            cin>>A[i];
        
        int maxr=0;
        for(int i=0;i<a;i++){
            dp[ A[i] ]=dp[ A[i]-1 ]+1;
            maxr=max(maxr,dp[ A[i] ]);
        }
        cout<<a-maxr<<endl;
        
        
        
        
        
    }



    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using lint = long long;

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

    vector<lint> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    lint ans = 0, tot = 0;
    vector<lint> vt;
    for (int i = 0; i < n; i++) {
        if (a[i] >= b[i])
            vt.push_back(a[i] - b[i]);
        else {
            tot += (b[i] - a[i]);
            ans++;
        }
    }

    sort(vt.begin(), vt.end(), greater<>());
    for (long long x : vt) {
        if (tot > 0) {
            tot -= x;
            ans++;
        }
    }

    if (tot > 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2936
#include <stdio.h>
#include <math.h>
const double eps=1e-9;
double ABS(double n){return n>=0?n:-n;}
bool same(double a,double b){return ABS(a-b)<eps;}
struct point{
	double x;
	double y;
	point(){}
	point(double a,double b){x=a;y=b;}
	point operator +(const point &a){return point(x+a.x,y+a.y);}
	point operator -(const point &a){return point(x-a.x,y-a.y);}
	point operator *(const double &a){return point(x*a,y*a);}
	point operator /(const double &a){return point(x/a,y/a);}
	void operator =(const point &a){x=a.x;y=a.y;}
	void operator +=(const point &a){x+=a.x;y+=a.y;}
	void operator -=(const point &a){x-=a.x;y-=a.y;}
	void operator *=(const double &a){x*=a;y*=a;}
	void operator /=(const double &a){x/=a;y/=a;}
	bool operator <(const point &a){return x<a.x||(same(x,a.x)&&y<a.y);}
	bool operator ==(const point &a){return same(x,a.x)&&same(y,a.y);}
	double length(){return sqrt(x*x+y*y);}
	void in(){scanf("%lf%lf",&x,&y);}
	void out(){printf("%.20lf %.20lf\n",x,y);}
};
struct segment{
	point a;
	point b;
	segment(){}
	segment(point x,point y){a=x;b=y;}
};
struct line{
	double A;
	double B;
	double C;
	line(){}
	line(double a,double b,double c){A=a;B=b;C=c;}
	line(point a,point b){
		A=a.y-b.y;
		B=b.x-a.x;
		C=A*a.x+B*a.y;
	}
	line(double a,double b,point p){
		A=a;
		B=b;
		C=A*p.x+B*p.y;
	}
	line(segment s){
		A=s.a.y-s.b.y;
		B=s.b.x-s.a.x;
		C=A*s.a.x+B*s.a.y;
	}
};
double dist(point a,point b){return (a-b).length();}
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-b.x*a.y;}
//angle only returns positive value
double angle(point a,point b){return acos(dot(a,b)/(a.length()*b.length()));}
double area(point a,point b,point c){return ABS(cross(b-a,c-a));}
double distancetoline(point a,line b){return (b.A*a.x+b.B*a.y-b.C)/sqrt(b.A*b.A+b.B*b.B);}
bool parallel(line a,line b){return same(a.A*b.B,b.A*a.B);}
point intersect(line a,line b){
	double x,y,det;
	x=(a.C*b.B-b.C*a.B);
	y=(a.A*b.C-b.A*a.C);
	det=(a.A*b.B-b.A*a.B);
	return point(x,y)/det;
}
/*
bool intersect(segment a,segment b){}
point intersect(segment a,segment b){}
*/
point projection(point a,line b){return intersect(line(b.B,-b.A,a),b);}
point reflection(point a,line b){return projection(a,b)*2-a;}
int main(){
	point from,to,p;
	line l;
	int q;
	from.in();
	to.in();
	l=line(from,to);
	scanf("%d",&q);
	while(q--){
		p.in();
		reflection(p,l).out();
	}
}



Measured memory_bytes: 2760
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    long long a,b;
    cin>>a>>b;
    
    if(a<=0 && b>=0){
        cout<<"Zero"<<endl;
    }else if(a>=0 && b<=0){
        cout<<"Zero"<<endl;
    }else if(a==0 || b==0){
        cout<<"Zero"<<endl;
    }else if(a>0 && b>0){
        cout<<"Positive"<<endl;
    }else if(a<0 && b<0){
        
        long long num=abs(a-b)+1;
        if(num%2){
            cout<<"Negative"<<endl;
        }else{
            cout<<"Positive"<<endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 768
x1, x2, x3, x4, x5 = map(int, input().split())
if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);

  ll start = 0;
  ll end = N-1;
  ll start_sex = 0;
  string str;
  std::cout << 0 << std::endl;
  IN(str);
  if(str=="Male") start_sex = 0;
  else if(str=="Female") start_sex = 1;
  else return 0;

  while(end-start>1){
    ll mid = (start+end)/2;
    std::cout << mid << std::endl;
    IN(str);
    ll sex = 0;
    if(str=="Male") sex = 0;
    else if(str=="Female") sex = 1;
    else return 0;
    if((mid-start)&1){
      if(start_sex!=sex){
        start = mid;
        start_sex = sex;
      }else{
        end = mid;
      }
    }else{
      if(start_sex!=sex){
        end = mid;
      }else{
        start = mid;
        start_sex = sex;
      }
    }
  }

  std::cout << start << std::endl;
  IN(str);
  if(str=="Vacant") return 0;

  std::cout << end << std::endl;
  IN(str);

  return 0;
}

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

using namespace std;

long long x[100000], y[100000];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < m; i++)
		cin >> y[i];
	long long xs = 0, ys = 0;
	for (int i = 0; i < n; i++)
		xs += x[i] * (i - (n - i - 1));
	for (int i = 0; i < m; i++)
		ys += y[i] * (i - (m - i - 1));
	cout << (xs % 1000000007) * (ys % 1000000007) % 1000000007 << endl;

	return 0;
}


Measured memory_bytes: 1792
a, b, h, m = gets.chomp.split.map(&:to_i)

mtheta = m / 60.0 * 2 * Math::PI
htheta = h / 12.0 * 2 * Math::PI + Math::PI * 2 / 12.0 * m / 60.0

#puts mtheta
#puts htheta
kaku = (mtheta-htheta)

yogen = a**2 + b**2 - 2 * b * a * Math.cos(kaku)
puts Math.sqrt(yogen)


Measured memory_bytes: 14612
#pragma warning (disable:4996)
#include<stdio.h>

int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	int count;
	int power = 1;
	for (count = 0; power < b;++count) {
		power--;
		power += a;
	}
	printf("%d", count);
	return 0;
}

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

int main() {
    int a, b, ans;
    cin >> a >> b;
    if (a < 10 && b < 10) ans = a*b;
    else ans = -1;
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,m; cin >> n >> m;
  vi c(n);
  int a,b;
  rep(i,m){
    cin >> a >> b;
    c[a-1]++; c[b-1]++;
  }
  rep(i,n) cout << c[i] << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int dp[500010][61];

int main(){
    string s;
    cin >> s;
    int n = s.size();
    Fill(dp,n+1);
    for(int i=n-1;i>=0;i--){
        int k = s[i]-'a';
        dp[i][k] = i+1;
        for(int j=k+1;j<=26;j++){
            dp[i][j] = dp[dp[i][j-1]][j-1];
        }
        for(int j=0;j<k;j++){
            dp[i][j] = dp[dp[i][26]][j];        
        }
        for(int j=27;j<=60;j++){
            dp[i][j] = dp[dp[i][j-1]][j-1];
        }
    }
    int q;
    cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        l--;
        bool ok = 0;
        int id = l;
        for(int j=60;j>=26;j--){
            if(dp[id][j]<=r)id = dp[id][j];
        }
        ok = id==r;
        if(ok){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 120440
import math
x = int(input())

if x <= 6:
    print(1)
elif x<= 11:
    print(2)
else:
    z = x%11
    if 1 <= z <= 6:
        print((math.ceil(x/11)*2)-1)
    elif z <= 10 or z== 0:
        print(math.ceil(x/11)*2) 

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

int main() {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
int a[10000],b[500],c=0,i,j,n,q;
cin >> n;
for(i=0;i<n;i++){
    cin >> a[i];
}
cin >> q;
for(i=0;i<q; i++){
    cin >> b[i];
}
for(i=0;i<q;i++){
    for(j=0; j<n; j++){
        if(b[i]==a[j]) {c++; break;}
    }
}
cout << c <<endl;
}


Measured memory_bytes: 3124
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()

    one = n % 10

    a = set([2, 4, 5, 7, 9])
    b = set([0, 1, 6, 8])
    if one in a:
        print('hon')
    elif one in b:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';				

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
    time_p = clock() - time_p;
	cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
	IOS

	int n,x,i;
	cin >> n >> x;

	int l[n];
	vi p;
	p.pb(0);
	forn(0,n,i){
		cin >> l[i];
		p.pb(p.back() + l[i]);
	}

	int idx = lower_bound(all(p), x) - p.begin();
	if(idx == n + 1 or p[idx] > x)idx--;
	cout << 1 + idx << '\n';

	ktj();
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)


//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,p[101],num[101];
	string s[101];
	cin >> n;
	rep(i,n){
	 cin >> s[i] >> p[i];
	 num[i]=i;
	}
	rep(i,n-1){
		reps(j,i+1,n){
			if(s[i] > s[j] || (s[i] == s[j] && p[i] < p[j])){
				swap(s[i],s[j]);
				swap(p[i],p[j]);
				swap(num[i],num[j]);
			}
		}
	}
	rep(i,n){
		cout << num[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 100000
#define ll long long 
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll res,v[MN+5],V[MN+5],ans,g[MN+5],G[MN+5];
int n,X,L[MN+5],R[MN+5],b[MN+5],rk[MN+5];
bool cmp(int x,int y){return v[x]+g[x]>v[y]+g[y];}
ll GetV(ll*s,int l,int r,int x){return s[r]-s[l-1]-((x>=l&&x<=r)?s[x]-s[x-1]:0);}
inline int Div(ll x,int y){return (x+y-1)/y;}
int main()
{
    n=read();X=read();
    for(int i=1;i<=n;++i)
    {
        b[i]=read();L[i]=read();R[i]=read();
        v[i]=1LL*(X-b[i])*R[i];g[i]=1LL*b[i]*L[i];
        rk[i]=i;ans+=b[i];
    }
    sort(rk+1,rk+n+1,cmp);
    for(int i=1;i<=n;++i) V[i]=V[i-1]+v[rk[i]],G[i]=G[i-1]+g[rk[i]];
    for(int i=1;i<=n;++i)
    {
        int l=0,r=n-1,mid,res=n;
        while(l<=r)
        {
            mid=l+r>>1;
            ll Val=GetV(V,1,mid,i)-GetV(G,mid+1,n,i)+v[rk[i]];
            if(Val>=0) res=mid,r=mid-1; else l=mid+1;
        }
        ll Val=GetV(V,1,res,i)-GetV(G,res+1,n,i);
        if(Val>=0) ans=min(ans,1LL*(res-(res>=i))*X+max(0,Div(g[rk[i]]-Val,L[rk[i]])));
        else ans=min(ans,1LL*(res-(res>=i))*X+b[rk[i]]+Div(-Val,R[rk[i]]));
    }
    cout<<ans;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e7;

int dp[210][210][2];
bool isl[210], isr[210];
string S;
int N;

int solve(int l, int r, int f){
  if(dp[l][r][f] != MOD) return dp[l][r][f];

  int& res = dp[l][r][f];
  res = f? -INF: INF;
  if(l+1 == r){
	if(!isl[l] && !isr[l])
	  res = S[l] - '0';
	return res;
  }

  bool pl = isl[l];
  bool pr = isr[r-1];
  isl[l] = isr[r-1] = false;
  for(int i=l+1;i<r-1;i+=2){
	if(isl[i-1] || isr[i+1]) continue;
	if(S[i] == '+'){
	  if(f)
		maxi(res, solve(l,i,1) + solve(i+1,r,1));
	  else
		mini(res, solve(l,i,0) + solve(i+1,r,0));
	}
	else if(S[i] == '-'){
	  if(f)
		maxi(res, solve(l,i,1) - solve(i+1,r,0));
	  else
		mini(res, solve(l,i,0) - solve(i+1,r,1));
	}
  }
  isl[l] = pl;
  isr[r-1] = pr;
  
  return res;
}


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

  string tmp;
  cin >> tmp;

  int j = 0;
  for(int i=0;i<SZ(tmp);++i){
	if(tmp[i] == '('){
	  isl[j] = true;
	}
	else if(tmp[i] == ')'){
	  isr[j-1] = true;
	}
	else{
	  S += string(1, tmp[i]);
	  ++j;
	}
  }
  N = SZ(S);

  fill((int*)dp, (int*)dp+210*210*2, MOD);
  cout << solve(0, N, 1) << endl;

  return 0;
}

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

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

	cin >> a >> b >> c;
	while (1)
	{
		if (a > b)
		{
			a = a + b;
			b = a - b;
			a = a - b;
		}
		if (b > c)
		{
			b = b + c;
			c = b - c;
			b = b - c;
		}
		if (a <= b && b <=  c)
		{
			break;
		}
	}
	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M, K;
    scan(N, M, K);
    auto A = new long[](M);
    auto B = new long[](M);
    auto C = new long[](K);
    auto D = new long[](K);
    foreach (i; 0 .. M)
        scan(A[i], B[i]);
    foreach (i; 0 .. K)
        scan(C[i], D[i]);
    A[] -= 1;
    B[] -= 1;
    C[] -= 1;
    D[] -= 1;
    auto uf = UnionFind(N);
    foreach (i; 0 .. M)
    {
        uf.unite(A[i], B[i]);
    }
    auto ans = new long[](N);
    foreach (i; 0 .. N)
    {
        ans[i] = uf.size(i);
    }
    foreach (i; 0 .. M)
    {
        ans[A[i]]--;
        ans[B[i]]--;
    }
    foreach (i; 0 .. K)
    {
        if (uf.find(C[i]) == uf.find(D[i]))
        {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }
    ans[] -= 1;
    arywrite(ans);
}

struct UnionFind
{
    alias T = long;
    T[] rank, parent, sizes;
    this(T n)
    {
        rank = new T[](n);
        sizes = new T[](n);
        sizes[] = 1;
        parent = iota!T(n).array();
    }

    T find(T x)
    {
        return (this.parent[x] == x) ? x : (this.parent[x] = this.find(this.parent[x]));
    }

    void unite(T x, T y)
    {
        T rx = this.find(x), ry = this.find(y);
        if (rx == ry)
            return;
        this.sizes[rx] = this.sizes[ry] = this.sizes[rx] + this.sizes[ry];
        if (this.rank[rx] == this.rank[ry])
            this.parent[rx] = ry, this.rank[ry]++;
        else if (this.rank[rx] < this.rank[ry])
            this.parent[rx] = ry;
        else
            this.parent[ry] = rx;
    }

    T size(T x)
    {
        return this.sizes[this.find(x)];
    }
}


Measured memory_bytes: 11320
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
#左側から倒せるだけ倒すのが正解
Monst = 0
killed = 0
for n,b in enumerate(B):
        cur = A[n]
        nex = A[n+1]
        cur -= killed
        if b<=cur:
            Monst += b
            killed = 0
        elif b<=cur+nex:
            Monst += b
            killed = b - cur
        else:
            Monst += cur+nex
            killed = nex
print(Monst)

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

long long int gcd(long long int a, long long int b)
{    
	long long int c;
	if (a < b) {
		a += b; b = a - b; a -= b;
	}
	while (b != 0) {
		c = a % b;
		a = b;     
		b = c;
	}
	return a;
}

int main() {
	long long int N, X;
	cin >> N >> X;
	cout << (N / gcd(N, X) - 1) * 3 * gcd(N, X) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    ostringstream os;
    os << N;
    string s = os.str();
    int dsum = 0;
    for (char d : s)
        dsum += d - '0';
    cout << (N % dsum == 0 ? "Yes" : "No") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0;
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		double x,y;cin>>x>>y;
		if(sqrt(x*x+y*y)<=d) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
ll n,A,B,C;
vector<string> s(1e+5),x;
bool jud=false;
bool dfs(int i,int a,int b,int c){
    if(a<0||b<0||c<0)return false;
    if(i==n){
        jud=true;
        return true;
    }
    if(s[i]=="AB"){
        if(dfs(i+1,a+1,b-1,c)){
            x.push_back("A");
            return true;
        }else if(dfs(i+1,a-1,b+1,c)){
            x.push_back("B");
            return true;
        }
        return false;
    }else if(s[i]=="BC"){
        if(dfs(i+1,a,b+1,c-1)){
            x.push_back("B");
            return true;
        }else if(dfs(i+1,a,b-1,c+1)){
            x.push_back("C");
            return true;
        }
        return false;
    }else if(s[i]=="AC"){
        if(dfs(i+1,a+1,b,c-1)){
            x.push_back("A");
            return true;
        }else if(dfs(i+1,a-1,b,c+1)){
            x.push_back("C");
            return true;
        }
        return false;
    }
    return false;
}
int main(void){
    cin>>n>>A>>B>>C;
    rep(i,n) cin>>s[i];
    dfs(0,A,B,C);
    reverse(x.begin(),x.end());
    if(jud){
        cout<<"Yes"<<endl;
        rep(i,n)cout<<x[i]<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 19956
x = input()
l = len(x)
y_original = x[0]
s = 0

for i in range(1,l):
  y_original += 't'+x[i]
  
for i in range(2**(l-1)):
  y = y_original
  for j in range(l-1):  
    if ((i>>j) & 1) == 1:
      z = list(y)
      z[(2*l-3)-2*j] = '+'
      y = ''.join(z)
  y2 = y.replace('t','')
  s += eval(y2)
print(s)

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

int main()
{
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, 0, n) cin >> x[i];

    ll dp[2][100][10010];
    rep(j, 0, 100)
    rep(i, 0, 10000) 
        dp[0][j][i] = dp[1][j][i] = 0;

    dp[0][0][0] = 1;
    rep(i, 0, n)
    {
        int now = i % 2;
        int next = (i + 1) % 2;
        rep(j, 0, 52)
        rep(k, 0, 5000)
                dp[next][j][k] = dp[now][j][k];
        
        rep(j, 0, 51)
        rep(k, 0, 5000)
        {
            dp[next][j + 1][k + x[i]] += dp[now][j][k];
            // cout << i << ' ' << j << ' ' << k << ' ' << dp[now][j][k] << ' ' << dp[next][j + 1][k + x[i]] << endl;
        }
    }

    ll ans = 0;
    rep(j, 1, 52)
    rep(i, 1, 5000) 
     if (i == a * j)
     {
         ans += dp[n % 2][j][i];
        //  cout << i << ' ' << j << ' ' << dp[n%2][j][i] << endl;
     }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val h = (0 until n).map { it + 1 to sc.next().toLong() }
    val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }
    println(problem166c(n, m, h, ab))
}

fun problem166c(
    n: Int,
    m: Int,
    h: List<Pair<Int, Long>>,
    ab: List<Pair<Int, Int>>
): Int {
    val heights = h.sortedBy { it.second }.toMap()
    val routes = hashMapOf<Int, Long>()
    for (i in 0 until m) {
        val abi = ab[i]
        if (routes.containsKey(abi.first)) {
            routes[abi.first] = (Math.max(routes[abi.first]!!, heights[abi.second]!!))
        } else {
            routes[abi.first] = heights[abi.second]!!
        }
        if (routes.containsKey(abi.second)) {
            routes[abi.second] = (Math.max(routes[abi.second]!!, heights[abi.first]!!))
        } else {
            routes[abi.second] = heights[abi.first]!!
        }
    }
    var count = 0
    for (i in 1..n) {
        if (!routes.containsKey(i)) {
            count++
            continue
        }
        if (routes[i]!! < heights[i]!!) count++
    }
    return count
}

Measured memory_bytes: 91672
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let x: Vec<i32> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let mut ans = std::i32::MAX;
    for i in 0..101 {
        let mut cost = 0;
        for j in 0..n {
            cost += (i-x[j]) *(i-x[j]);
        }
        ans = std::cmp::min(ans, cost);
    }
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int D[N]; rep(i,N) cin >> D[i];
  sort(D,D+N);
  int diff = 24;
  repr(i,2,N) diff = min(diff,D[i]-D[i-2]);
  diff = min(diff,D[0]);
  diff = min(diff,24-(D[N-2]+D[N-1]));
  cout << diff << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef vector<double> vd;
typedef vector<vd> vvd;

vi eratos(int n)
{
	vector<bool> isprime(n, true);
	isprime[0] = isprime[1] = false;
	reep(i, 2, n){
		if(isprime[i]){
			for(int j=i*2; j<n; j+=i)
				isprime[j] = false;
		}
	}
	
	vi prime;
	rep(i, n){
		if(isprime[i])
			prime.push_back(i);
	}
	
	return prime;
}

int main()
{
	vi prime = eratos(10001);
	int n;
	while(scanf("%d", &n), n){
		int id = distance(prime.begin(), upper_bound(prime.begin(), prime.end(), n)) - 1;
		for(;;){
			if(prime[id]-prime[id-1] == 2)
				break;
			--id;
		}
		
		printf("%d %d\n", prime[id-1], prime[id]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <tuple>

using namespace std;

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


int main(){
    int A[3][3];
    for(int i=0;i<3; i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;
    for(int i=0; i<N; i++){
        int b;
        cin >> b;
        for(int i=0;i<3; i++){
            for(int j=0; j<3; j++){
                if(A[i][j]==b)A[i][j]=-1;
            }
        }
    }

    bool flag=false;
    for(int i=0; i<3; i++){
        if(A[i][0]==-1 && A[i][1]==-1 && A[i][2]==-1) flag=true;
        if(A[0][i]==-1 && A[1][i]==-1 && A[2][i]==-1) flag=true;
    }
    if(A[0][0]==-1 && A[1][1]==-1 && A[2][2]==-1) flag=true;
    if(A[2][0]==-1 && A[1][1]==-1 && A[0][2]==-1) flag=true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#define MN 50005
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<int,ll> f;
int n,k,num[10000005],a[MN],sum[MN],tot,tt;ll ans;
ll pow(int x,int y){
	ll tmp=1;
	while(y){
		if(y&1)tmp=tmp*x%mod;
		y>>=1,x=1ll*x*x%mod;
	}return tmp;
}
void add(ll &x,int y){(x+=y)>=mod?x-=mod:0;}
void dec(ll &x,int y){(x-=y)<0?x+=mod:0;}
void dfs(int u,int now){
	if(u==tot+1){num[++tt]=now;return ;}
	for(int i=0;i<=sum[u];i++)dfs(u+1,now*pow(a[u],i));
}
int main(){
	scanf("%d%d",&n,&k);int tmp=(int)sqrt(n);f[1]=k;
	int now=n;
	for(int i=2;i<=tmp;i++)if(now%i==0){
		a[++tot]=i;
		while(now%i==0)now/=i,sum[tot]++;
	}if(now!=1)a[++tot]=now,sum[tot]=1;dfs(1,1);
	sort(num+1,num+tt+1);
	for(int i=2;i<=tt;i++){
		f[num[i]]=pow(k,(num[i]+1)/2);
		for(int j=2;j<sqrt(num[i]);j++)if(num[i]%j==0){
			dec(f[num[i]],f[j]),dec(f[num[i]],f[num[i]/j]);
		}dec(f[num[i]],f[1]);
		if((int)sqrt(num[i])*(int)sqrt(num[i])==num[i])dec(f[num[i]],f[(int)sqrt(num[i])]);
	}for(int i=1;i<=tt;i++)if(num[i]%2==1)add(ans,f[num[i]]*num[i]%mod);else add(ans,f[num[i]]*num[i]/2%mod);
	printf("%lld\n",ans);
}

Measured memory_bytes: 384
n=int(input());a=[];b=[2,1,0,0];x=0
for i in range(3):
  a.append(input())
for j in range(n):
  m=0
  if a[0][j]==a[1][j]:m+=1
  if a[1][j]==a[2][j]:m+=1
  if a[2][j]==a[0][j]:m+=1
  x+=b[m]
print(x)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

# こまめにmodを取る
mod = 10**9 + 7
s = 0
t = 0
for i in range(N):
    s += A[i]
    s %= mod
    t += (A[i]**2 % mod)
    t %= mod
s = s**2 % mod
ans = (s - t) % mod
# 割り算のmodを取るときは、逆元を求め掛け算に変換してmodを取る
ans = (ans * 500000004) % mod

print(ans)

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int N; cin >> N;
	ll W; cin >> W;
	vector<ll> v(N), w(N);
	rep(i,N) cin >> v[i] >> w[i];
	int N2 = N / 2;
	vector<pair<ll, ll>> P;
	// 前半 N2　個について、選ぶかどうかで全列挙 (2^N2)
	for (int i = 0; i < (1 << N2); i++) {
		ll sum_w = 0, sum_v = 0;
		for(int j = 0; j < N2; j++) {
			if ((i >> j) & 1) {
				// j番目のbitが経っている
				sum_w += w[j];
				sum_v += v[j];
			}
		}
		P.push_back(make_pair(sum_w, sum_v));
	}

	// 無駄な要素を取り除く
	// P[i].first <= P[j].firts かつ P[i].second >= P[j].secondとなる j は不要
	sort(P.begin(), P.end());

	int m = 1;
	for(int i = 1; i < (1 << N2); i++){
		// P[i].first <= P[j].first のとき P[i].second < P[j].secondとなるようにする
		if (P[m-1].second < P[i].second) { //この条件を満たすi を残す
			P[m] = P[i];
			m++;
		}
	}

	// 後半 N-N2 個について全列挙
	const ll INF = 1LL << 60;
	ll ans = 0;
	for (int i = 0; i < (1 << N - N2); i++){
		ll sum_w = 0, sum_v = 0;
		for (int j = 0; j < N - N2; j++) {
			if(( i >> j) & 1) {
				sum_w += w[N2 + j];
				sum_v += v[N2 + j];
			}
		}
		// P[idx].first <= W - sum_w を満たす最大のidxを求める
		if (sum_w <= W) {
			pair<ll, ll> tmp(W - sum_w, INF);
			// 範囲は [0, m)
			// idx = (W - sum_w を超える最初の要素の index) - 1
			int idx = lower_bound(P.begin(), P.begin() + m, tmp) - P.begin() - 1;
			ans = max(ans, sum_v + P[idx].second);
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 19452
import sys
from itertools import permutations as pm
from math import factorial as fact
si = sys.stdin.readline


def main():
    ans = dict()
    n = int(si())
    for x in range(1, 100):
        for y in range(x, 100):
            for z in range(y, 100):
                value = ((x+y+z)**2+x**2+y**2+z**2)//2
                if value > 10000:
                    break
                if x == y and y == z:
                    cases = 1
                elif x != y and y != z and z != x:
                    cases = 6
                else:
                    cases = 3
                if value in ans:
                    ans[value] += cases
                else:
                    ans[value] = cases

    for i in range(1, n+1):
        if i in ans:
            print(ans[i])
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9744