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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    ll N;
    string s;
    ll ans[4] = {0,0,0,0};

    cin >> N;

    REP(i,N){
        cin >> s;
        if(s.at(0)=='A') ans[0]++;
        else if(s.at(0)=='W') ans[1]++;
        else if(s.at(0)=='T') ans[2]++;
        else if(s.at(0)=='R') ans[3]++;

    }
    
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
}

Measured memory_bytes: 3620
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
let outl s = stdout.WriteLine(s|>string)
let outsep ls = stdout.WriteLine(String.concat " " (ls|>Array.map string))
let outsepl ls = stdout.WriteLine(String.concat "\n" (ls|>Array.map string))
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    RS int|>Array.distinct|>Array.length|>fun c->if c=2 then "Yes" else "No"
    |>outl
    0
    

Measured memory_bytes: 14176
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int sumd(int n){
    int res=0;
    while(n>0){
        res=n%10;
        n/=10;
    }
    return res;
}

int main(){
    int n;cin>>n;
    set<int> D;
  int d;
    rep(i,0,n){
      cin>>d;
      D.insert(d);
    }
  printf("%d\n",D.size());
}    

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	long long n;
	cin >> n;

	string s = "";

	while(n) {
		s += (char) ((n % 26 + 25) % 26 + 'a');
		n = (n - 1) / 26;
	}

	reverse(s.begin(), s.end());

	cout << s;

	
	return 0;
}


Measured memory_bytes: 3620
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from bisect import *

n = ni()
a = na()
b = na()
c = na()
a.sort()
c.sort()

ans = 0
for j in range(n):
    ap = bisect_left(a, b[j])
    cp = bisect_right(c, b[j])
    ans += ap * (n - cp)

print(ans)

Measured memory_bytes: 23312
def main():
    N, P = map(int, input().split())
    A = map(int, input())

    if 10 % P == 0:
        ret = 0
        for i, x in enumerate(reversed(tuple(A)), start=0):
            if x % P == 0:
                ret += N - i
        print(ret)
        return

    ctr = [0] * P
    ctr[0] = 1

    ret = 0
    t = 0
    c = 1
    for x in reversed(tuple(A)):
        t = (t + c * x) % P
        ret += ctr[t]
        ctr[t] += 1
        c = c * 10 % P

    print(ret)


if __name__ == '__main__':
    main()


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

    int num=n;
    int flag;
    while(num>0){
        flag=0;
        for(i=num;i<=n;i+=num){
            if(b[i-1]){
                flag++;//numの倍数の個数
            }
        }
        if((a[num-1] && flag%2==0)||(!(a[num-1]) && flag%2==1)){b[num-1]=1;}
        num--;
    }

    int sum=0;
    bool allzero=true;
    for(i=0;i<n;i++){
        if(b[i]){allzero=false;sum++;}
    }
    if(allzero){cout<<0<<endl;return 0;}

    cout<<sum<<endl;
    for(i=0;i<n;i++){if(b[i]){cout<<i+1<<" ";}}
    cout<<endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>vec(N);
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
    }

    int sum = INT_MAX;
    for (int i=-100; i <= 100; i++) {
        int ans = 0;
        for (int j=0; j < N; j++) {
            ans += pow(vec[j] - i, 2.0);
        }
        if (sum > ans) {
            sum = ans;
        }
    }

    cout << sum << endl;
    return 0;
}

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




int main()
{

    int n ;
    cin>>n;
    int a[n];
    for(int i = 0;i<n;i++)
    cin>>a[i];
    int mini = a[0];
    long int sum = 0;

    for(int i = 1;i<n;i++)
    {
      if(a[i] <= mini )
      sum += mini-a[i];
      else
      mini = a[i];
      // cout<<"i = "<<i<<"\n";
      // cout<<sum<<"\n";
    }

    cout<<sum<<"\n";





}


Measured memory_bytes: 4420
use std::io::stdin;

