akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=3;i<=N;i+=2){
    int value = i;
    int diviser = 1;
    for(int j=3;j<=i;j+=2){
      int count = 0;
      while(value%j==0){
//        cout << value;
        value/=j;
        count ++;
      }
      diviser*=(count+1);
    }
//    cout << " " <<diviser << endl;
    if(diviser==8) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int main() {
    ll  a,b,x;
    cin >> a >> b >> x;
    ll ans = 0;
    if(a % x == 0) ans++;
    a = a - (a % x);
    b = b - (b % x);
    ans += (b - a) / x;
    
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std; 
int X,A,B;
void input() { 
  cin >> X >> A >> B;
} 
void compute() { 
} 
void output() { 
  cout << (X-A) % B << endl;
} 
int main() { 
    input(); 
    compute(); 
    output(); 
    return 0; 
} 

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

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

    ll cnt = 0;
    rrep(i, n, 0)
    {
        ll d = (a[i] + cnt) % b[i];
        if (d > 0)
            cnt += b[i] - d;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
    long long int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for(auto&& e:a)
    cin >> e;
    long long int goukei = accumulate(a.begin(),a.end(),0);
    cout << max(-1LL,n-goukei) << endl;
}


Measured memory_bytes: 3668
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	string s, t;
	int ans = 0;
	cin >> s >> t;
	rep(i, 3) {
		if (s.at(i) == t.at(i)) ans++;
	}
	cout << ans;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans += v[i] * v[j];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



//#define int ll
signed main(){
    int n, m, q;
	cin>>n>>m>>q;
	int ct[501][501]={};
	for(int i=0; i<m; i++){
		int l, r;
		cin>>l>>r;
		ct[l][r]++;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			ct[i][j]+=(ct[i-1][j]+ct[i][j-1]-ct[i-1][j-1]);
		}
	}
	for(int i=0; i<q; i++){
		int x, y;
		cin>>x>>y;
		cout<<ct[y][y]-ct[x-1][y]-ct[y][x-1]+ct[x-1][x-1]<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int X;
int res[100005];

int dp(int i) {
    if (i == 0) return 1;
    if (i < 0) return 0;
    if (~res[i]) return res[i];
    return res[i] = dp(i-100) || dp(i-101) || dp(i-102) || dp(i-103) || dp(i-104) || dp(i-105);
}

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

    cin >> X;
    memset(res,-1,sizeof res);
    cout << dp(X) << '\n';
}



Measured memory_bytes: 640
#include <algorithm> //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main()
{
  ll a, b;
  cin >> a >> b;
  ll tmp =b;
  for (; b % 10; b /= 10)
    a *= 10;
  tmp += a;
  ll tmp2 = sqrt(tmp);

  if (tmp == tmp2 * tmp2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

Measured memory_bytes: 256
def check(a,b,c):
  s={a,b,c}
  if len(s)==3:
    return 2
  elif len(s)==2:
    return 1
  else:
    return 0

n = int(input())
a_list=list(input())
b_list=list(input())
c_list=list(input())

ans=0
for i in range(n):
  ans+=check(a_list[i],b_list[i],c_list[i],)
  
print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())
num = []

for i in range(1, N + 1):
  num.append(i)

for i in range(K):
  d = int(input())
  drops = list(map(int,input().split()))
  for k in drops:
    if k in num:
      num.remove(k)

print(len(num))

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << endl;
    
    return 0;
}



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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;//人数
            int s;//必要な個数
                  //人数nを入力
            n = int.Parse(Console.ReadLine());
            s = 0;//合計を０に初期化
            for (int i = 1; i <= n; i++)//１からnのくりかえし
            {
                s = s + i;//ｓをふやすs +=i
            }
            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			int inputNum = Integer.parseInt(line);
			
			int hour = inputNum / 3600;
			int minutes = (inputNum % 3600) / 60;
			int second = (inputNum % 3600) % 60;
			System.out.println(hour + ":" + minutes + ":" +second);
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}



Measured memory_bytes: 26080
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef unsigned long long lint;
typedef unsigned long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////

int main() {
	int n, l; cin >> n >> l;
	vector<int> a, b, c;
	int sum = 0;
	rep(n) {
		a.pb(l + i);
		sum += l + i;
	}
	vector<pair<int, int>> k;
	for (int i = 0; i < n; i++)
	{
		k.pb(mp(abs(a[i]), i));
	}
	sort(all(k));
	cout << sum - a[k[0].second] << endl;
	return 0;
	

}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll nmax = 100000;
ll bk = 1000;
vll dp(nmax, LLINF);
vll mi(100, LLINF);
ll minim(ll s, ll t){
    ll ret = LLINF;
    ll now = s;
    while(now<=t){
        if(now%bk==0){
            if(now+bk<=t){
                ret = min(ret, mi[now/bk]);
                now+=bk;
            }else{
                ret = min(ret, dp[now]);
                now++;
            }
        }else{
            ret = min(ret, dp[now]);
            now++;
        }
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<pair<pair<ll, ll>, ll> > rlc(m);
    REP(i,m){
        ll r,l,c;
        cin >> l >> r >> c;
        l--;
        r--;
        rlc[i] = make_pair(make_pair(r,l), c);
    } 
    //vll dp(n,LLINF);
    dp[0] = 0;
    mi[0] = 0;
    sort(ALL(rlc));
    REP(i,m){
        auto pp = rlc[i];
        ll pr = (pp.fi).fi;
        ll pl = (pp.fi).se;
        ll pc = pp.se;
        ll tp = minim(pl, pr-1);
        if(tp==LLINF){

        }else{
            dp[pr]=min(dp[pr], tp+pc);
            mi[pr/bk] = min(mi[pr/bk], dp[pr]);
        }
    }
    if(dp[n-1]==LLINF){
        cout << -1 << endl;
    }else{
        cout << dp[n-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main(){
   /*１回目の考え（破棄） int n,m;    cin>>n>>m;
    //N人にM種類の食べ物が好きか尋ねた。N人全員が好きな食べ物の種類数を求める
    for(int i = 0 ; i < n ; i ++){
        int k; cin >> k;
        vector<int> ai(k);//好きな種類数だけの配列を用意する
        for(int j = 0 ; j < k ; j++){
           cin>>ai.at(j) ;
           for(int l=1;l<=m;l++){
               if(ai.at(j)==l){

               }
           }
        }
    }１回目のコード　ここまで*/
    /*２回目のコードここから*/
    int n,m; cin >>n>>m;
    vector<int> A(m,0);//ここにどんどん足していって、最終的にnになった要素の数を数える
    for(int i = 0 ; i < n ; i ++){
        int k; cin >> k; 
        for(int l = 0;l < k; l ++){
            int a; cin >>a;
            A.at(a-1)++;
        }
    }
    int ans=0;
    for(int i = 0 ; i < m ; i ++ ){
        if(A.at(i)==n){
            ans++;
        }
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(6)<<w*h/2<<" ";
	if(2*x-w==0 && 2*y-h==0)
		cout<<1<<"\n";
	else
		cout<<0<<"\n";
	return 0;
}
	


Measured memory_bytes: 3796
n,w=map(int,input().split())
from copy import copy
a=[0]*(w+1)
for i in range(n):
    b=copy(a)
    x,y=map(int,input().split())
    for j in range(min(x,w),w+1):
        b[j]=max(a[j-x]+y,a[j])
    a=copy(b)
print(max(a))
        



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

int main(){
	queue<string> que1;
	queue<int> que2;
	int n, q, t,T=0;
	string name;
	cin >> n >> q;
	for (int i = 0; i < n; i++)
	{
		cin >> name;
		cin >> t;
		que1.push(name);
		que2.push(t);
	}
	while (!que1.empty() && !que2.empty())
	{
		if (que2.front()>q)
		{
			T += q;
			t = que2.front() - q;
			name = que1.front();
			que1.pop(); que2.pop();
			que1.push(name);
			que2.push(t);
		}
		else
		{
			T += que2.front();
			cout << que1.front() << ' ' << T << endl;
			que1.pop(); que2.pop();
		}
	}
}

Measured memory_bytes: 5720
#include<bits/stdc++.h>
#define ll long long 
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) rep(i, n)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll<(x))
#define MOD ((ll)1e9+7)
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
int n, m;
vector<int> line;
vector<int> maxs;
vector<int> places;
vvector<int> dp;

vvector<int> isdp;

bool isok(int l, int r){
	if(r<0)return true;
	if(isdp[l][r]>=0)return isdp[l][r];
	bool res = true;
	for(int i=l;i<r;++i){
		if(line[i]>line[i+1]){
			res = false;
		}
	}
	return isdp[l][r] = res;
}

ll func(int place, int used, int rightest){
	if(place==n){
		if(n-used<=m&&used<=m)return 1;
		return 0;
	}
	if(places[place]<rightest)return func(place+1, used, rightest);
	if(dp[place][used]>=0)return dp[place][used];
	if(isok(rightest+1, places[place]-1)==false)return 0;
	ll res = 0;
	if((rightest!=-1)&&(maxs[rightest]<=place)){
		res += func(place+1, rightest+1-used+1, places[place]);
	}
	if((rightest==-1)||((places[place]-rightest)==1)||(maxs[rightest]<line[rightest+1])){
		res += func(place+1, used+1, places[place]);
	}
	return dp[place][used] = res % MOD;
}

int main(){
	cin>>n>>m;
	line.resize(n);
	maxs.resize(n, 0);
	places.resize(n);
	isdp.resize(n, vector<int>(n, -1));
	dp.resize(n, vector<int>(n, -1));
	rep(i, n){
		cin >> line[i];
		--line[i];
		maxs[i] = line[i];
		places[line[i]] = i;
	}
	rep(i, n-1){
		maxs[i+1] = max(maxs[i+1], maxs[i]);
	}
	cout << func(0, 0, -1) * 2 % MOD << endl;

	return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    ll N, M;
    ll A[100005];
    cin >> N >> M;
    for (int i = 0; i < N; i++) { 
        cin >> A[i];
    }

    for (int p = 0; p < 40; p++) {
        bool odd = true; 
        bool even = true;
        for (int i = 0; i < N; i++) {
            A[i] >>= 1;
            odd &= (A[i] & 1);
            even &= (A[i] % 2 == 0);
        }
        if ((!even && !odd) || (M >> p) == 0) break;
        if (odd) {
            ll d = 1;
            for (int i = 0; i < N; i++) {
                d = lcm(d, A[i]);
                if (d > (M >> p)) {
                    cout << 0 << endl;
                    return (0);
                }
            }
            cout << ((M >> p) + d) / (2 * d) << endl;
            return (0);
        }
    }
    cout << 0 << endl;
    return (0);
}


Measured memory_bytes: 1024
import collections

if __name__ == '__main__':
    N, W = map(int, input().split())

    dp = [collections.defaultdict(int) for _ in range(N + 1)]
    dp[0][0] = 0

    for i in range(N):
        w, v = map(int, input().split())
        for j in dp[i]:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            if j + w <= W: dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v)

    ans = max(dp[N].values())
    print(ans)


Measured memory_bytes: 52848
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

#ifndef MDEBUG
#define NDEBUG
#endif

#define x first
#define y second
#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pss pair<string,string>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,ll>
#define pls pair<ll,string>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
// auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; };
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;}
template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; };

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    int N,L;
    scanf("%d %d", &N, &L);
    vector<int> A(N);
    for(int&a:A) scanf("%d", &a);

    int tie = -1;
    for (int i = 0; i < N-1; i++) {
        if (A[i] + A[i+1] >= L) {
            tie = i;
            break;
        }
    }
    if (tie == -1) {
        printf("Impossible\n");
    } else {
        printf("Possible\n");
        for (int i = 1; i <= tie; i++) {
            printf("%d\n", i);
        }
        for (int i = N-1; i > tie+1 ; --i) {
            printf("%d\n", i);
        }
        printf("%d\n", tie+1);
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>
#include<string>
#include<bitset>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<functional>
#include<chrono>
#include<random>

#define y0 asdahsdlkahsdad
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define taskname "C"
#define BeztDonkey

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int nAlpha = 'z' - 'a' + 1, maxN = 2e5 + 1;

deque<int> pos[nAlpha];
static int p[maxN], lab[maxN], n, mid;
ll ans = 0;
string s;

inline void Update(int i, int val) { for (; i <= n; i += i & -i) lab[i] += val; }
inline int Get(int i) { int res = 0; for (; i > 0; i &= i - 1) res += lab[i]; return res; }

int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) pos[s[i] -= 'a'].push_back(i + 1);
    int dem = 0;
    for (int c = 0; c < nAlpha; ++c)
        if (pos[c].size() & 1) ++dem, mid = pos[c][pos[c].size() >> 1];
    if (dem > 1) return cout << -1, 0;
    for (int i = 1; i <= n; ++i) lab[i] = i & -i;
    for (int dem = n; dem > 1; dem -= 2)
    {
        int _c, _cost = maxN;
        for (int c = 0; c < nAlpha; ++c)
        {
            auto &v = pos[c];
            if (v.size() <= 1) continue;
            int cost = dem - (Get(v.back()) - Get(v.front() - 1));
            if (cost < _cost) _cost = cost, _c = c;
        }
        ans += _cost;
        auto &v = pos[_c];
        Update(v.front(), -1); v.pop_front();
        Update(v.back(), -1); v.pop_back();
    }
    /*for (int i = 1; i <= n; ++i)
        if (i != mid) Update(i, 1);
    for (int i = 1; i <= n; ++i)
    {
        auto &v = pos[s[i - 1]];
        if (v.back() <= i) continue;
        p[i] = v.back();
        ans += Get(n) - Get(v.back());
        Update(i, -1);
        Update(v.back(), -1);
        v.pop_back();
    }
    if (n & 1)
        for (int i = 1; i <= n; ++i)
            ans += p[i] && (i < mid && p[i] < mid || i > mid && p[i] > mid);*/
    cout << ans;

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}


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

