akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    int N,M;
    cin >> N>>M;
    vector<int> k(M),p(M);
    vector<vector<int>> s(M, vector<int>(M,0));
    for (int i=0; i<M; i++) {
        cin>>k[i];
        s[i].resize(k[i]);
        for (int j=0; j<k[i]; j++) {
            cin >> s[i][j];
        }
    }
    for (int i=0; i<M; i++) {
        cin>>p[i];
    }
    
    vector<int> sw(N,0);
    int ans =0;
    for (int i=0; i<pow(2, N); i++) {
        // cout << '/';
        // for (int sss=0; sss<N; sss++) {
        //     cout << sw[sss];
        // }
        // cout << endl;
        bool can=true;
        
        for (int j=0; j<M; j++) {
            int sum=0;
            for (int l=0; l<k[j]; l++) {
                sum+=sw[s[j][l]-1];
            }
            //cout <<sum << ' ' << p[j] <<endl;;
            if (sum%2!=p[j]) {
                can=false;
                //break;
            }
        }
        if(can) ans++;
        
        sw[0]++;
        for (int j=0; j<N; j++) {
            if (i==pow(2, N)-1) {
                break;
            }
            if (sw[j]>1) {
                sw[j]=0;
                sw[j+1]++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
table.sort(a, function(x, y) return x > y end)
local c = {}
local found = 0
local pos = 1
local len = #a
while(pos < len) do
  if(a[pos] == a[pos + 1]) then
    found = found + 1
    c[found] = a[pos]
    if(found == 2) then break end
    pos = pos + 2
  else
    pos = pos + 1
  end
end
if(found < 2) then print(0) else print(c[1] * c[2]) end


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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define MSET(m,v) memset((m),(v),sizeof(m))
#define UB(c,v) (upper_bound((c).begin(),(c).end(),(v)))
#define LB(c,v) (lower_bound((c).begin(),(c).end(),(v)))
#define INREP int TC;cin>>TC;while(TC--)
#define CPPIO ios::sync_with_stdio(false);cin.tie(NULL);
#define PC(x) fixed<<setprecision(x)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

// SOLUTION

int n, k;

int main () {
	CPPIO;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << ceil (1.0 * (n - 1) / (k - 1));
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    long m = sc.nextLong();
    long[] listH = new long[n];

    for (int i = 0; i < n; i++) {
      listH[i] = sc.nextLong();
    }

    int[] listBad = new int[n];
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;

      if (listH[a] <= listH[b]) {
        listBad[a]++;
      }

      if (listH[b] <= listH[a]) {
        listBad[b]++;
      }
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
      if (listBad[i] == 0) {
        count++;
      }
    }
    System.out.println(count);

    sc.close();

  }
}

Measured memory_bytes: 60680
#include <iostream>

using namespace std;

int main(void) {
    int64_t a, b, x;
    cin >> a >> b >> x;
    if(a) {
        cout << b/x - (a-1)/x << endl;
    } else {
        cout << b/x + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
main=do
 [w,h,n]<-map read.words<$>getLine
 list<-replicateM n (map read.words<$>getLine)
 print$(max 0 ((min w (xa [x!!0|x<-list,x!!2==2]))-(xi [x!!0|x<-list,x!!2==1])))*(max 0 ((min h (ya [y!!1|y<-list,y!!2==4]))-(yi [y!!1|y<-list,y!!2==3])))
  where xa list = if list==[] then 100 else head(sort list)
        xi list = if list==[] then 0 else last(sort list)
        ya list = if list==[] then 100 else head(sort list)
        yi list = if list==[] then 0 else last(sort list)

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;

const int maxn = 105;
const int inf = 0x3f3f3f3f;
int H, W;
string mp[maxn];
int dp[maxn][maxn][2];

bool outside(int r, int c) {
    if (r < 0 || r >= H) return true;
    if (c < 0 || c >= W) return true;
    return false;
}

int dfs(int r, int c, int color) {
    if (dp[r][c][color] != -1) {
        return dp[r][c][color];
    }
    if (r == H - 1 && c == W - 1) {
        return 0;
    }
    // right
    int rr = r, rc = c + 1;
    int right = inf, down = inf;
    if (!outside(rr, rc)) {
        int col = mp[rr][rc] == '.' ? 0 : 1;
        right = dfs(rr, rc, col);
        if (color == 0 && col == 1) right += 1;
    }
    // down
    int dr = r + 1, dc = c;
    if (!outside(dr, dc)) {
        int col = mp[dr][dc] == '.' ? 0 : 1;
        down = dfs(dr, dc, col);
        if (color == 0 && col == 1) down += 1;
    }
    dp[r][c][color] = min(right, down);
    return dp[r][c][color];
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> mp[i];
    }
    int col = mp[0][0] == '.' ? 0 : 1;
    int res = dfs(0, 0, col);
    if (col == 1) {
        res += 1;
    }
    cout << res << endl;
}

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

int main(){
  int N,Vmax;
  cin >> N >> Vmax;

  vector<int64_t> data(N);
  int64_t buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    buf/= 2;
    
    data.at(i)= buf;
  }

  int64_t cumlcd= 1;
  int ord2= 0;
  bool possible= true;
  for(int i=0; i<N; i++){
    int cnt= 0;
    int64_t div= 2;
    while(data.at(i)% div==0){
      cnt++;
      div*= 2;
    }
    if(i==0){ ord2= cnt; }
    else if(ord2 != cnt){
      possible= false;
      break;
    }

    cumlcd= lcm(cumlcd, data.at(i));
    if(cumlcd > Vmax){
      possible= false;
      break;
    }
  }

  int64_t ans= possible ? ((Vmax/cumlcd)+ 1)/ 2
                        : 0;
  
  cout << ans << endl;
}

Measured memory_bytes: 3924
// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e9 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int ans[maxN];
bool used[maxN];
vi graph[maxN];
int dist[maxN];

void BFS(int start, int n) {
	vi dist(n + 1, inf);
	dist[1] = 0;
	queue<int> Q;
	Q.push(1);
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		if (used[u]) continue;
		used[u] = true;
		for (auto x: graph[u]) {
			//cout << u << " " << x << " " << dist[x] << endl;
			if (dist[x] > dist[u] + 1) {
				ans[x] = u;
				dist[x] = dist[u] + 1;
				Q.push(x);
			}
		}
	}
}
// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	REP(_, m) {
		int a, b;
		cin >> a >> b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	BFS(1, n);
	cout << "Yes\n";
	FOR(i, 2, n) cout << ans[i] << "\n";
	return 0;
}
 


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

