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

#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define TC ll test;cin>>test;while(test--)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005

int main(){
ll n;
cin>>n;
ll dp[3];
fr(i,0,3)
dp[i]=0;
ll arr[n][3];
ll temp[3];
fr(i,0,3)
temp[i]=0;
fr(i,0,n){
	fr(j,0,3){
		cin>>arr[i][j];
	}
}
dp[0]=arr[0][0];
dp[1]=arr[0][1];
dp[2]=arr[0][2];
for(ll i=1;i<n;i++){
	for(ll j=0;j<3;j++){
		temp[j]=arr[i][j]+max(dp[(j+1)%3],dp[(j+2)%3]);
	}
	fr(k,0,3)
	dp[k]=temp[k];
//cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
}
//cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2];
cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int n, m;
vector<int> s;

bool solve(int x)
{
    int level = 1, who = 0;
    rep(i, m - 1)
    {
        if (s[n - 1] < level + x)
            return false;
        for (; who < n - 1; who++)
        {
            if (s[who + 1] >= level + x)
                break;
            int a = max(1LL, x - abs(level - s[who]));
            int b = max(1LL, x - abs(level - s[who + 1]));
            if (a > b)
                break;
        }
        level += max(1LL, x - abs(level - s[who]));
    }
    return true;
}

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

    while (cin >> n >> m, n)
    {
        s.resize(n);
        rep(i, n) cin >> s[i];
        int l = s[0], r = s[n - 1];
        if (!solve(l))
        {
            cout << -1 << endl;
            continue;
        }
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if (solve(mid))
                l = mid;
            else
                r = mid;
        }
        cout << l << endl;
    }
}


Measured memory_bytes: 3940
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<iomanip>
#include<math.h>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<int> p;
    ll ans = 0;
    ll limit = 1000001;
    // int(sqrt(n))+1;
    int sosu[limit];

    rep(i, limit) sosu[i]=1;

    // sosu[i] = 1 if i in prime_number else 0
    for(int i=2;i<limit;i++){
        ll j=i*2;
        while(j<limit){
            sosu[j]=0;
            j += i ;
        }
    }

    // prime factorization
    ll wk = n;
    for(int i=2; i<limit; i++){
        if(sosu[i]==0) continue;
        if(wk%i == 0){
            ll e = 0;
            while(wk%i == 0){
                e++;
                wk /= i;
            }
            //cout << "i=" << i <<" ee=" << e << endl;
            p.push_back(e);
        }
    }

    // if n in prime_number
    if(p.empty()){
        if(n==1) cout << 0 << endl;
        else cout << 1 << endl;
        return 0;
    }
    
    if(wk > 1) {
       p.push_back(1);
    }

    // get answer
    for(auto i : p){
        ll count = 0;
        while(count < i){
            count++;
            i -= count;
        }
        ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7536
#include <stdio.h>

int main(void) {
    long long int n;
    int k, div, count = 0, sur = 0;

    scanf("%lld %d", &n, &k);
    div = k;
    while(n > 0) {
        sur = n % (long long int) div;
        n -= sur;
        div *= k;
        count++;
    }

    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  char s[3];
  int c[3]={0,0,0};
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i] == 'a')c[0]+=1;
    if(s[i] == 'b')c[1]+=1;
    if(s[i] == 'c')c[2]+=1;
  }
  if(c[0]==1 && c[1]==1 && c[2]==1)printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
n, x = input().split()
L = input().split()
for i, l in enumerate(L):
  if i == 0:
    D = int(l)
  else:
    D = int(l) + D

    
  if D > int(x):
    print(i + 1)
    break
    
