akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

struct City {
    int idx;
    int pref;
    int year;
    int order;
    bool operator<(const City &another) const {
        return year < another.year;
    }
};

signed main() {
    int n, m; cin >> n >> m;
    vector<City> v[n];

    for(int i = 0; i < m; i++) {
        int p, y; cin >> p >> y;
        p--;
        City c;
        c.idx = i + 1; c.pref = p + 1; c.year = y;
        v[p].push_back(c);
    }

    for(int i = 0; i < n; i++) {
        sort(v[i].begin(), v[i].end());
        for(int j = 0; j < v[i].size(); j++) {
            v[i][j].order = j + 1;
        }
    }

    City ans[m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < v[i].size(); j++) {
            ans[v[i][j].idx - 1] = v[i][j];
        }
    }

    for(int i = 0; i < m; i++) {
        cout << setfill('0') << right << setw(6) << ans[i].pref
             << setfill('0') << right << setw(6) << ans[i].order << endl;
    }

    return 0;
}


Measured memory_bytes: 11648
N,K=map(int,input().split())

from collections import defaultdict
d = defaultdict(int)

for _ in range(N):
    a,b=map(int,input().split())
    d[a]+=b

sorted_d = sorted(d.items(), key=lambda x: x[0])

cnt=0
for k,v in sorted_d:
    cnt+=v
    if cnt>=K:
        print(k)
        exit()

Measured memory_bytes: 15332
import bisect


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))

    best = 0
    for left in range(min(N, K) + 1):
        for right in range(min(N, K) + 1 - left):
            vs = sorted(V[:left] + V[len(V) - right:])
            first_pos = bisect.bisect_left(vs, 0)
            max_trash = K - left - right
            trash = min(first_pos, max_trash)
            value = sum(vs[trash:])
            if best < value:
                best = value
    print(best)


main()


Measured memory_bytes: 3316
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << a*b <<" "<< a * 2 + b * 2 << endl;
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int a=nextInt();
		int b=nextInt();
		int c=nextInt();
		int k=nextInt();
		if(a>k)
			out.println(k);
		else
			out.println(a-Math.max(k-a-b,0));
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32720
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;


int main(){

    ll K;
    cin >> K;

    vector <ll> v(K);
    for(int i = 0; i < K; i++) cin >> v[i];

    ll mini = 2;
    ll maxi = 2;
    for(int i = K - 1; i >= 0; i--){

        ll next = ( mini  / v[i]) * v[i];
        if(next < mini) next += v[i];
        if(maxi < next || next < mini){
            cout << -1 << endl;
            return 0;
        }
        mini = next;
        maxi = (maxi / v[i]) * v[i] + v[i] - 1;
    }
    cout << mini << " " << maxi << endl;

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
pair<int,pair<int,int> >mst[MAX];
int parent[MAX];
int root(int child)
{
    while(parent[child]!=child)
    {
        parent[child]=parent[parent[child]];
        child=parent[child];
    }
    return child;
}
void node_union(int x,int y)
{
    int a=root(x);
    int b=root(y);
    parent[min(a,b)]=parent[max(a,b)];
}
int kruskal(int nodes,int edges)
{
    for(int i=0; i<=nodes; i++)
        parent[i]=i;
    sort(mst,mst+edges);
    int x,y,cost,min_cost=0,i;
    for(i=0; i<edges; i++)
    {
        x=mst[i].second.first;
        y=mst[i].second.second;
        cost=mst[i].first;
        if(root(x)!=root(y))
        {
            min_cost+=cost;
            node_union(x,y);
        }
    }
    return min_cost;
}
bool cmp(pair<int,int> a,pair<int,int> b)
{
    if(a.second<b.second)
        return 1;
    return 0;
}
int dist(int a,int b,int c,int d)
{
    return min(abs(a-c),abs(b-d));
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,it=0,e=0;
    cin>>n;
    vector<pair<int,pair<int,int> > >x,y;
    for(int i=0; i<n; i++)
    {
        int l,r;
        cin>>l>>r;
        x.push_back({l,{r,i+1}});
        y.push_back({r,{l,i+1}});
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int i=1; i<n; i++)
    {
        int d=dist(x[i-1].first,x[i-1].second.first,x[i].first,x[i].second.first);
        int a=x[i-1].second.second;
        int b=x[i].second.second;
        mst[it++]= {d,{a,b}};
        e++;
        //cout<<v[i-1].first<<" "<<v[i-1].second<<" "<<v[i].first<<" "<<v[i].second<<" "<<d<<endl;
    }
    for(int i=1; i<n; i++)
    {
        int d=dist(y[i-1].first,y[i-1].second.first,y[i].first,y[i].second.first);
        int a=y[i-1].second.second;
        int b=y[i].second.second;
        mst[it++]= {d,{a,b}};
        e++;
        // cout<<v[i-1].first<<" "<<v[i-1].second<<" "<<v[i].first<<" "<<v[i].second<<" "<<d<<endl;
    }
    cout<<kruskal(n,e)<<endl;




    return 0;
}


Measured memory_bytes: 8484
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    ll N; cin>>N;
    ll ans=0;
    REP(i,1,N+1){
        ll K=N/i;
        ans+=K*(K+1)*i/2;
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n; cin >> n;

    cout << (n+pow(n, 2)+pow(n, 3)) << endl;

    return 0;
}

Measured memory_bytes: 4216
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i=0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);
    int ans1 = A[N-1];
    
    int candidate1 = Integer.MIN_VALUE/3;
    int candidate2 = Integer.MAX_VALUE/3;
    for (int i=0; i<N-1; i++) {
      if (A[i] < ans1/2) {
        candidate1 = A[i];
      } else {
        candidate2 = A[i];
        break;
      }
    }
    int ans2;
    if (Math.abs(candidate1*2 - ans1) > Math.abs(candidate2*2 - ans1)) {
      ans2 = candidate2;
    } else {
      ans2 = candidate1;
    }
    System.out.println(ans1 + " " + ans2);
  }
}


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