#define rep(i,n) for (int i = 0; i < n; ++i)
typedef pair<int,int> P;
const int INF=1e9+7;

int main() {
	int N,a=0;
	cin >> N;
	vector<P> r(N),b(N);

	rep(i,N)
		cin >> r.at(i).first >> r.at(i).second;
	rep(i,N)
		cin >> b.at(i).first >> b.at(i).second;
	sort(b.begin(), b.end());

	rep(i,N) {
		int mi=-1,my=-1;
		rep(j,N)
			if(r.at(j).first<b.at(i).first && r.at(j).second<b.at(i).second && r.at(j).second > my)
				mi=j, my=r.at(j).second;
		if(mi != -1) {
			++a;
			r.at(mi).first=INF, r.at(mi).second=INF;
		}
	}

	cout << a << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    for (i in 0 until n) {
        if (h[i] >= k) ans++
    }
    println(ans)
}


Measured memory_bytes: 50564
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int n, a, b, cnt;
int main() {
	n = read();
	bool ans = false;
	while (n--) {
		a = read(); b = read();
		if (a == b) cnt++;
		if (cnt == 3) ans = true;
		if (cnt && a != b) cnt = 0;
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll x = 0, y = 0;
    rep(i, N) {
        if (A[i] == A[i + 1]) {
            x = y;
            y = A[i];
            i++;
        }
    }
    cout << x * y << "\n";
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		int n = sc.nextInt();
		sc.nextLine();
		String[] data = sc.nextLine().split(" ");

		for ( int i = n-1; 1 <= i; i--) {
//			if (i==0) {
//				sb.append(data[i]);
//				break;
//			}
			sb.append(data[i] + " ");
		}

		System.out.println( sb.append(data[0]) );
	}

}

