akhauriyash/Code-Regression huggingface dataset:
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

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

const int N = 1000003;
const ll MOD = 1000003;
const ll INF = 1000000010;
const ll LOG = 25;

int q, x, d, n, fac[N], inv[N];

int POW(int x, int y){
	int res = 1;
	while (y){
		if (y & 1) res = res * 1ll * x % MOD;
		y >>= 1;
		x = x * 1ll * x % MOD;
	}
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> q;
	fac[0] = 1;
	for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * 1ll * i % MOD;
	inv[N - 1] = POW(fac[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; i--) inv[i] = inv[i + 1] * 1ll * (i + 1) % MOD;
	for (int i = 1; i <= q; i++){
		cin >> x >> d >> n;
		if (d == 0){
			cout << POW(x, n) << '\n';
			continue;
		}
		x = x * 1ll * POW(d, MOD - 2) % MOD;
		int L = x + n - 1;
//		cout << x << '\n';
		if (L >= MOD){
//			assert(0);
			cout << 0 << '\n';
			continue;
		}
		int res = fac[L] * 1ll * inv[x - 1] % MOD;
//		cout << res << '\n';
		res = res * 1ll * POW(d, n) % MOD;
		cout << res << '\n';
	}







	return 0;
}


Measured memory_bytes: 19304
#include<bits/stdc++.h>
using namespace std;
int dp[100001],h[100001],n,c=0;
int f(int i)
{
	if(dp[i]!=-1)
	return dp[i];
	
	
	
	
	if((i+1)<n && (i+2)<n)
	{
		c=min((f(i+1)+abs(h[i+1]-h[i])),(f(i+2)+abs(h[i+2]-h[i])));
	}
	else if((i+1 )<n)
	{
		c=f(i+1)+abs(h[i+1]-h[i]);
	}
	else
	return 0;
	
	return dp[i]=c;
}
int main()
{int i;
	cin>>n;
	for(i=0;i<n;i++)
	cin>>h[i];
	memset(dp,-1,sizeof(dp));
	cout<<f(0);
return 0;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val s = readLine()!!.split(" ")[0].toCharArray()
    var count = 0
    for (i in 0 until n-2){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            count++
        }
    }
    println(count)
}

Measured memory_bytes: 38004
#include <stdio.h>
int map[22][22];
int w, h;
int v;

int main(void){
	int i, x, y;
	
	scanf("%d %d", &w, &h);
	while(w && h){
		for(i=0; i<w*h; i++){
			switch (getchar()){
			case 10:
				i--;
				break;
			case '.':
				map[i%w + 1][i/w + 1] = 1;
				break;
			case '#':
				map[i%w + 1][i/w + 1] = 0;
				break;
			case '@':
				map[x = i%w + 1][y = i/w + 1] = 1;
				break;
			}
		}
		v = 0;
		searching(x, y);
		printf("%d\n", v);
		scanf("%d %d", &w, &h);
	}
	
	return 0;
}