if D <= int(x):
  print(int(n) + 1)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let (a, b, c, k): (u64, u64, u64, u32) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next(), sc.next(), sc.next())
    };
    let mut p = vec![a, b, c];
    p.sort();
    println!("{}", p[0] + p[1] + 2u64.pow(k) * p[2]);
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main () {
  int n, i, temp = 0, x, max;
  char s[300000];
  int e[300000];
  int w[300000];
  scanf ("%d", &n);
  scanf ("%s", s);
  for (i = 0; i < n; ++i) {
    if (s[i] == 'E') {
      temp += 1;
    }
    e[i] = temp;
  }
  temp = max = n - e[n-1];
  for (i = 0; i < n; ++i) {
    if (s[i] == 'W') {
      temp -= 1;
    }
    w[i] = temp;
    x = e[i] + w[i];
    if (x > max) {
      max = x;
    }
  }
  printf ("%d\n", n - max);
  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto H=in(),W=in(),K=in();
	vvll M(H,vll(W,0));

	REP(i,H){
		auto S=in<string>();
		REP(j,W){
			if(S[j]=='#') M[i][j]=1;
		}
	}

	int LH=1<<H,LM=1<<W,A=0;
	REP(i,LH){
		vll FH(H,0);
		int Y=i,yindex=0;
		while(Y){
			if(Y&1){
				FH[yindex]=1;
			}
			Y/=2;
			yindex++;
		}
		REP(j,LM){
			vll FW(W,0);
			int X=j,xindex=0;
			while(X){
				if(X&1){
					FW[xindex]=1;
				}
				X/=2;
				xindex++;
			}
			int C=0;
			REP(v,H){
				REP(u,W){
					if(M[v][u]==1 && FH[v]==0 && FW[u]==0) C++;
				}
			}
			if(C==K) A++;
		}
	}
	out(A);
	return 0;
}


Measured memory_bytes: 3648
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = args[0][0]
	if (N[0] === N[2]) console.log('Yes')
	else console.log('No')
}

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


