akhauriyash/Code-Regression huggingface dataset:
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (n, a, b): (usize, usize, usize);
    input!(n, a, b);
    println!("{}", std::cmp::min(n * a, b));
}


Measured memory_bytes: 4352
import java.util.*;
     
    public class Main {
    	public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
            int num = scanner.nextInt();	
    	String s = String.valueOf(num);
    if(isPalindrome(s)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
           }
    	}
     
    public static boolean isPalindrome(String sentence) {
            int minIdx = 0;
            int maxIdx = sentence.length() - 1;
     
            while(minIdx < maxIdx) {
                if(sentence.charAt(minIdx++) != sentence.charAt(maxIdx--)) {
                    return false;
                }
            }
            return true;
        }
    }

Measured memory_bytes: 22612
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int c=0;
		ArrayList<Integer> a=new ArrayList<Integer>();
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i)=='R')
				c++;
			else
			{
				a.add(c);
				c=0;
			}
		}
		a.add(c);
	                  System.out.println(Collections.max(a));

		
	}
}

Measured memory_bytes: 35576
s = input()
if len(s) < 26:
  for i in range(97, 124):
    if chr(i) not in s:
      break
  print(s + chr(i))
else:
  prep = [s[-1]]
  for i in s[-2::-1]:
    if i > prep[-1]:
      prep.append(i)
    else:
      break
  if len(prep) == 26:
    print(-1)
  else:
    print(s[:-len(prep)-1] + min(i for i in prep if i > s[-len(prep)-1]))

  

Measured memory_bytes: 9036
n = int(input())
a_list = list(map(int, input().split()))

s = 0
for a in a_list:
  s += a
  
x1 = s - (2 * sum(a_list[1::2]))

result = []
# result.append(x1)
print(x1)
xi = x1
for i in range(n-1):
    hoge = (a_list[i] * 2) - xi
    # result.append(hoge)
    print(hoge)
    xi = hoge
# print(result)


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

a = [int(x) for x in input().split()]

ma = max(a)
mi = min(a)

if(ma*mi < 0):
    print(2*n-1)
    if ma > -1*mi:
        for i in range(n):
            print(a.index(ma)+1, i+1)
        for i in range(n-1):
            print(i+1, i+2)
    else:
        for i in range(n):
            print(a.index(mi)+1, i+1)
        for i in range(n-1):
            print(n-i, n-i-1)
else:
    print(n-1)
    if(ma > 0):
        for i in range(n-1):
            print(i+1, i+2)
    else:
        for i in range(n-1):
            print(n-i, n-i-1)


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

main(){
    int N;
    cin >> N;
    vector<int> cardset(N);
    for(int i=0;i<N;i++){
        cin >> cardset.at(i);
    }
    sort(cardset.begin(),cardset.end());
    reverse(cardset.begin(),cardset.end());

    int a = 0;
    for(int i=0;i<N/2;i++){
        a += cardset.at(2*i)-cardset.at(2*i+1);
    }
    if (N%2==1){
        a += cardset.at(N-1);
    }

    cout << a << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long takahashi;
	long aoki;
	long sum;
} S_DISH;

