akhauriyash/Code-Regression huggingface dataset:
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin>>n;
	ll a[n+1];
	lp(i,1,n)
		cin>>a[i];
		//f=0 to buy
	ll f=0,amt=0,rem=1000,no=0,i=1;
	while(i<n){
		if(!f){
			if(a[i]<a[i+1])
			{
				amt=a[i];
				no=rem/a[i];
				rem=rem%a[i];
				f=1;
			}
		}
		else{
			if(a[i]>a[i+1]){
				rem=rem+no*a[i];
				no=0;
				amt=0;
				f=0;
			}
		}
		i++;
	}
	cout<<rem+no*a[i]<<endl;
	return 0;	
}


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

long long x[100003];

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int i = 1; i<n; i++) {
		ans += min(a*(x[i + 1] - x[i]), b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
gets.to_i.times {
	y,m,d = gets.split(' ').map(&:to_i)
	d += (y-1)/3*590+(y-1)%3*195 
	d += y%3 == 0 ? (m-1)*20 : (m-1)*19 + m/2
	puts 196471-d
}

Measured memory_bytes: 5648
import math
import collections

# 組み合わせ数
def combination(n, r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
a_list = list(map(int, input().split()))

sum_list = [0]
for a in a_list:
    sum_list.append(sum_list[-1]+a)

sum_list = sum_list[1:]

c = collections.Counter(sum_list)

count = 0

for key in c.keys():
    if key == 0:
        count += c[0]
    if c[key] > 1:
        count += combination(c[key], 2)

print(count)

Measured memory_bytes: 41976
// https://atcoder.jp/contests/abc166/tasks/abc166_e

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,avx512f")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>

using uint = unsigned int;
signed main() {
  uint n;
  std::cin >> n;
  std::vector<uint> a;
  a.reserve(n);
  for (uint i = 0; i < n; ++i) { uint t; std::cin >> t; a.emplace_back(t); }

  std::vector<uint> ansv(8);

  const uint n8 = n / 8;
  uint now = 0;
  for (int k = 0; k < 8; ++k) {
    const uint nown8 = now + n8;
    for (uint i = now; i < nown8; ++i) {
      for (uint j = i + 1; j < n; ++j) {
        ansv[k] += (j - i) == a[j] + a[i];
      }
    }
    now += n8;
  }
  for (uint i = now; i < n; ++i) {
    for (uint j = i + 1; j < n; ++j) {
      ansv[0] += (j - i) == a[j] + a[i];
    }
  }

  long long ans = 0;
  for (const auto& x : ansv) { ans += x; }
  std::cout << ans << std::endl;

  return 0;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	cout << (N - 1)*(M - 1) << endl;

	return 0;
}

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

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

    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> h(n), a(m), b(m), c(n), d(2 * n+1, 0);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int j = 0;
    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        ++d[a[i]-1];
        ++d[b[i]-1];
    }
 /*   for(int i = 0; i < n; ++i) {
        cout << d[i] << ' ';
    }*/
    for(int i = 0; i < m; ++i) {
        if(h[a[i]-1] > h[b[i]-1])
            ++c[a[i]-1];
        if(h[a[i]-1] < h[b[i]-1])
            ++c[b[i]-1];
    }
    /*cout << endl;
    for(int i = 0; i < n; ++i) {
        cout << c[i] << ' ';
    }*/
    for(int i = 0; i < n; ++i) {
        if(c[i] == d[i]) {
            ++ans;
        }
    }
 //   cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 5508
from copy import deepcopy

d=int(input())
c=list(map(int,input().split())) #scoreを減らす
s=[] #scoreを増やす
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
last=[0]*26 #それぞれのコンテストが最後に行われたのは何日目か
ans_lst=[]

for i in range(1,d): #364日、1日目ならi=1
    temp_best=-100000000
    for j in range(26): #それぞれの日において、26個のコンテストを順番にピックアップ
        temp=s[i-1][j]
        for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
            if j!=k:
                temp-=(c[k]*(i-last[k]))
        temp_last=deepcopy(last)
        temp_last[j]=i
        for k in range(26):
            temp+=s[i][k]
            for l in range(26):
                if k!=l:
                    temp-=(c[l]*(i+1-temp_last[l]))
        if temp>temp_best:
            temp_best=temp
            rem=j
    ans_lst.append(rem)
    last[rem]=i
    
temp_best=-100000000 #365日目は、次の日のことは考えなくてよい
for j in range(26): #26個のコンテストを順番にピックアップ
    temp=s[i-1][j]
    for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
        if j!=k:
            temp-=(c[k]*(i-last[k]))
    if temp>temp_best:
        temp_best=temp
        rem=j
ans_lst.append(rem) #AtCoder運営お疲れ様です

score=0
las=[0]*26
for i in range(d):
    for j in range(26):
        las[j]+=1
    score+=s[i][ans_lst[i]]
    las[ans_lst[i]]=0
    for j in range(26):
        score-=c[j]*las[j]

for q in range(1,31):
    for p in range(d-q):
        las=[0]*26
        temp_score=0
        temp_ans_lst=deepcopy(ans_lst)
        temp_ans_lst[p],temp_ans_lst[p+q]=temp_ans_lst[p+q],temp_ans_lst[p]
        for i in range(d):
            for j in range(26):
                las[j]+=1
            temp_score+=s[i][temp_ans_lst[i]]
            las[temp_ans_lst[i]]=0
            for j in range(26):
                temp_score-=c[j]*las[j]
        if temp_score>score:
            score=temp_score
            ans_lst=temp_ans_lst

for i in ans_lst:
    print(i+1)

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

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> a(n);
    for(int& i:a){
        cin>>i;
    }

    int c=0,ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            c++;
        }
        else{
            ans=max(ans,c);
            c=0;
        }
    }
    ans=max(ans,c);

    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] arr = new int[n];
        long total = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            total += arr[i];
        }
        if (total == x) {
            System.out.println(n);
            return;
        }
        Arrays.sort(arr);
        int count = 0;
        for (int i = 0; i < n && x >= 0; i++) {
            count++;
            x -= arr[i];
        }
        System.out.println(count - 1);
    }
}


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

