akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<ll, ll>;

template <typename T>
void compression(vector<T> &v)
{
    vector<T> t = v;
    sort(ALL(t));
    t.erase(unique(ALL(t)), t.end());
    for (size_t i = 0; i < v.size(); i++)
    {
        v[i] = distance(t.begin(), lower_bound(ALL(t), v[i]));
    }
}

struct BIT // 0-indexed
{
    ll n;
    vector<ll> bit;
    // 初期化
    void init(ll n_input)
    {
        n = n_input + 1;
        bit.resize(n + 1, 0);
    }
    // v[0] + ... + v[k-1]
    ll sum(ll k)
    {
        ll res = 0;
        for (ll i = k - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    // v[i] + ... + v[j]
    ll sum_between(ll i, ll j)
    {
        return i <= j ? sum(j + 1) - sum(i) : 0;
    }
    // v[k] += x
    void add(ll k, ll x)
    {
        for (ll i = k; i < n; i |= i + 1)
        {
            bit[i] += x;
        }
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n + 1, 0);
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] -= k;
        a[i] += a[i - 1];
    }
    vector<P> b(n + 1);
    for (ll i = 0; i <= n; i++)
    {
        b[i] = P(a[i], i);
    }
    sort(ALL(b));
    BIT bit;
    bit.init(n + 1);
    ll ans = 0;
    for (ll i = 0; i <= n; i++)
    {
        ans += bit.sum(b[i].second + 1);
        bit.add(b[i].second, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, K, R, S, P := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	T := nextLine()
	W := make([]bool, N)
	ans := 0
	v := map[byte]int{
		'r': P,
		'p': S,
		's': R,
	}

	for i := 0; i < N; i++ {
		if i < K {
			ans += v[T[i]]
		} else if T[i] == T[i-K] {
			if W[i-K] {
				ans += v[T[i]]
			} else {
				W[i] = true
			}
		} else {
			ans += v[T[i]]
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main() {
	int a;
	cin >> a;
	if(a >= 64){
		cout << 64 << endl;
		return 0;
	}
	if(a >= 32){
		cout << 32 << endl;
		return 0;
	}
	if(a >= 16){
		cout << 16 << endl;
		return 0;
	}
	if(a >= 8){
		cout << 8 << endl;
		return 0;
	}
	if(a >= 4){
		cout << 4 << endl;
		return 0;
	}
	if(a >= 2){
		cout << 2 << endl;
		return 0;
	}
	if(a >= 1){
		cout << 1 << endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String key = s.nextLine();
        char prev = 'a';
        for(char c:key.toCharArray()){
            if(prev==c){
                System.out.println("Bad");
                return;
            }
            prev=c;
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 22996
import java.util.*;

//01ナップサック
class Main {
	Scanner sc = new Scanner(System.in);

	class Tre{
		int weight;
		int value;
		Tre(int value,int weight){
			this.weight=weight;
			this.value=value;
		}
	}

	public void run() {
		int c=0;
		while (true) {
			c++;
			int W=sc.nextInt();if(W==0)break;
			int n=sc.nextInt();

			int[][] dp=new int[n][W+1];
			List<Tre> tres=new ArrayList<Tre>();
			for(int i=0;i<n;i++){
				String[] str=sc.next().split(",");
				tres.add(new Tre(Integer.parseInt(str[0]),Integer.parseInt(str[1])));
			}
			int i=0;
			for(Tre tre:tres){
				//Tre tre=tres.get(0);
				for(int w=0;w<=W;w++){
					if(w>=tre.weight){
						dp[i][w]=
						i==0?tre.value:
						Math.max(dp[i-1][w],dp[i-1][w-tre.weight]+tre.value);
					}else{
						dp[i][w]=(i!=0)?dp[i-1][w]:0;
					}
				}
				i++;
			}
			int weight=dp[n-1][W];
			int windex=-1;
			for(int w=W;w>=0;w--){
				if(dp[n-1][w]!=weight){
					windex=w+1;
					break;
				}
			}
			ln("Case "+c+":");
			ln(dp[n-1][W]);
			ln(windex);
		}
	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, ans;
  unsigned long long now;
  cin >> n;
  now = 7;
  ans = -1;
  for (int i = 0; i < pow(10, 8); i++) {
    now %= n;
    if (now%n == 0) {
      ans = i+1;
      break;
    }
    else {
      now *= 10;
      now += 7;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B;
  cin >> A >> B;

  if (B == 1)
    cout << 0 << endl;
  else if (B <= A)
    cout << 1 << endl;
  else
  {
    B -= A;
    A--;
    cout << 1 + (B + (A - 1)) / A << endl;
  }

  return 0;
}


Measured memory_bytes: 3572
/**
*    author:  souzai32
*    created: 12.08.2020 00:16:27
**/

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

int main() {

    vector<long long> f(1e5+1);
    f.at(0)=1;
    f.at(1)=1;
    for(int i=2; i<=1e5; i++){
        f.at(i)=f.at(i-1)+f.at(i-2);
        f.at(i)%=1000000007;
    }
    // rep(i,100) cout << f.at(i) << endl;
    // cout << f.at(0)+f.at(1) << endl;

    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a.at(i);
    int s=0;
    long long ans=1;
    rep(i,m){
        if(a.at(i)==s){
            ans=0;
            break;
        }
        ans*=f.at(a.at(i)-s-1);
        ans%=1000000007;
        s=a.at(i)+1;
    }
    ans*=f.at(n-s);
    ans%=1000000007;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4264
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    string S;
    cin >> K >> S;
    if ((int)S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }
    return 0;
}

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

int main()
{
  uint64_t n, p;
  cin >> n >> p;
  map<uint64_t, uint64_t> m;
  for (uint64_t i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      m[i] = 1;
      p /= i;
      while (p % i == 0) {
	m[i]++;
	p /= i;
      }
    }
  }
  if (p > 1) {
    m[p] = 1;
  }
  uint64_t ans = 1;
  for (auto&& e : m) {
    if (e.second / n > 0) {
      uint64_t x = e.second / n;
      for (uint64_t i = 0; i < x; i++) {
	ans *= e.first;
      }
    }
  }
  cout << ans << endl;
}


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

#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 3005;

int dp[N][N][4];
int a[N][N];

void solve()
{
   int n,m,k;
    cin >> n >> m >> k;
    
   int u,v,w;
    
   f(i,k)
   {
       cin >> u >> v >> w;
       a[u][v] = w;
   }
    
   for(int i=1;i<=n;i++)
       for(int j=1;j<=m;j++)
         for(int k=0;k<=3;k++)
   { 
        dp[i][j][k] = max(dp[i][j][k],dp[i][j-1][k]);
        if(k > 0) dp[i][j][k] = max(dp[i][j][k],dp[i][j][k-1]);
        if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + a[i][j]);
       
        dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][3]);
        if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][3] + a[i][j]);
   }
    
   int res = 0;
    
   f(i,4) res = max(res,dp[n][m][i]);
    
   cout << res; 
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 355488
#include<bits/stdc++.h>
				using namespace std; 
				#define max(a, b) (a < b ? b : a) 
				#define min(a, b) ((a > b) ? b : a) 
				#define mo 1e9 + 7 
				#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
				#define FORL(a, b, c) for (int(a) = (b); (a) < (c); (a)++) 
				#define FORR(a, b, c) for (int(a) = (b); (a) > (c); (a)--) 
				#define INF 1000000000000000003 
				typedef long long int ll; 
				typedef vector<int> vi; 
				typedef vector<long long int> vl; 
				typedef pair<int, int> pi; 
				typedef pair<long long int, long long int> pl; 
				#define F first 
				#define S second 
				#define pb push_back 
				#define POB pop_back 
				#define mp make_pair 
				//const int M=mod;
				const int M=1e9+7;
				    long long mod(long long x){
					return ((x%M + M)%M);
				    }
				     long long add(long long a, long long b){
					return mod(mod(a)+mod(b));
				    }
								    long long mul(long long a, long long b){
					return mod(mod(a)*mod(b));
				    }
								int main()
				 {ios_base::sync_with_stdio(false);
				    cin.tie(NULL);
					int n;
					int m=1000000007;
					cin>>n;
					int  x;
					vi a,b;
					FOR(i,n)
					{cin>>x;
					a.pb(x);
					b.pb(x);
					}
					for(int i=1;i<n;i++)
					a[i]=add(a[i],a[i-1]);
					ll s=0;
					x=a[n-1];
					FOR(i,n)
					s=add(s,mul(b[i],(x-a[i])));
					cout<<s;
				return 0;
				}
					
		

Measured memory_bytes: 5128
def main():
    """
    一番多い数の種類のケーキから食べる
    上記と異なる種類のケーキのうち、一番多い数の種類のケーキを食べる
    以下繰り返し
        他のケーキの個数がすべて0なら連続日数として追加
    """
    K, T = map(int, input().split())
    A = map(int, input().split())

    A = list(A)
    f(K, T, A)


def f(K, T, A):
    cake_type = None
    rest_K = K
    ans = 0
    while rest_K > 0:
        bef_cake_type = cake_type
        max_a = 0
        for i, a in enumerate(A):
            if a > max_a and i != bef_cake_type:
                cake_type = i
                max_a = a

        A[cake_type] -= 1
        rest_K -= 1
        if bef_cake_type == cake_type:
            ans += 1
        #print(A, "cur:", cake_type, "bef:", bef_cake_type, sep="\t")

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main() {
  string s;
  cin >> s;
  Rep(i, s.size()) {
    cout << 'x';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;


//
// Macro debug!
//

#[cfg(debug_assertions)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}


//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


//
// Main
//

fn main() {
    input! {
        n: usize,
        m: usize,
        submits: [(usize, String); m],
    }

    let mut acs = vec![0; n];
    let mut was = vec![0; n];

    // debug!(n, m, submits);

    for (p, s) in submits {
        if s == "AC" {
            acs[p-1] += 1;
        } else if acs[p-1] == 0 {
            was[p-1] += 1;
        }
    }

    let mut nac = 0;
    let mut penalty = 0;

    for i in 0..n {
        if acs[i] > 0 {
            nac += 1;
            penalty += was[i];
        }
    }

    // debug!(acs, was, nac, penalty);

    println!("{} {}", nac, penalty);
}


Measured memory_bytes: 10492
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000001],c[1000001];
int main(){
    int b,sum=0,l=0;
    cin>>a;
    b=strlen(a);
    for(int i=b-1;i>=0;i--) {
        c[sum]=a[i];
        if(c[sum]=='b') c[sum]='d';
        else if(c[sum]=='d') c[sum]='b';
        else if(c[sum]=='p') c[sum]='q';
        else if(c[sum]=='q') c[sum]='p';
        sum++;
    }
    for(int i=0;i<=b-1;i++) {
        if(a[i]!=c[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Set<Integer> s = new HashSet<>(), t = new HashSet<>();
        for (int i = 0; i < n; i++) {
            s.add(in.nextInt());
        }
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            t.add(in.nextInt());
        }
        s.retainAll(t);
        System.out.println(s.size());
    }
}

Measured memory_bytes: 84568
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int 
solve [a, b]
    | b `mod` a == 0 = a + b
    | otherwise = b - a

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max(max(A + B, A - B), A * B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b >> c;
    if( a + b >= c ) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b;
    string op;
    
    while(1){ cin >> a >> op >> b ;
        if(op == "?") break;
        else if(op == "+") cout << a+b <<endl;
        else if(op == "-") cout << a-b <<endl;
        else if(op == "*") cout << a*b <<endl;
        else cout << a/b <<endl;
        
    }
    
}



Measured memory_bytes: 3156
n = int(input())
for i in range(n):
    s = input()
    if s[:2] == ">'" and s[-1] == '~' and len(s) % 2 == 0 and '=#=' in s:
        temp = ">'" + '=' * (s.count('=')//2) + '#' + '=' * (s.count('=')//2) + '~'
        if s == temp:
            print('A')
            continue
    elif s[:2] == ">^" and s[-2:] == '~~' and len(s) % 2 == 0 and 'Q=' in s:
        temp = ">^" + 'Q=' * ((len(s)-4)//2) + '~~'
        if s == temp:
            print('B')
            continue
    print('NA')




Measured memory_bytes: 5620
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n:usize,
        l: [i64;n],
    }
    let mut cnt = 0;

    for i in 0..l.len() {
        for j in i + 1..l.len() {
            for k in j + 1..l.len() {
                if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
                    continue;
                }
                let a = l[i];
                let b = l[j];
                let c = l[k];

                if a + b > c && b + c > a && c + a > b {
                    cnt += 1;
                }
            }
        }
    }
    println!("{}", cnt);
}


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

int main(){
    int n,m,i,j;
    cin>>n>>m;
    int A[n];
    int sum=0;
    for(i=0;i<n;i++){scanf("%d",&A[i]);sum+=A[i];}
    sort(A,A+n);
    if(4*m*A[n-m]>=sum)printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 3640
n = input()
a = sorted([map(int, raw_input().split()) + [1] for _ in xrange(n)], key = lambda x: x[1], reverse = True)
b = sorted([map(int, raw_input().split()) + [1] for _ in xrange(n)], key = lambda x: x[0])
cnt = 0
for j in b:
    for i in a:
        if i[0] < j[0] and i[1] < j[1] and i[2] and j[2]:
            cnt, i[2], j[2] = cnt + 1, 0, 0
print cnt

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n, k;
	cin >> n >> k;
	ll ans = -1e12;
	deque<int> v;
	rep(i,n) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	int r = min(n, k);
	for(int i = 0; i <= r; i++){
		for(int j = 0; i+j<=r; j++){
			deque<int> nv = v;
			priority_queue<int, vector<int>, greater<int>> c;
			rep(a,i) {
				c.push(nv.front());
				nv.pop_front();
			}
			rep(b,j) {
				c.push(nv.back());
				nv.pop_back();
			}
			ll cost = 0;
			rep(a,max(0,k-(i+j))){
				if(c.size()&&c.top()<0) c.pop();
			}
			while(c.size()){
				cost += c.top();
				c.pop();
			}
			chmax(ans, cost);
		} 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

// Utility for binomial coefficient
ll ncr(ll n,ll k)
{
    if(n<k)
        return 0;
    ll C[n + 1][k + 1];
    ll i,j;
    for(i=0;i<=n;i++){
        for(j=0;j<=min(i,k);j++){
            if (j==0 || j==i)
                C[i][j]=1;
            else
                C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    return C[n][k];
}

const double p=0.57721566490153286;

void solve(){
	//code
	ll n,c=0;
	cin>>n;
	for(int i=1;i<n;i++){
		for(int j=1;j<double(n)/double(i);j++){
			c++;
		}
	}
	cout<<c;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<stack>
using namespace std;
long long n;

int main()
{
    while(~scanf("%lld",&n))
    {
        stack<char>p;
        while(n)
        {
            int t=n%26;

            if(n)
            {
            if(t==0)
            p.push('z');
            else
            p.push((char)('a'+t-1));
            }
            n/=26;
            if(!t)
            n--;
        }
        while(!p.empty())
        putchar(p.top()),p.pop();
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x;
	int ans=0;
	cin >>x;
	if(x < 600){
		ans=8;
	}else if(x<800){
		ans=7;
	}
	else if (x < 1000)
	{
		ans = 6;
	}
	else if (x < 1200)
	{
		ans = 5;
	}
	else if (x < 1400)
	{
		ans = 4;
	}
	else if (x < 1600)
	{
		ans = 3;
	}
	else if (x < 1800)
	{
		ans = 2;
	}
	else 
	{
		ans = 1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	int n;
  	cin>>n;
  	if(n % 2 == 1){
    	cout<<"No"<<endl;
      	return 0;
    }
  	string s;
  	cin>>s;
  	string t1, t2;
  	
  	t1 = s.substr(0,n/2);
  	t2 = s.substr(n/2,n/2);

  	if(t1 == t2)
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n; cin>>n;
    int k[100000]={};
    FOR(i,0,n){
        int a; cin>>a;
        k[a-1]++;
    }
    int sum=0;
    FOR(i,0,100000){
        sum+=max(0,k[i]-1);
    }
    co(n-(sum+1)/2*2);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class UF {
private:
    int sz; vector<int> par,nrank;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz); rep(i,sz){ par[i] = i; nrank[i] = 0; } }
    int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } }
    void unite(int x,int y)
    { x = find(x),y = find(y); if(x == y) return;
    	if(nrank[x] < nrank[y]){ par[x] = y; }else{ par[y] = x; if(nrank[x] == nrank[y]) nrank[x]++; } }
    bool same(int x,int y){ return find(x) == find(y); }
};

struct edge{
    int u,v;
    int cost;
    bool operator<(const edge& another) const {
        return cost < another.cost;
    }
};

template<typename T> class Kruskal{
public:
    vector<edge>& es;
	vector<int> par,rrank;
	int V;
    Kruskal(vector<edge>& e) : es{e}{
        V = len(e);
        es = e;
		par.resize(V), rrank.resize(V);
	}
	void add_edge(int u,int v,T cost){
		es.push_back((edge){u,v,cost});
	}
	T make(){
		UF uf(V);
		T res = 0;
		int cnt = 0;
        sort(es.begin(),es.end());
		rep(i,es.size()){
			edge e = es[i];
			if(!uf.same(e.u,e.v)){
				uf.unite(e.u,e.v);
				res += e.cost;
				cnt++;
				if(cnt == V-1){
					break;
				}
			}
		}
		return res;
	}
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<edge> vec;
    rep(i,n){
        rep(j,n){
            int a;
            cin >> a;
            if(i < j && a >= 0){
                vec.pb((edge){i,j,a});
            }
        }
    }
    Kruskal<int> kr(vec);
    cout << kr.make() << "\n";
    return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>

int main(int argc, char **argv)
{
  char s[5];
  fgets(s, 5, stdin);
  
  int tbl[256] = {0};
  int i;
  for (i = 0; i < 4; i++)
  {
    tbl[s[i]]++;
  }
  
  for (i = 0; i < 256; i++)
  {
    if (tbl[i] != 0 && tbl[i] != 2)
    {
      printf("No");
      return 0;
    }
  }
  
  printf("Yes");
  return 0;
}

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

int main(){
	string str;
	getline(cin, str);
	for(int i = 0; i < str.size(); i++){
		if(str[i] < 90){
			continue;
		}
		else{
			str[i] -= 32;
		}
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,m;
vector<int> G[610];
ld e[610];
int mi[610];


void solve(){
    cin >> n >> m;
    rep(i,m){
        int a,b;cin >> a >> b;a--;b--;
        G[a].push_back(b);
    }
    per(i,n-1){
        ld siz=G[i].size();
        mi[i]=-1;
        for(int t:G[i]){
            e[i]+=e[t]/siz;
            if(mi[i]==-1){
                mi[i]=t;
            }
            else if(e[mi[i]]<e[t]){
                mi[i]=t;
            }
        }
        e[i]+=1;
        //cout << i << " " << mi[i] << " " << e[i] << endl;
    }
    ld ans=e[0];
    rep(k,n-1){
        vector<ld> e2(n,0);
        bool flag=true;
        per(i,n-1){
            ld siz=G[i].size();
            if(k==i) siz-=1;
            if(abs(siz)<eps) {
                flag=false;
                break;
            };
            for(int t:G[i]){
                if(k==i && t==mi[i]) continue;
                e2[i]+=e2[t]/siz;
            }
            e2[i]+=1;
        } 
        if(flag)ans=min(ans,e2[0]);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
#define dg(...) fprintf(stderr,__VA_ARGS__);
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=2005;
const int mod=1000000000+7;
int n,a[200005],b[200005];
int f[maxn<<1][maxn<<1],C[maxn<<2][maxn<<2];
inline void add(int &x,int y){
	x+=y;if(x>=mod)x-=mod;
}
inline void dec(int &x,int y){
	x-=y;if(x<0)x+=mod;
}
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;a=1ll*a*a%mod;
	}return res;
}
int main(){
	read(n);rep(i,1,n)read(a[i]),read(b[i]);
	rep(i,0,8000){
		C[i][0]=1;
		rep(j,1,i)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	rep(i,1,n)f[2000-a[i]][2000-b[i]]+=1;
	rep(i,0,4000)rep(j,0,4000){
		if(i)add(f[i][j],f[i-1][j]);
		if(j)add(f[i][j],f[i][j-1]);
	}
	int res=0;
	rep(i,1,n)add(res,f[a[i]+2000][b[i]+2000]);
	rep(i,1,n)dec(res,C[a[i]+b[i]+a[i]+b[i]][a[i]+a[i]]);
	res=1ll*res*powmod(2,mod-2)%mod;
	cout<<res;
	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i))
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) ans += p[i];
  cout << ans << endl;
}


Measured memory_bytes: 3144
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String[] arr = sc.nextLine().split(" ");
      double x1 = Double.parseDouble(arr[0]);
      double y1 = Double.parseDouble(arr[1]);
      double x2 = Double.parseDouble(arr[2]);
      double y2 = Double.parseDouble(arr[3]);
      
      double distance = Math.pow(x2-x1,2) + Math.pow(y2-y1,2);
      distance = Math.sqrt(distance);
      
      System.out.println(String.format("%.6f", distance));
      
   }//main
}//class

Measured memory_bytes: 26600
#include <iostream>
#include <string.h>
#include<cstdlib>
using namespace std;
struct Node
{
	int key;//??°?????¬????????´??°key
	Node *next, *prev;//???????????????????´??????????next?????????????????????????´???????prev
};
Node *nil;//??´??????
Node* listSearch(int key)
{
	Node *cur = nil->next;//?????´???????????¢???????´?????§???????
	while (cur != nil&&cur->key != key)
	{
		cur=cur->next;
	}
	return cur;//?????????????????????????????????
}
void init()
{
	//malloc???C????¨?????????????????????°?????¨?????¨?????????????????§?°???????????????´???sizeof???Node????????????Node?±???????????????´?????§?°?
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}
void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while (1)
	{
		if (cur == nil) break;
		if (isf++ > 0)
			cout << " ";
		cout << cur->key;//?????°????????????
		cur = cur->next;//?????????????????????
	}
	cout << endl;
}
void deleteNode(Node *t)
{
	if (t == nil) return;//???t?????´????????¶????????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}
void deleteFirst()
{
	deleteNode(nil->next);
}
void deleteLast()
{
	deleteNode(nil->prev);
}
void deleteKey(int key)
{
	deleteNode(listSearch(key));//??????????´¢??°?????????
}
void insert(int key)
{
	Node *x = (Node*)malloc(sizeof(Node));
	x->key = key;
	//??¨??´???????????????????´?
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main()
{
	int key, n;//n???????????°
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	cin >> n;
	init();
	for (int i = 0; i < n; i++)//????????????????°±???????¬???????
	{
		cin >> com;
		if (com[0] == 'i')
		{
			cin >> key;
			insert(key);
			np++;
			size++;
		}
		else if (com[0] == 'd')
		{
			if (strlen(com) > 6)
			{
				if (com[6] == 'F')
					deleteFirst();
				else if (com[6] == 'L')
					deleteLast();
			}
			else
			{
				cin >> key;
				deleteKey(key); 
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}

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

long long int N;
long long int C;
long long int x[100001] = {0};
long long int v[100001] = {0};

long long int rtotalv[100001] = {0};
long long int ltotalv[100001] = {0};

long long int rprov[100001] = {0};
long long int lprov[100001] = {0};

long long int rmax(){
    
    long long int eachcal[100001] = {0};
    long long int max = 0;
    for(int i=0;i<N;i++){
        eachcal[i] = rtotalv[i] - x[i];
        if(max < eachcal[i]) max = eachcal[i];
    }
    return max;
}

long long int lmax(){

    long long int eachcal[100001] = {0};
    long long int max = 0;
    for(int i=N-1;i>=0;i--){
        eachcal[i] = ltotalv[i] - (C - x[i]);
        if(max < eachcal[i]) max = eachcal[i];
    }
    return max;
}

long long int rlmax(){
    long long int reachcal[100001] = {0};
    long long int rmax = 0;
    for(int i=0;i<N;i++){
        if((double)x[i] >= (double)(C / 2)) break;
        reachcal[i] = rtotalv[i] - 2 * x[i];
        if(rmax < reachcal[i] + lprov[i+1]) rmax = reachcal[i] + lprov[i+1];
    }
    return rmax;
}

long long int lrmax(){
    long long int leachcal[100001] = {0};
    long long int lmax = 0;
    for(int i=N-1;i>=0;i--){
        if(double(x[i]) <= double(C / 2)) break;
        leachcal[i] = ltotalv[i] - 2 * (C - x[i]);
        if(lmax < leachcal[i] + rprov[i-1]) lmax = leachcal[i] + rprov[i-1];
    }
    return lmax;
}

int main(){
    cin >> N >> C;
    for(int i=0;i<N;i++){
        cin >> x[i] >> v[i];
    }

    rtotalv[0] = v[0];
    for(int i=1;i<N;i++){
        rtotalv[i] = rtotalv[i-1] + v[i];
    }

    ltotalv[N-1] = v[N-1];
    for(int i=N-2;i>=0;i--){
        ltotalv[i] = ltotalv[i+1] + v[i];
    }

    long long int rp = 0;
    for(int i=0;i<N;i++){
        if(rp < rtotalv[i] - x[i]) rp = rtotalv[i] - x[i];
        rprov[i] = rp;
    }

    long long int lp = 0;
    for(int i=N-1;i>=0;i--){
        if(lp < ltotalv[i] - (C - x[i])) lp = ltotalv[i] - (C - x[i]);
        lprov[i] = lp;
    }
    long long int RMAX = rmax();
    long long int LMAX = lmax();
    long long int RLMAX = rlmax();
    long long int LRMAX = lrmax();

    cout << max({RMAX,LMAX,RLMAX,LRMAX}) << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a, b, c, d, f, m;
    bool b1 = false;
    cin>> a;
    int a1[a];
    for (int i = 0; i< a; i++){
        cin>> a1[i];
    }
    f = 0;
    b1 = false;
    m = 0;
    for (int i = 0; i< a; i++){

        if (a1[f] == 2){
            m++;
            b1 = true;
            break;
        }
        f = a1[f] -1;
        m++;
    }
    if (b1 == true){
        cout << m;
    }
    else if (b1 == false){
        cout << "-1";
    }
}


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

public class Main {
	
	public static void main(String[] args) throws Exception{
		FastReader in = new FastReader();
		//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		long sum = 0;
		int[] arr = new int[1000001];
		for(int i = 0; i<n; i++) {
			int a = in.nextInt();
			arr[a]++;
			sum+=a;
		}
		int q = in.nextInt();
		for(int i = 0; i<q; i++) {
			int q1 = in.nextInt(), q2 = in.nextInt();
			sum+=(arr[q1]*(q2-q1));			
			out.println(sum);
			int a = arr[q1];
			arr[q1]=0;
			arr[q2]+=a;
		}
		
        
		
		
		
		
		out.close();
	}
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
		
}


Measured memory_bytes: 58160
import java.util.*

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.nextLine()

    var z = 0
    var o = 0

    for (i in 0..s.length - 1) {
        if (s[i] == '0') {
            z += 1
        } else {
            o += 1
        }
    }
    if (z > o) {
        println(o*2)
    } else {
        println(z*2)
    }
}

Measured memory_bytes: 32356
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{
    int x,y;
    bool operator<(const P &a)const{
        if(y!=a.y)
        return y>a.y;
        return x>a.x;
    }
};
vector<int> v[200456];
int a,b,c,n,m,i,k,o[4513],d,e,dy[5]={0,0,-1,1,0},dx[5]={0,1,1,1,2};
int l[301100];
long long x,y,z[1111][33];
P u1[100100],u2[100100];
int j[200][10200];
priority_queue<P> q;
//long long x=0,y=0,z[99];

//deque<int> d;
//'1'==49;
map<int,int > p;
string r,r1;
//char r[1000];
bool asd(P a,P b)
{
   if(a.x-a.y!=b.x-b.y)
    return a.y-a.x<b.y-b.x;
   return a.x<b.x;
}

int f(int t,int w)
{
    if(w<0) return -1087654321;
    if(t==a) return 0;
    if(j[t][w]) return j[t][w];
    return j[t][w]=max(f(t+1,w-l[t+1])+o[t+1],f(t+1,w));

}

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    for(int t=0;t<=a;t++)
        for(int w=0;w<=b;w++)
    {
        int i=b*t+(a-t)*w-t*w;
        if(i==c)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


Measured memory_bytes: 5760
#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++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " "<< Y << endl;
	return 0;
}


Measured memory_bytes: 256
// AOJ 2510: Twin book report
// 2018.1.8 bal4u@uu

#include <stdio.h>
#include <string.h>

int n;
int r[1003], w[1003];
int dp[1000003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int i, j, k, sr, sw, max;
	int t;

	while (n = in()) {
		sr = sw = 0, max = 0;
		for (i = 0; i < n; i++) {
			int _r, _w;
			r[i] = _r = in(), w[i] = _w = in();
			if (r[max] < _r) max = i;
			sr += _r, sw += _w;
		}

		if ((r[max] << 1) <= sr) { printf("%d\n", sr + sw); continue; }

		t = r[n-1], r[n-1] = r[max], r[max] = t;
		t = w[n-1], w[n-1] = w[max], w[max] = t;
		k = (r[n-1] << 1) - sr;

		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for (i = 0; i < n-1; i++) for (j = k; j >= w[i]; j--) dp[j] |= dp[j-w[i]];
		t = -1; for (i = k; i >= 0; i--) if (dp[i]) { t = k - i; break; }
		printf("%d\n", sr + sw + t); 
	}
	return 0;
}


Measured memory_bytes: 5756
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=((ans%mod)*(x%mod))%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
li a[3][3],i,j,b[3][3];
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
memset(b,0,sizeof(b));
li n;
cin>>n;
while(n--)
{
  li x;
  cin>>x;
  for(i=0;i<3;i++)
  for(j=0;j<3;j++)
  {
    if(a[i][j]==x)
    b[i][j]=1;
  }
}
li flag1=0;
for(i=0;i<3;i++)
{li flag=1;
  for(j=0;j<3;j++)
{
  if(b[i][j]==0)
  flag=0;
}
if(flag)
{
  flag1=1;
  break;
}
}
for(i=0;i<3;i++)
{li flag=1;
  for(j=0;j<3;j++)
{
  if(b[j][i]==0)
  flag=0;
}
if(flag)
{
  flag1=1;
  break;
}
}
if(!flag1)
{
  if((b[0][0]==1)&&(b[1][1]==1)&&(b[2][2]==1))
  flag1=1;
  if((b[0][2]==1)&&(b[1][1]==1)&&(b[2][0]==1))
  flag1=1;
}
if(flag1)
cout<<"Yes";
else
cout<<"No";
  return  0;
}


Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author c0117321c5
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String weather = sc.next();
        if (weather.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (weather.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }

}


Measured memory_bytes: 21840
#include<iostream>
#include<algorithm>
#include<vector>
#include <unordered_map>
using namespace std;

int main() {
    int n,g=0;
    cin >> n;
	vector<int> vec(n);
	for (auto& v : vec){cin >> v;}

    unordered_map<int,vector<int>> mp;
    for (int i=0;i<n;i++) {
        if (i < vec[i]-1) {mp[vec[i]-1].push_back(i);}
        else {if (find(mp[i].begin(),mp[i].end(),vec[i]-1) != mp[i].end()) {g++;}}
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 6540
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n,x=L()
    l=L()
    ans=1
    d=0
    for i in range(n):
       d=d+l[i]
       if d<=x:
           ans+=1
    print(ans)
    

if __name__=='__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, m, v, p;
vector<ll> a;

bool f(ll idx) {
    if (idx < p) return true;
    if (a[p - 1] > (a[idx] + m)) return false;
    ll cnt = (p - 1) * m + (n - idx - 1) * m + m;
    reps(i, p - 1, idx) {
        cnt += (a[idx] + m) - a[i];
    }
    return cnt >= (m * v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> m >> v >> p;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll l = 0, r = n;
    while((l + 1) < r) {
        ll m = (l + r) / 2;
        if (f(m)) l = m;
        else r = m;
    }
    printf("%lld\n", l + 1);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>

using namespace std;

typedef unsigned long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

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

    int n;
    cin >> n;

    vi hight(n);
    vll cost(n);

    cin >> hight[0];
    cost[0] = 0;

    for(int i = 1 ; i < n ; ++i)
    {
        cin >> hight[i];

        if(i > 1)
        {
            ll one = abs(hight[i]-hight[i-1]), two = abs(hight[i]-hight[i-2]);

            cost[i] = min(one+cost[i-1],two+cost[i-2]);

            //cout << i << " " << cost[i] << endl;
        }
        else
        {
            cost[i] = abs(hight[0]-hight[1]);
        }
    }

    cout << cost[n-1];

    return 0;
}


Measured memory_bytes: 4456