int main(){
    ll x,y;
    cin>>x>>y;
    ll cnt=0;
    while(x<=y){
        x*=2;
        cnt++;
    }
    cout<<cnt<<"\n";
    return 0;
}

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

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

  int ans = 0, flag = 1;

  while (1) {
    for (int i = 0; i < n; i++) {
      if ((a[i] % 2) == 0) {
        a[i] = a[i] / 2;
      } else {
        cout << ans << endl;
        return 0;
      }
    }
    ans++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    int t,x;
    cin>>t>>x;
    cout<<fixed<<setprecision(10);
    cout<<(double)t/x<<endl;

}





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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    string s,t;
    cin>>s>>t;
    int ans=0;
    for (int i=0;i<sz(s);i++) ans+=(s[i]!=t[i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 3776
class Queue {
  private var nums: [Int] = []
  func enqueue(_ v: Int) {
    nums.append(v)
    buildFromBottom()
  }
  func dequeue() -> Int {
    let v = nums[0]
    nums.swapAt(0, nums.count - 1)
    nums.remove(at: nums.count - 1)
    buildFromTop()
    return v
  }
  
  func count() -> Int {
    return nums.count
  }
  
  func buildFromTop() {
    var current = 0
    while current < nums.count {
      var target = current
      let left = current * 2 + 1
      let right = left + 1
      if left < nums.count && nums[left] > nums[target] {
        target = left
      }
      if right < nums.count && nums[right] > nums[target] {
        target = right
      }
      if target == current {
        break
      }
      nums.swapAt(target, current)
      current = target
    }
  }
  
  func buildFromBottom() {
    var current = nums.count - 1
    var parent = (current - 1) / 2
    while parent >= 0 {
      if nums[parent] < nums[current] {
        nums.swapAt(parent, current)
        current = parent
        parent = (current - 1) / 2
      } else {
        break
      }
    }
  }
}

func f(_ list: [[Int]]) -> Int {
  let queue = Queue()
  var sum = 0
  for i in (1..<list.count).reversed() {
    list[i].forEach { queue.enqueue($0) }
    if queue.count() > 0 {
      sum += queue.dequeue()
    }
  }
  return sum
}

let T = Int(readLine()!)!

for t in 0..<T {
  let N = Int(readLine()!)!
  var sum = 0
  var left: [[Int]] = .init(repeating: [], count: N + 1)
  var right: [[Int]] = .init(repeating: [], count: N + 1)
  for i in 1...N {
    let inp = readLine()!.split(separator: " ").map { Int($0)! }
    let k = inp[0]
    let l = inp[1]
    let r = inp[2]
    sum += min(l, r)
    if l > r {
      left[k].append(l - min(l, r))
    } else {
      right[N - k].append(r - min(l, r))
    }
  }
  sum += f(left)
  sum += f(right)
  print(sum)
}


Measured memory_bytes: 18308
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
inf = float("inf")

Q = int(input())
queries = []

for _ in range(Q):
    l, r = map(int, input().split())
    queries.append([l, r])
# print(queries)

MAX = 10 ** 5 + 1

# Sieve of Eratosthenes
is_prime = [1 for _ in range(MAX)]
is_prime[0] = 0
is_prime[1] = 0

for i in range(2, MAX):
    if not is_prime[i]:
        continue
    j = i + i
    while j < MAX:
        is_prime[j] = 0
        j += i

a = [0 for _ in range(MAX)]
for i in range(MAX):
    if i % 2 == 0:
        continue
    if is_prime[i] and is_prime[(i + 1) // 2]:
        a[i] = 1

com_sum = [0 for _ in range(MAX + 1)]
for i in range(MAX):
    com_sum[i + 1] = com_sum[i] + a[i]

for left, right in queries:
    # print(f"s[left] = {com_sum[left]}")
    # print(f"s[right] = {com_sum[right]}")
    x = com_sum[right + 1] - com_sum[left]
    print(x)


Measured memory_bytes: 61660
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int i;
    int ans = s.length();
    bool tmp = true;
    for(int i=1; i<s.length(); i++){
        if(s.at(i) == s.at(i-1)){
            ans --;
            i+=2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
def main():
    a, b, c = map(int, input().split())
    l = [a, b, c]
    l.sort()
    ans = 0
    ans += l[2] - l[1]
    ans += (l[1] - l[0] + 1) // 2
    if ((l[1] - l[0]) % 2 == 1):
        ans += 1

    print(ans)


main()


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

from functools import lru_cache


def main(): 
    a,b = LI()

    if a == 1: a = 14
    if b == 1: b = 14
    print('Alice' if a>b else 'Bob' if b>a else 'Draw')



main()

Measured memory_bytes: 3572
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    int n = 0;
    int k = 0;
    Scanner s = new Scanner(System.in);
    n = Integer.parseInt(s.next());
    k = Integer.parseInt(s.next());
    String buffer = "";
    String[] array = new String[n];
    for(int i=0; i<n; i++){
      array[i] = s.next();
    }

    for(int i=0; i<n-1; i++){
      for(int j=n-1; i<j; j--){
        if(array[j].compareTo(array[j-1])<0){
          buffer = array[j];
          array[j] = array[j-1];
          array[j-1] = buffer;
        }
      }
    }

    for(int i=0; i<n; i++){
      if(i==n-1){
        System.out.println(array[i]);
      }else{
        System.out.print(array[i]);
      }
    }
  }
}


Measured memory_bytes: 36912
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
signed main(){
	IOS;
	int n , k ; 
	cin >> n >> k ; 
	vector<int>arr(n);
	for(int& i : arr) cin >> i ;
	vector<bool>dp(k+1,false);
	for(int i=0;i<=k;i++){
		for(int j: arr){
			if( i-j >= 0 and !dp[i-j]) dp[i] = true;
		}
	}
	cout << (dp[k]?"First":"Second") << endl;
	return 0;
}


Measured memory_bytes: 384
from bisect import bisect_right
N = int(input())
dp = [float("inf") for _ in range(N+1)]

rows = 0
for _ in range(N):
    c = -float(input())
    i = bisect_right(dp, c)
    if i == rows:
        rows += 1
    dp[i] = c
print(len(list(filter(lambda x:x < float("inf"), dp))))

Measured memory_bytes: 50308
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int main(){
	int n, a, b, sum = 0;
	scanf("%d%d%d", &n, &a, &b);
	for(int i = 1; i <= n; i++) {
		int p = i, s = 0;
		while(p) {
			int n = p % 10;
			s += n;
			p /= 10;
		}
		if(s >= a && s <= b) sum += i;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

int n;
int f[101][101][101];
int p[101][11];

int main(){
  cin>>n;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<5;j++){
      for(int k = 0;k<2;k++){
	cin>>f[i][j][k];
      }
    }
  }
  for(int i = 0;i<n;i++){
    for(int j = 0;j<=10;j++){
      cin>>p[i][j];
    }
  }
  int ans = -1111111111;
  for(int i = 1;i<1<<10;i++){
    int tmp = 0;
    for(int j = 0;j<n;j++){
      int num = 0;
      for(int k = 0;k<10;k++){
	if((i & (1<<k)) != 0 && f[j][4-(int)(k / 2)][1-(k%2)]){
	  num++;
	}
      }
      tmp += p[j][num];
    }
    ans = max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>k;
    vector<ld> a(n);
    ld x;
    fo(i,n)
    {
        cin>>x;
        a[i]=(x+1)/2;
    }
    ld c=0,mx=0;
    fo(i,k)c+=a[i];
    mx=max(mx,c);
    for(int j=i;j<n;j++)
    {
        c+=a[j]-a[j-k];
        mx=max(mx,c);

    }
    
    cout<< mx <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    sp(10);
    // w(t)
    sol();
    return 0;
}

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

int main(){

	ll N;
	cin >> N;

	ll ans=0;


	if(N==1 || N==2){
		ans = 0;
	}
	else{
		for(ll i=2; i<N; i++){
			if((N-i) % i == 0){
				ll t = (N-i) / i;
				if(t <= i) break;
				else {
	                  ans += t;

                }
			} 
			else{
				if(i >= (N-i)/i) break;
			}
		}
      	ans += (N-1);
	}

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

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

using namespace std;

const int max_n = 500555, mod = 1000000007;
const int max_x = (1 << 20) + 5;

int n, a[max_n], dp[max_n], zeros[max_n], sump[max_x], sumdp[max_x];
vector<int> all[max_x];

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int get_pr(int x, int pos) {
    auto it = lower_bound(all[x].begin(), all[x].end(), pos);
    if (it == all[x].begin()) {
        return -1;
    }
    --it;
    return *it;
}

bool get_bit(int mask, int pos) {
    return (bool) (mask & (1 << pos));
}

int triv() {
    int ans = 0;
    for (int mask = 0; mask < (1 << (n - 1)); ++mask) {
        int f = 0, x = -1, ok = 1;
        for (int i = 0; i < n; ++i) {
            if (get_bit(mask, i) || i + 1 == n) {
                if (x == -1) {
                    x = a[i];
                }
                if (f == 0 && x != a[i]) {
                    ok = 0;
                    break;
                }
                if (f == 1 && a[i] != 0) {
                    ok = 0;
                    break;
                }
                f ^= 1;
            }
        }
        if (x == 2) ans += ok;
    }
    return ans;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (i) {
            a[i] ^= a[i - 1];
        }
    }
    //cout << triv() << endl;
    for (int i = 0; i < n; ++i) {
        all[a[i]].push_back(i);
        zeros[i] = (a[i] == 0);
        if (i) {
            zeros[i] += zeros[i - 1];
        }
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] == 0) {
            //cout << i << ", a[i] = " << a[i] << endl;
            continue;
        }
        int pos = get_pr(a[i], i);
        dp[i] = 1;
        pos = get_pr(0, i);
        if (pos != -1) {
            pos = get_pr(a[i], pos);
            if (pos != -1) {
                dp[i] += mod - sump[a[i]];
                dp[i] %= mod;
                dp[i] += mul(sumdp[a[i]], zeros[i]);
                dp[i] %= mod;
            }
        }
        sump[a[i]] += mul(dp[i], zeros[i]);
        sump[a[i]] %= mod;
        sumdp[a[i]] += dp[i];
        sumdp[a[i]] %= mod;
        //cout << i << ", a[i] = " << a[i] << ": " << dp[i] << endl;
    }
    int ans = 0;
    if (a[n - 1] == 0) {
        ans = 1;
        for (int i = 1; i < all[0].size(); ++i) {
            ans = mul(ans, 2);
        }
        for (int i = n - 1; i >= 0; --i) {
            if (a[i]) {
                ans += dp[i];
                ans %= mod;
            }
        }
    } else {
        ans = dp[n - 1];
    }
    printf("%d\n", ans);
    return 0;
}


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

#define INF 1e18
#define int long long

string s;
int n, k;

int to_a(char c) {
    return ('a' + 26 - c) % 26;
}

signed main() {
    cin >> s >> k;
    n = s.size();

    for(int i = 0; i < n - 1; i++) {
        if(k > 0 && to_a(s[i]) <= k) {
            k -= to_a(s[i]);
            s[i] = 'a';
        }
    }

    k %= 26;
    for(int i = 0; i < k; i++) {
        s[n - 1]++;
        if(s[n - 1] > 'z') s[n - 1] = 'a';
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
from collections import Counter
from math import gcd

class Prime:
    def __init__(self, N):
        smallestPrime = [1] * (N + 1)
        primes = []

        for i in range(2, N + 1):
            if smallestPrime[i] != 1:
                continue
            primes.append(i)
            for p in range(i * 2, N + 1, i):
                if smallestPrime[p] == 1:
                    smallestPrime[p] = i

        self.smallestPrime = smallestPrime
        self.primes = primes

    def isPrime(self, n):
        return n > 1 and self.smallestPrime[n] == 1

    def factorization(self, n):
        ret = Counter()
        while (p := self.smallestPrime[n]) != 1:
            ret[p] += 1
            n //= p
        if n > 1:
            ret[n] += 1
        return ret

N = int(input())
A = list(map(int, input().split()))
prime = Prime(max(A) + 100)

def isSetwise(A):
    ret = A[0]
    for a in A:
        ret = gcd(ret, a)
    return ret == 1

def isPairwise(A):
    cnt = Counter()
    for a in A:
        for p in prime.factorization(a).keys():
            if cnt[p] >= 1:
                return False
            cnt[p] += 1
    return True

if not isSetwise(A):
    print('not coprime')
elif isPairwise(A):
    print('pairwise coprime')
else:
    print('setwise coprime')


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

int main(void){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    long long side1 = 0;
    long long side2 = 0;
    for(int i=0; i<n-1; i++) {

        if(a[i]==a[i+1]) {
            if(side1<a[i]) {
                side2 = side1;
                side1 = a[i];
            }
        }
        if(i<n-3) {
            if(a[i+2] == a[i] && a[i+3] == a[i]) {
                side2 = a[i];
                i += 2;
            }
        }

    }
    
    cout << side1*side2 << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int ans=0;
  int d=0;
  for(int a=1;a*a<n;a++){
    for(int b=a;b<n;b++){
      if(a*b<n){
        ans++;
      }
      if(a*b<n&&a==b){
        d++;
      }
    }
  }
  cout << 2*ans-d << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

        vector<int> grade(n);
        for(int i=0; i<n; i++){
            cin >> grade[i];
        }
        
        sort(grade.begin(), grade.end());
        int dmin=1e6;
        for(int i=0; i<n-1; i++){
            dmin = min(grade[i+1]-grade[i],dmin);
        }
        cout << dmin << endl;
    }
    return 0;
}

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

typedef long long ll;

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

  vector<ll> a(n+1), b(n);
  for (int i = 0; i < n + 1; i++){
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++){
    cin >> b.at(i);
  }

  ll ans = 0;
  for (int i = 0; i < n + 1; i++){
    for (int j = -1; j <= 0; j++){
      if ((i == 0 && j == -1) || (i == n && j == 0)) continue;
      ll num = min(a.at(i), b.at(i+j));
      a.at(i) -= num;
      b.at(i+j) -= num;
      ans += num;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n;
	cin >> n;
	cout << krag((n+0.0) / 111) * 111 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

signed main() {
    int n, m;
    int num[3] = { -1, -1, -1 };

    cin >> n >> m;

    bool exists = true;
    for(int i = 0; i < m; ++i)
    {
        int s, c;
        cin >> s >> c;

        --s;

        if(num[s] == -1)
        {
            num[s] = c;
        }
        else if(num[s] != c)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    if(n == 1)
    {
        cout << (num[0] == -1 ? 0 : num[0]) << endl;
    }
    else
    {
        if(num[0] == -1) num[0] = 1;

        for(int i = 1; i < n; ++i)
            if(num[i] == -1)
                num[i] = 0;

        bool appear = false;
        string s = "";
        for(int i = 0; i < n; ++i)
        {
            if(!appear && num[i] == 0)
            {
                cout << -1 << endl;
                return 0;
            }

            appear = true;

            s += '0' + num[i];
        }
        cout << s << endl;
    }

}

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

int main(){
    char ch;

    while(1){
        //cin>>ch;
        scanf("%c",&ch);

        if(ch=='\n')break;

        if('a'<=ch && ch<='z')ch-=32;
        else if('A'<=ch && ch<='Z')ch+=32;

        cout<<ch;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S[100010];
int a,b,c,d;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>S[i];
	}
	REP(i,N){
		if(S[i]=="AC"){
			a++;
		}
		else if(S[i]=="WA"){
			b++;
		}
		else if(S[i]=="TLE"){
			c++;
		}
		else{
			d++;
		}
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	return 0;
}


Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
struct st{ll x,y,z,sum;};
st dp[1010][1010];
int main(){
    int n,m;cin>>n>>m;
    ll x[1010],y[1010],z[1010];
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i];
    ll ans=0;
    for(int k=0;k<(1<<3);k++){
    	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)dp[i][j].sum=-LINF;
    	dp[0][0].sum=0;
		for(int i=0;i<n;i++){
	    	for(int j=0;j<=m;j++){
     			ll xx=dp[i][j].x;
				ll yy=dp[i][j].y;
				ll zz=dp[i][j].z;
				ll s=dp[i][j].sum;
				if(s>dp[i+1][j].sum){
					dp[i+1][j].x=xx;
					dp[i+1][j].y=yy;
					dp[i+1][j].z=zz;
					dp[i+1][j].sum=s;
				}
				if(s>dp[i+1][j+1].sum&&j+1<=m){
					ll sx=x[i];if(k&(1<<0))sx*=-1;
					ll sy=y[i];if(k&(1<<1))sy*=-1;
					ll sz=z[i];if(k&(1<<2))sz*=-1;
					dp[i+1][j+1].x=xx+sx;
					dp[i+1][j+1].y=yy+sy;
					dp[i+1][j+1].z=zz+sz;
					dp[i+1][j+1].sum=dp[i+1][j+1].x+dp[i+1][j+1].y+dp[i+1][j+1].z;
				}
			}
		}
		ans=max(dp[n][m].sum,ans);
	}
   
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 31872
n = int(input())
if n == 1:
    print(0)
    exit()

def fact(n):
    arr = []
    res = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
            res.append(cnt)
    if temp!=1:
        arr.append([temp, 1])
        res.append(1)

    if arr==[]:
        arr.append([n, 1])
        res.append(1)


    return res

alist = fact(n)
#print(alist)
ans = 0
for a in alist:
    for i in range(1,a+3):
        if a < i*(i+1)//2:
            #print(i-1)
            ans += i-1
            break

print(ans)


Measured memory_bytes: 63408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    const int N=1e6+1;
    vv div(N);
    for(int i=2;i<N;i++)
    {
        for(int j=2*i;j<N;j+=i)
        {
            div[j].pb(i);
        }
    }
    int n;cin>>n;
    v a(n);in(a,n);
    v cnt(N,0);
    f(i,n)
    {
        cnt[a[i]]++;
    }
    if(cnt[1]==1)
    {
        cout<<1<<endl;
        return 0;
    }
    if(cnt[1] > 1)
    {
        cout<<0<<endl;
        return 0;
    }
    int ans=0;
    f(i,n)
    {
        if(cnt[a[i]]>1)continue;
        bool flg=true;
        for(auto it:div[a[i]])
        {
            if(cnt[it]>0)
            {
                flg=false;
                break;
            }
        }
        if(flg)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 185552
from sys import stdin

def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in [0] * N]

    AB.sort(key=lambda x: x[1])
    now = 0
    for a, b in AB:
        now += a
        if now > b:
            print('No')
            break
    else:
        print('Yes')

input = lambda: stdin.readline()
main()


Measured memory_bytes: 31672
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int D, N; cin >> D >> N;
    int n = 0;
    int d = (int)pow(100, D);
    for (int i = 1; i < 100000001; ++i) {
        if (i % d == 0 && (i / d) % 100 != 0) ++n;
        if (N == n) {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        long A = nl();
        long B = nl();
        long C = nl();
        long D = nl();
        
        long ans = Long.MIN_VALUE;
        ans = Math.max(ans, A*C);
        ans = Math.max(ans, A*D);
        ans = Math.max(ans, B*C);
        ans = Math.max(ans, B*D);

        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33288
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    rep(i, n) {
        if (i == 0) h[i]--;
        else {
            if (h[i-1] < h[i]) h[i]--;
            if (h[i-1] > h[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


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

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int total = 0;
	for (int i = 1; i <= N; i++) {
		int sum = findSumOfDigits(i);
		if(sum >= A && sum <= B) total += i;
	}

	cout << total << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

    switch (D) {
    case 22:
        cout << "Christmas Eve Eve Eve\n";
        break;
    case 23:
        cout << "Christmas Eve Eve\n";
        break;
    case 24:
        cout << "Christmas Eve\n";
        break;
    case 25:
        cout << "Christmas\n";
        break;
    }
}

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

int main() {
	int k,x,n;
	cin >> k >> x;
	n=1000000;
	if (x-(k-1)<-n){
		for(int i=-n;i<=x+(k-1);i++) 
		cout << i << " ";
	}
	else if (x+(k-1)>n)	{
		for(int i=n;i<=x-(k-1);i--) 
		cout << i << " ";
	}
	else{
		for(int i=x-(k-1);i<=x+(k-1);i++) 
		cout << i << " ";
	}
}


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

using namespace std;

#define ll long long
const ll MOD = 1e9 + 7;
#define all(x)      (x).begin(), (x).end()
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())

int main(){
    int n, x;
    cin >> n;
    int a, b, c;
    a = b = c = 0;
    for(int i = 0; i < n; ++i){
        cin >> x;
        if(x % 4 == 0)a ++;
        else if (x % 2 == 0)b++;
        else c++;
    }
    if(a >= c && b)cout<<"Yes"<<endl;
    else if(a + 1 >= c && !b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
    int i,l,a,b,c,d,an;
    scanf("%d",&l);
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    if(a/c > b/d){
	an=a/c;
	if(a%c!=0){
	    an +=1;
	}
    }
    else {
	an=b/d;
	if(b%d!=0){
	    an +=1;
	}
    }
    printf("%d\n",l-an);
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>

using namespace std;

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

	string aa = to_string(a);
	string bb = to_string(b);

	string A = "";
	for (int i = 0; i < b; i++) {
		A += aa;
	}
	string B = "";
	for (int i = 0; i < a; i++) {
		B += bb;
	}

	if (a < b) {
		cout << A << endl;
	}
	else {
		cout << B << endl;
	}
} 

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int ninzu;

    int m[50],f[50],r[50];
    double total[50];
    char g[50];

    for(int i=0;;i++){
        cin>>m[i]>>f[i]>>r[i];
        if(m[i]==-1 && f[i]==-1 && r[i]==-1){
            ninzu = i;
            break;
        }
    }

    for(int i=0;i<ninzu;i++){
        total[i] = m[i] + f[i];
    }

    for(int i=0;i<ninzu;i++){
        if(m[i]==-1 || f[i]==-1)    g[i] = 'F';
        else if(total[i]>=80)   g[i] = 'A';
        else if(total[i]>=65 && total[i]<80) g[i] = 'B';
        else if(total[i]>=50 && total[i]<65) g[i] = 'C';
        else if(total[i]>=30 && total[i]<50){
            if(r[i]>=50)    g[i] = 'C';
            else    g[i] = 'D';    
        }
        else if(total[i]<30)   g[i] = 'F';
    }

    for(int i=0;i<ninzu;i++){
        cout<<g[i]<<'\n';
    }
}


Measured memory_bytes: 3092
n = int(input())
a = list(map(int,input().split()))

c = 0

def is_even(n):
    if n % 2 == 0:
        return True
    
    else:
        return False

while True:
    if list(map(is_even, a)).count(True) == n:
        c += 1
    
    else:
        break
    
    a = list(map(lambda x: int(x/2), a))
    
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
using namespace std; 
int main(){
    int d,n; cin >> d >> n;
    if (d==0){
        if (n!=100) cout << n << "\n";
        else cout << 101 << "\n";
    }   
    else if (d==1){
        if (n!=100) cout << 100*n << "\n"; 
        else cout << 10100 << "\n";
    } 
    else {
        if (n!=100) cout << 10000*n << "\n";
        else cout << 1010000 << "\n";
    }
}


    

  


    

  


  


Measured memory_bytes: 256