fn main() {
    loop {
        let mut s = String::new();
        stdin().read_line(&mut s).unwrap();
        let end: i32 = match s.trim().parse() {
            Ok(end) => end,
            Err(_) => return
        };
        if end < 2 {
            println!("{}", 0);
            continue;
        }
        // Create vector for prime number flags which manages only the odd number.
        // Num n is calculated from index. n = i * 2 + 1
        let mut flags = vec![true; ((end + 1) / 2) as usize];
        let flags_len = flags.len();
        flags[0] = false;
        for i in 1..flags_len {
            if !flags[i] {
                continue
            }
            let n = i * 2 + 1;
            let mut j = 3;
            let mut comp_index = (n * j - 1) / 2;
            while comp_index < flags_len {
                flags[comp_index] = false;
                j += 2;
                comp_index = (n * j - 1) / 2;
            }
        }
        // Count flags and add one for skip of two;
        println!("{}", flags.iter().filter(|x| **x).count() + 1);
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int mod = 998244353;
const int MAX = 100005;
vector<pair<int , int> > a , b;
int to[MAX];
int cnt = 0;
void dfs(int u)
{
	cnt++;
	if(to[u])
		dfs(to[u]);
}
int main()
{	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		a.pb({0 , i});
		b.pb({0 , i});
	}
	for(auto &x : a) cin >> x.x;
	for(auto &x : b) cin >> x.x;
	sort(a.begin() , a.end());
	sort(b.begin() , b.end());
	for(int i = 0; i < n; i++)
	{
		if(a[i].x > b[i].x){cout << "No";return 0;}
		to[a[i].y] = b[i].y;
	}
	for(int i = 1; i < n; i++)
	{
		if(a[i].x <= b[i - 1].x)
		{
			cout << "Yes";return 0;
		}
	}
	dfs(0);
	cout << ((cnt == n) ? "No" : "Yes") << endl;
}


Measured memory_bytes: 2412
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
char c[105][105];
int x,y,m = 5000000;
int a[105][105]={0};
//void dg(int i,int j,int s)
//{
//	if(c[i][j]=='#')s++;
//	if(i==x&&j==y){if(s<m)m=s;return;}
//	if(i<x)dg(i+1,j,s);
//	if(j<y)dg(i,j+1,s);
//}
//void dg(int i,int j,int s)
//{
//	//printf("s=%d\n",s);
//	int sf;
//	if(i==x&&j==y){if(s<m)m=s;return;}
//	if(i<x){if(c[i][j]=='.'&&c[i+1][j]=='#')sf=1;else sf=0;/*printf(".->#,c[%d][%d]->c[%d][%d],s=%d\n",i,j,i+1,j,s+sf);*/dg(i+1,j,s+sf);}
//	if(j<y){if(c[i][j]=='.'&&c[i][j+1]=='#')sf=1;else sf=0;/*printf(".--#,c[%d][%d]->c[%d][%d],s=%d\n",i,j,i,j+1,s+sf);*/dg(i,j+1,s+sf);}
//}
int yd(int i1,int j1,int i2,int j2)
{
	
	if(c[i1][j1]=='.'&&c[i2][j2]=='#'){/*printf("c[%d][%d]->c[%d][%d]=1\n",i1,j1,i2,j2);*/return 1;}
	/*printf("c[%d][%d]->c[%d][%d]=0\n",i1,j1,i2,j2);*/return 0;
}
int main()
{
	int i,j;
	cin>>x>>y;
	for(i=1;i<=x;i++)
	{
		//getchar();
		for(j=1;j<=y;j++)
		{
			scanf(" %c",&c[i][j]);
			//if(c[i][j]=='#')a[i][j]=1;
		}
	}	
//	cout<<endl;
//	for(i=1;i<=x;i++)
//	{
//		for(j=1;j<=y;j++)
//			printf("%c",c[i][j]);
//		cout<<endl;
//	}
	
//	dg(1,1,0);
//	cout<<m;
	
//	for(i=1;i<=x;i++)
//		for(j=1;j<=y;j++)
//		{
//			if(i==1)a[i][j] += a[i][j-1];
//			else if(j==1)a[i][j]+=a[i-1][j];
//			else a[i][j] += min(a[i][j-1],a[i-1][j]);
//		}	
			
//	for(i=1;i<=x;i++)
//	{
//		for(j=1;j<=y;j++)
//			printf("%d ",a[i][j]);
//		cout<<endl;
//	}
//	cout<<a[x][y];	
	
//	if(c[1][1]=='.'){/*printf(".\n");*/dg(1,1,0);}
//	else {/*printf("#\n");*/dg(1,1,1);}
//	cout<<m;
	
	if(c[1][1]=='#')a[1][1]=1;
	for(i=1;i<=x;i++)
		for(j=1;j<=y;j++)
		{
			if(i==1)a[i][j]+=a[i][j-1]+yd(i,j-1,i,j);
			else if(j==1)a[i][j]+=a[i-1][j]+yd(i-1,j,i,j);
			else a[i][j]+=min(a[i][j-1]+yd(i,j-1,i,j),a[i-1][j]+yd(i-1,j,i,j));
		}
	cout<<a[x][y];
	
	return 0;
}

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

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

    int h, a;
    cin >> h >> a;
    if (h % a == 0)
        cout << h / a << endl;
    else
        cout << h / a + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defun char-digit (c) (- (char-code c) 48))