using namespace std;
int main() {
	int N,M;
	cin >> N >> M;
	vector<int>S(M);
	for (int n = 0; n < M; ++n) {
		int num;
		cin >> num;
		for (int m = 0;m<num;++m) {
			int num2;
			cin >> num2;
			S[n] |= 1 << (num2-1); 
		}
	}
	vector<int>P(M);	
	for (int n = 0; n < M; ++n) {
		cin >> P[n];
	}
	int roop = 1 << (N);
	int ans = 0;
	for (int n = 0;n<roop;++n) {
		int num = 0;
		for (int m = 0;m < M;++m) {
			int count = 0;
			for (int l = 0;l<N;++l) {
				if (S[m]&1<<(l)) {
					if (n & 1<<l) {
						++count;
					}
				}
			}
			if (P[m] == count %2) {
				++num;
			}
		}
		if (M == num) {
			++ans;
		}
	}
	cout << ans << endl;
}


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

int main() {

    // マス目
    string s;
    
    // マス目を入力
    cin >> s;
    
    // 1のカウンタ
    int counter = 0;
    
    for (int i = 0; i < 3; ++i) {
    	if (s[i] == '1') {
    		counter += 1;
    	}
    }
    
    // 結果の出力
	cout << counter << endl;
}

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

int n, m;
vector<int> root(100000);
vector<int> prog(100000);
int find(int x) {
	if (root[x] == x)
		return x;
	return find(root[x]);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		root[i] = i;
	}
	for (int i = 0, x, y, xr, yr; i < m; i++) {
		cin >> x >> y >> xr;
		x--, y--;
		xr = find(x);
		yr = find(y);
		if (xr != yr) {
			if (prog[xr] >= prog[yr]) {
				root[yr] = xr;
				prog[xr] = prog[yr] + 1;
			} else {
				root[xr] = yr;
				prog[yr] = prog[xr] + 1;
			}

		}
	}
	int result = 0;
	for (int i = 0; i < n; i++) {
		if (root[i] == i)
			result++;
	}
	cout << result << endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
    vector<ll> A(9);
    rep(i, 9) cin >> A[i];
    ll N; cin >> N;
    vector<bool> C(9, false);
    rep(i, N) {
        ll b; cin >> b;
        rep(j, 10) {
            if (b == A[j]) C[j] = true;
        }
    }
    rep(i, 3) {
        if (C[3*i] && C[3*i+1] && C[3*i+2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i, 3) {
        if (C[i] && C[i+3] && C[i+6]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    
    if (C[0] && C[4] && C[8]) {
        cout << "Yes" << endl;
        return 0;
    }
    if (C[2] && C[4] && C[6]) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
int l,r;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>l>>r;
	if(r-l>=2019){//夹了1个2019 
		cout<<0<<endl;
		return 0;
	}
	int res=1e9;
	for(int i=l;i<=r;i++){
		for(int j=i+1;j<=r;j++){
			int ti=i%2019;
			int tj=j%2019;
			res=min(res,(ti*tj)%2019);
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    H, W, A, B = [int(x) for x in input().split()]

    ans = [[0] * W for j in range(H)]


    for j in range(H):
        if B > 0:
            for i in range(A):
                ans[j][i] = 1
            B -= 1
        else:
            for i in range(A, W):
                ans[j][i] = 1



    for j in range(H):
        print("".join(map(str, ans[j])))




    

if __name__ == '__main__':
    main()



Measured memory_bytes: 11892
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
const int N = 2e5+9;
int a[N],b[N],c[N],d[N];

int main()
{
    int n;
    cin>>n;
    int m = n;
    while(n--)
    {

        int x,y;
        scanf("%d%d",&x,&y);
        a[n] = x+y;
        b[n] = -x - y;
        c[n] = x - y;
        d[n] = -x + y;
    }
    sort(a,a+m);
    sort(b,b+m);
    sort(c,c+m);
    sort(d,d+m);
    LL ans = max(a[m-1]+b[m-1],c[m-1]+d[m-1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin >> n >> m;
	vector <vector <ll> >h(n+1);
	ll x,y;
	for1(i,n){
		cin >> x;
		h[i].push_back(x);
	}
	for0(i,m){
		cin >> x >> y;
		h[x].push_back(y);
		h[y].push_back(x);
	}
	bool check;
	set <ll> s;
	for1(i,n){
		check = false;
		for1(j,h[i].size()-1){
			if(h[i][0] <= h[h[i][j]][0]){
				check = true;
			}
		}
		if(check == false){
			s.insert(i);
		}
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 14304
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string S1, S2;
    cin >> S1 >> S2;
    YESNO(S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0], "YES", "NO");
    return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
lis = list(map(int,input().split()))
for i in range(n):
  lis[i] *= -1
lis.sort(reverse=True)
heapq.heapify(lis)
for m in range(m):
  a = -(-heapq.heappop(lis) // 2)
  heapq.heappush(lis, a)
print(-sum(lis))

Measured memory_bytes: 14180
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main(){
  int n,cnt;
  while(1){
  cin >> n;
  if(n==0)break;
  cnt=0;
  for(;n!=1;cnt++){
    if(n%2==0) n/=2;
    else n=n*3+1;
  }
  cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
	static int[] list1 = new int[180];
	static int[] list2 = new int[45];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makeList();
		int[] dp1 = new int[1000000];
		int[] dp2 = new int[1000000]; 
		

		Arrays.fill(dp1, 2 << 27);
		Arrays.fill(dp2, 2 << 27);

		dp1[0] = dp2[0] =  0;

		for(int i = 0; i < 180; i++) {
			for(int j = list1[i]; j < 1000000; j++) {
				dp1[j] = Math.min(dp1[j-list1[i]]+1, dp1[j]);
				if(list1[i] % 2 == 1) dp2[j] = Math.min(dp2[j-list1[i]]+1, dp2[j]);
			}
		}
		
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			System.out.println(dp1[a] + " " + dp2[a]);
		}
	}
	
	static void makeList() {
		for(int i = 0; i < 180; i++) {
			int sum = (i+1)*(i+2)*(i+3)/6;
			list1[i] = sum;
		}
	}
	

	
}

Measured memory_bytes: 29296
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  cout << (((n - 1) * (n - 1) + n) / 2) << endl;
}


Measured memory_bytes: 256
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]) and str[i] != "a":
    num =  num - (ord("z")-ord(str[i])+1)
    str[i] = "a"

num = num % 26
while(num > 0):
  if str[-1] == "z":
    num -= 1
    str[-1] = "a"
    continue
  str[-1] = chr(ord(str[-1])+1)
  num -= 1

ans = ""
for i in str:
  ans += i
print ans

Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long ans=0;
	int a[200001];
	map<int,int> mp;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		mp[a[i]+i]++;
	}
	for (int i=1;i<=n;i++)
		if (i-a[i]>=0)
			ans+=mp[i-a[i]];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14708
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

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

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

typedef pair<double, double> pdd;
typedef pair<double, pii> pdii;

int INF = 1000000000;

int n;
double pxyz[210][3], vxyz[210][3], r[210], vr[210];
double del_time[210];
vector<pdii> col_time;

vector<double> xyz_coef, r_coef;

void calc_xyz_coef(int idx1, int idx2) {
  xyz_coef = vector<double>();
  REP(i, 3) {
    xyz_coef.push_back(0.0);
  }
  
  REP(i, 3) {
    double a = pow(vxyz[idx1][i], 2) - 2*vxyz[idx1][i]*vxyz[idx2][i]
      + pow(vxyz[idx2][i], 2);
    xyz_coef[0] += a;

    double b = 2 * (pxyz[idx1][i] * vxyz[idx1][i]
        - (pxyz[idx1][i] * vxyz[idx2][i]
          + pxyz[idx2][i] * vxyz[idx1][i])
        + pxyz[idx2][i] * vxyz[idx2][i]);
    xyz_coef[1] += b;

    double c = pow(pxyz[idx1][i], 2) - 2*pxyz[idx1][i]*pxyz[idx2][i]
      + pow(pxyz[idx2][i], 2);
    xyz_coef[2] += c;
  }
}

void calc_r_coef(int idx1, int idx2) {
  r_coef = vector<double>();
  REP(i, 3) {
    r_coef.push_back(0.0);
  }

  double a = pow(vr[idx1], 2) + 2*vr[idx1]*vr[idx2]
    + pow(vr[idx2], 2);
  r_coef[0] += a;

  double b = -2 * (r[idx1] * vr[idx1]
      + r[idx1] * vr[idx2] + r[idx2] * vr[idx1]
      + r[idx2] * vr[idx2]);
  r_coef[1] += b;

  double c = pow(r[idx1], 2) + 2*r[idx1] * r[idx2]
    + pow(r[idx2], 2);
  r_coef[2] += c;
}

pdd quadeq(double a, double b, double c) {
  double D = sqrt(pow(b, 2) - 4*a*c);
  pdd ans;
  ans.first = (-b - D) / (2*a);
  ans.second = (-b + D) / (2*a);
  return ans;
}

double calc_col(int idx1, int idx2) {
  calc_xyz_coef(idx1, idx2);
  calc_r_coef(idx1, idx2);

  vector<double> coef;
  REP(i, 3) {
    coef.push_back(xyz_coef[i] - r_coef[i]);
  }

  double a = coef[0];
  double b = coef[1];
  double c = coef[2];
  if (pow(b, 2) - 4*a*c < 0) return (double)INF;

  pdd ans = quadeq(a, b, c);
#ifdef DEBUG
  cout << ans.first << " " << ans.second << endl;
#endif

  if (ans.first > 0) {
    return ans.first;
  } else if (ans.second > 0) {
    return ans.second;
  }
  return 110.0;
}

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

    col_time = vector<pdii>();

    REP(i, n) {
      cin >> pxyz[i][0] >> pxyz[i][1] >> pxyz[i][2];
      cin >> vxyz[i][0] >> vxyz[i][1] >> vxyz[i][2];
      cin >> r[i] >> vr[i];
    }

    REP(i, n) {
      del_time[i] = r[i] / vr[i];
    }

    REP(i, n) {
      for(int j=i+1; j<n; j++) {
        double col = calc_col(i, j);
        if (col < (double)INF) {
          col_time.push_back(pdii(col, pii(i, j)));
        }
      }
    }

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

    REP(i, col_time.size()) {
      pdii col = col_time[i];
      double colt = col.first;
      int idx1 = col.second.first;
      int idx2 = col.second.second;
      if (colt < del_time[idx1] && colt < del_time[idx2]) {
        del_time[idx1] = colt;
        del_time[idx2] = colt;
      }
    }

    REP(i, n) {
      printf("%.10lf\n", del_time[i]);
    }
  }
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  vector<int> num(3) ;
  
  rep(i, 3){
    cin >> num.at(i) ;
  }
  sort(num.begin(),num.end()) ;
  
  if(num.at(0)==num.at(1) && num.at(1)== num.at(2)){
    cout << 1 <<endl ;
  }
  else if(num.at(0)!=num.at(1) && num.at(1)!=num.at(2)){
    cout << 3 <<endl ;
  }
  else{
    cout << 2 <<endl ;
  }
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 8
#define FREE -1
#define NO 1

int row[MAX], col[MAX], dpos[2*MAX-1], dneg[2*MAX-1],X[MAX][MAX];
int counter;


void in(){
  int i;
  for (i = 0; i < MAX; i++ ){
    row[i] = FREE, col[i] = FREE;
  }
  for (i = 0; i < 2*MAX - 1; i++ ) {
    dpos[i] = FREE; dneg[i] = FREE;
  }
}

void print(){
  int i,j;
  for (i=0;i<MAX;i++){
    for (j=0;j<MAX;j++){
      if ( X[i][j]){
        if (row[i]!=j) return;
      }
    }
  }
  for ( i=0;i<MAX;i++ ){
    for ( j=0;j<MAX;j++ ){
      if(row[i]==j){
	printf("Q");
      }
      else{
	printf(".");
    }
    }
    printf("\n");
  }
  counter++;
}

void res( int i ){
  int j;
  if (i==MAX){ 
    print(); return;
  }
  
  for (j=0;j<MAX;j++){
    if ( col[j] == NO|| dpos[i+j] == NO || dneg[i-j+MAX-1] == NO) continue;
    row[i] = j; col[j] = dpos[i+j] = dneg[i-j+MAX-1] = NO;
    res( i + 1 );
    row[i] = col[j] = dpos[i+j] = dneg[i-j+MAX-1] = FREE;
  }
}

int main(){
  int i,j,n,r,c;
  in();
  counter = 0;
  
  for ( int i = 0; i < MAX; i++){
    for ( int j = 0; j < MAX; j++ ){
      X[i][j]=0;
    }
  }
  
  scanf("%d",&n);
  for ( i = 0; i < n; i++ ){
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }
  
  res(0);
  
  return 0;
}



Measured memory_bytes: 2112
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [K, S] = input[0].map(Number);

  let count = 0;

  for (let X = 0; X <= K; X++) {
    for (let Y = 0; Y <= K; Y++) {
      const Z = S - (X + Y);

      if (Z >= 0 && Z <= K) {
        count += 1;
      }
    }
  }

  return count;
};

console.log(main(read()));


Measured memory_bytes: 32240
require 'prime'

def mod_combi(n, m)
  return mod_combi(n, n-m) if n-m < m;

  ans = 1
  for i in 0...m do
    ans *= n - i;
    ans /= i + 1;
  end
  # puts "#{n} #{m} -> #{ans}"
  ans
end

mod = 10**9 + 7;
n, m = STDIN.gets.split(" ").map(&:to_i)
factors = m.prime_division

ans = 1
factors.each do |v, pow|
  ans *= mod_combi(n+pow-1, n-1)
end
puts ans % mod



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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n; 
  cin >> n;
  vector<ll> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(a.begin(), a.end());
  ll b = a[n/2];
  ll ans = 0;
  for(int i=0; i<n; i++){
    ans += abs(a[i]-b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n;cin >> n;
  int ans =0;
  rep(i,n) {
    int a;cin>>a;
    if ((i&1)== 0 && a&1) ans ++ ;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
typedef vector<char> chararr;
typedef vector<chararr> charmat;

double solve(vector<double> &p, int n) {
	vector<vector<double> > dp(n + 1, vector<double>(n + 1, 0));
	for (int i = 0; i <= n; ++i) {dp[i][0] = 1;}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1 - p[i - 1]) * dp[i - 1][j];
		}
	}
	return dp[n][(n / 2) + 1];

}


int main() {

	int n;
	cin >> n;
	vector<double> p(n, 0);
	for (int i = 0; i < n; ++i) {cin >> p[i];}
	cout << fixed << setprecision(10) << solve(p, n);

}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){ 
        cout<<"a > b"<<endl;
    }
    if(a==b){
        cout<<"a == b"<<endl;
    }
    if(a<b){
        cout<<"a < b"<<endl;
    }
}


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	 int c=sc.nextInt();
	 int n=sc.nextInt();
	 int sum=0;
	 int i,j;
	 ArrayList<Integer> arl = new ArrayList<Integer>();
	 for(i=0;i<c;i++)
	 {
	 	arl.add(sc.nextInt());
	 }
	 Collections.sort(arl);

	
	for(j=0;j<n;j++)
	{
		sum+=arl.get(j);
	}
	System.out.println(sum);
	
				
		
	}
}

