akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

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

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        a: chars,
    }

    let mut count = vec![0; 26];
    for i in 0..26 {
        count[i] = a.iter().filter(|&&x| x as u8 == b'a' + i as u8).count();
    }
    println!(
        "{}",
        (a.len() * (a.len() - 1)) / 2 + 1
            - count
                .iter()
                .map(|&x| if x == 0 { 0 } else { x * (x - 1) / 2 })
                .sum::<usize>()
    );
}


Measured memory_bytes: 4352
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
using namespace std; 
int main()
{
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if (h*w%2==0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		if (y%2==1)
		{
			if (x % 2 == 1)
			{
				cout << "Yes" << endl;
			} 
			else
			{
				cout << "No" << endl;
			}
		}
		else
		{
			if (x % 2 == 1)
			{
				cout << "No" << endl;
			}
			else
			{
				cout << "Yes" << endl;
			}
		}
	}
	
}



Measured memory_bytes: 3104
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 505
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int H,W,h,w;
int ans[MAXN][MAXN];
void print()
{
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++) printf("%d ",ans[i][j]);
        puts("");
    }
}
int main()
{
    scanf("%d%d%d%d",&H,&W,&h,&w);
    if(H%h==0&&W%w==0) {puts("No"); return 0;}
    else
    {
        puts("Yes");
        if(H%h!=0)
        {
            for(int i=1;i<=H;i++)
                for(int j=1;j<=W;j++)
                    ans[i][j]=(i%h==0?-501*(h-1)-1:501);
        }
        else
        {
            for(int i=1;i<=H;i++)
                for(int j=1;j<=W;j++)
                    ans[i][j]=(j%w==0?-501*(w-1)-1:501);
        }
        print();
    }
    return 0;
}



Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int n;

        Scanner input = new Scanner(System.in);

        n = input.nextInt();

        if (n >= 1 && n <= 100) {

            int meal = n * 800;

            int cashback = (n / 15) * 200;

            int total = meal - cashback;

            System.out.println(total);

        }

    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int A[2][105];