int cmpAscVal(const void * n1, const void * n2)
{
	if (((S_DISH *)n1)->sum > ((S_DISH *)n2)->sum)
	{
		return -1;
	}
	else if (((S_DISH *)n1)->sum < ((S_DISH *)n2)->sum)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
	scanf("%ld", &n);
	S_DISH dishes[n];
	for (long i = 0; i < n; i++) {
		scanf("%ld %ld", &dishes[i].takahashi, &dishes[i].aoki);
		dishes[i].sum = dishes[i].takahashi + dishes[i].aoki;
	}
	qsort(dishes, n, sizeof(S_DISH), cmpAscVal);
	long answer = 0;
	for (long i = 0; i < n; i++) {
		if (i%2 == 0) {
			answer += dishes[i].takahashi;
		} else {
			answer -= dishes[i].aoki;
		}
	}
	printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 4860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();
		char[][] s = new char[2][];
		s[0] = cin.next().toCharArray();
		s[1] = cin.next().toCharArray();

		long start = now();

		long ans = solve(n, s);
		cout.println(ans);

		trace("elapsed", now() - start);
	}

	private static long solve(int n, char[][] s) {
		// 縦
		// a
		// a
		// または横
		// aa
		// bb
		// のいずれかを横方向に組み合わせてできている
		final long MOD = 1000000007;
		long ans = s[0][0] == s[1][0] ? 3 : 6;
		int start = s[0][0] == s[1][0] ? 1 : 2;
		long[][] m = { { 2, 2 }, { 1, 3 } };
		for (int i = start; i < n; i++) {
			int pre = s[0][i - 1] == s[1][i - 1] ? 0 : 1;
			int cur = s[0][i] == s[1][i] ? 0 : 1;
			ans *= m[pre][cur];
			ans %= MOD;
			i += cur;
		}
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

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

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

}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//AtCoder Beginner Contest 135 - A
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	if (abs(A - B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
		return 0;
	}

	ll ans = abs(A - B) / 2;
	ll result = min(A, B) + ans;

	printf("%lld\n", result);
}


//AtCoder Beginner Contest 126 - B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}
*/

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 384
#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 A1, A2, A3;
  cin >> A1 >> A2 >> A3;

  cout << max({A1, A2, A3}) - min({A1, A2, A3}) << endl;
  return 0;
}

Measured memory_bytes: 3612
package main

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

var (
	N        int
	S        string
	patterns [4]string = [4]string{"SS", "SW", "WS", "WW"}
	sheep    []bool
	strings  []bool
)

func readVariables() {
	// N = nextInt()
	// scanner.Scan()
	// S = nextStr()
	fmt.Scan(&N)
	fmt.Scan(&S)
	sheep = make([]bool, N)
	strings = make([]bool, N)
	for i := 0; i < N; i++ {
		// fmt.Println(string(S[i]), S[i])
		strings[i] = string(S[i]) == "o"
	}
}

func main() {
	readVariables()
	var c int
	// fmt.Println(strings)
	for _, v := range patterns {
		sheep[0] = string(v[0]) == "S"
		sheep[N-1] = string(v[1]) == "S"
		sheep[1] = g(sheep[N-1], sheep[0], strings[0])
		// fmt.Println(sheep[1], g(sheep[N-1], sheep[0], strings[0]), sheep[N-1], sheep[0], strings[0])
		for i := 2; i < N-1; i++ {
			sheep[i] = g(sheep[i-2], sheep[i-1], strings[i-1])
		}
		ok1 := sheep[N-1] == g(sheep[N-3], sheep[N-2], strings[N-2])
		ok2 := sheep[0] == g(sheep[N-2], sheep[N-1], strings[N-1])
		if ok1 && ok2 {
			// fmt.Println(sheep)
			break
		}
		c++
	}
	// fmt.Println(c)
	if c < 4 {
		for _, v := range sheep {
			if v {
				fmt.Print("S")
			} else {
				fmt.Print("W")
			}
		}
		fmt.Println()
	} else {
		fmt.Println(-1)
	}
}

