akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        Pair[] A = new Pair[N];
        for (int i = 0; i < N; i++)
        {
            int a = NextInt();
            A[i] = new Pair(a, i);
        }
        var B = A.OrderByDescending(v => v.x).ToArray();
        for (int i = 0; i < N; i++) {
            if (i != B[0].y) Console.WriteLine(B[0].x);
            else Console.WriteLine(B[1].x);
        }
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 27716
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  if((A*B)%2==0) {
    cout<<"No"<<endl;
  }
  else {
cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [usize; n]
    }
    v.sort_by(|x, y| y.cmp(x));
    let mut w = 1.0;
    let mut ans = 0.0;
    for i in 0..n - 1 {
        w /= 2.0;
        ans += v[i] as f64 * w;
    }
    ans += v[n - 1] as f64 * w;
    println!("{}", ans);
}


Measured memory_bytes: 4352
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    iota(1, readln.chomp.to!(int)+1).count!(x => x % 2 == 1 && iota(1,x+1).count!(i => x % i == 0) == 8).writeln;
}



Measured memory_bytes: 256
import itertools
s = [input() for i in range(5)]
listS = list(itertools.permutations(s))
#順列で全探索
Min = float("inf")
time = 0
for i in range(120):
    time = 0
    for j in range(5):
        time += int(listS[i][j])
        if(j != 4):
            while(time % 10 != 0):
                time += 1
    if(time < Min):
        Min = time

print(Min)

Measured memory_bytes: 3064
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit()
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first

print(str(min_change))

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

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

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

  ll dp[40] = {};
  dp[0] = 1;
  dp[1] = 2;
  dp[2] = 4;
  for(int i = 3; i < 40; i++) {
    dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
  }

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

    ll day = (dp[n-1]+10-1)/10;
    cout << (day+365-1)/365 << '\n';
  }
  return 0;
}



Measured memory_bytes: 3128
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_list = list(map(lambda x: x * -1, a_list))

import heapq  # heapqライブラリのimport
heapq.heapify(a_list)  # リストを優先度付きキューへ

for i in range(m):
    max_a = heapq.heappop(a_list)
    max_a *= -1
    max_a //= 2
    max_a *= -1
    heapq.heappush(a_list, max_a)

print(sum(a_list) * -1)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<int, i_i> iii;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, Q;
set<int> out;
vector<iii> Query;
int ans[200500];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    for(int i = 1; i <= N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        Query.push_back({s-x, {1, x}});
        Query.push_back({t-x, {0, x}});
    }
    for(int i = 1; i <= Q; i++) {
        int d;
        cin >> d;
        Query.push_back({d, {2, i}});
    }
    sort(Query.begin(), Query.end());
    for(auto now : Query) {
        if(now.second.first == 0) {
            int pos = now.second.second;
            out.erase(pos);
        } else if(now.second.first == 1) {
            int pos = now.second.second;
            out.insert(pos);
        } else if(now.second.first == 2) {
            if(!out.empty()) {
                ans[now.second.second] = *out.begin();
            } else {
                ans[now.second.second] = -1;
            }
        }
    }
    for(int i = 1; i <= Q; i++) cout << ans[i] << endl;
    return 0;
}


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

int main()
{
  int tate,yoko;

  int n,m;
  while(1){
  cin >> tate >> yoko;

  if(tate == 0 && yoko == 0){break;}

  else{

  for(n = 1; n <= tate; n++){

    for(m = 1;m <= yoko; m++){
      cout << "#";
    }

    cout << "\n";
   }
  cout << "\n";

  }
  }
}

Measured memory_bytes: 1120
def pin(type=int):
    return map(type,input().split())
X,=pin()