Measured memory_bytes: 7372
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Step(i, a, b, x) for (i = a; i <= b; i += x)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
const int PYZ = 998244353;
map<string, int> f, g;
int F(string); int G(string);
int G(string s) {
	if (g[s]) return g[s]; int i, n = s.size(); if (n == 1) return g[s] = s[0] - '0' + 1;
	int j, k, res = 0; For (i, 1, n - 1) if (n % i == 0) {
		string t = ""; For (j, 1, i) {
			int r = 1; Step (k, j - 1, n - 1, i) r &= s[k] - '0';
			t += (char) (r + '0');
		}
		res = (res + F(t)) % PYZ;
	}
	return g[s] = res;
}
int F(string s) {
	if (f[s]) return f[s]; int i, n = s.size(); if (!n) return f[s] = 1;
	int res = 0; For (i, 1, n)
		res = (res + 1ll * G(s.substr(0, i)) * F(s.substr(i, n)) % PYZ) % PYZ;
	return f[s] = res;
}
int main() {
	string s; cin >> s; cout << F(s) << endl;
	return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sf(n) scanf("%lld",&n)
#define sff(n,m) scanf("%lld %lld",&n,&m)
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PLL pair<ll,ll>
#define mod 1000000007
#define mx 1000002
#define FILE freopen("input.txt","r",stdin)

ll n;
ll a[102];
ll dp[mx];

ll F(ll x)
{
  if(dp[x]!=-1) return dp[x];

  ll ret = 0;

  for(ll i = 1;i<=n;i++)
  {
    if(a[i]<=x) ret = ret | F(x-a[i]);
  }

  return dp[x] = !ret;
}

int main()
{
ll k;
sff(n,k);

for(ll i = 1;i<=n;i++)
{
  sf(a[i]);
}

memset(dp,-1,sizeof dp);

if(!F(k)) cout<<"First"<<endl;
else cout<<"Second"<<endl;

return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

long long dfs(long long num)
{
    if (num == 1)
    {
        return 1LL;
    }
    else
    {
        long long t = num / 2LL;
        return 1LL + 2LL * dfs(t);
    }
}

int main(void)
{
    long long h;
    cin >> h;
    cout << dfs(h) << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  ll h, w;
  cin >> h >> w;

  if (w == 1 || h == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = 0;
  ans += ((w + 1) / 2) * ((h + 1) / 2);
  ans += (w / 2) * (h / 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    bool[3] b;b[0]=true;
    foreach(s;stdin.byLine())
        swap(b[s[0]-'A'],b[s[2]-'A']);
    foreach(i,v;b) if(v) writeln(cast(char)('A'+i));
}

Measured memory_bytes: 1040
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	
    	double money = 100;
    	int week;
    	while (scan.hasNextInt()){
    		week = scan.nextInt();
    		for(int i = 0; i < week; i++){
    			money = Math.ceil(money*1.05);
    		}
    		System.out.println((int)money*1000);
    	}
    }
}

Measured memory_bytes: 17324
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# スペース区切りの整数の入力
mountains = list(map(int, input().split()))

height = mountains[0]
sum = 1
for i in range(1,a):
    if mountains[i] >= height:
        sum += 1
        height = mountains[i]

# 出力
print(sum)

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var xs = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var xsmin = xs.Min();
            var xsmax = xs.Max();
            var min = int.MaxValue;
            for(var i= xs.Min(); i<= xsmax; i++)
            {
                var tmpmin = 0;
                foreach(var x in xs)
                {
                    tmpmin += (x - i) * (x - i);
                }
                if (tmpmin < min) min = tmpmin;
            }
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 13396
H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = max(H, W)

f = [1] * W
for i in range(1, H):
    f = [(f[j]+1) if (S[i-1][j:j+2] + S[i][j:j+2]).count('#') in [0,2,4] else 1 for j in range(W-1)] + [0]
    stk = []
    for j, v in enumerate(f):
        while len(stk) > 0 and f[stk[-1]] >= v:
            ans = max(ans, f[stk.pop()] * (j - (stk[-1] if len(stk) > 0 else -1)))
        stk.append(j)

print(ans)


Measured memory_bytes: 77272
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string t; cin >> t;
	rep(i, 7) if(s[i] == t){
		cout << 7 - i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;

public class Main {

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

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
       int a=sc.nextInt(),b=sc.nextInt();
       System.out.println(a*b+" "+2*(a+b));
    }
}



Measured memory_bytes: 26160
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i=1; i<n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 3868
s=input()

while True:
    if s[-5::]=="dream":
        s=s[:-5:]
    elif s[-7::]=="dreamer":
        s=s[:-7:]
    elif s[-5::]=="erase":
        s=s[:-5:]
    elif s[-6::]=="eraser":
        s=s[:-6:]
    else:
        break

if s=="":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

lint dp[1000][2020];

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> d(n);
	vector<bool> ans(n, false);
	for (int i = 0; i < n; i++) cin >> d[i];
	for (int i = n - 1; i >= 0; i--) {
		int cnt = 0;
		for (int j = i; j < n; j += i + 1) {
			if (ans[j]) cnt++;
		}
		if (cnt % 2 != d[i]) ans[i] = true;
	}
	int cnt = 0;
	lint a = 0;
	for (int i = 0; i < n; i++) {
		if (ans[i]) a++;
	}
	cout << a << endl;
	for (int i = 0; i < n; i++) {
		if (ans[i]) {
			cout << i + 1;
			cnt++;
			if (cnt == a) cout << endl;
			else cout << ' ';
		}
	}

	return 0;
}

Measured memory_bytes: 3984
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input;
        int i, j;
        
        int n = Integer.parseInt(br.readLine());
        int[] s = new int[n];
        input = br.readLine().split(" ");
        for (i = 0; i < n; i++) {
            s[i] = Integer.parseInt(input[i]);
        }

        int q = Integer.parseInt(br.readLine());
        int[] t = new int[q];
        input = br.readLine().split(" ");
        for (i = 0; i < q; i++) {
            t[i] = Integer.parseInt(input[i]);
        }
        

        int count = 0;
        int target;
        for (i = 0; i < q; i++) {
            target = t[i];
            for (j = 0; j < n; j++) {
                if (s[j] == target) {
                    count++;
                    break;
                }
            }
        }

        System.out.println(count);
    }
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
ll n,m,mark[100005];
bool pos=1;
vll g[100005];
void dfs(ll st,ll clr){
    mark[st]=clr;
    for(ll v:g[st]){
        if(mark[v] == -1) dfs(v,!clr);
        else if(mark[v] == mark[st]) pos=0;
        else;
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>m;
    rep(i,1,m){
        ll u,v;cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    rep(i,1,n) mark[i]=-1;
    dfs(1,0);
    if(!pos) cout<<(n*(n-1))/2-m<<'\n';
    else{
        ll ct=0;
        rep(i,1,n) if(mark[i]==1) ct++;
        cout<<ct*(n-ct)-m<<'\n';
    }
}


Measured memory_bytes: 7936
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n = ii()
    a = li()
    if n!=0 and a[0]!=0:
        print(-1)
        exit()
    if n == 0 and a[0]!=1:
        print(-1)
        exit()
    M = 1
    m = 1
    flag = True
    mlist = []
    for i in range(n+1):
        mlist.append(M)
        if a[i]>M:
            flag = False
            break
        M-=a[i]
        M*=2
    if not flag:
        print(-1)
        exit()
    mlist.append(0)

    ans = 0
    tmp = 0
    #print(mlist)

    for _ in range(n+1):
        i = n-_
        #print(i,ans,tmp)
        tmp = min(tmp,mlist[i+1])
        ans+=tmp
        tmp +=a[i]
        #print(i,ans,tmp)
    print(ans+1)




main()




Measured memory_bytes: 675428
#include<iostream>
#include<vector>

using namespace std;

int main(){
  vector<int>times;
  int total_time=0;
  int n;
  cin >> n;
  while(n--){
  	int t;
    cin >> t;
    total_time+=t;
    times.push_back(t);
  }
  int m;
  cin >> m;
  while(m--){
    int p,x;
    cin >> p >> x;
    p--;
    int final_time = total_time + x - times[p];
    cout << final_time << endl;
  }
  return 0;
}

Measured memory_bytes: 256
public class ContestWithDrinksEasy
{
    public static void Main()
    {
        int qNum = int.Parse(System.Console.ReadLine());
        int[] qTimes = new int[qNum];
        int i = 0, j = 0;

        foreach(string s in System.Console.ReadLine().Split(' ')){
            qTimes[i++] = int.Parse(s);
        }

        int dNum = int.Parse(System.Console.ReadLine());
        string[] sepStr;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        int[] dTimes = new int[2];
        int allTimes = 0;

        for(i = 0; i < dNum; i++)
        {
            sepStr = System.Console.ReadLine().Split(' ');
            dTimes[0] = int.Parse(sepStr[0]);
            dTimes[1] = int.Parse(sepStr[1]);
            
            for(j = 0; j < qNum; j++)
            {
                if((j + 1) == dTimes[0])
                {
                    allTimes += dTimes[1];
                }
                else
                {
                    allTimes += qTimes[j];
                }
            }

            sb.Append(allTimes).AppendLine();
            allTimes = 0;
        }

        System.Console.Write(sb.ToString());
    }
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
int a[N+2];

int32_t  main(){
	IOS;
  int n;cin>>n;
  int sum=0;
  fori(i,n){cin>>a[i];sum+=a[i];}
  int ans=0;
  int val=sum/n;
  fori(i,n)ans+=(a[i]-val)*(a[i]-val);
  int ans2=0;
  val=val+1;
  fori(i,n)ans2+=(a[i]-val)*(a[i]-val);
  cout<<min(ans,ans2)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
ll dp[N],tong[N];
vector<ll> a;
int n,q;
int main(){
	n=read(); q=read();
	a.resize(1); a[0]=n;
	for(int i=1;i<=q;i++){
		ll jb=read();
		while(a.size()&&a[a.size()-1]>=jb)a.pop_back(); a.push_back(jb);
	}
	dp[a.size()-1]=1;
	//for(unsigned i=0;i<a.size();i++)cout<<a[i]<<" SZBAKKING"<<endl;
	for(int i=a.size()-1;i;i--){
		ll de=a[i];
		for(int pos=i-1;de&&pos>=0;pos=upper_bound(a.begin(),a.begin()+pos,de)-a.begin()-1){
			//cout<<pos<<" "<<dp[i]<<" "<<i<<endl;
			dp[pos]+=de/a[pos]*dp[i]; de%=a[pos];
		}
		tong[de%a[0]]+=dp[i];
	}
	tong[a[0]]+=dp[0];
	for(int i=n;i;i--)tong[i]+=tong[i+1];
	for(int i=1;i<=n;i++)writeln(tong[i]);
}

Measured memory_bytes: 4340
def f(x1, y1, x2, y2):
    return abs(x1*y2 - x2*y1)

def main():
    S = int(input())
    d = pow(10, 9)
    X1, Y1 = 0, 0
    X2, Y2 = d, 1
    X3 = (d - S%d)%d
    Y3 = (S + X3) // d
    print(X1, Y1, X2, Y2, X3, Y3)
    #print(f(X2, Y2, X3, Y3))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ios;
    string s,res="",a="";
    cin>>s;
    int cnt=0,n=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
        {
             res+=s[i];
            if(n<res.size())
            {
                n=res.size();
                a=res;
            }
        }
        else
        {
            res="";
        }

    }
    cout<<a.size()<<endl;


}









Measured memory_bytes: 256
n = int(input())
a_lst = sorted(list(map(int,input().split())),reverse=True)

bob = 0
alice = 0

for i in range(len(a_lst)):
    if i%2 == 0:
        alice += a_lst[i]
    else:
        bob += a_lst[i]

print(alice-bob)

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

int main() {
  string d;
  int k=0;
  cin >> d;

  for(int i=0; i<d.size(); i++){
    if(d.at(i)=='1'){
      k = k+1;
    }
  }

  cout << k << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
string a,b;
int cmp(char a,char b)
{
	return a>b;
}
int main() {
    getline(cin,a);
    getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    if(a>=b) 
    {
    	cout<<"No";
	}
	else 
	{
		cout<<"Yes";
	}
	cout<<endl;
	
}


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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n, m;
  cin >> n >> m;

  vector<int> a(m), b(m), c(m);
  rep(i, 0, m){
    cin >> a[i] >> b[i];
    int tc = 0;
    rep(j, 0, b[i]){
      int t;
      cin >> t;
      t--;
      tc |= (1<<t);
    }
    c[i] = tc;
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  rep(i, 0, 1<<n){
    rep(j, 0, m){
      chmin(dp[i|c[j]], dp[i] + a[j]);
    }
  }

  if(dp[(1<<n) - 1] == INF)cout << -1 << endl;
  else cout << dp[(1<<n) - 1] << endl;

  
  return 0;
}

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

const int INF = 1001001001;

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<vector<ll>> dp(n+1,vector<ll>(h+1, INF));
    dp[0][0]=0;
    rep(i,n){
        rep(j,h+1){
            dp[i+1][j] = min(dp[i+1][j] ,dp[i][j]); 
            int nj = min(j+a[i], h);
            dp[i+1][nj] = min(dp[i+1][nj], dp[i+1][j]+b[i]) ;
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int A,B,C,K;
   cin>>A>>B>>C>>K;
   int X=max(A,max(B,C));
   rep(i,K){
       X*=2;
   }
   if(max(A,max(B,C))==A){
       cout<<X+B+C<<endl;
   }
   else if(max(A,max(B,C))==B){
       cout<<X+A+C<<endl;
   }
   else{
       cout<<X+A+B<<endl;
   }
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
using namespace std;
int a,b,c;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  /*if(b/a>c){
	printf("%d\n",c);
  }else{
   printf("%d\n",b/a); 
  }*/
  printf("%d\n",min(c,b/a));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define MEM(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T> void dbg(T &x) {cerr << x << endl;}
template<typename T> void dbga(T &x, int &n) {for(int i = 0; i < n; i++) {cerr << i << ": "; cerr << x[i] << endl;} }
template<typename T> void dbgv(T &x) {bool first = true; cerr << "{"; for(auto i : x) {if(!first) cerr << ","; cerr << i; first = false;} cerr << "}" << endl;}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int r;
	cin >> r;
	int ans = r * r;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq


N, M = map(int, input().split())
ab_list = [ list(map(int, input().split())) for i in range(N)]

score_list = [[] for i in range(M+1)]


for ab in ab_list:
    if ab[0] <= M:
        score_list[ab[0]].append(ab[1])


ans = 0
candidates = []

for i in range(0, M+1):

    for s in score_list[i]:
        heapq.heappush(candidates, -s)
    if len(candidates) == 0:
        continue
    ans -= heapq.heappop(candidates)


print(ans)

Measured memory_bytes: 39648
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>
#include <queue>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



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

    int N;
    cin >> N;
    vector<int> p(N), acc(110, 0);
    REP(i, N)
    {
        cin >> p[i];
        acc[p[i]]++;
    }

    reverse(ALL(acc));

    for(int i = 1; i < 110; i++)
    {
        acc[i] += acc[i - 1];
    }

    reverse(ALL(acc));

    int ans = 0;

    REP(i, 110)
    {
        if(i <= acc[i])
        {
            ans = i;
        }
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 3116
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        long[] a;
        long[] p;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            long X = in.nextLong();
            a = new long[N + 1];
            p = new long[N + 1];
            a[0] = p[0] = 1;
            for (int i = 1; i <= N; i++) {
                a[i] = a[i - 1] * 2 + 3;
                p[i] = p[i - 1] * 2 + 1;
            }

            long count = calc(N, X);
            out.println(count);
        }

        private long calc(int N, long X) {
            if (X <= 1) {
                return N == 0 ? 1 : 0;
            } else if (X < 2 + a[N - 1]) {
                return calc(N - 1, X - 1);
            } else if (X == 2 + a[N - 1]) {
                return p[N - 1] + 1;
            } else if (X < 3 + 2 * a[N - 1]) {
                return p[N - 1] + 1 + calc(N - 1, X - 2 - a[N - 1]);
            }
            return 2 * p[N - 1] + 1;
        }

    }
}



Measured memory_bytes: 21844
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LINF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl
#define SP << " " << 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b;
  cin >>a >> b;

  cout << a*b << endl;

  return 0;
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int length = Integer.parseInt(br.readLine());
	String strArray[] = br.readLine().split(" ");

	List<String> list = new ArrayList<String>();
	for (int i = 0; i < length; i++) {
	    list.add(strArray[i]);
	}

	List<String> newList = new ArrayList<String>(new HashSet<>(list));

	if (list.size() == newList.size())
	    System.out.println("YES");
	else
	    System.out.println("NO");
    }
}

Measured memory_bytes: 62660
include Math


n = gets.to_i

Point = Struct.new("Point", :x, :y)
s, t, u, a, b = Point.new(0.0, 0.0)
a = Point.new(0.0, 0.0)
b = Point.new(100.0, 0.0)



def koch(d, a, b)
  return if d==0

  th = PI * 60.0 /180.0
  s = Point.new(0.0, 0.0)
  t = Point.new(0.0, 0.0)
  u = Point.new(0.0, 0.0)

  s.x =  (2.0 * a.x + 1.0 * b.x) / 3.0
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) +  s.x
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) +  s.y

  koch(d-1, a, s)
  puts ("#{s.x} #{s.y}")
  koch(d-1, s, u)
  puts "#{u.x} #{u.y}"
  koch(d-1, u, t)
  puts "#{t.x} #{t.y}"
  koch(d-1, t, b)