Measured memory_bytes: 26204
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <map>
using namespace std;

static const long long INFTY = (1LL<<32);

#define MAX 200001

vector<int> S[MAX];

int main() {
    int n, m;
    cin >> n >> m;
    
    for ( int i = 1; i <= m; i++ ) {
        int s, t;
        cin >> s >> t;
        S[s].push_back(t);
    }
    
    bool ans = false;
    for ( int i = 0; i < S[1].size(); i++ ) {
        int u = S[1][i];
        //cout << u << endl;
        for ( int j = 0; j < S[u].size(); j++ ) {
            //cout << S[u][j] << endl;
            if ( S[u][j] == n ) {
                ans = true;
            }
        }
    }
    
    if ( ans ) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

int cnt[2][100005];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		cnt[i & 1][--x]++;
	}
	priority_queue<pair<int, int>> que[2];
	for (int i = 0; i < 100000; i++) {
		que[0].push({ cnt[0][i], i });
		que[1].push({ cnt[1][i], i });
	}
	if (que[0].top().second != que[1].top().second) {
		cout << n - que[0].top().first - que[1].top().first << endl;
		return 0;
	}
	int tp[2] = { que[0].top().first, que[1].top().first };
	que[0].pop(); que[1].pop();
	cout << n - max(que[0].top().first + tp[1], que[1].top().first + tp[0]) << endl;
	return 0;
}

Measured memory_bytes: 2804
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    k = int(input())
    x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(x[k-1])
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
'use strict'