while(True):
    flag = 0
    l=int(X**0.5)
    for i in range(2,l+1):
        if X % i == 0:
            flag = 1
    if flag == 0:
        print(X)
        break
    else:
        flag = 0 
        X +=1

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <time.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long  ll;
static const ll INF = (ll)1 << 62;
static const ll MOD = 1e9 + 7;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001];
vector<pair<ll, ll>> p;
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, n)cin >> a[i];
	sort(a, a + n);

	rep(i, 0, m) {
		ll b, c; cin >> b >> c;
		p.push_back(make_pair(c, b));
	}
	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());

	ll L = 0;
	ll ans = 0;
	for (vector<pair<ll, ll>>::iterator it = p.begin(); it != p.end(); it++) {
		ll R = it->second + L - 1;
		ll*  i = lower_bound(a + L, a + n, it->first);
		ll q = min(R, (ll)((i - a) - 1));

		if (q - L + 1 == 0)break;

		ans += (q - L + 1)*it->first;
		L += (q - L + 1);// it->second;
	}

	rep(i, L, n) ans += a[i];
	cout << ans << endl;

	return 0;
}

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

int cal(int a,int b){
 return b ? cal(b,a%b):a;   
}

int main(){
  int a,b;
  double h;
  scanf("%d %d",&a,&b);
  while(a<1&&a>pow(h,9.0)&&b<1&&b>pow(h,9.0)){
    scanf("%d %d",&a,&b);
  }
  printf("%d\n",cal(a,b));

  return 0;
}





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

int main() {
	int n, a[100]; 
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int k = 0; k < n; k++) {
		cout << a[k];
		if (k < n -1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
	
	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		
		for (int k = 0; k < n; k++) {
		    cout << a[k];
		    if (k < n -1) {
			    cout << " ";
		    } else {
			    cout << endl;
		    }
	    }
	}
	return 0;
}


Measured memory_bytes: 3068
/*
      author : Nishikawa
      created: 05.08.2020 14:45:02
*/

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


int main(){
    int N; cin >> N;
    int AC=0,WA=0,TLE=0,RE=0;
    
    while(N--){
        string judge;
        cin >> judge;
        if(judge=="AC") AC++;
        else if(judge=="WA") WA++;
        else if(judge=="TLE") TLE++;
        else if(judge=="RE") RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<list>
#include<set>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	string s;
    cin >> s;
    
	int size = s.size();
  	bool conditionEven = size % 2 == 0;
    bool conditionStartMatchToEnd = s[0] == s[size-1];
    bool conditionWinner = conditionEven ^ conditionStartMatchToEnd;
    
  	string winner;
    if (conditionWinner){
      winner = "Second";
    }
  	else{
      winner = "First";
    }
  
    cout << winner << endl;
}


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

vector<int>to[100010],co[100010];
vector<ll>ans;

void dfs(int v, ll x, int p=-1){
    ans[v]=x;
    rep(i,to[v].size()){
        if(to[v][i]==p)continue;
        dfs(to[v][i],x+co[v][i],v);
    }
}

int main(){
    int n;
    cin>>n;
    ans.resize(n);
    rep(i,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
        co[a].push_back(c);
        co[b].push_back(c);
    }
    int q,k;
    cin>>q>>k;
    k--;
    dfs(k,0);
    vector<int>d(q),f(q);
    rep(i,q){
        cin>>d[i]>>f[i];
        d[i]--; f[i]--;
    }
    rep(i,q)cout<<ans[d[i]]+ans[f[i]]<<endl;
    return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[100005];
bool check[26];

int main(){

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

		check[i] = false;
	}

	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0'; i++){

		check[buf[i]-'a'] = true;
	}

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

		if(!check[i]){
			printf("%c\n",'a'+i);
			return 0;
		}
	}

	printf("None\n");

	return 0;
}


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

orders = [0, 0, 0, 0]

for i in range(3):
    s = input().split()
    a = int(s[0])
    b = int(s[1])
    orders[a-1] += 1
    orders[b-1] += 1

flag = True
nodds = 0
for e in orders:
    if e % 2 == 1:
        flag = False
        nodds += 1