Measured memory_bytes: 38788
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int ans=0;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]){
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict

n,k = map(int, input().split())
a = list(map(int, input().split()))

s = 1
w = [1]
y = defaultdict(lambda: 0)
y[1] = 1

flag = 0
zen = 0
for i in range(k):
#	print(s,a[s-1])
	if(y[a[s-1]] == 1):
#		print("w",w,a[s-1])
		flag = 1
		if(a[s-1] == 1):
			break
		else:
			for j in range(len(w)):
#				print("aa",w[j],a[s-1])
				if(w[j] == a[s-1]):
					zen = j
					w = w[j:]
					
					break
		break
	s = a[s-1]
	y[s] = 1
	w.append(s)

#print(s,w)

if(flag==0):
	print(s)
else:
	print(w[((k - zen) % (len(w)))])
#	print(w,zen,((k - zen) % (len(w))))

Measured memory_bytes: 116280
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	char a,b;
	cin>>a>>b;
	if(a>b)cout<<">"<<endl;
	else if(a==b)cout<<"="<<endl;
	else cout<<"<"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  long X,Y;
  cin>>X>>Y; 
  int ans=0;
  while(X<=Y){
    X*=2;
    ans++;
  }
  
 
    cout << ans<< endl;
  
}

Measured memory_bytes: 256
n = input()
s = list(input())

