akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFLL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int prime[1000010];//i番目の素数
bool is_prime[1000011];
//n以下の素数の個数を全て返す関数
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main() {
    sieve(100010);
    int cnt[100010];
    cnt[0] = 0;
    for(int i = 1; i < 100010; i++){
        if(is_prime[i] && is_prime[(i+1) / 2]){
            cnt[i] = cnt[i-1] + 1;
        }else{
            cnt[i] = cnt[i-1];
        }
    }
    
    
    
    
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int a,b;
        cin >> a >> b;
        cout << cnt[b] - cnt[a-1] << endl;
    }
    
    
    
}

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

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

void solve(std::string S){
    std::string ans;

    if( S[2] == S[3] && S[4] == S[5]){
        ans = YES;
    }else{
        ans = NO;
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        String s = in.next();
        int len = s.length();
        if(len > k) {
            s = s.substring(0, k) + "...";
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 38624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

class BPopularVote {
 public:
  void solve(std::istream &in, std::ostream &out) {

      int n, m, sum = 0;
      in >> n >> m;
      vector<int> v(n);
      forn(i, n)in >> v[i], sum += v[i];

      sort(all(v));
      reverse(all(v));
      bool ok = true;
      for (int i = 0; i < m; ++i) {
          if (v[i] < sum / (4.0 * m))
              ok = false;
      }

      out << (ok ? "Yes" : "No") << '\n';

  }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    BPopularVote solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
integers = list(map(int, input().split()))
integers.sort()
if len(integers) == 0:
    print(x)
    exit()
x1 = x
while x1 in integers:
    x1 -= 1
x2 = x
while x2 in integers:
    x2 += 1
if x-x1 > x2-x:
    print(x2)
else:
    print(x1)

Measured memory_bytes: 9196
#include<stdio.h>
#include<string.h>
using namespace std;
int ans[150][150];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int ans=n;
        for(int i=1;i<=n;i*=2)
        {
            ans=i;
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 128
Input=[list(map(int,s.split())) for s in open(0)]
NN=Input[0]
N=NN[0]
A1=Input[1]
A2=Input[2]
canlist=[]
for i in range(N):
    candy=0
    candy+=sum(A1[:i+1])
    candy+=sum(A2[i:])
    canlist.append(candy)
print(max(canlist))

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll l, r;
  cin >> l >> r;
  ll ans = INT_MAX;
  ll end = min(r, l + 2019LL);
  for (ll i = l; i <= end - 1; i++) {
    for (ll j = i + 1; j <= end; j++) {
      ll val = (i * j) % 2019LL;
      ans = min(ans, val);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
#define sz(v) ((int)(v).size())
using pi = complex<double>;

int main(){
	int n, l;
	scanf("%d %d",&n,&l);
	vector<pi> a(n);
	for(int i=0; i<n; i++){
		int x; cin >> x;
		a[i] = pi(cos(acos(-1) * x / l), sin(acos(-1) * x / l));
	}
	auto ret = pi(0, 0);
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int L = i, M = j - i - 1, R = n - j - 1;
			ret += (1.0 * L + R - M) * (a[i] * a[j]);
		}
	}
	ret /= (1.0 * n * (n-1) * (n-2) / 6);
	printf("%.10f %.10f\n", ret.real(), ret.imag());
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int ans;
int dp[10000][10000];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    ans = 0;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        char c;
        scanf(" %c", &c);
        if (c == '.') {
          dp[i][j] = 1;
          if (i > 0 && j > 0) {
            int t = min(dp[i-1][j], dp[i][j-1]);
            dp[i][j] = max(dp[i][j], min(t, dp[i-1][j-1])+1);
          }
        } else dp[i][j] = 0;
  
        ans = max(ans, dp[i][j]);
      }
    }
  
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 10484
#!/usr/bin/env python
#-*- coding:utf-8 -*-

def binarySearch(arr, key):
	left = 0
	right = len(arr)
	
	while left < right:
		mid = (left + right) / 2
		if arr[mid] == key:
			return True
		
		if arr[mid] > key:
			right = mid
		#elif arr[mid] < key:
		else:
			left = mid + 1 
	
	return False

def main():
	Ns = int(raw_input())
	S  = map(int, raw_input().split())
	Nt = int(raw_input())
	T  = map(int, raw_input().split())
	
	total_v = 0
	for key in T:
		if binarySearch(S,key):
			total_v += 1

	print total_v
			
	

#def test():

if __name__ == '__main__':
	main()
	#test()

Measured memory_bytes: 14736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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 gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll s;
cin>>s;
map<ll,ll>rensou;
rensou[s]++;
ll cnt=1;
while(1){
    cnt++;
    if(s%2){
        s=3*s+1;
    }else{
        s=s/2;
    }
    rensou[s]++;
    if(rensou[s]>1){
        cout<<cnt<<endl;
        break;
    }
}
}












Measured memory_bytes: 256
#include<iostream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    ll a[m];
    ll sum = 0;
    for(int i = 0 ; i < m ; i++){
        cin >> a[i];
        sum += a[i];
    }
    cout << max(0ll , n-sum + 1) - 1 << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

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

        String s,t,ans;
        boolean eq,eq2;        
        Integer n;

        ans="";
        s=sc.next();
        n=s.length();
        StringBuffer str = new StringBuffer(s);
        t=str.reverse().toString();

        eq=s.equals(t);
        t=s.substring((n+1)/2, n);
        s=s.substring(0,(n-1)/2);
        eq2=s.equals(t);
        
        if(eq && eq2){
            ans="Yes";
        }else{
            ans="No";
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];

  map<char, int> m;
  for (char c = 'a'; c <= 'z'; c++) m[c] = 50;

  for (int i = 0; i < n; i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      int num = count(s[i].begin(), s[i].end(), c);
      m[c] = min(m[c], num);
    }
  }
  string ans;
  for (char c = 'a'; c <= 'z'; c++) {
    string t(m[c], c);
    ans += t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556
n, m = map(int,input().split())
data = [list(map(int, input().split())) for _ in range(m)]
start = set(i[1] for i in data if i[0] == 1)
goal = set(j[0] for j in data if j[1] == n)

if start & goal:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 59512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<math.h>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    _cin;

    int arr[5];
    for(int i=0;i<5;i++){
        cin>>arr[i];
        if(arr[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3148
#include<stdio.h>
int main()
{
	int r, D, X, n;
	int x[10];
	
	scanf("%d %d %d", &r, &D, &X);
	
	x[0] = X*r - D;
	
	for(n=1; n<10; n++){
		x[n] = x[n-1]*r - D;
	}
	
	
	for(n=0; n<10; n++){
	printf("%d\n", x[n]);
	}
	
	return 0;
	
}

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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int q = sc.NextInt();
        string s = sc.NextString();
        
        int[] a = new int[n];
        int c = 0;
        for (int i = 1; i < n; i++)
        {
        	if (s[i - 1] == 'A' && s[i] == 'C') c++;
        	a[i] = c;
        }
        
        for (int k = 0; k < q; k++)
        {
        	int l = sc.NextInt() - 1;
        	int r = sc.NextInt() - 1;
        	
        	Console.WriteLine(a[r] - a[l]);
        }
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 16716
n,m=[int(i) for i in input().split()]

hyou=[]

for i in range(m):
    hyou.append([int(i) for i in input().split()])


next_island=set()
pre_island=set()
for go in hyou:
    one,two=go
    newone=min(one,two)
    newtwo=max(one,two)

    if newone==1:
        next_island.add(newtwo)
    if newtwo==n:
        pre_island.add(newone)

ans=next_island&pre_island

if len(ans)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Measured memory_bytes: 49276
import java.io.*;
import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static int getgcd(int n1,int n2){
        while(n1 != n2){
            if(n1 > n2) n1 -= n2;
            else n2 -= n1;
        }
        return n1;
    }
    static boolean isSorted(int[] arr, int n){
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]) return false;
        }
        return true;
    }
    static boolean isPrime(long n){
        if(n==2) return true;
        else if(n%2==0) return false;
        for(int i=3;i<=n/2;i+=2){
            if(n%i==0) return false;
        }
        return true;
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader s=new FastReader();
        int a=s.nextInt(),b=s.nextInt(),c=s.nextInt(),k=s.nextInt();
        int count=0;
        while((b)<=a){
            b*=2;count++;
        }
        while((c)<=b){
            c*=2;count++;
        }
        if(count<=k) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 25380
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0)cout << s.at(i);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int ary[3];
	rep(i, 3) cin >> ary[i];
	sort(ary, ary + 3);
	if (ary[0] == ary[1]) cout << ary[2] << endl;
	else cout << ary[0] << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
public class Main{
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	String input = scan.nextLine();
	String[] inputs = input.split(" ");
	int[] numbers = new int[n];
	for (int i = 0; i < n; i++) {
	    numbers[i] = Integer.parseInt(inputs[i]);
	}
	int min = 1000000;
	int max = -1000000;
	long sum = 0;
	for (int i = 0; i < n; i++) {
	    if (min > numbers[i]) {
		min = numbers[i];
	    }
	    if (max < numbers[i]) {
		max = numbers[i];
	    }
	    sum += (long)numbers[i];
	}
	System.out.println(min + " " + max + " " + sum);
    }
}

Measured memory_bytes: 31812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,k; cin >> n >> k;
    vector<ll> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    ll ans = 1e9;
    for(int i = 0; i < n-k+1; i++){
        if(ans > x[i+k-1] - x[i] + min(abs(x[i]),abs(x[i+k-1]))){
            ans = x[i+k-1] - x[i] + min(abs(x[i]),abs(x[i+k-1]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<map>

using namespace std;

int dp[100000][3];


int main(){

    int n;

    cin>>n;
    vector<vector<int>> v;

    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++) dp[i][j] = -1;
    }

    int t1,t2,t3;
    for(int i=1;i<=n;i++){
        vector<int> temp;
        cin>>t1>>t2>>t3;
        temp.push_back(t1);
        temp.push_back(t2);
        temp.push_back(t3);
        v.push_back(temp);
    }

    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];

    for(int i=1;i<n;i++){
        dp[i][0] = v[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = v[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = v[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;

}

Measured memory_bytes: 9996
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, L;
  cin >> N >> L;

  int R = L + N - 1;

  int eat;
  if (R <= 0)
  {
    eat = R;
  }
  else if (L >= 0)
  {

    eat = L;
  }
  else
  {
    eat = 0;
  }

  int answer = (((R + L) * (R - L + 1)) / 2) - eat;

  cout << answer << endl;
}


Measured memory_bytes: 256
N = int(input())
S = []
for _ in range(N):
    S.append(input())
M = int(input())
T = []
for _ in range(M):
    T.append(input())

L = set(S + T)
ans = 0
for l in L:
    blue = S.count(l)
    red = T.count(l)
    ans = max(ans, blue-red)

print(ans)

Measured memory_bytes: 62648
N, M = map(int, input().split())
red = [0] * N
red[0] = 1
num = [1] * N
for _ in range(M):
    x, y = map(int, input().split())
    num[x - 1] -= 1
    num[y - 1] += 1
    if red[x - 1] == 1:
        red[y - 1] = 1
        if num[x - 1] == 0:
            red[x - 1] = 0
print(sum(red))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
		int q;
		cin>>q;
		int cnt[26];
		rep(i,26)cnt[i]=1e9+7;
		while(q--){
			string s;
			cin>>s;
			int res[26];
			rep(i,26)res[i]=0;
			rep(i,sz(s)){
				res[s[i]-'a']++;
			}
			rep(i,26){
				cnt[i]=min(cnt[i],res[i]);
				//cout<<cnt[i]<<" "<<res[i]<<" ";
			}
			//cout<<"\n";
		}
		rep(i,26){
			if(cnt[i]>0){
				int x=cnt[i];
				while(x--){
					cout<<char(i+'a');
				}
			}
		}
}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

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

A = list(map(int, input().split()))
A.sort(reverse=True)

ans = 0
cnt = 0

for i in range(len(A)):
    if i == 0:
        cnt += 1
        ans += A[i]
    else:
        if cnt == N-2:
            cnt += 1
            ans += A[i]
        else:
            cnt += 2
            ans += A[i] * 2    

    if cnt == N-1:
        break
print(ans) 

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

int main(void){
  int n;cin >> n;
  //偶数は,n/2個 奇数はn-(n/2)個
  cout << (n/2)*(n-n/2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n;
   cin >> n;
   VI p(n);
   rep(i,n){
      cin >> p.at(i);
   }
   int cnt=0;
   int cp=0;
   rep(i,n){
      if(p[i]==i+1 && cp%2==0){
         cnt++;
         cp++;
      }
      else if(p[i]==i+1){
         cp++;
      }
      else if(p[i]!=i+1 ){
         cp=0;
      }
   }
   cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        rep(i, b) cout << a;
    } else {
        rep(i, a) cout << b;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
main () {
	string str;
	int q;
	cin >> str >> q;
	for (int i=0; i<q; i++) {
		string code;
		int a, b;
		cin >> code >> a >> b;
		if (code == "print") cout << str.substr(a, b-a+1) << endl;
		if (code == "reverse") reverse(str.begin()+a, str.begin()+b+1);
		if (code == "replace") {
				string p;
				cin >> p;
				str.replace(a, b-a+1, p);
		}
	}
}


Measured memory_bytes: 3240
def main():
    n , m = map(int, input().split())
    con = list(set([tuple(map(int, input().split())) for i in range(m)]))
    if (len(con) > n) or (m != 0 and n != 1 and con[0] == (1,0)):
        print(-1)
        return
    if (n == 1 and m == 0):
        print(0)
        return
    ans = 10**(n-1)
    if (m == 0):
        print(ans)
        return
    tmp = -1
    for s,c in con:
        if (s == tmp):
            print(-1)
            return
        else:
            tmp = s
        if (s==1):
            ans += (c-1)*10**(n-1)
        else:
            ans += c*10**(n-s)
    print(ans)
main() 

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

int main() {
    int N, K; cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) {
        if (i < K) continue;
        else {
            if (A[i-K] < A[i]) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4412
#include <iostream>

using namespace std;

int main() {
    int N;

    cin >> N;

    switch (N % 10) {
    case 0:
        cout << "pon" << endl;
        return 0;
    case 1:
        cout << "pon" << endl;
        return 0;
    case 2:
        cout << "hon" << endl;
        return 0;
    case 3:
        cout << "bon" << endl;
        return 0;
    case 4:
        cout << "hon" << endl;
        return 0;
    case 5:
        cout << "hon" << endl;
        return 0;
    case 6:
        cout << "pon" << endl;
        return 0;
    case 7:
        cout << "hon" << endl;
        return 0;
    case 8:
        cout << "pon" << endl;
        return 0;
    case 9:
        cout << "hon" << endl;
        return 0;
    default:
        break;
    }

    return 0;
}

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

int main() {

	// A
	/*int input, a, b, c;
	cin >> input;
	a = input / 100;
	b = (input - a * 100) / 10;
	c = input - a * 100 - b * 10;
	cout << a + b + c << endl;
	return 0;*/

	// B
	int n;
	cin >> n;
	std::vector<int> a = {};
	bool flag = true;

	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a.push_back(x);
	}

	int count = 0;
	while (flag) {
		for (int i = 0; i < n; ++i){ 
			if (a[i] % 2 != 0) {
				flag = false;
				--count;
				break;
			}
			a[i] /= 2;
		}
		++count;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	int h, w;
	cin >> h >> w;
	repi(i, 0, h) {
		string str;
		rd(str);
		wrln(str);
		wrln(str);
	}
	return 0;
}

Measured memory_bytes: 256
class Bookmark
  attr_reader :index
  attr_accessor :head,:tail
  def initialize(index)
    @index = index
    @head = 0
    @tail = 0
  end
end

N, K = gets.split.map(&:to_i)
S = gets.chomp
B = (0 .. N).select{|i| i.zero? || i == N || S[i - 1] != S[i] }
  .map{|i| Bookmark.new(i)}

B.each_cons(2) do |a,b| 
    if S[a.index] == '1'
      d = b.index - a.index
      a.head = d
      b.tail = d
    end
  end

ans = (2 * K >= B.size) ? N : B.each_index.take_while{|i| (i + 2 * K) < B.size }
  .map{|i| B[i + 2 * K].index - B[i].index + B[i + 2 * K].head + B[i].tail }.max

puts ans

Measured memory_bytes: 11896
alp = "abcdefghijklmnopqrstuvwxyz"
def f(S):
    global alp
    A = []
    for s in S: A.append(alp.find(s))
    return A
S = f(input())
T = f(input())
S.sort()
T.sort(reverse=True)
flg = 0
for i in range(min(len(S),len(T))):
    if S[i]<T[i]:
        flg = 1
        break
    elif S[i]>T[i]:
        flg = -1
        break
if flg == 1: print("Yes")
elif flg == -1: print("No")
elif len(S)>=len(T): print("No")
else: print("Yes")

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
a_=sum(a)
b=0
for i in range(1,n,2):
    b+=2*a[i]
ans=a_-b
c=[]
c.append(str(ans))
for i in range(n-1):
    ans=2*a[i]-ans
    c.append(str(ans))
print(' '.join(c))




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

namespace ConsoleApp11
{
    class Class59
    {
        static void Main()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            s = new string(s.OrderBy(x => x).ToArray());
            t = new string(t.OrderByDescending(x => x).ToArray());
            for(int i = 0; i < Math.Min(s.Length, t.Length); i++)
            {
                if (s[i] < t[i])
                {
                    Console.WriteLine("Yes");
                    return;
                }
                else if (s[i] > t[i])
                {
                    
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine(s.Length<t.Length?"Yes":"No");
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
char a[110];
int main()
{
    int i,j,k;
    LL n;
    scanf("%s%lld",a,&n);
    k=strlen(a);
    for(i=0;i<k;i++)
    {
        j=a[i]-'0';
        if(j==1)
        {
            n--;
            if(n==0)
                break;
        }
        else
            break;
    }
    printf("%c\n",a[i]);
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[400][400],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

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

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

      
      cin>>n>>m;
      ans=INF;
     
     rep(i,n)rep(j,m)cin>>a[i][j];
     map<ll,ll> mp;

     while(1){
       map<ll,ll> mpp;
       fl=false;
       rep(i,n){
         rep(j,m){
           if(mp[a[i][j]]==0){
             mpp[a[i][j]]++;
             fl=true;
             break;
           }
         }
       }
       if(!fl)break;
       pos=0;
       rep(i,m){
         if(pos<=mpp[i+1]){
           pos=mpp[i+1];
           cmp=i+1;
         }
       }
       ans=min(ans,pos);
       mp[cmp]++;
     }
     Cout(ans);

       
return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstring>
#include<climits>
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> p64;
typedef vector<ll> v64;
const int N = 2 * 1e5 + 10;
const ll inf = 1e18 + 100;
const ll mod = 1e9 + 7;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    for(int i = 0; i < n ; i++) {
        cin>>arr[i];
    }

    ll cnt = 0;

    ll m = arr[0];
    for(int i = 0; i < n ;i++) {
        if(m > arr[i]) {
            m = arr[i];
            cnt++;
        }
    }
    cout<<cnt+ 1;
}
int main()
{
    ll t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const int Mod = 998244353;
const int MN = 305;

inline void Sub(int &x, int y) { x -= y; x += x >> 31 & Mod; }
inline void Add(int &x, int y) { Sub(x, Mod - y); }

char s[MN];
int N, K, A[MN];
int M, C[MN];
int f[2][MN][MN], tmp[MN][MN];

int main() {
	scanf("%s%d", s + 1, &K), N = strlen(s + 1);
	for (int i = 1; i <= N; ++i) A[i] = s[i] - '0';
	A[N + 1] = 0;
	for (int i = 1, c = 0; i <= N + 1; ++i)
		if (A[i]) ++c;
		else C[++M] = c, c = 0;
	int o = 0;
	f[o][0][0] = 1;
	for (int i = 1; i <= M; ++i) {
		o ^= 1;
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N; ++k)
				f[o][j][k] = tmp[j][k] = 0;
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N; ++k) if (f[o ^ 1][j][k]) {
				int val = f[o ^ 1][j][k];
				f[o][j][k] = val;
				Add(tmp[std::max(0, j - C[i])][k], val);
				Sub(tmp[j][k], val);
			}
		for (int j = 1; j <= N; ++j)
			for (int k = 0; k <= N; ++k) {
				if (k) Add(f[o][j][k], f[o][j - 1][k - 1]);
				Add(tmp[j][k], tmp[j - 1][k]);
			}
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N; ++k)
				Add(f[o][j][k], tmp[j][k]);
	}
	K = std::min(K, N);
	int Ans = 0;
	for (int k = 0; k <= K; ++k) Add(Ans, f[o][0][k]);
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
lint M = 1e18;

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

    int n;
    cin >> n;
    vector<lint> v(n);
    bool is0 = false;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        is0 = is0 || (v[i] == 0);
    }
    if (is0) {
        cout << 0 << endl;
        return 0;
    }
    
    lint res = 1;
    for (int i = 0; i < n; ++i) {
        if (log10(res) + log10(v[i]) > 18){
            res = -1;
            break;
        }
        res *= v[i];
    }
    if (res > M || res == -1)
        cout << -1 << endl;
    else
        cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 3992
from operator import itemgetter
n,m=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(n)]
lis.sort()
s=0
for i in range(n):
  if m>lis[i][1]:
    s+=lis[i][0]*lis[i][1]
    m-=lis[i][1]
  else:
    s+=lis[i][0]*m
    break
print(s)


Measured memory_bytes: 27824
#include <bits/stdc++.h>
#define int long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int32_t main() 
{  
   FIO;
  string s;
  cin>>s;
  if(s[0]=='S' && s[1]=='S'&& s[2]=='S')
  cout<<"0\n";
  else if(s[0]=='R' && s[1]=='R'&& s[2]=='R')
  cout<<"3\n";
  else if(s[0]=='R' && s[1]=='R'&& s[2]=='S')
  cout<<"2\n";
  else if(s[0]=='R' && s[1]=='S'&& s[2]=='R')
  cout<<"1\n";
  else if(s[0]=='R' && s[1]=='S'&& s[2]=='S')
  cout<<"1\n";
  else if(s[0]=='S' && s[1]=='R'&& s[2]=='R')
  cout<<"2\n";
  else if(s[0]=='S' && s[1]=='R'&& s[2]=='S')
  cout<<"1\n";
  else if(s[0]=='S' && s[1]=='S'&& s[2]=='R')
  cout<<"1\n";
  
  
  
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

int n = 0;

int main(){
    cin >> n;
    vector<int> x;
    int res = 0, number = 0;
    for(int i = 0; i < n; ++i){
        cin >> number;
        x.push_back(number);
        res+=number;
    }
    ll ans = 0, k = 0;
    ll ans1 = 0, ans2 = 0, finalans = 1000000;
    res = res / n;
    ll res1 = res, res2 = res;
    ++res1;
    --res2;
    ll t = 0;
    for(int i = 0; i < n; ++i){
        k = x[i] - res;
        t = pow(k, 2);
        ans+=t;
    }
    for(int i = 0; i < n; ++i){
        k = x[i] - res1;
        t = pow(k, 2);
        ans1+=t;
    }
    for(int i = 0; i < n; ++i){
        k = x[i] - res2;
        t = pow(k, 2);
        ans2+=t;
    }
    finalans = min(ans,finalans);
    finalans = min(ans1,finalans);
    finalans = min(ans2,finalans);
    cout << finalans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	char c;
	cin >> c;
	if(c == tolower(c)) cout << "a" << endl;
	else cout << "A" << endl;
		
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

string S;

int num, form, latt;

int main(){
  cin >> S;
  num = stoi(S);

  int a, b, c, d;

  a = num / 1000;
  b = (num - a*1000) / 100;
  c = (num - a*1000 - b*100) / 10;
  d = num - a*1000 - b*100 - c*10;

  form = 10*a + b;
  latt = 10*c + d;

  if( form==0 || 13<=form && form<=99){
    if( 1<=latt && latt<=12){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }else{
    if( latt==0 || 13<=latt && latt<=99 ){
      cout << "MMYY" << endl;
    }else{
      cout << "AMBIGUOUS" << endl;
    }
  }

}


Measured memory_bytes: 3556
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, vector<ll> t, vector<ll> v) {
  const int T = accumulate(ALL(t), 0LL);
  vector<int> limit(T), speed(T + 1, 1e9);
  int ti = 0;
  REP(i,N) {
    REP(j,t[i]) { limit[ti] = v[i]; ++ti; }
  }
  REP(i,T) {
    chmin(speed[i], limit[i]);
    chmin(speed[i+1], limit[i]);
  }
  speed[0] = speed[T] = 0;
  REP(i,T) chmin(speed[i+1], speed[i] + 1);
  REP(i,T) chmin(speed[T-i-1], speed[T-i] + 1);
  ld res = 0;
  REP(i,T) {
    // cout << speed[i] << endl;
    if (speed[i] == speed[i+1] && speed[i] < limit[i]) res += speed[i] + 0.25;
    else res += (speed[i] + speed[i+1]) / 2.0L;
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	vector<ll> v(N-1+1);
	vector<ll> t(N-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &t[i]);
	}
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &v[i]);
	}
	solve(N, t, v);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	double n, d;
	cin >> n >> d;
	cout << ceil(n/((2*d)+1));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long int ulli;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
/* TUMSE NAA HO PAAYEGA HAR DO DIN MAI LAGEGA
   LEKIN RUKNE KA NAHI :P */
ll mod=1000000007;

int main() {
	// your code goes here
	FASTIO
	ll n;
	cin >> n;
	ll ans=0;
	if(n<=1){
	    cout << ans << endl;
	    return 0;
	}
	ans=1;
	ll temp1=1,temp2=2;
	for(ll i=0;i<n;i++){
	    ans = (ans%mod * 10%mod)%mod;
	    temp1 = (temp1%mod * 8%mod)%mod;
	    temp2 = (temp2%mod * 9%mod)%mod;
	}
	temp2 = (((temp2%mod) - (temp1%mod))+mod)%mod;
	ans = (((ans%mod) - (temp2%mod))+mod)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
using P = pair<ll, ll>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<P> bc(m);
  rep(i, n) cin >> a[i];
  rep(i, m){
    ll b, c;
    cin >> b >> c;
    bc[i] = P(c, b);
  }
  sort(a.rbegin(), a.rend());
  sort(bc.rbegin(), bc.rend());
  ll ans = 0;
  ll x = 0, y = 0, z = 0;
  rep(i, n){
    if (a[x] > bc[y].first){
      ans += a[x];
      x++;
    }
    else{
      ans += bc[y].first;
      z++;
      if (z == bc[y].second){
        z = 0;
        y++;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 5556
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	s := r.nextString()

	maxInt := func(a int, vs ...int) int {
		for i := range vs {
			v := &vs[i]
			if a < *v {
				a = *v
			}
		}
		return a
	}
	cnt := 1
	ans := 0
	for i := 0; i <= n-2*cnt; {
		if strings.Index(s[i+cnt:], s[i:i+cnt]) >= 0 {
			ans = maxInt(ans, cnt)
			cnt++
		} else {
			i++
		}
	}

	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,m[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
   while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&m[u][v]!=INFTY){
	if(d[v]>d[u]+m[u][v]){
	  d[v]=d[u]+m[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }

   for(int i=0;i<n;i++){
     cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
   }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      m[i][j]=INFTY;
    }
  }

  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      m[u][v]=c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 3136
x,y= map(int,input().split()) # read No of Animals and total of legs 
crane= 2 # declare no of legs of crane
turtle= 4 # declare no of legs of turtles 
ans="No" # pre define the answer to No
for i in range(x+1): # for loop and we put the range until x+1
    b=x-i 
    if crane*i + turtle*b == y: # check the total of legs and compare to the result
        ans = "Yes"
print(ans) # Then print the result either yes or no

Measured memory_bytes: 9104