if flag or nodds == 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){
  
  double A,B,ans=-1;

  cin >> A >> B;
  int N=1;
  while(1){
    int tax8 = N*0.08;
    int tax10 = N*0.1;

    if(tax8==A&&tax10==B){
      ans=N;
      break;
    }

    if(tax8>A || tax10>B){
      break;
    }
    N++;
  }
  cout << ans << endl;

  return 0;
}



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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i = 0 ; i<s.length() ; i++){
            cout<<s[i];
            if(i==n-1){
                break;
            }
    }
    if(s.length()>n){
        cout<<"...";
    }
    return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		int[] a = new int[n];
		boolean c = true;
		Arrays.fill(a, -1);
		for(; m > 0; m--) {
			int x = sc.nextInt()-1, y = sc.nextInt();
			if(a[x] == -1 || a[x] == y) {
				a[x] = y;
			}else {
				c = false;
			}
		}
		if(!c || (n != 1 && a[0] == 0)) {
			System.out.println(-1);
		}else {
			for(int i = 0; i < n; i++) {
				if(a[i] != -1) {
					System.out.print(a[i]);
				}else {
					if(i == 0 && n != 1) {
						System.out.print(1);
					}else {
						System.out.print(0);
					}
				}
			}
		}
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

    using namespace std;

    const int a[7] = {1, 3, 5, 7, 8, 10, 12};
    const int b[4] = {4, 6, 9, 11};

    int main() {
        ios_base::sync_with_stdio(false);
        int x, y;
        cin >> x >> y;
        bool ch = false, ch1 = false;
        for (int i = 0; i < 7; ++i) {
            if (x == a[i]) {
                ch = true;
            }
            if (y == a[i]) {
                ch1 = true;
            }
        }
        if (ch && ch1) {
            cout << "Yes" << endl;
            return 0;
        } else {
            ch = false;
            ch1 = false;
            for (int i = 0; i < 4; ++i) {
                if (x == b[i]) {
                    ch = true;
                }
                if (y == b[i]) {
                    ch1 = true;
                }
            }
        }
        if (ch && ch1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    long long int cnt = 0;

    std::map<int, int> mp;
    //for(int i=0; i<n; i++){
        cnt = 0;
        //cout << "### " << i+1 << endl;
        for(int x=1; x<=101; x++){
            //long long int x2 = x*x;
            //if(x2 > n) continue;
            for(int y=1; y<=101; y++){
                //long long int y2 = y*y;
                //long long int xy = x*y;
                //long long int num = x2+y2+xy;
                //if(num+3 > n) continue;
                for(int z=1; z<=101; z++){
                    
                    //long long int z2 = z*z;
                    //long long int xz = x*z;
                    //long long int yz = y*z;
                    long long int num = x*x + y*y + z*z + x*y + x*z + y*z;
                    mp[num]++;
                    /*
                    if(num == i+1){
                        //cout << x << ", " << y << ", " << z << endl;
                        //cout << num << ":" << num+z2+xz+yz << endl;
                        cnt++;
                    }
                    */
                }
            }
        }
        //cout << cnt << endl;
    //}
    for(int i=1; i<=n; i++){
        cout << mp[i] << endl;
    }
 
    return 0;
}

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int N, K;
    cin >> N >> K;

    combination c(N);
    mint ans;

    chmin(K, N-1);
    rep(i, K+1) {
        ans += c(N, i) * c(N-1, i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
from collections import defaultdict


An = defaultdict()
for _ in range(int(input())):
  i = int(input())
  if i not in An:
    An[i] = 1
  else:
    An[i] += 1

ans = 0
for i in An:
  ans += An[i]%2
print(ans)

Measured memory_bytes: 53720
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
    static final int UNCALC = -1;
    static final int INF = (int) 1e9;
    static int n, k;
    static int[] memo;
    static int[] h;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        k = sc.nextInt();
        h = sc.nextIntArray(n);
        memo = new int[n];
        Arrays.fill(memo, UNCALC);
        out.println(dp(0));
        out.flush();
        out.close();

    }

    static int dp(int i) {
        if (i == n - 1) return 0;
        if (memo[i] != UNCALC) return memo[i];
        int min = INF;
        for (int j = 1; j <= k; j++) {
            int to = i + j;
            if (to == n) break;
            min = Math.min(min, Math.abs(h[to] - h[i]) + dp(to));
        }
        return memo[i] = min;
    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

    }
}

Measured memory_bytes: 45720
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
y = 0
while True:
    x += int (l[a])
    a += 1
    if a == N:
        break
    y += int (l[a])
    a += 1
    if a == N:
        break
print (x-y)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define read(x) scanf("%d",&x)
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
LL a[maxn];
LL sum1[maxn];
LL sum2[maxn];
LL d1[maxn];
LL d2[maxn];
int main() {
    int n,k;
    read(n),read(k);
    LL ans=1e18;
    for(int i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
    }
    stack<LL>s;
    int cnt1=0,cnt2=0;
    for(int i=1;i<=n;i++) {
        if(a[i]<0)s.push(a[i]);
        else d1[++cnt1]=a[i];
    }
    while(!s.empty()) {
        LL t=s.top();
        s.pop();
        d2[++cnt2]=abs(t);
    }
    for(int i=0;i<=k;i++) {
        if(cnt1>=i && cnt2>=k-i) {
            ans=min(ans,min(d1[i]+d1[i]+d2[k-i],d1[i]+d2[k-i]+d2[k-i]));
        }
    }
    printf("%lld\n",ans);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T;
	FOR(i,N) cout<<S[i]<<T[i];
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, R;

    scanf("%jd%jd", &N, &R);

    if (N >= 10) {
        printf("%jd\n", R);
    } else {
        printf("%jd\n", R + 100 * (10 - N));
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  ll m = 1000;
  ll k = 0;
  rep(i, n) {
    if (i) {
      // sell
      if (vec.at(i-1) < vec.at(i)) {
        m += k * vec.at(i);
        k = 0;
      }
    }
    if (i != n - 1) {
      // buy
      if (vec.at(i+1) > vec.at(i)) {
        k += m / vec.at(i);
        m %= vec.at(i);
      }
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
    int main()
    {
        int N,i,j,k,l;
        k = 0;
        l = 0;
        int data[101];
        scanf("%d",&N);
        for(i = 0;i < N;i++){
        scanf("%d",&data[i]);
        }
        for(i = 0;i < 8;i++){
          for(j = 0;j < N; j++){
            if(400*i <= data[j] && data[j] < 400*(i+1)){
            k++;
            break;
            }
          }
        }
        j = 0;
        for(i = 0;i < N;i++){
          if(3200 <= data[i]) j++;
        }
        l = k + j;
        if(k == 0) k = 1;
        printf("%d %d\n",k,l);
        return 0;
    }

Measured memory_bytes: 128
//shan61916
#include <bits/stdc++.h>
    using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull ;
typedef double dll ;
ll fast_exp(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
bool perf(ll x) {
  ll xy = (ll)(sqrt(x)) ;
  return ((xy*xy) == x);
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, d;
  cin >> n >> d;
  vector< vector<ll>> a(n) ;
  for(ll i = 0; i < n; i++) {
    for(ll j = 0; j < d; j++) {
      ll tp ;
      cin >> tp;
      a[i].push_back(tp);
    }
  }
  ll xx = 0 ;
  for(ll i = 0; i < n; i++) {
    for(ll j = i+1; j < n; j++) {
       ll tt = 0;
       for(ll k = 0; k < d; k++) {
        tt+= fast_exp(abs(a[i][k] - a[j][k]), 2) ;
       }
       if(perf(tt)) xx++;
    }
  }
  cout << xx ;
  return 0;
} //good night.

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
ans = 0
cnt = [[0]*20 for _ in range(45)]
for _ in range(n):
    a = list(map(str, input().rstrip().split(".")))
    x = 0
    if len(a) == 1:
        x = int(a[0]) * 10**9
    else:
        x = int(a[0]) * 10**9 + int(a[1]) * pow(10, 9-len(a[1]))
    cnt_2, cnt_5 = 0, 0
    while x % 2 == 0:
        cnt_2 += 1
        x //= 2
    while x % 5 == 0:
        cnt_5 += 1
        x //= 5
    for i in range(45):
        for j in range(20):
            if cnt_2 + i >= 18 and cnt_5 + j >= 18:
                ans += cnt[i][j]
    cnt[cnt_2][cnt_5] += 1
print(ans)

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

a.append(a[0] + k)

max_distance = a[1] - a[0]
for i in range(n):
    if a[i + 1] - a[i] > max_distance:
        max_distance = a[i + 1] - a[i]

print(k - max_distance)

Measured memory_bytes: 26060
#include "stdio.h"
#include "iostream"
using namespace std;
int main()
{
	int a, b, c;
	int ret = 0;
	cin >> a;
		cin >> b;
		cin>> c;

	if (c >= (a - b))
	{
		ret = c - a + b;
	}
	else
	{
		ret = 0;
	}
	cout << ret;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int nums[N], dp[N];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i = 0; i < n; ++i){
		cin>>nums[i];
	}
	dp[0] = 0;
	dp[1] = abs(nums[1] - nums[0]);
	for(int i = 2; i < n; ++i){
		dp[i] = min(dp[i-2] + abs(nums[i] - nums[i-2]), dp[i-1] + abs(nums[i] - nums[i-1]));
	}
	cout << dp[n-1] << endl;
}

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9;
const ll INF = 1e18;
int n;
ll ans;
char s[N];
int main(){
	scanf("%s", &s);
	n = strlen(s);
	for(int i = 0, j = 0; i < n; i++)
		if(s[i] == 'B')
			j++;
		else
			ans += j;
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {

  while( true ) {
	int n;
	cin >> n;
	if ( n == 0 ) break;
	for ( int i = 0; i < n; i++ ) {
	  int pm, pe, pj;
	  cin >> pm >> pe >> pj;
	  if ( max( max( pm, pe ), pj ) == 100 ||
		   pm + pe >= 180 ||
		   pm + pe + pj >= 240 ) {
		
		cout << "A" << endl;
	  } else if ( pm + pe + pj >= 210 ||
				  ( pm + pe + pj >= 150 && max( pm, pe ) >= 80 ) ) {
		cout << "B" << endl;
		
	  } else {
		cout << "C" << endl;
	  }
	}
  }  
}

Measured memory_bytes: 1156
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

print(sum([math.fabs((x[i] - y[i])) for i in range(n)]))
print(sum([math.fabs((x[i] - y[i]))**2 for i in range(n)])**(1/2))
print(sum([math.fabs((x[i] - y[i]))**3 for i in range(n)])**(1/3))
print(max([math.fabs((x[i] - y[i]))for i in range(n)]))

Measured memory_bytes: 7876
import math

h,w = map(int,input().split())

count = math.ceil(h/2)
# for i in range(0,h,2):
#     count += 1
#print(count)
if (h == 1 or w == 1) or (h == 1 and w == 1):
    print(1)
else:
    if h % 2 == 0:
        print(count * w)
    else:
        #a = math.ceil(w/2)
        a = math.floor(w/2)
        #print(a)
        print((w - a) * count + (count - 1) * a)

Measured memory_bytes: 3060
class SegmentTree: #1-indexed
    def __init__(self,list,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.zero=2**(self.height-1) #最下段に添字を合わせる用
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            self.tree[self.zero+i]=list[i]
        for i in range(self.zero-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更
        i+=self.zero
        self.tree[i]=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r): #区間[l,r)
        l+=self.zero
        r+=self.zero
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)

    '''
    Falseを探索するかTrueを探索するかは問題によって使い分ける(デフォはTrue探索)
    FFFFTTTTとしたときの最小のTを求める
    '''
    def BinarySearch(self,l,r,f): #fの返り値はboolにする
        if not f(self.query(l,r)):
            return r+1
        l+=self.zero
        r+=self.zero
        while True:
            if f(self.tree[l]):
                if l>=self.zero:
                    return l-self.zero+1 #最下段ならreturn
                else:
                    l*=2 #左の子供を見る
            else:
                if l%2==0:
                    l+=1 #左の子なら右を見る
                else:
                    l=(l//2)+1 #右の子なら親の右を見る

#####################################################

n,q=map(int,input().split())
a=list(map(int,input().split()))
seg=SegmentTree(a,max)
for i in range(q):
    t,x,y=map(int,input().split())
    if t==1:
        seg.update(x-1,y)
    elif t==2:
        print(seg.query(x-1,y))
    else:
        print(seg.BinarySearch(x-1,n,lambda x:x>=y))

Measured memory_bytes: 101808
#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 sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

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

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n, r, c;
    cin >> h >> w >> n;
    cin >> r >> c;
    --r, --c;
    string s,t;
    cin >> s >> t;
    int left = 0, right = w;
    rrep(i,n){
        if(t[i] == 'L'){
            right = min(w, right + 1);
        }else if(t[i] == 'R'){
            left = max(0, left - 1);
        }
        if(s[i] == 'L'){
            left++;
        }else if(s[i] == 'R'){
            right--;
        }
        if(left >= right){
            cout << "NO\n";
            return 0;
        }
    }
    if(c < left || right <= c){
        cout << "NO\n";
        return 0;
    }
    left = 0, right = h;
    rrep(i,n){
        if(t[i] == 'U'){
            right = min(h, right + 1);
        }else if(t[i] == 'D'){
            left = max(0, left - 1);
        }
        if(s[i] == 'U'){
            left++;
        }else if(s[i] == 'D'){
            right--;
        }
        if(left >= right){
            cout << "NO\n";
            return 0;
        }
    }
    if(r < left || right <= r){
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


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

int digits_sum(int a){
  int ans = 0;
  while(a>0){
    ans += a%10;
    a /= 10;
  }
  return ans;
}

int main(void){
  int N, ans;
  cin >> N;
  ans = N;

  for(int i=1;i<N;i++){
    ans = min(ans, digits_sum(i)+digits_sum(N-i));
  }
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
template<typename T>
long long pow(T n, T x, T MOD=(T)(1e9)+7){
    long long res = 1LL;
    while(x){
        if(x%2==1) res = (res*n) % MOD;
        x = x>>1;
        n= (n*n) % MOD;
    }
    return res%MOD;
}
signed main(){
    ll N; cin>>N;
    vector<ll> A(N);
    REP(i, N) cin>>A[i];
    sort(ALL(A));
    long double ans = .0;
    ll d = 1;
    for(int i=N-1; i>=0; i--){
        if(i) d *= 2;
        ans += 1.0*A[i] / d;
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(a,b) ((a < b) ? b : a)

int main(void) {
  int W, a, b;
  scanf("%d %d %d", &W, &a, &b);

  int X = 0;
  if(a < b) {
    int a_e = a + W;
    X = MAX(0, b - a_e);
  } else if(a > b) {
    int b_e = b + W;
    X = MAX(0, a - b_e);
  }
  printf("%d\n", X);
  return 0;
}


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

int main (void)
{
	int A, B, K;
	cin >> A >> B >> K;
	int diff = B - A + 1;

	if (diff <= 2*K)
	{
		for (int i = A; i <= B; i++)
			cout << i << endl;
	}
	else
	{
		for (int i = A; i < A + K; i++)
			cout << i << endl;
		for (int i = B - K + 1; i <= B; i++)
			cout << i << endl;
	}
	return 0;
}


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

int main() {
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x3, y3, x4, y4;
  x3 = x2 + y1 - y2;
  y3 = y2 + x2 - x1;
  x4 = x1 + y1 - y2;
  y4 = y1 + x2 - x1;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

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

    if(a<10 && b<10) cout << a*b << endl;
    else cout << -1 << endl;

    return 0;
}

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

int main()
{
  int N;

  cin >> N;

  vector<int> P(N);

  for (int i = 0; i < N; i++)
  {
    cin >> P.at(i);
  }

  int cnt = 0;
  int min_num = INT_MAX;

  for (int i = 0; i < N; i++)
  {
    min_num = min(min_num, P.at(i));
    if (min_num >= P.at(i))
    {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 4052
// AOJ ITP1_10_B Triangle
// 2018.4.28 bal4u

#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793

int main()
{
	double a, b, c, s, C;
	double S, L, h; 
	
	scanf("%lf%lf%lf", &a, &b, &C);
	c = sqrt(a*a + b*b - 2*a*b*cos(C*PI/180));
	L = a+b+c;
	s = L/2;
	S = sqrt(s*(s-a)*(s-b)*(s-c));
	h = 2*S/a;
	printf("%.8lf\n%.8lf\n%.8lf\n", S, L, h);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(n); i++)
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }
using namespace std;

int main(){
    int N,K; cin >> N >> K;
    map<int,int> mp;
    vector <int> A(N);
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
    }
    
    priority_queue<int,vector<int> ,greater<int> > pq;
    for (auto i:mp) pq.push(i.second);
    
    //cout << pq.size() << endl;
    ll ans=0;
    while(1){
        if (pq.size()<=K) break;
        int a=pq.top(); pq.pop();
        ans+=a;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << (x) << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << ((a)[qwq]);\
		else cerr << ", " << ((a)[qwq]);\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template<typename A, typename B>
ostream& operator << (ostream& out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}

const int maxN = 1000000 + 5;
int n, s[maxN];
char a[maxN];

int work(int low) {
	s[0] = 0;
	for(int i = 1; i <= n; ++i) s[i] = s[i - 1] + 1 - 2 * int(a[i] == '0');
	
	for(int i = n, pf = s[n]; i >= 1; --i) {
		chmin(pf, s[i]);
		s[i] = pf - s[i - 1];
	}
	displaya(s, 0, n);
	
	int now = 0, mx = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] == '0') now--;
		else if(a[i] == '1') now++;
		else {
			if(now + s[i] - 2 >= low) now--;
			else now++;
		}
		chmax(mx, now);
		display(now);
	}
	return mx - low;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> (a + 1);
	n = strlen(a + 1);
	
	s[0] = 0;
	for(int i = 1; i <= n; ++i) s[i] = s[i - 1] + 1 - 2 * int(a[i] == '0');
	
	int mn = *min_element(s, s + n + 1);
	int a1 = work(mn);
	int a2 = work(mn - 1);
	eprintf("a1 = %d, a2 = %d\n", a1, a2);
	cout << min(a1, a2) << endl;
	
	return 0;
}


Measured memory_bytes: 8576
s = input()
L = []
for i in range(len(s)):
  if (s[i] == '0'):
    L.append('0')
  elif (s[i] == '1'):
    L.append('1')
  else:
    if (len(L) != 0):
      del L[len(L)-1]
print((''.join(L)))

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

using namespace std;

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

  sort(a.begin(), a.end());

  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int a,p,ans; cin>>a>>p;
  ans=(a*3+p)/2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int LIM = 2019;
int main(){
    string s;
    cin >> s;
    int x = 0;
    vector<int> cnt(LIM);
    cnt[0] ++;
    ll ans = 0;
    ll p = 1;
    for(int i = s.size()-1; i >= 0; i --){
        x += (s[i] - '0') * p;
        x %= LIM;
        ans += cnt[x];
        cnt[x] ++;
        p *= 10;
        p %= LIM;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3676