count = 0
for i in range(1000):
    a = str(i)
    a = list(a.zfill(3))
    sw = 0
    for j in range(len(s)):
        if sw == 0:
            if a[0] == s[j]:
                sw = 1
        elif sw == 1:
            if a[1] == s[j]:
                sw = 2
        elif sw == 2:
            if a[2] == s[j]:
                count += 1
                break
print(count)

Measured memory_bytes: 43356
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		while (true) {
			int H = scan.nextInt();
			int W = scan.nextInt();
			if (H == 0 && W == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				for(int i = 0;i < H;i++){
					for(int t = 0;t < W ;t++){
						text.append("#");
					}
					text.append("\n");
				}
				text.append("\n");
			}
		}
	}
}

Measured memory_bytes: 20868
N, M = gets.chomp.split(" ").map(&:to_i)

@g = Array.new(N+1){Array.new()}

M.times do
  a, b = gets.chomp.split(" ").map(&:to_i)
  @g[a] << b
  @g[b] << a
end

@ret = 0

def walk(node, visited)
  tmp = visited + [node]
  # p node, tmp
  @ret += 1 if tmp.size == N
  @g[node].each do |nd|
    if !tmp.include?(nd) then
      walk(nd, visited + [node])
    end
  end
end
walk(1, [])
puts @ret

Measured memory_bytes: 1916
N = long(raw_input())

prime_factor = []

all_sum = 0

for i in range(1, long(N ** 0.5)+1):
    if N % i == 0:
        if i > 2 and N % (i-1) == int(N /(i-1)): all_sum += i-1
        if i != N // i:
            if N // i > 2 and N % (N//i-1) == int(N/(N//i-1)): all_sum += N // i -1

print all_sum

Measured memory_bytes: 34436