(deftype unum nil `(integer 0 ,(expt 10 9)))

(defun get-ops (digits ops sum)
  (if (null digits)
      (if (= sum 7)
	  (nreverse ops)
	  nil)
      (or (get-ops (cdr digits) (cons #\+ ops) (+ sum (car digits)))
	  (get-ops (cdr digits) (cons #\- ops) (- sum (car digits))))))

(defun main ()
  (let* ((digits (map 'list #'char-digit (read-line)))
	 (ops (get-ops (cdr digits) nil (car digits))))
    (loop initially (princ (car digits))
       for digit in (cdr digits)
       for op in ops
       do (format t "~A~A" op digit)
       finally (write-line "=7"))))

#-swank(main)


;; Für Test

(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(defun gendat ()
  (with-open-file (out *dat-path*
		       :direction :output :if-exists :supersede)
    ))

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 7144
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, T;
	cin >> n >> T;
	int start = 0;
	int end = 0;
	int count = 0;
	rep(i, n) {
		int now;
		cin >> now;
		if (now > end) {
			count += end - start;
			start = now;
			end = now + T;
		}
		else if ((start < now && now <= end)or now==0) {
			end = now + T;
		}
		if (i == n - 1) {
			count += end - start;
		}
	   // cout << "s" << start << endl;
		//cout <<"e"<< end << endl;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    string s;
    cin >> s;
    int vic = 0;
    for(int i = 0;i < s.size();i++) {
        if(s.at(i) == 'o') ++vic;
    }
    if(15 - s.size() + vic >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
use std::io;
use std::collections::HashSet;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut uf = UnionFind::new(n);
    for _ in 0..m {
        let (x, y, _) = {
            let i = read::<usize>();
            (i[0] - 1, i[1] - 1, i[2])
        };
        uf.unite(x, y)
    }

    let mut hs = HashSet::new();
    for i in 0..n { hs.insert(uf.find(i)); }
    println!("{}", hs.len());
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {

    fn new(n: usize) -> Self {
        UnionFind {
            par: (0..n).collect(),
            rank: vec![0;n],
        }
    }

    fn find(&mut self, x: usize) -> usize {
        if x == self.par[x] { x }
        else {
            let par = self.par[x];
            self.par[x] = self.find(par);
            self.par[x]
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }

    fn unite(&mut self, x: usize, y: usize) {
        use std::cmp::Ordering;
        let x = self.find(x);
        let y = self.find(y);
        if x == y { return; }

        match self.rank[x].cmp(&self.rank[y]) {
            Ordering::Equal => {
                self.par[y] = x;
                self.rank[x] += 1;
            },
            Ordering::Less => {
                self.par[x] = y;
            },
            Ordering::Greater => {
                self.par[y] = x;
            }
        }
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n,m;
    cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> seen(n,-1);
    seen[0]=0;
    vector<int> pre(n,-1);
    
    queue<int> que;
    que.push(0);
    
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv:G[v]){
            if(seen[nv]==-1){
                que.push(nv);
                seen[nv]=seen[v]+1;
                pre[nv]=v;
            }
        }
    }
    bool ans=true;
    rep(i,n) if(seen[i]==-1) ans=false;
    if(ans){
        cout<<"Yes"<<endl;
        rep(i,n-1) cout<<pre[i+1]+1<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 10568
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	int n,k,c; cin >> n >> k>> c;
	string s; cin >> s;
	if(c == 0){
		rip(i,n,0) if(s[i]=='o') k--;
		if(k < 0) return 0;
		rip(i,n,0){
			if(s[i] == 'o') printf("%d\n", i+1);
		}
		return 0;
	}
	vector<int> dp(n),dpp(n);
	dp[0] = 1;
	dpp[n-1] = 1;
	if(s[0] == 'x') dp[0] = 0;
	if(s[n-1] == 'x') dp[n-1] = 0;
	rip(i,n,1){
		dp[i] = dp[i-1];
		if(c < i && s[i] == 'o') chmax(dp[i], dp[i-c-1]+1);
		else chmax(dp[i], 1);
	}
	for(int i = n-2;i>-1;i--){
		dpp[i] = dpp[i+1];
		if(i+c+1 < n && s[i] == 'o') chmax(dpp[i], dpp[i+c+1]+1);
		else chmax(dpp[i], 1);
	}
	vector<int> ans(0);
	vector<int> su(n+1);
	rip(i,c+1,0){
		if(dpp[i] >= k) su[0]++, su[i]--;
	}
	rip(i,n-c-1,0){
		if(dp[i] + dpp[i+c+1] >=k) su[i+1]++, su[i+c+1]--;
	}
	rip(i,n,n-c-1){
		if(dp[i] >= k) su[n]--, su[i+1]++;
	}
	int ok= 0;
	rip(i,n,0){
		ok += su[i];
		if(ok == 0) ans.push_back(i+1);
	}
	// vdeb(dp);vdeb(dpp);vdeb(su);
	rip(i,ans.size(),0) printf("%d\n", ans[i]);
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll=long long;
signed main()
{
	ll N; cin >> N;
	vector<ll> S(N); FOR(i,N) cin >> S[i];
	ll sum = accumulate(ALL(S), 0LL);
	if (sum % 10 != 0) {
		cout << sum << endl;
		exit(0);
	} 
	sort(ALL(S));
	FOR(i,N) {
		if (S[i] % 10 != 0) {
			cout << sum - S[i] << endl;
			exit(0);
		}
	}

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

Measured memory_bytes: 256
from itertools import permutations

def solve():    
    for ch in permutations(set(list("".join(field))) - set(["."])):
        cp = map(list,field[:])
        for c in ch:
            if check(cp, c) == False:
                break
        else:
            return "SAFE"
    return "SUSPICIOUS"
            
def check(field, c):
    for y in xrange(corner[c][2], corner[c][3] + 1):
        for x in xrange(corner[c][0], corner[c][1] + 1):
            if field[y][x] != c and field[y][x] != "*":
                return False
            field[y][x] = "*"
    return True

for _ in xrange(input()):
    h, w = map(int, raw_input().split())
    if h | w == 0:
        break    
    field = [raw_input() for _ in xrange(h)]
    corner = {}
    for y in xrange(h):
        for x in xrange(w):
            if field[y][x] == ".":
                continue
            if field[y][x] not in corner:
                corner[field[y][x]] = [x, x, y, y] # left right top buto
            else:
                corner[field[y][x]][0] = min(corner[field[y][x]][0], x)
                corner[field[y][x]][1] = max(corner[field[y][x]][1], x)
                corner[field[y][x]][2] = min(corner[field[y][x]][2], y)
                corner[field[y][x]][3] = max(corner[field[y][x]][3], y)
    print solve()

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

// DAME:
int main() {
    int n;
    cin >> n;
    vector<int> a;
    for(int t=1; t<=n; t*=6) a.push_back(t);
    for(int t=9; t<=n; t*=9) a.push_back(t);
    sort(a.begin(), a.end());
    int dp[20][100010];     // dp[i][j] := i番目まで使用して、合計がjになる時の最小の操作数
    int m = a.size();

    rep(i, m+1)rep(j, n+1) dp[i][j] = inf;
    rep(i, m+1) dp[i][0] = 0;
    rep(j, n+1)rep(i, m+1){
        if(i==0) continue;
        dp[i][j] = min(dp[i][j], dp[i-1][j]);
        dp[i][j+a[i-1]] = min(dp[i][j]+1, dp[i-1][j+a[i-1]]);
    }

    cout << dp[m][n] << endl;
    return 0;
}

Measured memory_bytes: 7168
fun main() {
    val n = nextInt()
    val k = nextInt()
    val x = nextInt()
    val y = nextInt()
    println(if (n >= k) {
        k.times(x) + (n - k).times(y)
    } else {
        n.times(x)
    })
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 34448
#include<bits/stdc++.h>
using namespace std;
int N,M,a,b,ans;
int main(){
  cin>>N>>M;
  vector<vector<int>>v(1<<17);
  for(int i=0;i<N;i++){
    cin>>a>>b;
    v[a].push_back(b);
  }
  priority_queue<int>q;
  for(int i=1;i<=M;i++) {
    for(auto e:v[i])q.push(e);
    if(q.size())ans+=q.top(),q.pop();
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6400
#include<stdio.h>
int N, K, X, Y;
int main(){
  scanf("%d%d%d%d", &N, &K, &X, &Y);
  if(N>K){
    printf("%d\n", X*K+Y*(N-K));
  }else{
    printf("%d\n", X*N);
  }
}


Measured memory_bytes: 128
import math

n = int(input())
s = [0]*n
ans = {}
ans_v = 0

for i in range(n):
    s[i] = "".join(sorted(list(input())))
    
s_set = set(s)

for i in s_set:
    ans[i] = 0
    
for i in s:
    ans[i] += 1

for j in ans.values():
    if j >= 2:
        ans_v += math.factorial(j) /( (math.factorial(j - 2)* math.factorial(2)))
    
print(int(ans_v))

Measured memory_bytes: 26500
#include <bits/stdc++.h>
using namespace std;
struct fastio { fastio () { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _io;
template<class T, class U> bool chmax(T& a, const U &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmin(T& a, const U &b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	long long all = 0;
	for (auto &e : a) all ^= e;
	
	for (int i = 0; i < n; i++) {
		cout << (all ^ a[i]) << '\n';
	}
	
	return 0;
}
	

Measured memory_bytes: 4712
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> a(3);
	vector<ll> b(3);
	for (int i = 0;i < 3;i++)
		cin >> a[i];
	for (int i = 0;i < 3;i++)
		cin >> b[i];

	vector<P> v;
	for (int i = 0;i < 3;i++) {
		if (a[i] < b[i])
			v.push_back(P(a[i], b[i]));
	}

	ll big = N;
	if (v.size() > 0) {
		vector<ll> num;
		ll rest = N;
		if (v.size() == 1) {
			num.push_back(N / v[0].first);
			ll tmp = N;
			for (int k = 0;k < num.size();k++)
				tmp += num[k] * (v[k].second - v[k].first);
			big = max(big, tmp);
			num.pop_back();
		}
		else {
			for (int i = 0;i * v[0].first <= N;i++) {
				num.push_back(i);
				rest = N - i * v[0].first;
				if (v.size() == 2) {
					num.push_back(rest / v[1].first);
					ll tmp = N;
					for (int k = 0;k < num.size();k++)
						tmp += num[k] * (v[k].second - v[k].first);
					big = max(big, tmp);
					num.pop_back();
				}
				else {
					for (int j = 0;j*v[1].first <= N - i * v[0].first;j++) {
						num.push_back(j);
						rest = N - i * v[0].first - j * v[1].first;
						num.push_back(rest / v[2].first);
						ll tmp = N;
						for (int k = 0;k < num.size();k++)
							tmp += num[k] * (v[k].second - v[k].first);
						big = max(big, tmp);
						num.pop_back();
						num.pop_back();
					}
				}
				num.pop_back();
			}
		}
	}

	N = big;
	v.clear();
	for (int i = 0;i < 3;i++) {
		if (a[i] > b[i])
			v.push_back(P(b[i], a[i]));
	}

	if (v.size() > 0) {
		vector<ll> num;
		ll rest = N;
		if (v.size() == 1) {
			num.push_back(N / v[0].first);
			ll tmp = N;
			for (int k = 0;k < num.size();k++)
				tmp += num[k] * (v[k].second - v[k].first);
			big = max(big, tmp);
			num.pop_back();
		}
		else {
			for (int i = 0;i * v[0].first <= N;i++) {
				num.push_back(i);
				rest = N - i * v[0].first;
				if (v.size() == 2) {
					num.push_back(rest / v[1].first);
					ll tmp = N;
					for (int k = 0;k < num.size();k++)
						tmp += num[k] * (v[k].second - v[k].first);
					big = max(big, tmp);
					num.pop_back();
				}
				else {
					for (int j = 0;j*v[1].first <= N - i * v[0].first;j++) {
						num.push_back(j);
						rest = N - i * v[0].first - j * v[1].first;
						num.push_back(rest / v[2].first);
						ll tmp = N;
						for (int k = 0;k < num.size();k++)
							tmp += num[k] * (v[k].second - v[k].first);
						big = max(big, tmp);
						num.pop_back();
						num.pop_back();
					}
				}
				num.pop_back();
			}
		}
	}
	cout << big << endl;

	return 0;
}






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

void fnInput(llong& rnLow, llong& rnHigh, int& rnDivsor1, int& rnDivsor2)
{
  cin >> rnLow >> rnHigh >> rnDivsor1 >> rnDivsor2;
}
  
llong fnAntiDivCnt(llong nLow, llong nHigh, int nDivsor1, int nDivsor2)
{
  int nDividend = max(nDivsor1, nDivsor2);
  int nDivisor  = min(nDivsor1, nDivsor2);

  while (nDividend % nDivisor)
  {
    int nRemndr = nDividend % nDivisor;
    nDividend = nDivisor;
    nDivisor  = nRemndr;
  }
  llong nDivLcm = (llong)nDivsor1 * (nDivsor2 / nDivisor);
  llong nLowLessDiv1Cnt = (nLow - 1) / nDivsor1;
  llong nLowLessDiv2Cnt = (nLow - 1) / nDivsor2;
  llong nLowLessDLcmCnt = (nLow - 1) / nDivLcm;

  llong nHighDev1Cnt = nHigh / nDivsor1;
  llong nHighDev2Cnt = nHigh / nDivsor2;
  llong nHighDLcmCnt = nHigh / nDivLcm;
  
  llong nDivsible = (nHighDev1Cnt + nHighDev2Cnt - nHighDLcmCnt) -
                    (nLowLessDiv1Cnt + nLowLessDiv2Cnt - nLowLessDLcmCnt);
  return (nHigh - nLow + 1) - nDivsible;
}
  
int main()
{
  llong nLow, nHigh;
  int nDivsor1, nDivsor2;

  fnInput(nLow, nHigh, nDivsor1, nDivsor2);
  cout << fnAntiDivCnt(nLow, nHigh, nDivsor1, nDivsor2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>  
#include <stack>  
#include <queue>
#include <cmath>  
#include <vector>  
#include <cstring>  
#include<set>
#include<map>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef unsigned long long uLL;
const int M = 1000005;
const int N = 1000005;
const int mod = 1000000007;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const LL lINF = 0x3f3f3f3f3f3f3f3fLL;
const int sINF = 0xcfcfcfcf;
#define ls (rt<<1)
#define rs (rt<<1|1)
int a[3];
int main()
{
	while (~scanf("%d%d%d", &a[0],&a[1],&a[2]))
	{
		sort(a, a + 3);
		printf("%d\n", a[2] - a[0]);
	}
}

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

int main(){
    int N;
  int t = 0;
  cin >> N;
  for(int i = 1; i < 10; i++){
  for(int j = 1; j < 10; j++){
  if(i * j == N){
  t = 1;
  break;}
  }}
  if(t != 0){
  cout << "Yes" << endl;}
  else{
  cout << "No" << endl;}
}

Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))

p1 = (0, 0)
p2 = (w, h)

for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if p1[0] < x:
            p1 = (x, p1[1])
    elif a == 2:
        if p2[0] > x:
            p2 = (x, p2[1])
    elif a == 3:
        if p1[1] < y:
            p1 = (p1[0], y)
    elif a == 4:
        if p2[1] > y:
            p2 = (p2[0], y)

area = (max(p2[0]-p1[0], 0))*(max(p2[1]-p1[1], 0))
print(area)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    vector<pair<ll, ll> > pairs(n);
    rep(i,n) {
      ll a;
      cin >> a;
      pairs[i] = make_pair(a, i+1);
    }
    sort(pairs.begin(), pairs.end());
    rep(i,n){
      cout << pairs[i].second << " ";
    }
}

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

int main()
{
    int a[3][3];
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N];
    bool r[3][3];
    rep(i,3){
        rep(j,3){
            r[i][j]=false;
        }
    }
    rep(i,N)cin>> b[i];
    int count=0;
    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(b[i]==a[j][k]){
                    r[j][k]=true;
                    count++;
                }
            }
        }
    }
    bool result=false;
    if(count<=2){
        cout << "No" << endl;
    }

    else{
        if(r[0][0]==true&&r[1][1]==true&&r[2][2]==true){
            result=true;
        }if(r[0][2]==true&&r[1][1]==true&&r[2][0]==true){
            result=true;
        }if(r[0][0]==true&&r[0][1]==true&&r[0][2]==true||r[1][0]==true&&r[1][1]==true&&r[1][2]==true||r[2][0]==true&&r[2][1]==true&&r[2][2]==true){
            result=true;
        }if(r[0][0]==true&&r[1][0]==true&&r[2][0]==true||r[0][1]==true&&r[1][1]==true&&r[2][1]==true||r[0][2]==true&&r[1][2]==true&&r[2][2]==true){
            result=true;
        }
        if(result==true){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int N = 1e5 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;
const int LN = 62 ;

lint basis[LN] ;
int n ; lint a[N] ;
int bitCnt[LN] ;
lint ans = 0 ;

void addVector(lint mask)
{
    for(int i = LN - 1; i >= 0; i--)
    {
        if(mask & (1LL << i))
        {
            if(!basis[i])
            {
                basis[i] = mask ;
                return ;
            }
            mask ^= basis[i] ;
        }
    }
}

int main()
{
    fastio; cin >> n ;
    memset(basis, 0LL, sizeof(basis)); memset(bitCnt, 0LL, sizeof(bitCnt));

    for(int i = 0; i < n; i++)
    {
        cin >> a[i] ;
        for(int j = 0; j < LN; j++)
            if(a[i] & (1LL << j))
                bitCnt[j]++ ;
    }

    for(int i = 0; i < LN; i++)
        if(bitCnt[i] & 1)
            ans += (1LL << i) ;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < LN; j++)
            if(a[i] & (1LL << j) and bitCnt[j] & 1)
                a[i] ^= (1LL << j) ;
        addVector(a[i]);
    }

    lint ans2 = 0 ;
    for(int j = LN - 1; j >= 0; j--)
    {
        if(!basis[j]) continue;
        if(ans2 & (1LL << j)) continue ;
        ans2 ^= basis[j] ;
    }
    ans += ans2 * 2LL ;
    cout << ans ;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
      
      if(a+b >= c){
        System.out.println(b+c);       
      } else{
        System.out.println(a+2*b+1);       
      }
      
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,K;
  cin >> N >> K;
  int max_e = (N-1)*(N-2)/2;
  if(K > max_e){
    cout << -1 << endl;
    return 0;
  }
  int M = (max_e - K) + N-1;
  cout << M << endl;
  rep1(i,N-1){
    cout << 1 << " "<< i+1 << endl;
  }
  int c=0;
  rep1(i,N-1){
    for(int j=i+2; j<=N; j++){
      if(c==(max_e-K)) break;
      cout << i+1 << " " << j << endl;
      c++;
    }
  }

  return 0;
    

}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    s = " " + s;
    int cnt = 0;
    rep(i, n+1) {
        if (i == 0 || i == 1) continue;
        if (s[1] == '1') {
            if (i % 2 == 0 && s[i] == '1') cnt++;
            else if (i % 2 == 1 && s[i] == '0') cnt++;
        } else if (s[1] == '0') {
            if (i % 2 == 0 && s[i] == '0') cnt++;
            else if (i % 2 == 1 && s[i] == '1') cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main()
{
    int flag1=0, flag2=0, len;
    string str1, str2, str3;
    cin >> str1;
    len = str1.size();
    for (int i = 0; i < len-1;i++){
        int j = str1.size();
        str1 = str1.erase(j - 1);
        if(j%2!=0){
            str2 = str1.substr(0,j/2);
            str3 = str1.substr(j/2);
            if(str2==str3){
                cout << str2.size() * 2 << endl;
                ;
                return 0;
            }
            //cout << str2 << " " << str3 << " " << endl;
        }
    }

        
    //cout << str1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    rep1(i, 1000){
        for(ll j=-500; j<=1000; j++){
            if(x==pow(i, 5)-pow(j, 5)){
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>

using namespace std;

long m, q;
long unsigned int n;
vector<vector<int>> v;  

int ans = 0;

void reFun(vector<int> nv){
    if(nv.size() == n){
        int sum = 0;
        for(int i = 0; i < q; i++){
            if(nv[v[i][1] - 1] - nv[v[i][0] - 1] == v[i][2]){
                sum += v[i][3];
            }
        }
        if(sum > ans){
            ans = sum;
        }
        return;
    }
    int s = 1;
    if(nv.size()){
        s = nv[nv.size() - 1];
    }
    for(int i = s; i <= m; i++){
        vector<int> new_nv = nv;
        new_nv.push_back(i);
        reFun(new_nv);
    }
    return;
}

int main() {
    cin >> n >> m >> q; 
    for(int i  = 0; i < q; i++){
        vector<int> vx;
        for(int i = 0; i < 4; i++){
            int x;
            cin >> x;
            vx.push_back(x);
        }
        v.push_back(vx);
    }
    vector<int> nv;
    reFun(nv);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//***Bismillahir Rahmanir Rahim***//

//*********************************//
//******Ashraful Haque Toni********//
//********Dept. of CSE,JnU*********//
//email:ashrafulhaquetoni@gmail.com//
//*******contact:01640690531*******//
//*********************************//


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);
#define         pb push_back
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d %d ",&m,&n);
#define         sc2l(m,n) scanf("%I64d %I64d ",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

typedef long long ll;


int main()
{
    ash;
    int s,c;
    sc(s);
    sc(c);
    c+=s*3;
    pf("%d\n",c/2);




    return 0;
}




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

typedef pair<int, int> pii;

const int MAXN = 2e5 + 5;

int n, d, a;
pii m[MAXN];
int endEff[MAXN];

int main() {
	cin >> n >> d >> a;
	for (int i = 0; i < n; i++) {
		cin >> m[i].first >> m[i].second;
	}
	sort(m, m + n);
	long long res = 0, cur = 0;
	for (int i = 0; i < n; i++) {
		cur -= endEff[i];
		if (cur * a < m[i].second) {
			long long h = m[i].second - cur * a;
			long long need = (h + a - 1) / a;
			res += need;
			cur += need;
			// st = i, end = n
			int nxt = upper_bound(m + i, m + n, make_pair(m[i].first + 2 * d + 1, 0)) - m;
			endEff[nxt] += need;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2560
N=int(input())
S=input()
cnt=0
 
for i in range(10):
    a=S.find(str(i))
    if a==-1:
        continue
    for j in range(10):
        b=S.find(str(j),a+1)
        if b==-1:
            continue
        for k in range(10):
            if S.find(str(k),b+1)!=-1:
                cnt+=1
print(cnt)

Measured memory_bytes: 9268
from math import factorial
class Facts():
    def __init__(self, max_num=10**5, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        """ nCk mod p を求める """
        """ 計算量 O(log(p)) """
        """ n! / (n-k)! / k! mod p """
        """ フェルマーの小定理 a^(-1) ≡ a^(p-2) """
        """ n! * k!^(p-2) * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[k]
        c = self.fact[n-k]
        return (a*self.power_func(b, self.p-2) *
                self.power_func(c, self.p-2)) % self.p

    def perm(self, n, k):
        """ nPk mod p を求める """
        """ 計算量 O(b - a)? """
        """ n! / (n-k)! mod p """
        """ n! * (n-k)!^(p-2) mod p """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        b = self.fact[n-k]
        return (a * self.power_func(b, self.p-2)) % self.p

    def power_func(self, a, b):
        """ a^b mod p　を繰り返し二乗法で求める """
        """ 計算量 O(log(b)) """
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

MOD = 10**9 + 7

fact = Facts()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
# pos
for i in range(n-1):
    c = fact.comb(n-1-i, k-1)
    ans += a[n-1-i] * c
    ans %= MOD
    ans -= a[i] * c
    ans %= MOD
print(ans)



Measured memory_bytes: 67496
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,maxx,dp[200005],w;
pair <long long,long long> A[200005];
int main() {
           cin>>n>>w;
           for(long long i=1;i<=n;i++) {
                      cin>>A[i].first>>A[i].second;
           }
           for(long long i=1;i<=100000;i++)
           dp[i]=99999999999;
           for(long long i=1;i<=n;i++) {
                      for(long long j=100000;j>=A[i].second;j--) {
                                 dp[j]=min(dp[j],dp[j-A[i].second]+A[i].first);
                      }
           }
           for(long long i=1;i<=100000;i++) {
           if(dp[i]<=w) maxx=max(maxx,i);
           //cout<<dp[i]<<" ";
           }
           cout<<maxx;
}

Measured memory_bytes: 2304
#include<stdio.h>
#include<string.h> 
int main()
{
	int n, r;
	scanf("%d", &n);
	char s[n];
	char t[n];
	
	scanf("%s %s", s, t);
	
	
	for(r=0; r<n; r++){
		printf("%c%c", s[r], t[r]);
	}
 
	return 0;
}

Measured memory_bytes: 128
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int X;
    cin >> X;
    for(int i = 1; ; i++) {
        X -= i;
        if(X <= 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            int gems;
            var table = new Dictionary<string, int[]>() {
                { "N", new[] { 1,  1 } },
                { "E", new[] { 0,  1 } },
                { "S", new[] { 1, -1 } },
                { "W", new[] { 0, -1 } }
            };
            while((gems = int.Parse(Console.ReadLine())) != 0){
                var now = new []{10, 10};
                var map = new bool[21, 21];
                for(int i = 0; i < gems; ++i){
                    var point = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                    map[point[0], point[1]] = true;
                }
                int count = 0;
                for(int i = int.Parse(Console.ReadLine()); i > 0; --i){
                    var input = Console.ReadLine().Split();
                    for(int j = int.Parse(input[1]); j > 0; --j) {
                        now[table[input[0]][0]] += table[input[0]][1];
                        if(map[now[0], now[1]]) {
                            ++count;
                            map[now[0], now[1]] = false;
                        }
                    }
                }
                Console.WriteLine(count == gems ? "Yes" : "No");
            }
        }
    }
}

Measured memory_bytes: 5736