int main() {

	int N;

	scanf("%d",&N);

	int i,j;

	for(i=0;i<2;i++){
		for(j=0;j<N;j++){
			scanf(" %d",&A[i][j]);
		}
	}

	int ans=0;

	for(i=0;i<N;i++){
		int candie=A[0][0];
		int posx=0;
		int posy=0;
		j=0;
		while(1){
			if(posx==N-1&&posy==1){
				break;
			}
			if(i==j){
				posy++;
			}
			else{
				posx++;
			}
			candie+=A[posy][posx];
			j++;
		}
		if(ans<candie){ans=candie;}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
import itertools
n,m,q=map(int,input().split())
li=[list(map(int,input().split()))for _ in range(q)]

ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for a,b,c,d in li:
        if A[b-1] - A[a-1] == c:
            tmp += d 
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 9060
#include<iostream>
#include<string>
#include<sstream>

int data[2][1001];

int toInt(std::string str){
	std::stringstream z;
	int res;

	z << str;
	z >> res;

	return res;
}

int main(){

	int i = 0;
	std::string str;
	while (std::getline(std::cin, str)){
		if (str.find(',') == -1)i++;
		else data[i][toInt(str.substr(0, str.find(',')))]++;
	}

	for (int j = 0; j < 1001; j++){
		if (data[0][j] != 0 && data[1][j] != 0){
			std::cout << j << " " << data[0][j] + data[1][j] << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


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

	int n;
    cin>>n;
    cout<<(n+1)/2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    long long N,on=0,tw=0;cin>>N;
    map<int,int> bo;
    REP(i,N){
        long long a;cin>>a;
        bo[a]++;
        if(bo[a]%2==0){
            if(a>=tw){
                tw=a;
                if(a>=on){
                    tw=on;
                    on=a;
                }
            }
        }
    }
    if(on==0||tw==0)cout<<0<<endl;
    else cout<<on*tw<<endl;
}

Measured memory_bytes: 4992
import math

N=int(input())
A=[int(input()) for _ in range(N)]
#print(A)

B=0
for a in A:
  B^=a

C=[]
D=[0]*100
for a in A:
  C.append(bin(a^(a-1))[2:])
#print(C)
for c in C:
  D[len(c)]=1
#print(D)

ans=0
while B:
  #print(B,bin(B))
  if D[len(bin(B)[2:])]:
    B^=2**len(bin(B)[2:])-1
    ans+=1
  else:
    ans=-1
    break
print(ans)  

Measured memory_bytes: 15012
#include <stdio.h>

int main(void){
	int a,b,r;
	scanf("%d %d",&a,&b);
	
	while(1){
		r = a%b;
		a = b;
		b = r;
		if(r==0)break;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 592
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int m;
		int money, year, n;
		m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			money = sc.nextInt();
			year = sc.nextInt();
			n = sc.nextInt();
			int max = 0;
			for (int j = 0; j < n; j++) {
				int ans = money;
				int a = sc.nextInt();
				double rate = sc.nextDouble();
				int fee = sc.nextInt();
				if (a == 0) {
					int pool = 0;
					for (int k = 0; k < year; k++) {
						pool += (int)Math.floor(ans*rate);
						ans -= fee;
					}
					ans += pool;
				} else {
					for (int k = 0; k < year; k++) {
						ans = ans + (int)Math.floor(ans*rate) -fee;
					}
				}
				max = Math.max(max, ans);
			}
			out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 42808
#include<string.h>
#include<iostream>
int main()
{
	int n;
	std::cin >> n;
	char**taro = new char*[n];
	for(int i = 0; i < n; i++)
	{
		taro[i] = new char[101];
	}
	char**hanako = new char*[n];
	for(int i = 0; i < n; i++)
	{
		hanako[i] = new char[101];
	}
	for(int i = 0; i < n; i++)
	{
		std::cin >> taro[i] >> hanako[i];
	}
	int p_t = 0, p_h = 0;
	for(int i = 0; i < n; i++)
	{
		const int result = strcmp(taro[i], hanako[i]);
		result > 0 ? p_t += 3 : result < 0 ? p_h += 3 : (p_t++, p_h++);
	}
	std::cout << p_t << ' ' << p_h << std::endl;
	return 0;
}


Measured memory_bytes: 3232
# CODE FESTIVAL 2016 予選 B: B – Qualification simulator
N, A, B = [int(s) for s in input().split()]
S = input()

domestics = 0
abroads = 0

for s in S:
    if s == 'a':
        if domestics + abroads < A + B:
            print('Yes')
            domestics += 1
        else:
            print('No')
    elif s == 'b':
        if domestics + abroads < A + B and abroads < B:
            print('Yes')
            abroads += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
#include <stdio.h>
int main(void)
{
	int n, m;
	int i;
	char change[1000][2];
	char c;
	
	while (scanf("%d", &n), n){
		for (i = 0; i < n; i++){
			scanf(" %c %c ", &change[i][0], &change[i][1]);
		}
		
		scanf("%d", &m);
		while (m--){
			scanf(" %c", &c);
			
			for (i = 0; i < n; i++){
				if (c == change[i][0]){
					c = change[i][1];
					break;
				}
			}
			printf("%c", c);
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int h, w, k;
int dp[110][10];
int mu[9] = { 1,1,2,3,5,8,13,21,34 };

signed main() {
	cin >> h >> w >> k;
	dp[0][0] = 1;
	for (int i = 1; i <= h; i++) {
		rep(j, w) {
			dp[i][j] = dp[i - 1][j] * mu[j] * mu[(w - 1) - j] % mod;
			if (j != 0)dp[i][j] += dp[i - 1][j - 1] * mu[j - 1] * mu[(w - 1) - j] % mod;
			if (j != w - 1)dp[i][j] += dp[i - 1][j + 1] * mu[j] * mu[(w - 1) - (j + 1)] % mod;
			dp[i][j] %= mod;
		}
	}
	cout << dp[h][k - 1] << endl;
}



Measured memory_bytes: 256
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

int main()
{
    _io
    string s; cin >> s;
    if(s == "SUN")
        cout << 7;
    if(s == "MON")
        cout << 6;
    if(s == "TUE")
        cout << 5;
    if(s == "WED")
        cout << 4;
    if(s == "THU")
        cout << 3;
    if(s == "FRI")
        cout << 2;
    if(s == "SAT")
        cout << 1;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
 string o,e;
 cin>>o>>e;
  if(o.size()-e.size()==0){
   for(int i=0;i<o.size();i++){
   cout<<o[i]<<e[i];
   }
  }
  else{
    for(int i=0;i<e.size();i++){
      cout<<o[i]<<e[i];
    }
    cout<<o[o.size()-1]<<endl;
  }
}

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

using namespace std;
const int maxN = 1e6 + 100;
const int INF = 1e9;
const int MOD = 1e9 + 7;

void rwFile() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

struct List{
    int p;
    List *left, *right;
    List(int x){
        p = 0;
        left = NULL;
        right = NULL;
    };
    //Node (int p_, int left_, int right_) : p(p_), left(left_), right(right_){};
};

typedef List *Node;

void Inorder(Node head){
    if (head == NULL) return;
    Inorder(head->left);
    cout << " " << head->p;
    Inorder(head->right);
}

void Preorder(Node head){
    if (head == NULL) return;
    cout << " " << head->p;
    Preorder(head->left);
    Preorder(head->right);

}

void Print(Node head){
    Inorder(head);
    cout << '\n';
    Preorder(head);
    cout << '\n';
}



Node Cre(int x){
    Node temp;
    temp = new List(0);
    temp->p = x;
    return temp;
}

Node push(Node head, int x){
    if (head == NULL) {
        head = Cre(x);
        return head;
    }

    Node t = head, last = NULL;
    while (t != NULL){
        last = t;
        if (x < t->p) t = t->left;
        else t = t->right;
    }
    Node temp = Cre(x);
    if (x < last->p)
        last->left = temp;
    else
        last->right = temp;
    return head;
}

void solve() {
    int n;
    cin >> n;
    Node head = NULL;
    //for(int i = 0; i < 1e6; i++) T[i].p = T[i].left = T[i].right = -1;
    for(int i = 0; i < n; i++){
        string s;
        int x;
        cin >> s;
        if (s[0] == 'i') {
            cin >> x;
            head = push(head, x);
        }
        else Print(head);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
   // rwFile();
    solve();
}



Measured memory_bytes: 18860
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128

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

signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int h, w;
  cin >> h >> w;
  string s;
  memset(dp, 0x3f, sizeof(dp));
  priority_queue<pii, std::vector<pii>, greater<pii> > pq;
  for(int i = 0; i < h; ++i) {
    cin >> s;
    for(int j = 0; j < w; ++j) {
      if(s[j] == '#') {
        dp[i][j] = 0;
        pq.push(pii(0, i * w + j));
      }
    }
  }
  while(!pq.empty()) {
    auto cur = pq.top(); pq.pop();
    int x = cur.se / w, y =  cur.se % w;
    if(dp[x][y] < cur.fi) continue;
    // cout << x << ' ' << y << ' ' << cur.fi << endl;
    for(int i = 0; i < 4; ++i) {
      int tx = x + dx[i], ty = y + dy[i];
      if(0 <= tx && tx < h && 0 <= ty && ty < w) {
        if(dp[tx][ty] > cur.fi + 1) {
          dp[tx][ty] = cur.fi + 1;
          pq.push(pii(cur.fi + 1, tx * w + ty));
        }
      }
    }
  }
  int res = 0;
  for(int i = 0; i < h; ++i) {
    res = max(res, *max_element(dp[i], dp[i] + w));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 14572
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
typedef long long int lli;
const int MaxN=200060;
#define fst first
#define snd second
#define mp make_pair
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}	
	lli teleport[MaxN];
	lli N,K,res;
	bool vis[MaxN];
	lli dfs(){
		lli i,j,p,q,v,e,tam,llevo=0;
		e=1;		
		vector <lli> ciclo;
		while(true){
			if(vis[e]!=0){
				v=e;
				break;
			}
			if(llevo==K){
				return e;
			}
			llevo+=1;
			vis[e]=1;
			e=teleport[e];
		}
		//cout<<K<<"\n";
		//llevo-=1;
		K-=llevo;
		//cout<<llevo<<" "<<K<<"\n";
		llevo=0;
		for(i=0;i<=N+5;i++)vis[i]=0;
		while(true){
			if(vis[v]==1)break;
			//cout<<v<<" "<<vis[v]<<"\n";
			vis[v]=1;
			ciclo.push_back(v);	
			v=teleport[v];
			llevo+=1;
		}
		tam=ciclo.size();
		//cout<<llevo<<" "<<tam<<" "<<K<<" ";;
		K=K%tam;
		K+=tam;
		K=K%tam;
		return ciclo[(K)%tam];
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,p;
	cin>>N>>K;
	for(i=1;i<=N;i++){
		cin>>teleport[i];
	}
	cout<<dfs();
}	
		

Measured memory_bytes: 6604
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    cout << (x-1)*(y-1) << endl;
}

Measured memory_bytes: 256
package main

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

func solve(sc *scanner, wr *bufio.Writer) {
	cs1 := sc.getString()
	cs2 := sc.getString()

	ans := "YES"
	if cs1[0] != cs2[2] || cs1[1] != cs2[1] || cs1[2] != cs2[0] {
		ans = "NO"
	}
	fmt.Fprintln(wr, ans)
}

func main() {
	sc := newScanner()
	wr := bufio.NewWriter(os.Stdout)
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)

	solve(sc, wr)
	wr.Flush()
}

// input ------------------------
type scanner struct {
	*bufio.Scanner
}

func newScanner() *scanner {
	sc := bufio.NewScanner(os.Stdin)
	return &scanner{sc}
}
func (sc *scanner) getInt() int {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getInt2() (int, int) {
	return sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt3() (int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInt4() (int, int, int, int) {
	return sc.getInt(), sc.getInt(), sc.getInt(), sc.getInt()
}
func (sc *scanner) getInts(n int) []int {
	ret := make([]int, n)
	for i := range ret {
		ret[i] = sc.getInt()
	}
	return ret
}
func (sc *scanner) getString() string {
	sc.Scan()
	return sc.Text()
}
func (sc *scanner) getRunes() []rune {
	return []rune(sc.getString())
}
func (sc *scanner) getFloat() float64 {
	sc.Scan()
	ret, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}
func (sc *scanner) getFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := range ret {
		ret[i] = sc.getFloat()
	}
	return ret
}

// math ----------------------------
func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

func pow(a, b int) int {
	ret := 1
	for b > 0 {
		if b&1 > 0 {
			ret = ret * a
		}
		a = a * a
		b >>= 1
	}
	return ret
}


Measured memory_bytes: 1776
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] pres = sc.next().toCharArray();
		int n = pres.length;
		int[] s = new int[n];
		for(int i = 0; i < n; i++) {
			s[i] = Integer.parseInt(String.valueOf(pres[i]));
		}
		
		/*Stack<Task> stack = new Stack<Task>();
		stack.push(new Task(0, 0, 0));
		long ans = 0;
		while(!stack.isEmpty()) {
			Task t = stack.pop();
			int i = t.i;
			long x = t.x;
			long y = t.y * 10 + s[i];
			
			if(i == n - 1) {
				ans += x + y;
				continue;
			}
			stack.push(new Task(x * 10 + y, 0, i + 1));
			stack.push(new Task(x, y, i + 1));
		}
		
		System.out.println(ans);*/
		/*System.out.println(calc(s, n, 0, s[0], 1));*/
		int a = 0;
		System.out.println(calc2(s, n, a, 0));
	}
	
	/*private static long calc(int[] s, int n, long x, long y, int i) {
		if(i == n) {
			return x + y;
		}
		return calc(s, n, x + y, s[i], i + 1) + calc(s, n, x, y * 10 + s[i], i + 1);
	}*/
	
	private static long calc2(int[] s, int n, int a, int i) {
		if(i == n - 1) {
			long tmp = s[0];
			long ans = 0;
			for(int j = 0; j < n - 1; j++) {
				if(a % 2 == 1) {
					tmp = tmp * 10 + s[j + 1];
				}else {
					ans += tmp;
					tmp = s[j + 1];
				}
				a >>= 1;
			}
			return ans + tmp;
		}
		a <<= 1;
		return calc2(s, n, a, i + 1) + calc2(s, n, a + 1, i + 1);
	}
	
	//xとyの間に"+"が入っていて、次に入る数はyにつなげる場合と新たに"+"をつけてyに入れる2通りがある
	/*static class Task {
		long x;
		long y;
		int i;
		
		Task(long x, long y, int i) {
			this.x = x;
			this.y = y;
			this.i = i;
		}
	}*/
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,i;
  cin>>a>>b;
  double res=0;
  for(i=1;i<=a;i++)
  {
    double t=1.0/a;
    int n=i;
    while(n<b)
    {
      n*=2;
      t/=2;
    }
    res+=t;
  }
  printf("%.15lf",res);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void output();
char mp[109][109];
int n=100,a,b;
bool f=0;
int dx[]={0,1,1,1,0,-1,-1,-1};
int dy[]={-1,-1,0,1,1,1,0,-1};

int main(){
  cin>>a>>b;
  if(a>b){
    f=true;
    swap(a,b);
  }

  int cnt=0,s=-1;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i%2==0){
	mp[i][j]='#';
      }
      else{
	if(j%2==0||cnt>=a-1){
	  mp[i][j]='#';
	  if(s==-1&&cnt>=a-1)s=i+2;
	}
	else{
	  mp[i][j]='.';
	  cnt++;
	}
      }
    }
  }
  for(int i=s;i<n;i++){
    for(int j=0;j<n;j++){
      mp[i][j]='.';
    }
  }

  int c=1;
  for(int i=s+1;i<n;i++){
    for(int j=1;j<n-1;j++){
      if(c==b){
	output();
	return(0);
      }
      bool w=true;
      for(int k=0;k<8;k++){
	int nx=j+dx[k];
	int ny=i+dy[k];
	if(mp[ny][nx]=='#')w=false;
      }
      if(w==true){
	mp[i][j]='#';
	c++;
      }
    }
  }

  return(0);
}

void output(){
  cout<<n<<' '<<n<<endl;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(f==true){
	if(mp[i][j]=='.'){
	  cout<<'#';
	}
	else{
	  cout<<'.';
	}
      }
      else{
	cout<<mp[i][j];
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  rep(i,n) vec[i]--;

  int now=0;
  vector<bool> visited(n,false);
  visited[0]=true;
  int cnt=0;
  while( now!=1 ){
    now = vec[now];
    if(visited[now]){cout<<-1<<endl;return 0;}
    visited[now]=true;
    cnt++;
  }
  cout << cnt<<endl;

  return 0;
}


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

int N;
int A[210];

int main() {
    cin >> N;
    for(int i=0; i<N; ++i) cin >> A[i];
    
    bool flag = true;
    int c = 0;
    while(flag) {
        for(int i=0; i<N; ++i) {
            if(A[i]%2!=0) flag=false;
            else A[i] = A[i]/2;
        }
        ++c;
    }
    cout << c-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

int main(){
    int n;
    int ans = 0;
    int now = 0;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
        v[i]--;
    }

    int q = 100010;
    while(q--){
        if(now == 1){
            break;
        }else{
            now = v[now];
        }
        ans++;
    }

    if(ans >= 100001){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,x;
  cin>>N>>x;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int sum=0,j=0;
  for(j;j<N;j++){
    sum+=a[j];
    if(sum>x)
      break;
  }
  if(sum>=x)
  cout<<j<<endl;
  else
    cout<<j-1<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		long ans = 0;
		for(int i = 0 ; i < n ; i++) {
			if(i == n - 1 || t <= a[i + 1] - a[i]) {
				ans += t;
			} else {
				ans += a[i + 1] - a[i];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<int> s(N + 1, 0);
  for (int i = 0; i < N; i++){
    s[i + 1] = s[i] + a[i];
  }
  int idx = 0;
  vector<int> c(H * W);
  for (int i = 0; i < H * W; i++){
    if (i >= s[idx + 1]){
      idx++;
    }
    c[i] = idx + 1;
  }
  vector<vector<int>> c2(H, vector<int>(W));
  int cnt = 0;
  for (int i = 0; i < H; i++){
    if (i % 2 == 0){
      for (int j = 0; j < W; j++){
        c2[i][j] = c[cnt];
        cnt++;
      }
    } else {
      for (int j = W - 1; j >= 0; j--){
        c2[i][j] = c[cnt];
        cnt++;
      }
    }
  }
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << c2[i][j];
      if (j < W - 1){
        cout << ' ';
      }
    }
    cout << endl;
  }
}

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

from collections import defaultdict
import itertools
def soinsu(n):
    arr = []
    now = n
    for i in range(2, int(n**0.5)+1):
        if now%i==0:
            cnt=0
            while now%i==0:
                cnt+=1
                now //= i
            arr.append([i, cnt])
    if now!=1:
        arr.append([now, 1])
#     if arr==[]:
#         arr.append([n, 1])
    return arr

d = defaultdict(int)
for i in range(1,N+1):
    bunkai =soinsu(i)
    for b in bunkai:
        d[b[0]]+=b[1]

prime_list=[k for k in d.keys() if d[k]>=2]

N2 = sum(d[k]>=2 for k in d.keys())
N4 = sum(d[k]>=4 for k in d.keys())

N14 = sum(d[k]>=14 for k in d.keys())
N24 = sum(d[k]>=24 for k in d.keys())
N74 = sum(d[k]>=74 for k in d.keys())

pattern2_4_4 = N4*(N4-1)*(N2-2)//2
pattern2_24 = N24*(N2-1)
pattern4_14 = N14*(N4-1)
pattern74 = N74

print(pattern2_4_4 + pattern2_24 + pattern4_14+pattern74)

Measured memory_bytes: 65792
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}





Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint a, b;
    cin >> a >> b;
    string res;
    if (a < b) {
        res = string(b, a + '0');
    } else {
        res = string(a, b + '0');
    }
    cout << res << "\n";
}

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

// O(|s|)
bool isPalindrome(string s) {
    lint n = s.length();

    bool res = true;
    for(lint i=0; i<n; i++) {
        res &= s[i] == s[n-1-i];
    }
    return res;
}

void leave(string message) {
    cout << message << endl;
    exit(0);
}

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

    lint n = s.length();

    string s_without_x;
    for(lint i=0; i<n; i++) {
        if(s[i] == 'x')  continue;
        s_without_x += s[i];
    }

    // xをなくした文字が回文でないなら不可能
    if(not isPalindrome(s_without_x))  leave("-1");
    lint m = s_without_x.length();
    if(m == 0)  leave("0");

    lint ans = 0;
    lint left = 0;
    lint right = n-1;
    for(lint i=0; i<=(m-1)/2; i++) {
        lint cnt = 0;
        while(s[left] == 'x')  left++, cnt++;
        while(s[right] == 'x')  right--, cnt--;
        ans += abs(cnt);
        left++, right--;
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pair<ll, ll>> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

ll N, T;
vpll AB;
vll dp;
vll dmax;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N,T);
  AB.resize(N);
  REP(i,N) IN(AB[i].first, AB[i].second);
  sort(AB.begin(), AB.end());
  dp.resize(T, 0);
  dmax.resize(N, 0);
  dmax[N-1] = 0;
  REP(i,N-1){
    dmax[N-2-i] = max(dmax[N-1-i], AB[N-1-i].second);
  }

  vll dp_copy;
  ll ans = 0;
  REP(i,N){
    dp_copy = dp;
    FOR(t,AB[i].first,T){
      dp[t] = max(dp[t], dp_copy[t-AB[i].first]+AB[i].second);
    }
    ans = max(ans, dp[T-1]+dmax[i]);
  }

  OUT(ans);


  return 0;
}

Measured memory_bytes: 384
n=int(input())

e=[0]*(n+1)
def soinsu(n,e):
    for i in range(2,n+1):
        cur=i
        for j in range(2,i+1):
            while cur%j==0:
                e[j]+=1
                cur//=j
soinsu(n,e)
ans=1
for i in range(n+1):
    ans*=(e[i]+1)
    ans%=(10**9+7)
print(ans)


Measured memory_bytes: 39408
N, M = map(int, input().split())
L, R = [], []
for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)

m = max(L)
M = min(R)
if m <= M: print(M-m+1)
else: print(0)

Measured memory_bytes: 16764
#include <iostream>

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

using namespace std;



int main() {
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) {
        cout << -1 << endl;
        return 0;
    } else {
        cout << a*b << endl;
    }

    return 0;
}


Measured memory_bytes: 3580
n = int(input())
d = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  if d[i] == 'AC':
    ac = ac + 1
  elif d[i] == 'WA':
    wa = wa +1
  elif d[i] == 'TLE':
    tle = tle +1
  else:
    re = re +1

print("AC x ",ac)
print("WA x ",wa)
print("TLE x ",tle)
print("RE x ",re)

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

using namespace std;
using namespace __gnu_pbds;

/*
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define ll long long
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz size()
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ld long double
#define sqr(x) (x)*(x)

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int> > vvi;
typedef pair < int, pair < int, int> > piii;
typedef vector < pair < int, int > > vpii;
typedef vector < ll >  vll;

bool valid(int x, int y, int n, int m){
    return x > 0 && x <= n && y > 0 && y <= m;
}

ll gcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return gcd(b , a % b);
}

ll nok(ll a, ll b){
    return (a / gcd(a, b) * b);
}

ld dist(ll x, ll y, ll x2, ll y2){
    return sqrt(sqr(x - x2) + sqr(y - y2));
}


void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    ll sum = 0;
    sort(a.begin() + 1, a.begin() + n + 1);
    for(int i = 1; i <= k; i++){
        sum += a[i];
    }
    cout << sum;
}

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





Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int five=5;
    int ans;
    while(cin >> n && n)
    {
        ans = 0;
        five = 5;
        while(n/five)
        {
            ans += n/five;
            five *= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#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 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<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<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int k;
    ll ans=0;
    cin >>k;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans+=__gcd(__gcd(a,b),c);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >>n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  for(int i=n-2; i >=0; i--){
//    cout << a[i] << ' ' << a[i+1] << endl;
    if(a[i] -a[i+1] >1){
      cout << "No" << endl;
      return 0;
    }
    if(a[i]-a[i+1] ==1){
      a[i] -=1;
    }
//    rep(i,n) cout << a[i] << ' ';
//    cout << endl;
  }
  cout << "Yes" << endl;
  return 0;

}

Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int A[1000100];

int main(){
  int n;
  cin>>n;
  
  rep(j,n){
    int x;
    cin>>x;
    set<int> s;
    for(int i=2;i*i<=x;i++){
      while(x%i==0){
        s.insert(i);
        x/=i;
      }
    }
    if(x!=1) s.insert(x);
    
    for(auto y:s){
      A[y]++;
    }
  }
  
  int ma=0;
  for(int i=2;i<=1000000;i++){
    ma=max(ma,A[i]);
  }
  
  if(ma==n) cout<<"not coprime"<<endl;
  else if(ma>1) cout<<"setwise coprime"<<endl;
  else cout<<"pairwise coprime"<<endl;

  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    int sum = 0;
    bool ok = true;
    string ans;

    sort(A.begin(), A.end(), greater<int>());
    rep(i,N) sum += A.at(i);
    rep(i,M) {
        if (A.at(i) < sum / 4.0 / M) {
            ok = false;
            break;
        }
    }
    if (ok == true) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 4000000;
const int mod = 998244353;
int d[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int k;
    cin >> k;
    vector <int> a;
    a.pb(0);
    d[0] = 1;
    for (int i = 1; i <= 10; i++) d[i] = d[i - 1] * 10;
    for (int i = 1; i <= 10; i++){
        vector <int> b;
      //  cout << endl;
        for (auto x: a){
            int len = 0;
            int y = x;
            int c = y % 10;
            while(y){
                c = y % 10;
                y /= 10;
                len++;
            }
            if (len != i - 1 && c > 1) continue;
            if (c == 0){
                if (i != 1) b.pb(d[i - 1]); else
                for (int j = 1; j < 10; j++) b.pb(j);
            } else
            if (len != i - 1){
                if (c != 1) continue;
                b.pb(d[i - 1] + x);
            } else{
                if (c == 1){
                    b.pb(d[i - 1] + x);
                    b.pb(2 * d[i - 1] + x);
                }
                else{
                  //  cout << c * d[i - 1] + x << " " << (c - 1) * d[i - 1] + x << " " << (c + 1) * d[i - 1] + x << endl;
                    b.pb(c * d[i - 1] + x);
                    b.pb((c - 1) * d[i - 1] + x);
                    if (c != 9) b.pb((c + 1) * d[i - 1] + x);
                }
            }
        }
        for (auto x: b) a.pb(x);
        sort(a.begin(), a.end());
    }
    //for (int i = 0; i < 40; i++) cout << a[i] << " ";
    cout << a[k];
}


Measured memory_bytes: 3512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int n;
  cin >> n;
  n = pow(int(sqrt(n)),2);
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split()))
O = [0 for k in range(max(v)+1)]
E = [0 for k in range(max(v)+1)]

for k in range(n):
    if k%2 == 0:
        E[v[k]] += 1
    else:
        O[v[k]] += 1
if E.index(max(E)) != O.index(max(O)):
    print(n-max(E)-max(O))
else:
    E = sorted(E)
    O = sorted(O)
    print(min((n-max(E)-O[-2]),(n-max(O)-E[-2])))

Measured memory_bytes: 14396
#include <iostream>
#include <string>
#include <vector>
#include <cctype>

using namespace std;

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

int main()
{
	int a,b;
	cin >> a >> b;

	cout << (a-1)*(b-1) << endl;

	return 0;
}

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

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		int cnt = 0;
			while(true){
				String[] str = br.readLine().split(" ");
					if(str[0].equals("END_OF_TEXT")){
						break;
					}	
					for(int i = 0;i < str.length; i++){
					if(str[i].equalsIgnoreCase(x)) cnt += 1;	
				}
			}

		    System.out.println(cnt);
	}
}

Measured memory_bytes: 24120
#include<bits/stdc++.h>
    #define add(i,j) (i+j>=1000000007)?(i+=j-1000000007):(i+=j)
    using namespace std;
    int f[3010][3010][2];
    int main()
    {
    	int n,m;scanf("%d%d",&n,&m);
    	for (int i=0;i<=n;i++) f[0][i][0]=1;
    	for (int i=0;i<m;i++)
    	for (int j=0;j<=n;j++)
    	for (int k=0;k<=1;k++)
    	{
    		if (j==0)
    		{
    			add(f[i+1][j+1][1],f[i][j][k]);
    			add(f[i+1][j][1],f[i][j][k]);
    		}
    		else if (j==1)
    		{
    			add(f[i+1][j][1],f[i][j][k]);
    			add(f[i+1][j-1][1],f[i][j][k]);
    			if (j!=n)
    			{
    				add(f[i+1][j][k],f[i][j][k]);
    				add(f[i+1][j+1][k],f[i][j][k]);
    			}
    		}
    		else if (j==n)
    		{
    			add(f[i+1][j][k],f[i][j][k]);
    			add(f[i+1][j-1][k],f[i][j][k]);
    		}
    		else
    		{
    			add(f[i+1][j][k],f[i][j][k]);
    			add(f[i+1][j-1][k],f[i][j][k]);
    			add(f[i+1][j][k],f[i][j][k]);
    			add(f[i+1][j+1][k],f[i][j][k]);
    		}
    	}
    	int sum=0;
    	for (int i=0;i<=n;i++) add(sum,f[m][i][1]);
    	cout<<sum<<endl;
    }

Measured memory_bytes: 70784