int N, x[100005], K;
int ans;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	ans = 1e9;
	for (int i = 0; i + K - 1 < N; i++) {
		ans = min(ans, x[i + K - 1] - x[i] + min(abs(x[i + K - 1]), abs(x[i])));
	}
	cout << ans;
}


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

template<typename T>
struct CumSum{
private:
  size_t size;
  vector<T> data;
public:
  CumSum(vector<T> dat){
    size = dat.size();
    data.resize(size+1,0);
    for(size_t i = 0; i < size; ++i)
      data[i+1] = data[i] + dat[i];
  }
  T getsum(size_t l, size_t r){//0-indexed, [l,r)
    return data[r] - data[l];
  }
  T getsum(size_t r){//0-indexed, [0,r)
    return data[r];
  }
};

int main(){
  long long N, M, L;
  cin >> N >> M >> L;
  vector<long long> K(N), S(M);
  for(long long i = 0; i < N; ++i)
    cin >> K[i], --K[i];
  for(long long i = 0; i < M; ++i)
    cin >> S[i];
  CumSum<long long> cs(S);
  const long long INF = 1e18;
  sort(K.begin(), K.end());
  vector<long long> dp(N,INF);
  dp[0] = 0;
  for(long long i = 1; i < N; ++i){
    vector<long long> dp_(N,INF);
    for(long long j = 0; j < N; ++j){
      if(dp[j] >= INF) continue;
      {
        // i-1 | i
        //  j  |
        long long l = K[i-1], r = K[i];
        if(r < l) swap(l,r);
        ++r;
        dp_[j] = min(dp_[j],dp[j]+cs.getsum(l,r)/L);
      }
      {
        // i-1 |
        //  j  | i
        long long l = K[j], r = K[i];
        if(r < l) swap(l,r);
        ++r;
        dp_[i-1] = min(dp_[i-1],dp[j]+cs.getsum(l,r)/L);
      }
    }
    swap(dp,dp_);
  }
  long long ans = INF;
  for(long long i = 0; i < N; ++i){
    if(i == N-1) continue;
    if(dp[i] >= INF) continue;
    long long l = K[i], r = K.back();
    if(r < l) swap(l,r);
    ++r;
    ans = min(ans,dp[i]+cs.getsum(l,r)/L);
  }
  cout << ans << endl;
}



Measured memory_bytes: 5252
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

static int
can_build(int *a, int n, int m) {
  if (m == 0) return 1;
  if (m < 0 || n <= 0) return 0;
  --n;
  return (can_build(a, n, m) || can_build(a, n, m - a[n]));
}