int searching(int X, int Y){
	if(map[X][Y] == 1){
		map[X][Y] = 2;
		v++;
		if(X>0) searching(X-1, Y);
		if(X<w) searching(X+1, Y);
		if(Y>0) searching(X, Y-1);
		if(Y<h) searching(X, Y+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b) swap(a,b);
    if(a>c) swap(a,c);
    if(b>c) swap(b,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

    return 0;
}


Measured memory_bytes: 3096
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long H, W;
  scanln(H, W);
  if (H == 1 || W == 1) {
    1.writeln;
    return;
  }
  (H*W).ceil(2).writeln;
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 63324
import java.util.*;

class Main {
	public static void main (String[] args) {
		Scanner in=new Scanner(System.in);
		int a[]=new int [3];
		int n=in.nextInt();
        for(int i=2;i>=0;i--)		{
		    a[i]=n%10;
		    if(a[i]==1)
		        a[i]=9;
		    else if(a[i]==9)
		        a[i]=1;
		    n=(n-(n%10))/10;
		}
		for(int i=0;i<3;i++)
		    System.out.print(a[i]);
	}
}

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

int main(void)
{
	int q, com, x;
	set<int> S;
    cin >> q;
    rep(i, q)
    {
        cin >> com >> x;
        if (com == 0)
        {
            S.insert(x);
            cout << S.size() << endl;
        }
        else if (com == 1)
        {
            cout << S.count(x) << endl;
        }
        else if (com == 2)
        {
            S.erase(x);
        }
        else
        {
            int y;
            cin >> y;
            set<int>::iterator st, en, itr;
            st = S.lower_bound(x);
            en = S.upper_bound(y);
            for(itr = st; itr != en; ++itr) {
                cout << *itr << endl;
            }
        }
    }
}


Measured memory_bytes: 12388
$mod = 10**9+7

def pow(a,b)
  if b == 1
    a
  elsif b%2 == 0
    (pow(a,b/2)**2)%$mod
  else
    (a*pow(a,b/2)**2)%$mod
  end
end

def create_fact(n)
  for i in 2..n
    $fact[i] = ($fact[i-1]*i)%$mod
  end
end

def create_fact_inv(n)
  $fact_inv[n] = pow($fact[n],$mod-2)
  n.downto(1) do |i|
    $fact_inv[i-1] = ($fact_inv[i]*i)%$mod
  end
end

def create_inv(n)
  for i in 1..n
    $inv[i] = ($fact[i-1]*$fact_inv[i])%$mod
  end
end

def create_table(n)
  $fact = Array.new(n+1,1)
  $fact_inv = Array.new(n+1,1)
  $inv = Array.new(n+1,0)
  create_fact(n)
  create_fact_inv(n)
  create_inv(n)
end

n = gets.to_i
a = gets.split.map(&:to_i)
create_table(n)

for i in 1..n-1
  $inv[i+1] += $inv[i]
  $inv[i+1] %= $mod
end

ans = 0
n.times do |i|
  m = $inv[i+1]+$inv[n-i]-1
  ans += m*a[i]
  ans %= $mod
end

puts (ans*$fact[n])%$mod

Measured memory_bytes: 10892
a,b=['light fly', 'fly', 'bantam', 'feather', 'light', 'light welter','welter', 'light middle', 'middle', 'light heavy', 'heavy'],[48, 51, 54, 57, 60, 64, 69, 75, 81, 91]
while True:
  try:
    c = float(input())
  except:
    break
  for i in range(10):
    if c <= b[i]:
      print(a[i])
      break
  else:print(a[10])


Measured memory_bytes: 5580
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

const int  MAXN=111;

char str[MAXN][MAXN];
long long vis[MAXN][MAXN][4];
int dir[][2]= {0,-1,1,0,0,1,-1,0};
int H, W, cnt;
long long L;

main()
{
    int i, j;
    int x, y, z, tx, ty;
    char p[5]="NESW";
    while(scanf("%d%d%lld",&H,&W,&L),H||W||L)
    {
        memset(vis,0,sizeof(vis));
        memset(str,0,sizeof(str));

       for(i=1;i<=H;i++)
        {
            scanf("%s",str[i]+1);

           for(j=1;j<=W;j++)
            {
                if(str[i][j]!='.'&&str[i][j]!='#')
                {
                    x=j;
                    y=i;
                    if(str[i][j]=='N') z=0;
                    if(str[i][j]=='E') z=1;
                    if(str[i][j]=='S') z=2;
                    if(str[i][j]=='W') z=3;
                    str[i][j]='.';
                }
            }
        }
        cnt=0;
        for(; L>=1; L--,cnt++)
        {
            if(vis[y][x][z])
            {
                L=L%(cnt-vis[y][x][z]);
                if(!L) break;
            }
            vis[y][x][z]=cnt;
            while(1)
            {
                tx=x+dir[z][0];
                ty=y+dir[z][1];
                if(str[ty][tx]=='.') break;
                z=(z+1)%4;
            }
            x=tx, y=ty;
        }
        printf("%d %d %c\n",y,x,p[z]);
    }
    return 0;
}

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

char s[101101];

int main() {
	scanf("%s", s);
	int s0 = 0, s1 = 0;
	for(int i=0;s[i];i++)
		if (s[i]=='0') s0++;
		else s1++;
	printf("%d\n", min(s0, s1)*2);
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(u == s) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#define FAST {ios::sync(false);}
#define pb push_back
#define fi first
#define se second
#define f(i,a,b) for(int i=a;i<b;i++)

int main(){

    // FAST

    int n;
    cin>>n;

    vector<int> arr(n);
    f(i,0,n){
        cin>>arr[i];
    }

    vector<int> ans(n,INT_MAX);
    ans[0]=0;
    for(int i=0;i<n-1;i++){
        if(i+2 < n ){
            ans[i+2] = min(ans[i+2],ans[i]+abs(arr[i]-arr[i+2]));
        }
        ans[i+1] = min(ans[i+1],ans[i]+abs(arr[i] - arr[i+1]));
    }
    cout<<ans[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, a;
vector<int> G[MX];
int dfs(int t){
	int sz = (int)G[t].size(), ret = 0;
	vector<int> dep(sz);
	rep(i,sz) dep[i] = dfs(G[t][i]);
	sort(dep.begin(), dep.end());
	rep(i,sz) ret = max(ret, dep[i]+sz-i);
	return ret;
}
int main(){
	scanf("%d", &n);
	rep(i,n-1){
		scanf("%d", &a);
		G[a-1].push_back(i+1);
	}
	printf("%d\n", dfs(0));
}

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

e=[0]*(N+1)

for i in range(N+1):
    cur=i
    for j in range(2,cur+1):
        while cur % j==0:
            e[j]+=1
            cur=cur//j
def num(m):
    return(len([i for i in e if i>=m-1]))

print(num(75)+
      num(25)*(num(3)-1)+
      num(15)*(num(5)-1)+
      num(5)*(num(5)-1)//2 * (num(3)-2)
     )

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

using ll = long long;
using namespace std;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll, vector<ll>, greater<ll>> p, q;
    priority_queue<ll> r;
    for (int i = 0; i < a; i++) {
        ll _p;
        cin >> _p;
        p.push(_p);
        if ((int)p.size() > x) {
            p.pop();
        }
    }
    for (int i = 0; i < b; i++) {
        ll _q;
        cin >> _q;
        q.push(_q);
        if ((int)q.size() > y) {
            q.pop();
        }
    }
    for (int i = 0; i < c; i++) {
        ll _r;
        cin >> _r;
        r.push(_r);
    }
    while (!r.empty()) {
        ll r_top = r.top();
        r.pop();
        ll p_top = p.top();
        ll q_top = q.top();
        if (p_top < r_top && q_top < r_top) {
            if (p_top < q_top) {
                p.push(r_top);
                p.pop();
            } else {
                q.push(r_top);
                q.pop();
            }
        } else if (p_top < r_top) {
            p.push(r_top);
            p.pop();
        } else if (q_top < r_top) {
            q.push(r_top);
            q.pop();
        } else {
            break;
        }
    }
    ll ans = 0;
    while (!p.empty()) {
        ans += p.top();
        p.pop();
    }
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100000),bufio.NewWriterSize(os.Stdout,100)}
  x,y,a,b,c := io.NextInts()
  p := io.NextIntArray()
  q := io.NextIntArray()
  r := io.NextIntArray()
  var pq PriorityQueue
  heap.Init(&pq)
  for i:=0;i<a;i++ { heap.Push(&pq,&Item{p[i],0}) }
  for i:=0;i<b;i++ { heap.Push(&pq,&Item{q[i],1}) }
  for i:=0;i<c;i++ { heap.Push(&pq,&Item{r[i],2}) }
  n,np,nq := 0,0,0
  ans := int64(0)
  for n < x+y {
    it := heap.Pop(&pq).(*Item)
    if np == x && it.color == 0 { continue }
    if nq == y && it.color == 1 { continue }
    if it.color == 0 { np++ }
    if it.color == 1 { nq++ }
    n++
    ans += it.value
  }
  io.Println(ans)
  io.Flush()
}

type Item struct {
  value int64
  color int
}
type PriorityQueue []*Item
func(pq PriorityQueue) Len() int { return len(pq) }
func(pq PriorityQueue) Less(i,j int) bool { return pq[i].value > pq[j].value }
func(pq PriorityQueue) Swap(i,j int) { pq[i],pq[j] = pq[j],pq[i] }
func(pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) NextInts() (int,int,int,int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  a,_ := strconv.Atoi(s[2])
  b,_ := strconv.Atoi(s[3])
  c,_ := strconv.Atoi(s[4])
  return x,y,a,b,c
}
func(io *IO) NextIntArray() []int64 {
  s := strings.Fields(io.NextLine())
  a := make([]int64,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.ParseInt(s[i],10,64) }
  return a
}


Measured memory_bytes: 19456
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    vector<int> v(n);
    rep(i, n) {
        if (s[i] == 'R')
            v[i] = 0;
        else if (s[i] == 'G')
            v[i] = 1;
        else
            v[i] = 2;
    }

    vector<vector<int>> pre(3, vector<int>(n));
    rep(i, n) pre[v[i]][i] = 1;
    rep(i, 3) rep(j, n - 1) pre[i][j + 1] += pre[i][j];

    ll ans = 0;
    rep(i, n) for (int j = i + 1; j < n; ++j) {
        if (v[i] == v[j]) continue;
        int idx = 3 - v[i] - v[j];

        int d = j - i;
        int ng_k = j + d;

        int add = pre[idx][n - 1] - pre[idx][j];
        if (ng_k < n && v[ng_k] == idx) --add;

        ans += add;
    }
    cout << ans << "\n";
    return 0;
}


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

signed main(){
  string S;
  cin>>S;
  int ans=0;
  if(S=="RSR"){
    ans=1;
    cout<<ans<<endl;
    return 0;
  }
  rep(i,3){
    if(S[i]=='R')ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int ans = INF;
	Loop(i, n) {
		bool judge = true;
		Loop(j, n - i) {
			if (s[i + j] != t[j]) {
				judge = false;
				break;
			}
		}
		if (judge) {
			ans = n + i;
			break;
		}
	}
	if (ans == INF) ans = n * 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

vector<int> eratosthenes(const int &n) {
  vector<int> v(n);
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < n; i++) {
    if (v[i]) {
      for (int j = i * 2; j < n; j += i) {
        v[j] = false;
      }
    }
  }
  return v;
}

void solve() {
  vi v = eratosthenes(1000000);
  int n;
  while (cin >> n, n) {
    int s = 0, i = 0;
    while (n--) {
      while (!v[i]) i++;
      s += i++;
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 10548
#include <bits/stdc++.h>
using namespace std;
// ascii 97~122

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    vector<vector<int>> rec(W+1, vector<int>(H+1,1));
    int x,y,a;
    for(int i=0; i<N; i++){
        cin >> x >> y >> a;
        if(a==1){
            for(int j=0; j<x; j++){
                for(int k=0; k<=H; k++){
                    rec.at(j).at(k) = 0;
                }
            }
        }else if(a==2){
            for(int j=W; j>x; j--){
                for(int k=0; k<=H; k++){
                    rec.at(j).at(k) = 0;
                }
            }
        }else if(a==3){
            for(int j=0; j<y; j++){
                for(int k=0; k<=W; k++){
                    rec.at(k).at(j) = 0;
                }
            }
        }else if(a==4){
            for(int j=H; j>y; j--){
                for(int k=0; k<=W; k++){
                    rec.at(k).at(j) = 0;
                }
            }
        }
    }
    int start_check = 0;
    pair<int, int> start;
    pair<int, int> end;
    int end_check= 0;
    for(int i=0; i<=W; i++){
        for(int j=0; j<=H; j++){
            if(start_check == 0 and rec.at(i).at(j) == 1){
                start.first = i;
                start.second = j;
                start_check = 1;
            }
            else if(rec.at(i).at(j) == 1){
                end.first = i;
                end.second = j;
            }
        }
    }
    int ans;
    ans = (end.first - start.first) * (end.second - start.second);
    cout << ans << endl;
}

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

int main(){
	double a,b,x,pi=acos(-1);
	cin >> a >> b >> x;
	if(2*x<=a*a*b)printf("%.10f\n",(double)90.0-(atan((x*2.0)/(a*b*b))*180.0/pi));
	else printf("%.10f\n",atan((a*a*b-x)*2.0/a/a/a)*180.0/pi);
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

n, m = map(int, input().split())

works = []
for i in range(0, n):
    a, b = map(int, input().split())
    if a > m:
        continue
    works.append((a, b))

works.sort(reverse=True)

q = []
ans = 0

for i in range(1, m + 1):
    while works and works[-1][0] <= i:
        a, b = works.pop()
        heappush(q, -b)
    if q:
        b = -heappop(q)
        ans += b

print(ans)

Measured memory_bytes: 17144
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int a = x2 - x1;
		int b = y2 - y1;

		int x3 = x2 - b;
		int y3 = y2 + a;
		int x4 = x1 - b;
		int y4 = y1 + a;

		out.println(x3 + " " + y3 + " " + x4 + " " + y4);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21460
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int[] a = new int[4];
			int hit = 0;
			int blow = 0;
			for(int i=0;i<4;i++){
				a[i] = sc.nextInt();
			}
			for(int i=0;i<4;i++){
				int b = sc.nextInt();
				for(int j=0;j<4;j++){
					if(b==a[j]){
						if(j==i){
							hit++;
						}else{
							blow++;
						}
						j=4;
					}
				}
			}
			System.out.println(hit + " " + blow);
			
		}

	}
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int n;
vector<vector<int>> a;
set<pair<int, int>> allGames;

void updateGames(queue<pair<int, int>> &games, int player) {
	if (a[player].empty()) {
		return;
	}

	int enemy = a[player].back();
	if (a[enemy].empty()) {
		return;
	}

	if (a[enemy].back() != player) {
		return;
	}

	if (player > enemy) {
		swap(player, enemy);
	}

	int prevSize = allGames.size();
	allGames.emplace(player, enemy);

	if (allGames.size() == prevSize) {
		return;
	}

	games.emplace(player, enemy);
}

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

	cin >> n;

	a.resize(n, vector<int>(n - 1));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(begin(a[i]), end(a[i]));
	}

	queue<pair<int, int>> games;
	for (int i = 0; i < n; i++) {
		updateGames(games, i);
	}

	int ans = 0;
	while (!games.empty()) {
		ans++;
		queue<pair<int, int>> playGames;
		swap(playGames, games);

		for (queue<pair<int, int>> que = playGames; !que.empty();) {
			int player = que.front().first;
			int enemy = que.front().second;
			que.pop();

			a[player].pop_back();
			a[enemy].pop_back();
		}

		for (queue<pair<int, int>> que = playGames; !que.empty();) {
			int player = que.front().first;
			int enemy = que.front().second;
			que.pop();

			updateGames(games, player);
			updateGames(games, enemy);
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (!a[i].empty()) {
			cout << -1 << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 27648
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= z;
  int n = x/(y+z);
  int m = x%(y+z);

  cout << n << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(3*n),left(n+1),right(n+1);
    rep(i,3*n) cin >> a[i];
    ll suml = 0,sumr = 0;
    priority_queue<ll,vector<ll>,greater<ll>> ql;
    priority_queue<ll> qr;
    rep(i,n){
        suml += a[i];
        ql.push(a[i]);
        sumr += a[i+2*n];
        qr.push(a[i+2*n]);
    }
    left[0] = suml;
    right[0] = sumr;
    rep(i,n){
        ql.push(a[n+i]);
        ll m = ql.top();ql.pop();
        suml += a[n+i]-m;
        left[i+1] = suml;
        qr.push(a[n+n-i-1]);
        m = qr.top();qr.pop();
        sumr += a[n+n-i-1]-m;
        right[i+1] = sumr;
    }
    reverse(all(right));
    ll ans = -INF;
    rep(i,n+1){
        chmax(ans,left[i]-right[i]);
    }
    PRINT(ans);
}    


Measured memory_bytes: 6124
import heapq
n, q = map(int, input().split())
Q = [[] for i in range(n)]
queries = list()
for i in range(q):
    queries.append(list(map(int, input().split())))
for query in queries:
    if query[0] == 0:
        heapq.heappush(Q[query[1]], -query[2])
    elif query[0] == 1:
        if Q[query[1]]:
            print(-Q[query[1]][0])
    elif query[0] == 2:
        if Q[query[1]]:
            heapq.heappop(Q[query[1]])


Measured memory_bytes: 49356
from sys import stdin
import string

t = stdin.readline().rstrip()
alpha = string.ascii_lowercase
mi = 10**10
if len(set(t)) == 1:
    print(0)
    exit() 
for target in alpha:
    s = t
    cnt = 0
    while True:
        cnt += 1
        sin = ""
        for i in range(len(s)-1):
            sin += s[i] if s[i] == target else s[i+1]
        s = sin
        if s.count(target) == len(s):
            break
    mi = min(mi,cnt)

print(mi)

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    string S;
    ll K;
    cin >> S >> K;

    for(int i = 0; i < min((ll)S.size(), K); i++){
		if (S[i] >= '2'){
            cout << S[i] << endl;
            return 0;
        }
	}

    cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}

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

int main() {
	IOS;
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	REP(i, h)cin >> s[i];
	REP(i, h)REP(j, w) {
		if (s[i][j] == '#')continue;
		int cnt = 0;
		REP(k, 8) {
			int ni = i + dx[k];
			int nj = j + dy[k];
			if (ni >= 0 && nj >= 0 && ni < h && nj < w) {
				if (s[ni][nj] == '#')cnt++;
			}
		}
		s[i][j] = '0' + cnt;
	}
	REP(i, h) {
		cout << s[i] << endl;
	}
}



Measured memory_bytes: 256
from collections import defaultdict

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def comb2(n):
  return n*(n-1)//2
    
N,M=map(int,input().split())
E = [tuple(map(int,input().split())) for _ in range(M)]

total=comb2(N)
uf = UnionFind(N+1)
ans = [total]
for i in range(M-1):
  a,b = E[-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp)
print(*ans[::-1])

Measured memory_bytes: 31644
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
  	val s = sc.nextInt()
    val list = mutableListOf<Int>()
    var a = s
    var n = 1
    while (a !in list) {
        list.add(a)
        n++
        a = if (a%2 == 0) a/2 else 3*a+1 
    }
    println(n)
}


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

using namespace std;

const int cons = 1e3;
const int mod = 1e9 + 7;

int main() {

    int h, w;
    cin >> h >> w;
    char a[cons][cons];
    for(int i = 0; i < h; i++) {

        cin >> a[i];
    }

    vector<vector<int>> dp(h, vector<int> (w));
    dp[0][0] = 1;

    for(int i = 0; i < h; i++) {

        for(int j = 0; j < w; j++) {

            for(int i2 : {i, i + 1}) {

                int j2 = j;
                if(i2 == i) {

                    j2 = j + 1;
                }
                if(i2 < h && j2 < w && a[i2][j2] == '.') {

                    dp[i2][j2] += dp[i][j];
                    if(dp[i2][j2] >= mod) {

                        dp[i2][j2] -= mod;
                    }
                }
            }
        }
    }

    cout << dp[h - 1][w - 1];

    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll a[n];
    fo(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    ll asn = 0;
    fo(i,k){
        asn += a[i];
    }
    cout<<asn<<nl;

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


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

int main() {
  int kflag = 0;
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++) {
    if(i%2 == 0) {
      if(s.at(i) != '0') {
        kflag++;
      }
    }
    else {
      if(s.at(i) != '1') {
        kflag++;
      }
    }
  }
  if(kflag > s.size() - kflag) {
    kflag = s.size() - kflag;
  }
  cout << kflag << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;
int main(){
	int i,j,c[9],d[4];
	for(i=0;i<9;i++){
	cin >> c[i];
	}
	d[0] = c[1] - c[0];
	d[1] = c[2] - c[0];
	d[2] = c[3] - c[0];
	d[3] = c[6] - c[0];
	for(i=0;i<=100;i++){
		if(c[0]==i && c[1]==(i+d[0]) && c[2]==(i+d[1]) && c[3]==(i+d[2]) && c[4]==(i+d[0]+d[2]) && c[5]==(i+d[1]+d[2]) && c[6]==(i+d[3]) && c[7]==(i+d[0]+d[3]) && c[8]==(i+d[1]+d[3])){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}
	

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

using namespace std;

int main() {
        int N;
        cin >> N;
        vector<pair<int,int> > r(N);
        vector<pair<int,int> > b(N);
        for(auto& x: r) {
                cin >> x.first >> x.second;
        }
        for(auto& x: b) {
                cin >> x.first >> x.second;
        }

        sort(b.begin(), b.end());
        sort(r.begin(), r.end());
        int res = 0;
        for(int i = 0; i < N; i++) {
                int y = -1, k;
                for(int j = 0; j < r.size(); j++) {

                        if(b[i].first > r[j].first && b[i].second > r[j].second) {
                                if(y < r[j].second) {
                                        y = r[j].second;
                                        k = j;
                                }
                        }
                }
                if(y >= 0) {
//                      cout << b[i].first << " " << b[i].second << " " << r[k].first << " " << r[k].second << endl;
                        res++;
                        r.erase(r.begin() + k);
                }
        }

        cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
 
int main() {
 
  int n,G[101][101];
  int i,j,k,l,u,a,t;
 
 
  scanf("%d",&n);
 
  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;
 
    }
 
  for(i=0;i<n;i++){
 
    scanf("%d %d ",&k,&u);
    //	printf("u = %d\n",u);
 
    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
     
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) {
      printf("%d",G[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }
 
 
  return 0;
 
     
     
}

Measured memory_bytes: 636
#include<iostream>

using namespace std;

int main(void){
	int sec, h, m, s;
	
	cin >> sec;
	h = sec/3600;
	m = (sec%3600)/60;
	s = sec%3600%60;
	
	cout << h << ':' << m << ':' << s << endl;
	return 0;
}

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




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



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <unordered_map>
#define rep(i,m,n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll A[200010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    ll lv = 0, rv = N;
    while(rv - lv > 1){
        map<ll,ll> mp;
        ll K = (lv + rv)/2;
        bool is_ok = true;
        rep(i,1,N){
            if(A[i-1] < A[i]) continue;
            if(K == 1 && N >= 2){
                is_ok = false;
                continue;
            }
            ll pre = A[i];
            mp.erase(mp.upper_bound(pre),mp.end());
            while(mp[pre] == K-1){
                mp[pre] = 0;
                pre--;
                if(pre == 0) is_ok = false;
            }
            // mp.erase(mp.upper_bound(pre),mp.end());
            mp[pre]++;
        }
        if(is_ok){
            rv = K;
        }else{
            lv = K;
        }
    }
    // print(cnt);
    print(rv);
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int x;
	cin >> x;

	int pos = 0;
	int ans = 0;
	for (int i = 1; pos < x; i++) {
		if (pos < x) {
			pos += i;
		}
		ans++;
	}

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

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

ll n;
ll a[100010];
ll c[100010];
ll s1[100010];//片端つき長さn
ll s2[100010];//両端なし長さn
//[l,r)
#define aa(l,r)(c[r]-c[l])

int main(){
	scanf("%lld",&n);
	rep(i,0,n){
		scanf("%lld",a+i);
		c[i+1]=(c[i]+a[i])%MOD;
	}
	//片端つき長さn
	if(n>=2)rep(i,1,n)s1[i]=(aa(0,i)+aa(n-i,n))%MOD;
	//両端なし長さn
	if(n>=3){
		ll dd=a[0]+a[n-1];
		rep(i,1,n-1){
			s2[i]=(aa(0,n)*i-dd)%MOD;
			dd=(dd+aa(0,i+1)+aa(n-(i+1),n))%MOD;
		}
	}
	
	
	ll fn=1;
	rep(i,1,n+1)fn=fn*i%MOD;
	
	ll ans=fn*c[n]%MOD;//全体
	rep(i,1,n)ans=(ans+fn*invp(i+1,MOD)%MOD*s1[i])%MOD;
	rep(i,1,n-1)ans=(ans+fn*invp(i+1,MOD)%MOD*invp(i+2,MOD)%MOD*2*s2[i])%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 60;
const int N = (int)1e6 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

int cnt[N];

int mul(int a, int b) {
	return a * b % 2019;
}

void solve() {
	string s; cin >> s;
	cnt[0] = 1;
	int rest = 0, pw = 1;
	LL ans = 0;
	for (int i = size(s) - 1; i >= 0; i--, pw = mul(pw, 10)) {
		rest = (rest + mul(s[i] - '0', pw)) % 2019;
		ans += cnt[rest];
		cnt[rest]++;
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
//#include "toollib.h"
#pragma warning (disable:4018)

using namespace std;

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n, 0);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			a[x - 1] += y;
		}
		else {
			cout << accumulate(a.begin() + x - 1, a.begin() + y, 0) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3108