const main = arg => {
    var input = arg.trim().split("\n");
    const lastIndex = input.indexOf("-1 -1 -1");
    input = input.filter((a, i) => i < lastIndex);
    const result = [];

    const scoreCheck = (scores) => {
        if(scores[0] === -1 || scores[1] === -1){ return "F"; }
        const mAndf = scores[0] + scores[1];
        if(mAndf >= 80){
            return "A";
        } else if(80 > mAndf && mAndf >= 65){
            return "B";
        } else if( (65 > mAndf && mAndf >= 50) || (scores[2] >= 50)){
            return "C";
        } else if(50 > mAndf && mAndf >= 30){
            return "D";
        }

        return "F";
    }

    input.forEach(obj => {
        const nums = obj.split(" ").map(str => parseInt(str, 10));
        result.push(scoreCheck(nums));
    });

    console.log(result.join("\n"));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15248
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;
//////////////////
vector< vector<int> > G;
vector< vector<int> > num;
vector<bool> visit;
bool dfs(int v,int L,int R,int path){
	visit[v] = true;
	if( num[v][2] != -1 && num[v][0] == num[v][1] ){//値が決まっている。
		int odd;//0:偶数,1:奇数
		//odd = ( ((L%2)+2)%2 + path%2 );
		odd = L%2;
		if( L <= num[v][0] && num[v][1] <= R &&
			(num[v][0]%2) == odd ){
			L = num[v][0];
			R = num[v][1];
			path = 0;
		}else{
			return false;
		}
	}else{
		num[v][0] = L;
		num[v][1] = R;
		num[v][2] = path;
	}
	int size = G[v].size();
	for(int i=0;i<size;++i){
		int to = G[v][i];
		if( visit[to] ) continue;
		bool res = dfs(to,L-1,R+1,path+1);
		if( res == false ) return false;
		//num[to][0]
		if( num[to][1]+1 < L || R < num[to][0]-1 ){
			return false;
		}
		
		int odd = ((num[to][0]-1)%2+2)%2;
		int odd2 = ((L%2)+2)%2;
		if( odd != odd2 ) return false;
		L = max(L,num[to][0]-1);
		R = min(R,num[to][1]+1);
		path = odd;
	}
	num[v][0] = L;
	num[v][1] = R;
	num[v][2] = path;
	return true;
}

void setNum(int v,int prev){
	visit[v] = true;
	if( num[v][0] != num[v][1] ){
		if( num[v][0] <= prev+1 && prev+1 <= num[v][1] ){
			num[v][0] = prev+1;
			num[v][1] = prev+1;
		}else{
			num[v][0] = prev-1;
			num[v][1] = prev-1;
		}
	}
	int size = G[v].size();
	for(int i=0;i<size;++i){
		int to = G[v][i];
		if( visit[to] ) continue;
		setNum(to,num[v][0]);
	}
}
void solve(){
	int N;
	cin >> N;
	G = vector< vector<int> >(N);
	num = vector< vector<int> >(N,vector<int>(3,-1));
	//値最小値、最大値、長さ？
	visit = vector<bool>(N,false);

	for(int i=0;i<N-1;++i){
		int A,B;
		cin >> A >> B;
		--A;--B;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	int K;
	cin >> K;
	int root;
	for(int i=0;i<K;++i){
		int V,P;
		cin >> V >> P;
		--V;
		root = V;
		num[V][0] = P;
		num[V][1] = P;
		num[V][2] = 0;
	}
	bool res = dfs(root,num[root][0],num[root][1],num[root][2]);
	if( res ){
		cout << "Yes" << endl;
		visit = vector<bool>(N,false);
		setNum(root,0);
		for(int i=0;i<N;++i){
			cout << num[i][0] << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 19712
def solve():
    N, Q = map(int, input().split())
    S = input()
    l = [0 for _ in range(Q)]
    r = l[:]
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    
    ac_head = [0 for _ in range(N+1)]
    for i, char in enumerate(S[:-1]):
        if char == 'A' and S[i+1] == 'C':
            ac_head[i+1] = 1 + ac_head[i]
        else:
            ac_head[i+1] = ac_head[i]
    
    for a, b in zip(l, r):
        print(ac_head[b-1] - ac_head[a-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14188
#template
def inputlist(): return [int(j) for j in input().split()]
#template
"""
H,W = inputlist()
st = inputlist()
gl = inputlist()
maze = ['0']*H
for i in range(H):
    maze[i] = list(input())
table = [[10**9+7]*W for _ in range(H)]

"""
D,T,S = inputlist()
time = D//S + int(D%S != 0)
if time <= T:
    print("Yes")
else:
    print("No")

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

int main(void){
   int A,B,C,K;
   cin>>A>>B>>C;
   cin>>K;
   while(A>=B){
      B=B*2;
      K=K-1;
   }
   while(B>=C){
      C=C*2;
      K=K-1;
   }
   if(K<0) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
   return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.Calendar;
import java.text.SimpleDateFormat;

 
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	while(true){
	    String s[]=br.readLine().split(" ");
	    String gen=s[0];
	    if(gen.equals("#")){
		break;
	    }
	    int y=Integer.parseInt(s[1]);
	    int m=Integer.parseInt(s[2]);
	    int d=Integer.parseInt(s[3]);

	    if((y>=31&&m>=5)||(y>31)){
		gen="?";
		y-=30;
	    }

	    System.out.println(gen+" "+y+" "+m+" "+d);

	}
	
	br.close();
    }


    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}



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

using namespace std;
using ll = long long;

const vector<vector<int>> dir2 = {{0, 1}, {1, 0}};
const vector<vector<int>> dir8 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};

const int def = 13000;

int main()
{
    int h, w; cin >> h >> w;
    vector<vector<int>> fir(h, vector<int>(w)), sec(h, vector<int>(w));
    vector<vector<vector<int>>> dp(h, vector<vector<int>>(w, vector<int>(def * 2))); //dp[i][j] := g[i][j]に来てる時点で blue - redの有りうる値

    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++)cin >> fir[i][j];
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++)cin >> sec[i][j];


    dp[0][0][fir[0][0] - sec[0][0] + def] = true;
    dp[0][0][sec[0][0] - fir[0][0] + def] = true;

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            for(auto d: dir2) {
                int ny = d[0] + i, nx = d[1] + j;
                if(ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
                for(int nxt = 0; nxt < def * 2; nxt++) {
                    if(!dp[i][j][nxt])continue;
                    dp[ny][nx][nxt + fir[ny][nx] - sec[ny][nx]] = true;
                    dp[ny][nx][nxt + sec[ny][nx] - fir[ny][nx]] = true;
                }
            }
        }
    }

    int nin = 1e9;
    for(int i = 0; i < def * 2; i++) {
        if(dp[h - 1][w - 1][i]) {
            nin = min(nin, abs(i - def));
        }
    }
    cout << nin << endl;
}

Measured memory_bytes: 658816
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int p[MX][2];
int a[MX][2];

signed main() {
  int n;
  cin>>n;
  string s;
  cin >> s;
  int pp=0;
  rep(i,n) {
    if(s[i]=='1') pp++;
  }
  int now = 1;
  int tm = s[n-1]-'0';
  if(pp>1)p[n-1][0]=tm%(pp-1);
  p[n-1][1]=tm%(pp+1);
  //cout << tm%(pp-1)<<p[n-1][1] << endl;
  int k = 1;
  int kk = 1;
  a[n-1][0]=k;
  a[n-1][1]=kk;
  RFOR(i,n-2,0) {
    tm = s[i]-'0';
    k*=2;
    kk*=2;
    if(pp>1)k%=(pp-1);
    kk%=(pp+1);
    a[i][0]=k;
    a[i][1]=kk;
    if(pp>1)p[i][0]=(tm*k+p[i+1][0])%(pp-1);
    p[i][1]=(tm*kk+p[i+1][1])%(pp+1);
    //cout << i<<" "<<p[i][1] << endl;
  }
  //cout << pp << endl;
  rep(i,n) {
    int ans = 1;
    int y = 0;
    if(s[i]=='0') {
      y=p[0][1]+a[i][1];
      y%=(pp+1);
    //cout << "y "<<p[0][1]<<" + "<<a[i][1]<<" "<<y << endl;
    }else {
      if(pp>1){y=p[0][0]-a[i][0];
      y%=pp-1;
      if(y<0) y+=pp-1;
      }else{
        ans=0;
      }
    //  cout << "y "<<p[0][0]<<" - "<<a[i][0]<<" "<<y << endl;
    }
    
    while(y>0) {
      int cy = y;
      int ppp=0;
      while(cy>0) {
        ppp += cy%2;
        cy /=2;
      }
      y = y%ppp;
      ans++;
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 9948
#include <iostream>
using namespace std;
typedef long long ll;

int N,A[22][22];
ll inf = 1e9+7,dp[1<<21];

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> A[i][j];
		}
	}
	dp[0] = 1;
	for(int i=0;i<N;i++){
		for(int S=0;S<(1<<N)-1;S++){
			if(i!=__builtin_popcount(S)) continue;
			for(int j=0;j<N;j++){
				if(!(S & (1<<j)) && A[i][j]){
					(dp[S|(1<<j)] += dp[S])%=inf;
				}
			}
		}
	}
	cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 16640
def main(I):
    #並び替え
    I[0].sort()
    I[1].sort(reverse = True)
    if str(I[0]) == str(I[1]):
        return False
    else:
        return str(I[0]) == str(sorted(I)[0])

I = list(list(input()) for _ in range(2))
print("Yes" if main(I) else "No")

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

using namespace std;

int arr[3][3];

int ok(int a1)
{
	int b[3],a[3];
	a[0]=a1;
	b[0]=arr[0][0]-a1; b[1]=arr[0][1]-a1; b[2]=arr[0][2]-a1;
	a[1]=arr[1][0]-b[0]; a[2]=arr[2][0]-b[0];
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			if(arr[i][j]!=a[i]+b[j]) return 0;
	return 1;
}

int main()
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin >> arr[i][j];
	for(int x=-200;x<=200;x++)
	{
		if(ok(x))
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
int num[1<<18];
int main()
{
    int n;scanf("%d",&n);
    rep(i,0,1<<n)scanf("%d",&num[i]);
    sort(num,num+(1<<n),greater<int>());
    priority_queue<int> pq;
    int flag=1;vector<int> tmp;
    tmp.push_back(n);
    rep(i,1,(1<<n))
    {
        if(num[i]!=num[i-1])
        {
            for(int k:tmp)pq.push(k);
            tmp.clear();
        }
        if(pq.empty()){flag=0;break;}
        int x=pq.top();pq.pop();
        if(x!=1)tmp.push_back(x-1),pq.push(x-1);
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 2044
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int ans;
int main(){
	int n;
	scanf("%d",&n);
	int pre=0,crr=0;
	while(n--){
		int t;
		scanf("%d",&t);
		if(t<=pre)crr++;
		else crr=1;
		ans=max(ans,crr);
		pre=t;
	}
	printf("%d",ans-1);
}

Measured memory_bytes: 128
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1000000000ll + 7ll)
#define OO (1050000000)
#define OOL (1100000000000000000)

//global
int a[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n;
	cin >> n;
	map<int,int> m;
	rep(i,0,n){
		cin >> a[i];
		m[a[i]]++;
	}
	sort(a,a+n);
	if(a[n-1] != a[n-2]) return cout << "Impossible",0;
	int len = a[n-1];
	if(len > n-1) return cout << "Impossible",0;
	if(len&1) if(a[0] > (len+1)/2) return cout << "Impossible",0;
	else if((len&1) == 0) if(a[0] > len/2) return cout << "Impossible",0;
	m.erase(len);
	if(len&1){
		rep(i,len/2+1,len){
			if(m[i] < 2) return cout << "Impossible",0;
			m[i] -= 2;
		}
		if(m[len/2+1] > 0) return cout << "Impossible",0;
	}else{
		rep(i,len/2+1,len){
			if(m[i] < 2) return cout << "Impossible",0;
			m[i] -= 2;
		}
		if(m[len/2] > 1 || m[len/2] == 0) return cout << "Impossible",0;
	}
	cout << "Possible";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A+B >= C){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}



Measured memory_bytes: 256
#他の人の回答例　後から見返す用

A = input()
n = len(A)-1
for i in range(2**n):
  pn = ['-']*n
  for j in range(n):
    if ((i>>j)&1):
      pn[n-1-j] = '+'
  ans = A[0]+pn[0]+A[1]+pn[1]+A[2]+pn[2]+A[3]
  
  if eval(ans) == 7:
    print(ans+'=7')
    break

    

Measured memory_bytes: 9128
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <vector>

int main() {
  using namespace std;
  int n;
  cin >> n;
  if (n % 10 == 7 || ((n - n % 10) / 10) % 10 == 7 ||
      ((n - n % 100) / 100) % 10 == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


int main(){
    int a,b;
    cin >> a >> b;
    if(b%a==0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    vector<int> t(d);
    rep(i, d) cin >> t[i], t[i]--;
    
    
    int v = 0;
    vector<int> last(26, -1);

    rep(i, d) {
        v += s[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) {
            v -= c[j] * (i - last[j]);
        }
        cout << v << endl;
    }
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<vector<int> > sum10;
vector<int> as;

void dfs(vector<int> v, int now, int sum) {
  if (sum == 10) {
    sum10.push_back(v);
    return;
  }
  if (now == as.size()) return;
  dfs(v,now+1,sum);
  if (sum + as[now] <= 10) {
    v.push_back(now);
    dfs(v,now,sum+as[now]);
  }
}

map<vector<int> , int> mp[50];

int solve(int now, vector<int> v) {
  if (now == sum10.size()) return 0;
  if (mp[now].count(v)) return mp[now][v];

  int a;
  int &r = a;
  if (now<sum10.size()-5) r = mp[now][v];
  int res = 0;
  REP(i,100) {
    bool dame = 0;
    res = max(res, solve(now+1, v) + i);
    FOR(it, sum10[now]) {
      if (v[*it]-- == 0) dame = 1;
    }
    if(dame) break;
  }
  if (now<sum10.size()-5) return r = res;
  return res;
}

int a[10];

int main() {
  // REP(i,9) as.push_back(i+1);
  // vector<int> t;
  // dfs(t,0,0);
  // FOR(it, sum10) {
  //   FOR(jt, *it) cout << *jt << " ";
  //   cout << endl;
  // }
  int n;
  while(cin>>n,n) {
    int ans = 0;
    memset(a,0,sizeof(a));
    REP(i,n) {
      int b;cin >> b;
      if (b >= 10) {
        if (b == 10) ans++;
      } else {
        a[b]++;
      }
    }
    for (int i=1; i<=4; ++i) {
      int j = 10-i;
      int m = min(a[i], a[j]);
      a[i] -= m;
      a[j] -= m;
      ans += m;
    }
    ans += a[5] / 2;
    a[5] -= a[5]/2*2;
    vector<int> v;
    as.clear();
    REP(i,10) if (a[i]) {
      as.push_back(i);
      v.push_back(a[i]);
    }
    sum10.clear();
    vector<int> t;
    dfs(t,0,0);
    REP(i,sum10.size()) mp[i].clear();
    ans += solve(0,v);
    cout << ans << endl;
  }
}

Measured memory_bytes: 64524
#include<iostream>
using namespace std;
typedef long long ll;

ll mincost(ll n, ll h[], ll *cost){
    if(cost[n] != 0) return cost[n];
    else{
        cost[2] = abs(h[2] - h[1]);
        cost[3] = abs(h[3] - h[1]);
        for(ll i = 4; i<=n; i++){
            cost[i] = min(abs(h[i] - h[i-1]) + cost[i-1],abs(h[i]-h[i-2])+cost[i-2]);
        }
        return cost[n];
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
  	ll i, h[n+1];
    ll *cost = new ll[n+1];
	for(i=1; i<=n; i++){
        cin>>h[i];
        cost[i] = 0;
    }
  	ll ans = mincost(n, h, cost);
  	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define be begin
#define en end
#define endl '\n'
#define SIZE 100000000
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1e9 + 7

typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
 
map<int,list<int>> l ;
bool vis[SIZE]={0};

int dp[SIZE];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	map<int,list<int>> l;
	int h[n+1] ;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		l[a].pb(b);
		l[b].pb(a);

	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		if(l[i].size()==0){
			ans++;
			continue;
		}
		bool flag =0;
		for(auto x:l[i])
		{
			if(h[x] >= h[i]){
				flag=1;
				break;
			}
		}
		if(!flag)
			ans++;


	}
	cout<<ans;

	

	return 0;
	
	
	
}

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

int main()
{
  int n;

  cin >> n;

  vector<int> a(n);

  double sum = 0;

  double ans = 0;

  rep(i, n)
  {
    cin >> a.at(i);
    // cout << a.at(i) << endl;
    sum += 1.0 / a.at(i);

    // cout << sum << endl;
  }

  ans = 1 / sum;

  cout << ans;
}


Measured memory_bytes: 3824
#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, T;
    cin >> n >> T;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    ll ans = 0;
    ll last = 0;
    rep(i, n){
        if(last <= v[i]) ans += T;
        else ans += (T - (last - v[i]));
        last = v[i] + T;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,x,y,a[16][15],n[15][15],k,ans;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
	cin >> n[i][j];
      }
    }

    for(j=0;j<x;j++){
      for(i=0;i<=y;i++) a[i][j] = 0;
      if(n[0][j] == 0) a[0][j] = 1;
    }

    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
	if(n[i][j] == 1) continue;
	if(i == y-1) a[i+1][j] += a[i][j];
	else if(n[i][j] == 0){
	  for(k=-1;k<=1;k++){
	    if(j == 0 && k == -1 || j == x-1 && k == 1) continue;
	    if(n[i+1][j+k] == 0) a[i+1][j+k] += a[i][j];
	  }
	  if(n[i+1][j] == 2) a[i+1][j] += a[i][j];
	}
	else if(n[i][j] == 2){
	  if(n[i+2][j] != 1) a[i+2][j] += a[i][j];
	}
      }
    }

    ans = 0;
    for(j=0;j<x;j++) ans += a[y][j];
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
import string
numbers = "0123456789"
alphabets = string.ascii_letters
characters = numbers + alphabets


def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
 
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result


def main():
    n, k = map(int, input().split(' '))

    after = base_cvt(n, k)
    print(len(after))

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll MAX_V=2005 ;//問題の条件による
struct edge {ll to, cost;};
typedef pair<ll, ll> P; // firstは最短距離、secondは頂点の番号
ll INF=1001001001001;
vector<vector<edge>> G(MAX_V); //辺のデータ G[a]={aからいける場所b,コストc}の集合
vector<ll> d(MAX_V); //始点からの距離
void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    ll n,x,y; cin>>n>>x>>y;
    for(ll i=1; i<=n-1; i++){
        G[i].push_back({i+1,1});
        G[i+1].push_back({i,1});
    }
    G[x].push_back({y,1});
    G[y].push_back({x,1});
    vector<ll> res(n,0);
    for(ll i=1; i<=n; i++){
        dijkstra(i);
        for(ll j=1; j<=n; j++){
            res[d[j]]++;
        }
    }
    for(ll i=1; i<=n-1; i++){
        cout<<res[i]/2<<endl;
    }
    return 0;
}

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

int main()
{
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  bool existOdd = false;
  for (int i = 0; i < N; i++)
  {
    if (A[i] % 2 == 1)
      existOdd = true;
  }
  long long int ans = 0;
  if (!existOdd)
  {
    if (P == 0)
      ans = pow(2, N);
    else
      ans = 0;
  }
  else
  {
    ans = pow(2, N - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

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

#define DEBUG
#undef DEBUG

int N;
int A[100000];

void solve()
{
    int len;          // LIS?????????
    int tail[100001]; // ??????i????¢??????¨??????????°????????°????

    len = 1;
    tail[1] = A[0];

    FOR(i, 1, N) {
        int a = A[i];
        if(a > tail[len]) {
            ++len;
            tail[len] = a;
        }
        else {
            auto it = lower_bound(tail+1, tail+1+len, a);
            *it = a;
        }
    }

#ifdef DEBUG
    FOR(i, 1, len+1) {
        cout << tail[i] << " ";
    }
    cout << "\n";
#endif

    cout << len << "\n";
}

int main()
{
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    solve();

    return 0;
}

Measured memory_bytes: 3792
# coding: utf-8
import time
import re
import math
import fractions

def main():
    A=list(map(int,input().split()))
    K=int(input())
    A.sort(key=lambda x:-x)
    print(sum(A)-A[0]+A[0]*(2**K))
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())



Measured memory_bytes: 5064
/*---> 20 January 2020 <--- > 01:54:25 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n,m;
	cin>>n>>m;
	if(n==m){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <string>
     
    using namespace std;
     
    int main(){
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	
    	int ans=0;
    	for(int i=1;i<n;i++){
    		int cnt=0;
    		
    		for(char c='a';c<='z';c++){
    			bool left=false,right=false;
    			
    			for(int j=0;j<i;j++)
    				if(s[j]==c)
    					left=true;
    			
    			for(int j=i;j<n;j++)
    				if(s[j]==c)
    					right=true;
    			
    			if(left&&right)
    				cnt++;
    		}
    		
    		if(ans<cnt)
    			ans=cnt;
    	}
    	
    	cout<<ans<<endl;
    }

Measured memory_bytes: 256
# (int(x) for x in input().split())
k  = int(input())
seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(seq[k-1])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x;
  FOR(i,1,6){
    cin >> x;
    if(i != x)
      cout << i << endl;
  }
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	string s;
	cin >> s;

	int ans = 0;
	for(int i = 0; i < s.length() / 2; i++){
		// cout << i << " " << s[i] << " " << s[s.length() - i - 1] << endl;
		
		if (s[i] == s[s.length() - i - 1]) continue;
		else{
			ans++;
		}
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 256