int main(int argc, char **argv) {
  int ret, n, i, q, m;
  int a[20];

  ret = scanf("%d", &n);
  if (errno != 0) perror("scanf: n");
  if (ret < 1) exit(1);

  for (i = 0; i < n; ++i) {
    ret = scanf("%d", &a[i]);
    if (errno != 0) perror("scanf: a[i]");
    if (ret < 1) break;
  }

  ret = scanf("%d", &q);
  if (errno != 0) perror("scanf: q");
  if (ret < 1) exit(1);

  for (i = 0; i < q; ++i) {
    ret = scanf("%d", &m);
    if (errno != 0) perror("scanf: m[i]");
    if (ret < 1) break;
    printf("%s\n", can_build(a, n, m) ? "yes" : "no");
  }

  exit(0);
}


Measured memory_bytes: 2052
def euclid(n, a_list):
    a1, a2 = a_list[0:2]
    gcd_ = gcd(a1, a2)
    for i in range(2, n):
        gcd_ = gcd(gcd_, a_list[i])
    return gcd_

def gcd(a1, a2):
    r = 1
    while (r > 0):
        r = a1 % a2
        a1, a2 = a2, r
    return a1


n = int(input())
a_list = [int(i) for i in input().split()]
a_list = sorted(a_list)
ans = euclid(n, a_list)
print(ans)

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long int ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n;
string vertex[45];
int m[45];
int power[45];
string adj[45][45];

ull graph[45];

int dfs(int cur,ull used){
	if(cur==n) return 0;
	if(used>>cur&1) return dfs(cur+1,used);

	int res=0;
	ull nused=used|(1LL<<cur);

	if(__builtin_popcountll((~nused)&(graph[cur]))<=1){
		res=power[cur]+dfs(cur+1,nused|graph[cur]);
	}else{
		res=dfs(cur+1,nused);
		res=max(res,power[cur]+dfs(cur+1,nused|graph[cur]));
	}
	return res;
}