func g(left, center, saysSame bool) bool {
	same := center && saysSame || !center && !saysSame
	if same {
		return left
	} else {
		return !left
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <math.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int NMAX = 200100;

//int A[NMAX];
//int B[NMAX];
//int AA[NMAX];
//int BB[NMAX];
int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    vector<int> AA(N),BB(N);
    REP(i,N){
        int a;
        cin >> a;
        A[i] = a;
    }
    REP(i,N){
        int b;
        cin >> b;
        B[i] = b;
    }

    ll ans = 0;
    ll num;
    for(int k = 0; k < 29; k++){
        num = 0;
        //ull T = pow(2,k);
        ll T = pow(2,k);
        //printf("ull:%lld\tll:%lld\n", T, TT);
        REP(i,N){
            BB[i] = B[i] % (2*T);
            AA[i] = A[i] % (2*T);
        }
        sort(BB.begin(), BB.end());
        REP(i,N){
            int a = AA[i];
            num += (lower_bound(BB.begin(), BB.end(), 2*T-a) - lower_bound(BB.begin(), BB.end(), T-a));
            num += BB.end() - lower_bound(BB.begin(), BB.end(), 3*T-a);
            ll x = 0;
            //x += (lower_bound(BB.begin(), BB.end(), 2*TT-a) - lower_bound(BB.begin(), BB.end(), TT-a));
            //x += BB.end() - lower_bound(BB.begin(), BB.end(), 3*TT-a);
            //printf("ull:%lld\tll:%lld\n", num, x);
            //printf("T-a:%lld\tTT-a:%lld\n", T-a, TT-a);
            //printf("ull:%d\tll:%d\n",lower_bound(BB.begin(), BB.end(), (int)(T-a)), lower_bound(BB.begin(), BB.end(), (int)(TT-a)));
        }
        if(num % 2 != 0) ans += T;
    }
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 3328
#include <stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);
	if (n == 1) printf("Hello World");
	else if (n == 2) {
		int a, b;
		scanf("%d", &a);
		scanf("%d", &b);
		printf("%d", a + b);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin>>n;
    k=n%10;
    if(k==2||k==4||k==5||k==7||k==9)cout << "hon" << endl;
    if(k==0||k==1||k==6||k==8)cout << "pon" << endl;
    if(k==3)cout << "bon" << endl;
    return 0;
}


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

int main()
{
    int n,a;
    int count,check;
    vector<int> A;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        A.push_back(a);       
    }
    for(int i=0;i<n;i++){
        check = A[i];
        while(check/2!=0){
            if(check%2==0){
                count++;
                check /= 2;
            }else {
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


bool check(int n){
    int cnt = 0;
    for(int i=1;i <= n;++i){
        if(n%i==0){
            ++cnt;
        }
    }
    return cnt == 8;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    for(int i=1; i <= N; i = i+2){
        if(check(i)) ++ans;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll res = 0, n, k;
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		res = (res / (k - 1)) + 1 + res;
	}
	cout << res << endl;
}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            if(X >= 30)
            {
                return "Yes";
            }
            return "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27520
#include <stdio.h>

int main(void){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?'){
            break;
        }else if(op == '+'){
            printf("%d\n",a+b);
        }else if(op == '-'){
            printf("%d\n",a-b);
        }else if(op == '*'){
            printf("%d\n",a*b);
        }else if(op == '/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}


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

int calc(vector<int>& v, bool plus){
  // std::cout << "calc:" << std::endl;
  // for (int i = 0; i < v.size(); i++) {
  //   std::cout << v[i] << std::endl;
  // }
  int res = (plus != true);
  for (int i = 0; i < v.size(); i++) {
    if(plus)res += v[i];
    else res *= v[i];
  }
  // std::cout << "res:" << res << std::endl;
  // std::cout << std::endl;
  return res;
}

int dfs(bool plus, int &s, int k = 0){
  vector<int> res;
  //std::cout << "k:" << k << " plus:" << plus<< std::endl;
  for (;s < vs.size(); s++) {
    //std::cout << vs[s] << std::endl;
    if(vs[s][k] != '.'){
      s--;
      return calc(res, plus);
    }else if(vs[s][k + 1] == '+' or vs[s][k + 1] == '*'){
      int tmp = dfs(vs[s - 1][k + 1] == '+', ++s, k + 1);
      res.emplace_back(tmp);
    }else{
      res.emplace_back(atoi(vs[s].substr(k + 1).c_str()));
    }
  }
  // for (int i = 0; i < res.size(); i++) {
  //   std::cout << res[i] << std::endl;
  // }
  return calc(res, plus);
}

int main(){
  int n;
  while(std::cin >> n, n){
    vs.resize(n);
    int maxi = 0;
    for (int i = 0; i < n; i++) {
      std::cin >> vs[i];
      maxi = max(maxi, (int)vs[i].length());
    }
    for (int i = 0; i < n; i++) {
      if(vs[i].length() < maxi)
        vs[i] += string(maxi - vs[i].length(), 'o');
    }
    if(n == 1){
      std::cout << vs[0] << std::endl;
    }else{
      int s = 0;
      std::cout << dfs(vs[s - 1][0] == '+', ++s) << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int a,b,k;
  cin>>a>>b>>k;
  vi A;
  int m=min(a,b);
  rrep(i,m){
    if(a%i==0&&b%i==0){
      A.pb(i);
    }
  }
  cout<<A[A.size()-k]<<endl;
}


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

int main(){
	int A,B;
	cin >> A >> B;
	int K=0;
	int flag=0;
	while(abs(A-K)!=abs(B-K)){
		K++;
		if(K>=B and K>=A){
			break;
		}
	}
	if(K>=A and K>=B){
		cout << "IMPOSSIBLE";
	}
	else{
		cout << K;
	}
	return 0;
} 

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

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A), greater<int>());
    ll ans=0;
    FOR(i, 1, N){
        ans += A[i/2];
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 4748
#include <iostream>

using namespace std;

int main(void){

    int n,m,l;
    int foods[30] = {0};
    int tmp;

    cin >> n >> m;

    for(int i = 0; i < n; i++){
        cin >> l;
        for(int j = 0; j < l; j++){
            cin >> tmp;
            foods[tmp - 1]++;
        }
    }

    int count = 0;

    for(int i = 0; i < m; i++){
        if(foods[i] == n){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,A,max = 0, min =1000;
    cin >> N;
    for(int i=1; i <= N; i++){
        cin >> A;
        if(A > max){
            max = A;
        }if(A < min){
            min = A;
        }
    }
    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	cout<<180*(n-2)<<endl;











	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
class UnionFind
{
public:
  int par[100005];
  int depth[100005];
  int nGroup[100005];
 
  UnionFind(int n) {
    init(n);
  }
 
  void init(int n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }
 
  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
 
  bool same(int x, int y) {
    return root(x) == root(y);
  }
 
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return;
 
    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
} 
int main() {
ll n; cin>>n;
if(400<=n&&n<600) cout << "8" << endl;
if(600<=n&&n<800) cout << "7" << endl;
if(800<=n&&n<1000) cout << "6" << endl;
if(1000<=n&&n<1200) cout << "5" << endl;
if(1200<=n&&n<1400) cout << "4" << endl;
if(1400<=n&&n<1600) cout << "3" << endl;
if(1600<=n&&n<1800) cout << "2" << endl;
if(1800<=n&&n<2000) cout << "1" << endl;}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
    long long H, W, x, y; std::cin >> H >> W >> x >> y;
    printf("%.10f ", H*W / 2.);
    if (2 * x == H && 2 * y == W) {
        printf("1\n");
    }
    else {
        printf("0\n");
    }
    return 0;
}


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

bool flag[110000];
int a[110000];
int n;
int res = 0;

int main(){
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    flag[i] = false; //訪れたか
  }
  int pos = 1;
  while(true){
    if(pos == 2){
      break;
    }
    if(flag[pos]){
      res = -1;
      break;
    }
    flag[pos] = true;
    pos = a[pos];
    res++;
  }
  cout << res << endl;
}

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

int main () {
  int N, K;
  cin >> N >> K;
  cout << (N%K == 0 ? 0 : 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,A,B;

    scanf("%d %d %d", &N,&A,&B);

    int x = N*A;
    int y = B;

    if(x>=y) {
        printf("%d\n",y);
    }else{
        printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  map<string ,int> m;
  m.insert(pair<string,int>("SUN",7));
  m.insert(pair<string,int>("MON",6));
  m.insert(pair<string,int>("TUE",5));
  m.insert(pair<string,int>("WED",4));
  m.insert(pair<string,int>("THU",3));
  m.insert(pair<string,int>("FRI",2));
  m.insert(pair<string,int>("SAT",1));
  
  cout<<m[s];
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
// ^^^ Template ^^^ //
 
int main() {
	in(ll, N, A, B);
	out(min(A, B), max(A + B - N, 0ll));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MOD = (int) 1e9 + 7;


int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string str;
    cin >> n >> str;

    if(str[0] == 'W' || str[2 * n - 1] == 'W') {
        cout << 0;
        return 0;
    }

    vector <bool> dp(2 * n);
    for(i = 0; i < 2 * n - 1; i++) {
        if(str[i] != str[i + 1]) dp[i + 1] = dp[i];
        else dp[i + 1] = dp[i] ^ 1;
    }
    int ans = 1, cur = 0;
    for(i = 1; i <= n; i++) {
        ans = (1LL * ans * i) % MOD;
    }
    for(i = 0; i < 2 * n; i++) {
        if(dp[i] == 1) {
            ans = (1LL * ans * cur) % MOD;
            cur--;
        }
        else {
            cur++;
        }
    }
    if(cur != 0) {
        ans = 0;
    }
    cout << ans;

    return 0;
}




Measured memory_bytes: 720
import fractions


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


def div_count_by_2(x):
    count = 0
    while x % 2 == 0:
        count += 1
        x //= 2

    return count


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

num = A[0]
count = div_count_by_2(num)
for a in A:
    if count == div_count_by_2(a):
        continue
    else:
        print(0)
        exit()

x = A[0]//2
for a in A:
    x = lcm(x, a//2)

ans = m//x - m//(2*x)
print(ans)

Measured memory_bytes: 16540
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+4;
int a[N];
int dp[N];

void solve(int i,int n){
    if(i<=n){
        if(i==0)
            dp[0]=0;
        else if(i==1)
        dp[1]=abs(a[1]-a[0]);
        else{
            int w1=dp[i-2]+abs(a[i-2]-a[i]);
            int w2=dp[i-1]+abs(a[i]-a[i-1]);
            dp[i]=min(w1,w2);
        }
        solve(i+1,n);
    }
}

int main(){
  int n;
  cin>>n;
  memset(dp,-1,n);
  for(int i=0;i<n;i++) cin>>a[i];
  solve(0,n);
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

bool primenum(int x);

int main()
{
	int n;
	int i;
	int num[10000];
	int ans = 0;
	
	cin >> n;
	
	for (i = 0; i < n; i++){
		cin >> num[i];
	}
	
	for (i = 0; i < n; i++){
		if (primenum(num[i]) == true)ans++;
	}
	
	cout << ans << "\n";
}

bool primenum(int x)
{
	int j = 3;
	
	if (x == 2) return (true);
	if (x % 2 == 0 || x < 2) return (false);
	
	while (j * j <= x){
		if (x % j == 0){
			return (false);
		}
		j += 2;
	}
	
	return (true);
}



Measured memory_bytes: 3120
n, m, Q = map(int, input().split())
List=[[0]*n for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    List[n-l][r-1]+=1
for i in range(n):
    tmp=0
    for j in range(n):
        tmp+=List[i][j]
        List[i][j]=tmp
for i in range(n):
    tmp=0
    for j in range(n):
        tmp+=List[j][i]
        List[j][i]=tmp
pq=[list(map(int, input().split())) for i in range(Q)]
for pqi in pq:
    print(List[n-pqi[0]][pqi[1]-1])

Measured memory_bytes: 30780
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long ans = modPow(10, n) - modPow(9, n) - modPow(9, n) + modPow(8, n);
        ans %= MOD;
        System.out.println((ans + MOD) % MOD);
    }

    // 繰り返し２乗法
    private static int modPow(int n, int p) {
        long res = 1;
        long a = n;
        for (a %= MOD; p > 0; a = a * a % MOD, p >>= 1) {
            if ((p & 1) > 0) {
                res = res * a % MOD;
            }
        }
        return (int) res;
    }
}

Measured memory_bytes: 35460
solve :: Int -> Int -> Int
solve a b
 | ((mod a b) == 0) = div a b
 | otherwise = (div a b) + 1

main = do
  h <- read <$> getLine :: IO Int
  w <- read <$> getLine :: IO Int
  n <- read <$> getLine :: IO Int
  print $ solve n (max h w)

Measured memory_bytes: 3884
#include <stdio.h>
#include <string.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)

void run(void) {
	char s[200009];
	(void)scanf("%s", s);
	int l = strlen(s), mod = 0;
	rep(i, l)mod += s[i] - '0';
	printf(mod % 9 ? "No" : "Yes");
}

int main(void) {
	run();
	return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector <int> mountain(n);
    for(int i = 0; i < n; i++){
        cin >> mountain.at(i);
    }
    int count = 1;
    int max_maountain = mountain.at(0);
    for(int i = 1; i < n; i++){
        if(max_maountain <= mountain.at(i)){
            count++;
            max_maountain = mountain.at(i);
        }
    }
    
    cout << count << endl;

}


Measured memory_bytes: 768
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int listCount = scanner.nextInt();
        int[] listSort = new int[listCount];
        for(int i = 0; i < listCount; i++){
            listSort[i] = scanner.nextInt();
        }
        trace(listSort, listCount);
        insertionSort(listSort, listCount);
    }
 
    private static void insertionSort(int[] listSort, int listCount){
        for(int i = 1; i < listCount; i++){
            int v = listSort[i];
            int j = i - 1;
            while((j >= 0) && (listSort[j] > v)){
                listSort[j + 1] = listSort[j];
                j--;
            }
            listSort[j + 1] = v;
            trace(listSort, listCount);
        }
    }
 
    private static void trace(int[] listSort, int listCount){
        int jugeCount = listCount - 1;
        for(int i = 0; i < listCount; i++){
            System.out.print(listSort[i]);
            if(i < jugeCount){
                System.out.print(" ");
            }
        }
        System.out.print("\n");
    }
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B,C,D =MI()
    S=input()
    A-=1
    B-=1
    C-=1
    D-=1
    
    flag=1
    if "##" in S[A:C+1]:
        flag=0
    if "##" in S[B:D+1]:
        flag=0
        
    if C>D:
        if "..." in S[B-1:D+2]:
            pass
        else:
            flag=0
            
    if flag:
        print("Yes")
    else:
        print("No")
        

main()


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, p);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

vector<int> L(200010), R(200010);
vector<vector<int>> X(510, vector<int>(510, 0));
vector<vector<int>> C(510, vector<int>(510, 0));
int main() {
    int N, M, Q; cin >> N >> M >> Q;
    rep(i, M) {
        cin >> L[i] >> R[i];
        X[L[i]][R[i]]++;
    }
    REP(i, 1, N+1) {
        REP(j, 1, N+1) {
            C[i][j] = C[i][j-1] + X[i][j];
        }
    }
    REP(i, 1, Q+1) {
        int p, q; cin >> p >> q;
        int sums = 0;
        REP(j, p, q+1) {
            sums += C[j][q] - C[j][p-1];
        }
        cout << sums << endl;
    }
    return 0;
}

Measured memory_bytes: 4608
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <bitset>
#include <climits>

#define SIZE 200001
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "0";
    }else{
        cout << "1";
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vii vector<vi>

int main() {
	double d;
	cin >> d;
	double ans=sqrt(2)*d;
	for(int i=1; (double)i<d+0.0001; i++)
	{
		double tmp=(double)i;
		tmp*=tmp;
		if(tmp*tmp+1.0>=d*d)
		{
			ans=max(ans, (double)(i+1));
		}
	}
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n) cin>>a[i];
    ll ans = 0;
    rep(i,n-1) {
        if(a[i+1]<a[i]) {
            ans += a[i]-a[i+1];
            a[i+1] += a[i]-a[i+1];
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll x,c=0,b;
    cin>>x;
    ll y=100;
    b=y;
    while(y<x)
    {

        b+=y/100;
        y=b;
        c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
const int S=105;

int len;
long long cnt,tot,at;
char s[S],k[S];

int main() {
	scanf("%s",s+1);
	len=strlen(s+1);
	scanf("%lld",&cnt);
	at=1;
	k[1]='-';
	for(int i=2;i<=len;i++) {
		k[i]=s[i];
		if(s[i]==s[i-1])
			tot++,s[i]='-';
		if(k[i]==k[i-1])
			at++,k[i]='-';
	}
	if(s[1]!=s[len])
		printf("%lld\n",1LL*cnt*tot);
	else {
		if(k[len]=='-')
			printf("%lld\n",cnt/2*tot+cnt/2*at+(cnt%2)*tot);
		else printf("%lld\n",tot+(cnt-1)*at);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
 
int main()
{
int L,i,count;
int M,N;
while(cin>>L,L){
count = 0;
for(i=0;i<12;i++){
cin>>M>>N;
L -= (M-N);
if(L<=0 && !count)count=i+1;
}
if(L<=0)cout<<count<<endl;
else cout<<"NA"<<endl;
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int h,w,i;
	string s[100];
	cin>>h>>w;
	for(i=0;i<h;i++) cin>>s[i];
	for(i=0;i<w+2;i++) cout<<"#";
	cout<<endl;
	for(i=0;i<h;i++) {
	cout<<"#";
	cout<<s[i];
	cout<<"#"<<endl;
	}
	for(i=0;i<w+2;i++) cout<<"#";
	cout<<endl;
}

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

int main()
{
    long long int n, i, sum=0;
    cin >> n;

    for(i=1; i<=n; i++)
    {
        if(i%3==0 && i%5==0) sum=sum+0;
        else if(i%3==0) sum=sum+0;
        else if(i%5==0) sum=sum+0;
        else sum=sum+i;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

int main () {
	cin >> n >> m;
	if (n % 500 <= m) cout << "Yes" << endl; else cout << "No" << endl;
	return 0;
}

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

ll n, px;
ll ans;

int main(){
	scanf("%lld %lld", &n, &px);
	ll a, b;
	a = min(px, n - px); b = max(px, n - px);
	while(a){
		if(b % a != 0){
			ans += (b / a) * 2 * a;
			b = b % a; swap(a, b);
		}else{
			ans += (b / a) * 2 * a;
			ans -= a;
			break;
		}
	}
	printf("%lld\n", ans + n);
	return 0;
}

Measured memory_bytes: 3800
N, M = map(int, input().split())

list=[]
a=1
for i in range(N+2):
    if i==0 or i==N+1:
        list.append(1)
    else:
        list.append(N*i+a)
        a-=2*i

ans=0
for i in range(M,N+2):
    ans+=list[i]

print(ans%1000000007)

Measured memory_bytes: 16916
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<long long> dp(3,0);
  for(int activity=0;activity<N;activity++){
  int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    vector<long long> new_dp;
    new_dp=dp;
    for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    if(j!=i)
      new_dp[j]=max(new_dp[j],dp[i]+(long long)arr[j]);
    }
    }
    dp=new_dp;
  }
  cout<<max(dp[0],max(dp[1],dp[2]));
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  
 string s = "ACL";
 int t; cin >> t;
 while(t--){
     cout << s;
 } 


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    cin.sync_with_stdio(false);
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y < 2019)
    {
        cout << "Heisei" << endl;
        return 0;
    }
    if (y > 2019)
    {
        cout << "TBD" << endl;
        return 0;
    }
    if (m > 4)
    {
        cout << "TBD" << endl;
        return 0;
    }
    if (m < 4)
    {
        cout << "Heisei" << endl;
        return 0;
    }
    if (d <= 30)
        cout << "Heisei" << endl;
    else
    {
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256