end

puts "#{a.x} #{a.y}"
koch(n, a, b)
puts "#{b.x} #{b.y}"

Measured memory_bytes: 9024
#include<cstdio>
#include<iostream>
#include<cstring>

const int MAXN=1e5;
int ans=-0x3f3f3f3f,tmp=0;
char c[MAXN];

using namespace std;
int main()
{
	scanf("%s",c+1);
	int lenth=strlen(c+1);
	for (int i=1;i<=lenth;i++)
	{
		if (c[i]=='R')
		{
			tmp++;
			ans=max(ans,tmp);
		} 
		else
		{
			tmp=0;
			ans=max(ans,tmp);
		}
	}
	printf("%d",ans);
}

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

int gcd(int p,int q){
    int tmp;
    if(p<q){tmp=p;p=q;q=tmp;}
    if(p%q==0)return q;
    return gcd(q,p%q);
}

int main(){
    int K;
    cin>>K;
    long long int ans=0;
    for(int i=0;i<K;i++){
        for(int j=0;j<K;j++){
            for(int k=0;k<K;k++){
                ans+=gcd(i+1,gcd(j+1,k+1));
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
  	int n;
  cin >> n;
  string s;
    cin >> s;
    for(char i: s){
    	cout << char((i-'A'+n)%26+'A');
    }
   return 0;
}

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

using namespace std;
typedef long long int ll;
int main(){
	int n, x;
	cin>>n>>x;
	int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	ll ans=0;
	for(int i=1; i<n; i++){
		ll t=a[i]+a[i-1];
		if(t>x){
			t-=x;
			if(a[i]>t){
				a[i]-=t;
				ans+=t;
			}
			else{
				t-=a[i];
				ans+=a[i];
				a[i]=0;
				a[i-1]-=t;
				ans+=t;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/



int main() {
	int N;
	cin >> N;
	vector<lint>A(N);
	for (int i = 0; i < N ; i++) {
		cin >> A[i];
	}
	vector<lint>AA(N);
	for (int i = 0; i < N; i++) {
		AA[i] = A[i];
	}
	sort(AA.rbegin(), AA.rend());
	if (AA[0] == AA[1]) {
		for (int i = 0; i < N; i++) {
			cout << AA[0] << endl;
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (A[i] == AA[0]) {
				cout << AA[1] << endl;
			}
			else {
				cout << AA[0] << endl;
			}
		}
	}
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    short N;
    string X;
    cin >> N;

    vector<string> s(N);
    vector<int> t(N);

    for(short i=0; i<N; i++){
        cin >> s[i];
        cin >> t[i];
    }

    cin >> X;
    
    bool flag = false;
    int time = 0;

    for(short i=0; i<N; i++){
        if(s[i] == X){
            flag = true;
        }else if(flag){
            time += t[i];
        }
    }

    cout << time << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,K = inpl()
AA = inpl()

rAA = [0]
for a in AA:
    rAA.append(rAA[-1]+a)


AA = [(A+N-i)%K for i,A in enumerate(rAA)]


cnts = defaultdict(int)
ans = 0
for i,a in enumerate(AA):
    if i >= K:
        cnts[AA[i-K]] -= 1

    ans += cnts[a]
    cnts[a] += 1



print(ans)


Measured memory_bytes: 43620
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, H: "List[int]"):
    if N <= K:
        print(0)
        return

    H.sort(reverse=True)
    print(sum(H[K:]))
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28924
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(int argc,char** argv){
  int N,K;
  cin >> N >> K;
  if(N%K==0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll ans = 1e12;
  for(ll i=1;i*i<=n;i++){
    if(n%i != 0)continue;
    ll j = n/i;
    ans = min(ans,i+j-2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256