int main(void){
	while(cin >> n,n){
		rep(i,n){
			cin >> vertex[i] >> power[i];
			cin >> m[i];
			rep(j,m[i]) cin >> adj[i][j];
		}
		for(int i=1;i<n;++i){
			for(int j=i+1;j<n;++j){
				if(power[i]<power[j]){
					swap(vertex[i],vertex[j]);
					swap(power[i],power[j]);
					swap(m[i],m[j]);
					rep(k,45) swap(adj[i][k],adj[j][k]);
				}
			}
		}
		rep(i,n){
			graph[i]=0LL;
			rep(j,m[i])rep(k,n)
				if(adj[i][j]==vertex[k])
					graph[i]|=(1LL<<k);
		}
		cout << power[0]+dfs(1,graph[0]|1LL) << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
from collections import deque

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

d = deque()
for i, value in enumerate(a, start=1):
    if n % 2 == i % 2:
        d.appendleft(value)
    else:
        d.append(value)

for value in d:
    print(f'{value} ', end="")
print()
exit()


Measured memory_bytes: 32436
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
for i in range(len(b)):
    c = False
    for j in range(i):
        if b[i] < b[j]:
            c = True
    if c == False:
        d.append(i+1)

print(len(d))



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

using namespace std;

int main() {
	int N;
	while(cin >> N, N) {
		vector< set<int> > M(N, set<int>());
		for(int i = 0; i < N; i++) {
			int m; cin >> m;
			for(int j = 0; j < m; j++) {
				int tmp; cin >> tmp;
				M[i].insert(tmp);
			}
		}
		int K ; cin >> K;
		vector<int> l(K);
		for(int i = 0; i < K; i++) cin >> l[i];

		int ans = -1;
		for(int i = 0; i < N; i++) {
			bool flag = true;
			for(int j = 0; j < K; j++) {
				if(M[i].find(l[j]) == M[i].end()) {
					flag = false;
				}
			}
			if(flag && ans != -1) {ans = -1; break;}
			if(flag) ans = i+1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3492
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("6 1");
            WillReturn.Add("3");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("10 2");
            WillReturn.Add("4");
            WillReturn.Add("5");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("100 5");
            WillReturn.Add("1");
            WillReturn.Add("23");
            WillReturn.Add("45");
            WillReturn.Add("67");
            WillReturn.Add("89");
            //608200469
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int N = wkArr[0];

        var ASet = new HashSet<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            ASet.Add(int.Parse(EachStr));
        }

        //場合の数[現在位置]なDP表
        int[] DPArr = new int[N + 1];
        DPArr[0] = 1;
        int UB = N;

        for (int I = 0; I <= UB; I++) {
            int NextDan;

            //1段あがる場合
            NextDan = I + 1;
            if (NextDan <= UB && ASet.Contains(NextDan) == false) {
                DPArr[NextDan] = DPArr[NextDan] + DPArr[I];
                DPArr[NextDan] %= 1000000007;
            }

            //2段あがる場合
            NextDan = I + 2;
            if (NextDan <= UB && ASet.Contains(NextDan) == false) {
                DPArr[NextDan] = DPArr[NextDan] + DPArr[I];
                DPArr[NextDan] %= 1000000007;
            }
        }
        Console.WriteLine(DPArr[UB]);
    }
}


Measured memory_bytes: 19680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int h,w,k; cin >> h >> w >> k;
    vector<string> masu(h);
    rep(i,h) cin >> masu[i];

    int ans=0;

    rep(i,1<<h){
        rep(j,1<<w){
            int count=0;
            rep(p,h)rep(q,w){
                if(masu[p][q]=='#' && (i>>p)%2==1 && (j>>q)%2==1) count++;
            }
            if(count==k) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

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

    cin >> a >> b >> c;

    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
def solve(N, Y):
    for x in range(0, N+1, 1):
        for y in range(0, N+1, 1):
            z = N - x - y
            if(z >= 0 and Y == 10000 * x + 5000 * y + 1000 * z):
                return (x, y, z)
    
    return (-1, -1, -1)



def main():
    N, Y = map(int, input().split())
    comb = solve(N, Y)
    print(*comb)
    
# print(solve(9, 45000))
# print(solve(20, 196000))
# print(solve(1000, 1234000))
# print(solve(2000, 20000000))
main()

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

int main()
{
	int l=0,n;
	int ar[25];
	scanf("%d",&n);
	scanf("%d%d",&ar[0],&ar[1]);
	for(int i=2;i<n;i++)
	{
		scanf("%d",&ar[i]);
		if((ar[i-1]-ar[i])*(ar[i-2]-ar[i-1])>0) l++;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 128
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let ma: usize = sc.read();
    let mb: usize = sc.read();
    let drugs: Vec<(usize, usize, usize)> = (0..n).map(|_| (sc.read(), sc.read(), sc.read())).collect();

    let a_sum: usize = drugs.iter().map(|t| {
        let (a, _, _) = *t;
        a
    }).sum();
    let b_sum: usize = drugs.iter().map(|t| {
        let (_, b, _) = *t;
        b
    }).sum();

    let inf = std::usize::MAX;
    let mut dp = vec![vec![inf; b_sum + 1]; a_sum + 1];
    dp[0][0] = 0;
    for t in &drugs {
        let (a, b, c) = *t;
        for from_a in (0..a_sum).rev() {
            for from_b in (0..b_sum).rev() {
                if from_a + a > a_sum || from_b + b > b_sum {
                    continue;
                }
                if dp[from_a][from_b] == inf {
                    continue;
                }
                dp[from_a + a][from_b + b] = cmp::min(dp[from_a + a][from_b + b], dp[from_a][from_b] + c);
            }
        }
    }

    let mut ans = inf;
    let mut cur = 1;
    while ma * cur <= a_sum && mb * cur <= b_sum {
        ans = cmp::min(ans, dp[ma * cur][mb * cur]);
        cur += 1;
    }
    if ans == inf {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

const int BIT_MAX = 3333;

template <class T> class BIT{
	T x[BIT_MAX + 1];
	
public:
	
	void dft(){
		fill(x,x+BIT_MAX+1,0);
	}
	
	void add(int a , T b){
		++a;
		for(; a <= BIT_MAX ; a += a & -a) x[a] += b;
	}
	
	T get(int a){
		++a;
		T b = 0;
		for(; a > 0 ; a -= a & -a) b += x[a];
		return b;
	}
};

int N,M;
char s[3333];
BIT<int> bit[3333];
int p[3333];
long long dp[3333][3333];
const int mod = 1e9 + 7;

int main(){
	scanf("%d%d %s" , &N , &M , s);
	int x = 0;
	bit[0].add(0,1);
	bit[0].add(1,-1);
	p[0] = 0;
	repp(i,0,N){
		if(s[i] == '1') ++x;
		bit[i+1].add(x,1);
		bit[i+1].add(x+1,-1);
		p[i+1] = x;
	}
	int r = 0;
	repp(i,0,M){
		int x , y;
		scanf("%d%d" , &x , &y);
		if(r >= y) continue;
		--x;
		int b = 0;
		while(bit[x].get(b) == 0) ++b;
		int e = b + 1;
		while(bit[x].get(e) > 0) ++e;
		repp(j,x+1,y){
			if(j + p[y] - b > y) ++b;
			if(p[y] >= e) ++e;
			bit[j].add(b,1);
			bit[j].add(e,-1);
		}
		r = y;
	}
	dp[0][0] = 1;
	repp(i,1,N+1){
		repp(j,0,p[N]+1){
			if(bit[i].get(j) > 0){
				dp[i][j] = (dp[i-1][j] + (j > 0 ? dp[i-1][j-1] : 0)) % mod;
			}
		}
	}
	printf("%lld\n" , dp[N][p[N]]);
	return 0;
}


Measured memory_bytes: 40064
from collections import defaultdict
N, M = map(int, input().split())
D = defaultdict(list)
for i in range(M):
  a, b = map(int, input().split())
  D[a-1].append(b-1)
  D[b-1].append(a-1)

for i in range(N):
  print (len(D[i]))

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	ll R, G, B, N;
	cin >> R >> G >> B >> N;
	ll b1 = max(R, max(G, B));
	ll b3 = min(R, min(G, B));
	ll b2 = R + G + B - b1 - b3;

	ll i, j;
	ll ans = 0;
	for (i = 0; i*b1 <= N; i++){
		for (j = 0; i*b1 + j*b2 <= N; j++){
			if ((N - i*b1 - j*b2) % b3 == 0){
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    ll a, b;
    cin >> a >> b;

    if (a < b)
    {
        ll temp = a;
        a = b;
        b = temp;
    }
    // a>=b
    if (a == b) 
    {
        cout << "0\n";
        return 0;
    }else if ((a + b) % 2 == 0)
    {
        cout << (a+b)/2 << "\n";
        return 0;
    }
    else
    {
        cout << "IMPOSSIBLE\n";
        return 0;
    }

}
    

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	string s,u,v;
	t = 1;
	while(t--) {
	 cin >> s >> u >> v;
	 cout << s[0] << u[0] << v[0] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a;
	cin>>a;
	vector<int> b(a);
	for(int i=0;i<a;i++)
		cin>>b.at(i);
	int dp[100010];
	dp[0]=0;
	dp[1]=abs(b.at(0)-b.at(1));
	for(int i = 2;i < a;i++) {
		dp[i]=min(dp[i-1]+abs(b.at(i-1)-b.at(i)),dp[i-2]+abs(b.at(i-2)-b.at(i)));
	}
	cout<<dp[a - 1]<<endl;
}

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

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

  int n, m;
  cin >> n >> m;
  priority_queue<int> pq;

  rep(i, 0, n) {
    int a;
    cin >> a;
    pq.push(a);
  }
  rep(i, 0, m) {
    int v = pq.top();
    pq.pop();
    v /= 2;
    pq.push(v);
  }
  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long


int main() {
	int N, K; cin >> N >> K;
	cout << N-K+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=100005;

void solve()
{
   int h,w,m;
   cin>>h>>w>>m;
   set<pair<int,int>>s;int x,y;
   int cnt1[h+1]={0},cnt2[w+1]={0};
   for(int i=0;i<m;i++)
   {
       cin>>x>>y;
       s.insert(m1(x,y));
       cnt1[x]++;
       cnt2[y]++;
   }
   int mxr=0,mxc=0;
   for(int i=1;i<=h;i++)
   mxr=max(mxr,cnt1[i]);
   for(int i=1;i<=w;i++)
   mxc=max(mxc,cnt2[i]);
   vi rw,cl;
   for(int i=1;i<=h;i++)
   {
       if(cnt1[i]==mxr)
       rw.pb(i);
   }
   for(int i=1;i<=w;i++)
   {
       if(cnt2[i]==mxc)
       {
           cl.pb(i);
       }
   }
   int ans=cnt1[rw[0]]+cnt2[cl[0]];
   if(s.find(m1(rw[0],cl[0]))!=s.end())
   ans--;
   else
   {
       cout<<ans<<endl;
       return;
   }
   
   for(int i:rw)
   {
       for(int j:cl)
       {
           if(s.find(m1(i,j))==s.end())
           {
               cout<<ans+1<<endl;
               return;
           }
       }
   }
   cout<<ans<<endl;
   


    
}
int32_t main()
{
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}





Measured memory_bytes: 35024
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n, k;
string s;

int main() {
    cin >> n >> k >> s;
    ll score = 0;
    rep(i, n-1) {
        if(s[i] == s[i+1]) score++;
    }
    ll ret = min(score + 2*k, n-1);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


bool water[3001];
bool sugar[3001];

int main() {
	init();

	int AB[2], CD[2];
	rep(i, 0, 2) {
		int a; cin >> a;
		AB[i] = a;
	}
	rep(i, 0, 2) {
		int a; cin >> a;
		CD[i] = a;
	}
	int E, F; cin >> E >> F;

	//作れる水と砂糖の質量
	memset(water, false, sizeof(water));
	memset(sugar, false, sizeof(sugar));
	water[0] = true;
	sugar[0] = true;
	rep(i, 0, F + 1) {
		rep(j, 0, 2) {
			if (water[i] && i + AB[j] * 100 <= F) {
				water[i + AB[j] * 100] = true;
			}
			if (sugar[i] && i + CD[j] <= F) {
				sugar[i + CD[j]] = true;
			}
		}
	}

	int num[3001];
	memset(num, 0, sizeof(num));
	rep(i, 0, F + 1) {
		if (!water[i])continue;
		rep(j, 0, min(i / 100 * E, F - i) + 1) {
			if (sugar[j]) {
				num[i] = max(num[i], j);
			}
		}
	}
	int m = 0, wm = 0;
	double cnt = 0;
	bool ok = false;
	rep(i, 1, F + 1) {
		if (num[i] != 0) {
			if (i + num[i] > F)continue;
			if (chmax(cnt, (double)(100 * num[i]) / (double)(num[i] + i))) {
				ok = true;
				m = i + num[i];
				wm = num[i];
			}
		}
	}
	if (ok)cout << m << " " << wm << "\n";
	else cout << AB[0]*100 << " " << 0 << "\n";

	return 0;
}

Measured memory_bytes: 3576
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int x, y;
	cin >> x >> y;
	if (x < y)return cout << 0 << endl, 0;
	else return cout << 10 << endl, 0;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int maxn=3005;
int dp[maxn][maxn];//dp[i][j]代表a串前i个字符，b串前j个字符的公共子序列长度 
int rec[maxn][maxn];//rec[i][j]
string a,b;
void printlcs(int i,int j)
{
	if(i==0||j==0)
	  return ;
	else if(rec[i][j]==1)//上移,a串减1，b串不变
	{
		printlcs(i-1,j);
	} 
	else if(rec[i][j]==2)//左移，a串不变，b串减一
	{
		printlcs(i,j-1);
	}
	else//左上移，ab串同时减1
	{
		printlcs(i-1,j-1);
		cout<<a[i-1];
	} 
}
int main()
{
	while(cin>>a>>b)
	{
		int n=a.length(),m=b.length();
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(a[i-1]==b[j-1])
				{
					dp[i][j]=dp[i-1][j-1]+1;
					rec[i][j]=3;//1=上移，2=左移，3=左上移 
				}
				else if(dp[i-1][j]>=dp[i][j-1])
				{
					dp[i][j]=dp[i-1][j];
					rec[i][j]=1;
				}
				else
				{
					dp[i][j]=dp[i][j-1];
					rec[i][j]=2;
				}
			}
		}
		printlcs(n,m);
		cout<<endl;
	}
}


Measured memory_bytes: 74168
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 3000;

int n;
double p[MAXN];
double dp[MAXN][MAXN]; //dp[i][j] je vjerojatnost da je u prvih i novcica j glava

int main(){

    cin >> n;
    cin >> p[0];
    dp[0][1] = p[0];
    dp[0][0] = 1-p[0];

    for (int i = 1; i < n; i++){
        cin >> p[i];
        for (int j = 0; j < MAXN; j++){
            if (j > 0) dp[i][j] += (double)dp[i-1][j-1]*p[i];
            dp[i][j] += (double)dp[i-1][j]*(1-p[i]);
        }
    }

    double sol = 0;
    for (int i = n/2+1; i <= n; i++) sol += (double)dp[n-1][i];

    cout << setprecision(10) << fixed << (double)sol;

    return 0;

}

Measured memory_bytes: 70528
N=int(input())
L=list(map(int,input().split()))
L_temp=L

A_N=100010
counter=[0]*A_N

for l in L_temp:
    counter[l]+=1
    
for c_idx in range(1,len(counter)):
    counter[c_idx]+=counter[c_idx-1]
# print(counter)
    
L_sort=[0]*len(L_temp)

for l in L_temp[::-1]:
    L_sort[counter[l]-1]=l
    # print(l,counter[l],L_sort)
    counter[l] -= 1
    
print(' '.join(map(str,L_sort)))


Measured memory_bytes: 243500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	cout << s.substr(0,s.size()-8) << endl;
}

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

int ans;
bool searched[101];

void dfs(vector<vector<int>>& G, int p, int cost) { // p:position
    bool updated = false;
    for(int i=0; i<G[p].size(); ++i) {
        int next = G[p][i];
        if(!searched[next]) {
            searched[next] = true;
            dfs(G, next, cost+1);
            searched[next] = false;
            updated = true;
        }
    }
    if(!updated) ans = max(ans, cost);
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<vector<int>> G(101);
        ans = 0;

        for(int i=0; i<n; ++i) {
            int a, b;
            cin >> a >> b;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        for(int i=1; i<101; ++i) {
            fill(begin(searched), end(searched), false);
            searched[i] = true;
            dfs(G, i, 1);
        }
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 3032
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));
    }

    private static String solve(String S) {
        return S.substring(0, 3);
    }
}

Measured memory_bytes: 35628
import collections
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a



c = collections.Counter(prime_factorize(n))
ans = 0
for i in c:
    nn = c[i]
    st = 1
    while nn>=st:
        nn=nn-st
        ans += 1
        st=st+1

print(ans)


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

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (auto &e: s) cin >> e;
    vector<vector<int>> dpL(h, vector<int>(w, 0)), dpR(dpL), dpU(dpL), dpD(dpL);
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (s[i][j] == '#') continue;
        dpL[i][j] = (j ? dpL[i][j - 1] : 0) + 1;
        dpU[i][j] = (i ? dpU[i - 1][j] : 0) + 1;
    }
    for (int i = h - 1; i >= 0; i--) for (int j = w - 1; j >= 0; j--) {
        if (s[i][j] == '#') continue;
        dpR[i][j] = (j + 1 < w ? dpR[i][j + 1] : 0) + 1;
        dpD[i][j] = (i + 1 < h ? dpD[i + 1][j] : 0) + 1;
    }
    int ans = 0;
    for (int i = 0, j; i < h; i++) for (j = 0; j < w; j++) if (s[i][j] == '.') {
        ans = max(ans, dpL[i][j] + dpR[i][j] + dpU[i][j] + dpD[i][j] - 3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67200
#include <stdio.h>

int main(){

    int i,a,b,op;

    while(i == 0){

    scanf("%d %c %d",&a,&op,&b);

    if(op =='+'){
          printf("%d\n",a+b);
   } else if(op == '-'){
          printf("%d\n",a-b);
   } else if(op == '*'){
          printf("%d\n",a*b);
   } else if(op == '/'){
          printf("%d\n",a/b);
   } else if(op == '?'){
          break;
   }
}
   
   return 0;

}


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

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main(int argc, char const *argv[]) {
    
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a > b) {
        swap(&a, &b);
    }

    if (b > c) {
        swap(&b, &c);
    }

    if (a > b) {
        swap(&a, &b);
    }
    
    cout << a << ' ' << b << ' ' << c << endl;

    return 0;
}



Measured memory_bytes: 3152
#include<stdio.h>
#define N 100
//void insert(int*,int);
//void print(int*,int);
void print(int A[],int n){
  int i;

  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insert(int A[] ,int n){
  int i,j,v;

  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
     
    }
     A[j+1]=v;
    print(A,n);
  }

}


int main(){

  int i,n,ar[N];

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&ar[i]);

  print(ar,n);

  insert(ar,n);

  return 0;
}

/*void insert(int A[] ,int n){
  int i,j,v;

  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
     
    }
     A[j+1]=v;
    print(A,n);
  }

}

void print(int A[],int n){
  int i;

  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
*/



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

int main() {
    //エラトステネスの篩
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0; is_prime[1] = 0;
    for (int i=2; i<MAX; i++) {
        if (!is_prime[i]) continue;
        for (int j= i*2; j<MAX; j += i) is_prime[j] = 0;
    }
    vector<int> is_like(MAX);
    for (int i=1; i<MAX; i += 2) {
        if (is_prime[i] && is_prime[(i+1)/2]) is_like[i] = 1;
    }
    vector<int> sum(MAX+1);
    for (int i=0; i<MAX; i++) {
        sum[i+1] = sum[i] + is_like[i];
    }
    int q; cin >> q;
    for (int i=0; i<q; i++) {
        int l, r; cin >> l >> r;
        r++;
        cout << sum[r] - sum[l] << endl;
    }
}

Measured memory_bytes: 1792
def main():
    A, B, C, D, E, F = map(int, input().split())

    max_d = 0
    max_a, max_b = 100*A, 0
    for i in range(F//(100*A)+1):
        F1 = F - 100*A*i
        for j in range(F1//(100*B)+1):
            F2 = F1 - 100*B*j
            if i+j > 0:
                for k in range(min(F2,(A*i+B*j)*E)//C+1):
                    F3 = F2 - C*k
                    for l in range(min(F3,((A*i+B*j)*E-C*k))//D+1):
                        #F4 = F3 - D*l
                        #if F4 >=0 and C*k+D*l <= (A*i+B*j)*E:
                        d = (C*k+D*l) / (A*i+B*j)
                        if d > max_d:
                            max_d = d
                            max_a = C*k+D*l + 100*(A*i+B*j)
                            max_b = C*k+D*l
    return max_a, max_b


if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Measured memory_bytes: 3064
from array import array
from itertools import repeat
from operator import itemgetter


def main():
    height, width = map(int, input().split())

    grid = []
    for _ in repeat(None, height):
        grid.append(array('B', (int(c == '.') for c in input())))

    for index in range(height - 1, -1, -1):
        if all(grid[index]):
            del grid[index]

    for index in range(width - 1, -1, -1):
        if all(map(itemgetter(index), grid)):
            for row in grid:
                del row[index]

    for row in grid:
        print(''.join('.' if b else '#' for b in row))


if __name__ == '__main__':
    main()


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

#define debug(x) cout << '[' << #x << " is: " << x << "] " <<"\n";
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("fike.txt","r",stdin );
#define outF freopen("cbs.out" , "w" , stdout ) ;
#define sum(a)a * (a + 1 ) / 2
#define ll long long

const double eps = 1e-9 , PI = acos(-1) ;
const int N = 1e5 + 6, oo = 1e9 , M = 4 * N, mod = 2004 , K = 12;

int n , m , vis[N] , dp[N] ;
vector<int>adj[N] ;
int dfs(int u){

    if(adj[u].empty())
        return 0 ;
    vis[u]++;
    int &ret = dp[u];
    if(~ret)
        return ret ;
    for(auto f : adj[u])
        ret = max(ret , dfs(f) + 1 );
    return ret ;
}


int32_t main(){

    //inF;
    // Dont Forget memset
    memset(dp , -1 , sizeof dp);
    //calculate constraints please!!!
    fastio;
    cin >> n >> m ;
    while(m--){
        int u , v ;
        cin >> u >> v ;
        adj[u].push_back(v);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++)
        if(!vis[i])
            ans = max(ans , dfs(i));
    cout << ans ;
   return 0 ;
}



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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 3010;
int n, t;
struct dish {
  int dt, val;
  bool operator<(const dish &o) const {
    return dt < o.dt;
  }
};

dish dishes[maxn];
int dp[maxn]; //maxval with first i dishes in j minutes

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

  cin>>n>>t;
  for (int i=1; i<=n; i++) {
    int a,b; cin>>a>>b;
    dishes[i] = {a,b};
  }
  sort(dishes+1,dishes+1+n);


  
  int ans = 0;
  for (int i=0; i<n; i++) {
    for (int j=t-1-dishes[i].dt; j>=0; j--) {
      dp[j+dishes[i].dt] = max(dp[j+dishes[i].dt], dp[j] + dishes[i].val);
    }
    for (int j=1; j<=t; j++) {
      dp[j] = max(dp[j], dp[j-1]);
    }
    ans = max(ans, dp[t-1] + dishes[i+1].val);
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

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

    int ans = 1;
    N -= K;

    ans += N / (K - 1);
    if (N % (K - 1) != 0) ++ans;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a,b,c,d;
    string s,t,u;
 
    cin >> a >> b;//>> c >> d;

    cout << a / (2 * b + 1) + min(ll(1), a % (2 * b + 1)); 
 
 
    return 0;
}

Measured memory_bytes: 256
n = int(input())

count_dict = {}

for num in range(1, n + 1):
    count_dict[num] = 0
    tmp = num
    while True:
        if tmp % 2 == 0:
            tmp /= 2
            count_dict[num] += 1
        else:
            break

max_count = max(count for count in count_dict.values())
result = [k for k, v in count_dict.items()
          if v == max_count][0]

print(result)


Measured memory_bytes: 3060