akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct lines {
  int h;  //横線の高さ                                                            
  int p, q; //横線に繋がる縦線の番号                                              

  bool operator>(const lines &left) const {
    return h > left.h;
  }
};

int amida(int n, int m, int a, lines* line, int size) {
  for(int i = 0; i < size; i++) {
    if(line[i].p == a)
      a = line[i].q;
    else if(line[i].q == a)
      a = line[i].p;
  }
  return a;
}

int main() {
  int n; //縦線の本数                                                             
  int m; //横線の本数                                                             
  int a; //調べる縦線の番号                                                       
  vector<lines> line;

  while(1) {
    cin >> n >> m >> a;
    if(n == 0 && m == 0 && a == 0) break;

    for(int i = 0; i < m; i++) {
      lines l;
      cin >> l.h >> l.p >> l.q;
      line.push_back(l);
    }

    sort(line.begin(), line.end(), greater<lines>());
    cout << amida(n, m, a, &line.front(), line.size()) << endl;
    line.clear();
  }
  return 0;
}



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

int main(){
  ll N,M;
  cin >> N >> M;
  vector<vector<ll>> S(M,vector<ll>(0));
  for(ll i=0;i<M;i++){
    ll k;
    cin >> k;
    vector<ll> t(k);
    for(ll j=0;j<k;j++){
      cin >> t[j];
    }
    S[i]=t;
  }
  vector<ll> P(M);
  for(ll i=0;i<M;i++){
    cin >> P[i];
  }
  ll ans=0;
  for(ll i=0;i<(1<<N);i++){
    bool TF=true;
    for(ll j=0;j<M;j++){
      ll count =0;
      for(ll m=0;m<S[j].size();m++){
        if(i & (1<<(S[j][m]-1))){
          count++;         
        }
      }
      if((count%2)!=P[j]){
        TF=false;
        break;
      }
    }
    if(TF){
      ans++;
    }
  }
  cout << ans <<  endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

int main()
{
	int N;
	std::cin >> N;
	std::string C;
	std::cin >> C;
	int r = std::count(C.begin(), C.end(), 'R');
	int ans = std::count(C.begin(), C.begin() + r, 'W');
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3700
$n = gets.to_i
$arr = $n.to_s.split("").map &:to_i
$len = $arr.size

count = 0

def count_xy(x, y)
	result = 0

	if $len == 1 then
		if x == y && $arr[0] >= x then
			result = 1
		end
		return result
	end

	#start x, end y
	if x == y then
		result+=1
	end
	
	($len - 1).downto(2){ |i|
		result += 10 ** (i - 2)
	}
	
	if $len > 2 then
		if $arr[0] == x then
			result += $arr[1..-2].join("").to_i + 1
			if $arr[-1] < y then
				result -= 1
			end
		elsif $arr[0] > x then
			result += 10 ** ($len - 2)
		end
	elsif $len == 2 && ($arr[0] > x || ($arr[0] == x && $arr[1] >= y)) then
		result += 1
	end
	
	result 
end

(1..9).each{ |x|
	(1..9).each{ |y|
		count += count_xy(x, y) * count_xy(y, x)
	}
}

puts count


Measured memory_bytes: 3836
package main

/*
   N M C
   B1 B2 B3 ... BM
   Ai1 Ai2 Ai3 ... AiM
   ...
   AN1 AN2 AN3 ... ANM
*/
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	//      "sort"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	firstline := strings.Split(stdin.Text(), " ")
	n, _ := strconv.Atoi(firstline[0])
	m, _ := strconv.Atoi(firstline[1])
	c, _ := strconv.Atoi(firstline[2])
	stdin.Scan()
	bline := strings.Split(stdin.Text(), " ")
	bs := make([]int, m)
	for j, bval := range bline {
		bs[j], _ = strconv.Atoi(bval)
	}
	numofpass := 0
	for i := 0; i <= n-1; i++ {
		stdin.Scan()
		cline := strings.Split(stdin.Text(), " ")
		ci := strtoint(cline)
		if exam(ci, bs, c) {
			numofpass++
		}
	}
	fmt.Println(numofpass)
}

func strtoint(chara []string) []int {
	mark := make([]int, len(chara))
	for idx, val := range chara {
		mark[idx], _ = strconv.Atoi(val)
	}
	return mark
}
func exam(a []int, b []int, c int) bool {
	sum := 0
	for i, _ := range a {
		sum += a[i] * b[i]
	}
	if sum+c > 0 {
		return true
	} else {
		return false
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()
int dp[1005][1005];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int h,w;
   cin>>h>>w;
   char a[h+1][w+1];
   for(int i=1;i<=h;i++)
   {
       for(int j=1;j<=w;j++)
        cin>>a[i][j];
   }
   dp[1][1]=1;
   for(int i=1;i<=h;i++)
   {
       for(int j=1;j<=w;j++)
       {   if(i==1 && j==1)continue;
           if(a[i-1][j]=='#' && a[i][j-1]=='#')
            dp[i][j]=0;
           else if(a[i-1][j]=='#')
            dp[i][j]=(dp[i][j-1])%M;
           else if(a[i][j-1]=='#')
            dp[i][j]=(dp[i-1][j])%M;
           else
            dp[i][j]=(dp[i-1][j] + dp[i][j-1])%M;
       }
   }
   cout<<(dp[h][w])%M<<endl;
}


Measured memory_bytes: 9088
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int a, b;
int main() {
    while (cin >> a >> b) {
        a *= b;
        if (a % 2 == 1) cout << "Odd" << endl;
        else cout << "Even" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda val: val[2])
 
for cx in range(101):
    for cy in range(101):
        check = True
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        for x in xyh[:-1]:
            if x[2] != max(H - abs(x[0] - cx) - abs(x[1] - cy), 0):
                check = False
                break
        if check:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,K,A;
    cin>>N>>K;
    A=1;
    for(int i=0;i<N;i++){
        if(A<K){
            A*=2;
        }
        else{
            A+=K;
        }
    }
cout<<A<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstdio>

using namespace std;

int main(void){
	double sp;
	while(cin >> sp){
		double t=(double)sp/9.8;
		t=pow(t,2);
		t*=4.9;
		int f=0;
		while(1){
			if((f-1)*5>t){
				printf("%d\n",f);
				break;
			}
			f++;
		}
	}
    return 0;
}

Measured memory_bytes: 0
if __name__ == '__main__':
    n = int(input())
    list =[]
    sumN=0
    for i in range(n):
        a = [str(i) for i in input().split()]
        list.append(a)
        sumN += int(a[1])
    x = input()

    for i in list:
        sumN -= int(i[1])
        if x == i[0]:
            break
    print(sumN)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    int A, B, C;
    cin >> A >> B >> C;


    bool b = false;
    for (int i = 1; i <= A * B; i++) {
        int n = A * i;
        if (n % B == C) {
            b = true;
            break;
        }
    }

    cout << (b ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3524
n,*a=map(int,open(0).read().split())
from math import *
l,r=[0]*n,[0]*n
for i in range(1,n):
  l[i]=gcd(l[i-1],a[i-1])
  r[~i]=gcd(r[-i],a[-i])
m=0
for i in range(n):
  m=max(m,gcd(l[i],r[i]))
print(m)

Measured memory_bytes: 20720
#include <stdio.h>
   
int main(){
    int i,n,tmp;
    long min,max,sum;
   
    min=1000000000;
    max=-1000000000;
    sum=0;
   
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<min){
            min=tmp;
        }
        if(tmp>max){
            max=tmp;
        }
        sum+=tmp;
    }
   
    printf("%ld %ld %ld\n",min,max,sum);
   
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

int m[3][3];
string s;

int main(){
	while(cin>>s){
		int res=-1;
		rep(i,9){
			int t;
			if(s[i]=='o') t=0;
			else if(s[i]=='x') t=1;
			else if(s[i]=='s') t=-1;
			m[i/3][i%3]=t;
		}
		rep(i,2){
			bool f=false;
			rep(j,3){
				if(m[j][0]==i&&m[j][1]==i&&m[j][2]==i) f=true;
				if(m[0][j]==i&&m[1][j]==i&&m[2][j]==i) f=true;
			}
			if(m[0][0]==i&&m[1][1]==i&&m[2][2]==i) f=true;
			if(m[2][0]==i&&m[1][1]==i&&m[0][2]==i) f=true;
			if(f){
				res=i;
				break;
			}
		}
		if(res==0) cout<<"o\n";
		else if(res==1) cout<<"x\n";
		else if(res==-1) cout<<"d\n";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>M;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec right(N,0);
    map<ll,ll> mods;
    ++mods[0];
    ll temp = 0;
    reps(i,1,N){
        (temp += a[N-i])%=M;
        ++mods[temp];
        right[i] = temp;
    }
    ll sum = (right[N-1] + a[0])%M;
    ll ans = 0;
    temp = 0;
    rep(i,N){
        ans += mods[(sum - temp + M)%M];
        (temp += a[i])%=M;
        --mods[right[N - 1 - i]];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 3005; 
const int mod = 998244353;
int dp[N][N];
int a[N],n,s;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s;
	up(i,1,n) cin >> a[i];
	dp[0][0] = 1;
	for (int i=1;i<=n;++i){
		dp[i][0] = i+1;
		for (int j=1;j<a[i];++j) dp[i][j] = dp[i-1][j];
		dp[i][a[i]] = i + dp[i-1][a[i]];
		for (int j=a[i]+1;j<=s;++j){
			dp[i][j] = (dp[i-1][j] + dp[i-1][j-a[i]]) % mod;
		}
	}
	long long ans = 0;
	for(int i=1;i<=n;++i) {
		if (a[i] > s) continue;
		ans += 1LL * dp[i-1][s - a[i]] * (n - i + 1);
		// cout << dp[i-1][s - a[i]] * (n - i + 1) << ' ';
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 38820
require 'pp'
n, q = gets.split.map &:to_i
# a = []
# b = []
nodes = Array.new(n, {pa: nil, cos: 0})
(n-1).times do
  aa, bb = gets.split.map(&:to_i)
  # a << aa # 親の数字
  # b << bb # 子(node番号)
  nodes[bb-1] = {
    pa: aa,
    cos: 0
  }
end

# p = []
# x = []
q.times do
  pp, xx = gets.split.map(&:to_i)
  # p << pp # node番号
  # x << xx # cost
  nodes[pp-1][:cos] += xx
end

nodes.reverse!
cost_dp = Array.new(n,0)

# pp nodes
index = 0
while nodes.size != 0
  nod = nodes.pop
  index += 1
  # p nod
  if nod[:pa] == nil
    cost_dp[index] = nod[:cos]
  else
    cost_dp[index] = nod[:cos] + cost_dp[nod[:pa]]
  end
end
puts cost_dp[1..-1].join(' ')


Measured memory_bytes: 65252
{-# LANGUAGE TupleSections #-}

import qualified Data.ByteString.Char8 as C
import Data.Vector.Unboxed
import Prelude hiding (filter, map, maximum, replicate, tail)

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . show

sol v = h2!maxIndex h2
  where
  u = tail v
  m = maximum u
  h0 = accumulate (+) (replicate (m+1) 0) $ map (,1) u :: Vector Int
  h1 = accumulate (+) h0 $ map (,1) . filter (<=m) $ map succ u
  h2 = accumulate (+) h1 $ map (,1) . filter (0<=) $ map pred u

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++)cin >> h[i];

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

	int ret = 1 << 30;
	for (int i = 0; i <= N - K; i++) {
		ret = min(ret, h[i + K - 1] - h[i]);
	}
	cout << ret << endl;
}

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

int main() {
  int N, ans=0;
  cin >> N;
  int a[N];
  bool flag=true;
  for(int i=0; i<N; i++) cin >> a[i];
  for(int i=1; i<100; i++) {
    for(int j=0; j<N; j++) {
      ans=i-1;
      if(a[j]%2!=0) {
        flag=false;
        break;
      }
      a[j]/=2;
    }
    if(flag==false) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <random>
#include <cstdlib>

using namespace std;

#define R 10
#define PSIZE 5
//????????????????????????14*14????????????????????£????????????????????????
//??¢?´¢?????§????????????????????§?????????
//??¨?????£????????????????????????????????????????????????????????????????????£??????
int T[10][10];
int N;

//????????????????????¨???????????????????????????????????¶??????????????????????????????????????´
//?????´????????????center??§???????????´
int mid = (PSIZE - 1) / 2;
int p[3][5][5] = {
	{0,0,1,0,0,
	0,1,1,1,0,
	0,0,1,0,0,
	0,0,0,0,0,
	0,0,0,0,0},

	{0,0,1,1,1,
	0,0,1,1,1,
	0,0,1,1,1,
	0,0,0,0,0,
	0,0,0,0,0},

	{0,0,1,0,0,
	0,1,1,1,0,
	1,1,1,1,1,
	0,1,1,1,0,
	0,0,1,0,0}

};
//{2,0}???????????????????????????
int center[3][2] = { {0,1},{1,1},{0,2} };
int psize[] = { 3,3,5 };

void add_point(int x, int y, int point[5][5]) {
	for (int i = 0; i < PSIZE; i++) {
		for (int j = 0; j < PSIZE; j++) {
			if (point[i][j]) T[y + i][x + j - mid] += point[i][j];
		}
	}
}

void delete_point(int x, int y, int point[5][5]) {
	for (int i = 0; i < PSIZE; i++) {
		for (int j = 0; j < PSIZE; j++) {
			if (point[i][j]) T[y + i][x + j - mid] -= point[i][j];
		}
	}
}

bool can_delete(int x, int y, int point[5][5]) {
	for (int i = 0; i < PSIZE; i++) {
		for (int j = 0; j < PSIZE; j++) {
			if (y + i < 0 || y + i >= R ||
				x + j - mid < 0 || x + j - mid >= R)
				if (point[i][j]) return false;
			if (T[y + i][x + j - mid] - point[i][j] < 0) return false;
		}
	}
	return true;
}

bool checkT() {
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < R; j++) {
			if (T[i][j] != 0) return false;
		}
	}
	return true;
}

vector<pair< pair<int, int>, int> > points;
bool rec(int x, int y, int cnt) {
	if (checkT()) return true;
	if (cnt == N) return false;

	for (; !T[y][x];) {
		y += (x == 9 ? 1 : 0);
		x = (x + 1) % 10;
		if (y == 10) return false;
	}

	for (int i = 0; i < 3; i++) {
		if (!can_delete(x, y, p[i])) continue;
		delete_point(x, y, p[i]);
		points.push_back(make_pair(make_pair(x + center[i][0], y + center[i][1]), i));
		if (rec(x, y, cnt + 1)) return true;
		points.pop_back();
		add_point(x, y, p[i]);
	}
	return false;
}

void q91() {
	cin >> N;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < R; j++) {
			cin >> T[i][j];
		}
	}
	bool ans = rec(0, 0, 0);
	for (auto it = points.begin(); it != points.end(); it++) {
		cout << (*it).first.first << " " << (*it).first.second << " " << (*it).second + 1 << endl;
	}

}

int main() {
	q91();
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;



void dump(vector<long long > hoge) {
    int n = hoge.size();
    for(int i = 0; i < n; ++i){
        cout << hoge[i] << " ";
    }
    cout << endl;
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);

    int n;
    cin >> n;

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

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

    double av = a[n-1]/2.0;

    double mindif = 10000000000;
    int ind = -1;
    for(int i = 0; i < n; ++i){
        double dif = abs(a[i] - av);
        if (dif < mindif) {
            mindif = dif;
            ind = i;
        }
    }
    cout << a[n-1] << " " << a[ind] << endl;
}

Measured memory_bytes: 1152
// Nothing Special

#include <cstdio>
#include <iostream>

int main() {
    std::string S;
    std::cin >> S;

    if(S[S.length() - 1] == 's')
                S += "es";

    else
        S += 's';

    std::cout << S << "\n";

    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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << ((c-1)/b > (a-1)/d? "No" : "Yes" ) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    if(B % A == 0)cout << A + B << endl;
    else cout << B - A << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int gcd(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = gcd(ret, v[i]);
	return ret;
}
int lcm(const vector<int> &v) {
	int ret = v[0];
	for (int i = 1; i < v.size(); i++)
		ret = lcm(ret, v[i]);
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> T(N); rep(i, 0, N) {
		cin >> T[i];
	}
	cout << lcm(T) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>


using namespace std;

int main() {
  int n,m,p,A[100001][2],wa=0,ac=0;
  string s;
  cin >> n>>m;
  for(int i=0;i<n;i++){
    A[i][0]=0;
    A[i][1]=0;
  }
  for(int i=0;i<m;i++){
    cin >>p>>s;
    if(s=="AC"){
      A[p-1][1]=1;
    }else{
      if(A[p-1][1]==1){
        continue;
      }else{
        A[p-1][0]++;
      }
    }
  }
  for(int i=0;i<n;i++){
    ac+=A[i][1];
    if(A[i][1]==1)wa+=A[i][0];
  }
  cout<<ac<<" "<<wa<<endl;
}


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

int main() {
 int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    while(a[i]%2==0){
      b[i]++;
      a[i]/=2;
    }
  }
  
  sort(b.begin(),b.end());
  cout<<b[0]<<endl;
}

  
  

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
box=[0]*(n+1)
for i in range(n):
    k=n-i
    count=0
    for j in range(k,n+1,k):
        count+=box[j]
    if count%2!=l[k-1]:
        box[k]=1
ll=[]
for i in range(1,n+1):
    if box[i]==1:
        ll.append(i)
print(box.count(1))
print(*ll) 

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

int main(){
	int n;double t;scanf("%d%lf",&n,&t);
	double Max=0;
	rep(i,n){
		double x,h;scanf("%lf%lf",&x,&h);
		Max=max(Max,h/x*t);
	}
	printf("%.7lf\n",Max);
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, X;
	vector<llong> m;

	cin >> N >> X;
	m.resize(N);
	for(int i = 0; i < N; i++){
		cin >> m[i];
		X -= m[i];
	}

	sort(BE(m));
	cout << N + X/m[0] << endl;

	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)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  vi vec;
  int ans = 0;

  rep(i,n) {
    if (vec.empty()) {
      vec.push_back(arr[i]);
    }
    else {
      if (vec.back() >= arr[i]) {
        ans += vec.back() - arr[i];
        vec.erase(lower_bound(all(vec), arr[i]), vec.end());
      }
      vec.push_back(arr[i]);
    }
  }

  if (!vec.empty()) {
    ans += vec.back();
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;++i) cin>>d[i];
  sort(d.begin(), d.end());
  cout<<d[N/2]-d[N/2-1]<<endl;
}



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

N, K = map(int, input().split())
nums = []
for i in range(N):
    t, d = map(int, input().split())
    nums.append((d, t))
nums.sort(reverse=True)
se = set()
doubled = []
rest = []
points = 0
for i, n in enumerate(nums):
    if i < K:
        if not n[1] in se:
            se.add(n[1])
        else:
            doubled.append(n)
        points += n[0]
    else:
        rest.append(n)
ans = points + pow(len(se), 2)
idx = len(doubled)-1
for d, t in rest:
    if idx < 0: break
    if t in se: continue
    points -= doubled[idx][0]
    idx -= 1
    points += d
    se.add(t)
    ans = max(ans, points+pow(len(se), 2))
print(ans)


Measured memory_bytes: 19188
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  ll a,b;
  cin >> a >> b;
  string ans;
  if(a<=0 && 0<=b) ans="Zero";
  else if(0<a) ans="Positive";
  else if(b<0){
    if((b-a+1)%2==0) ans="Positive";
    else ans="Negative";
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  VEC<int> a(n+2,0);
  LL sum = 0;
  REP(i, 1, n+1) { cin >> a[i]; }
  REP(i, 0, n+1) { sum += abs(a[i + 1] - a[i]); }
  DUMP(sum,a);
  REP(i,1,n+1){
    LL ans ;
    if(a[i-1]<=a[i] && a[i]<=a[i+1]){
      ans=sum;
    }
    else {
      ans = sum - abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
    }
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int fun(int x){
  int r=0;
  string s=to_string(x);
  for(int i=0; i<s.size(); i++){
    r+=x%10;x/=10;
  }
  return r;
}

int main() {
  int X;cin>>X;
  cout << (X%fun(X)==0 ? "Yes":"No") <<endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> t(n+1); for(int i = 1;i<=n;i++) cin >> t[i];
  int m; cin >> m;
  vector<int> p(m+1),x(m+1); for(int i = 1;i<=m;i++) cin >> p[i] >> x[i];

  for(int i = 1;i<=m;i++){
    int ans = 0;
    for(int j = 1;j<=n;j++){
      if(p[i] != j) ans += t[j];
      else ans += x[i];
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3580
n = 0
bounce = []

def IsReachable() :
    current = 0
    for i in range(n) :
        if current < 10*i : return False
        current = max( current, 10*i + bounce[i] )
        if current >= 10*n : return True
    return False

n = int(input())
for i in range(n) :
    bounce.append( int(input()) )

if not IsReachable() : print("no")
else :
    bounce.reverse()
    if IsReachable() : print("yes")
    else : print("no")



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

int main(){
 int n;cin>>n;
 int a[200000];
 int ans=0;
 for(int i=0;i<n;i++){
	 cin>>a[i];
	 ans=ans^a[i];
 }
 for(int i=0;i<n;i++){
	 cout<<(ans^a[i])<<endl;
 }
}


Measured memory_bytes: 4364
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<ll> A(N+1),B(N);
    REP(i,N+1) cin>>A[i];
    REP(i,N) cin>>B[i];
    ll ans=0;
    REP(i,N){
        ans+=min(A[i],B[i]);
        B[i]-=A[i];
        ans+=min(A[i+1],max(B[i],0LL));
        A[i+1]-=min(A[i+1],max(B[i],0LL));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
n,k = map(int,input().split())
v = list(map(int,input().split()))

m=[]
for i in range(k+1):
 for j in range(min(k,n)-i+1):
  # print(i,j)
  t=sorted(v[:i]+v[:~j:-1])
  while t and(k-i-j)*t[0]<0:t.pop(0);j+=1
  m+=sum(t),
print(max(m))


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

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

  int n;
  cin >> n;

  vector<int> a(n);
  int mx = -1;
  rep(i, n) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  a.erase(find(a.begin(), a.end(), mx));

  int r = mx;
  int mindiff = 1e9;
  rep(i, n) {
    int diff = min(abs(a[i] - mx / 2), abs(a[i] - (mx + 1) / 2));
    if(diff < mindiff) {
      r = a[i];
      mindiff = diff;
    }
  }

  cout << mx << " " << r << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){
	
	char c[4];
	scanf("%s",c);
	
	int cnt = 0;
	
	for(int i=0;i<3;i++){
		if(c[i]=='1')cnt ++;
	}
	printf("%d\n",cnt);
	
		
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public class Plane
	{
		public long Time;
		public long X;
		public long Y;
	}

	public static class Question
	{
		public static void Exec()
		{
			long n = int.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			var dict = new Dictionary<long, long>();
			for (var i = 0; i < n; ++i) {
				if (dict.ContainsKey(array[i]) == false) {
					dict.Add(array[i], 1);
				} else {
					++dict[array[i]];
				}
			}

			long total = 0;
			foreach (var item in dict) {
				if (item.Key < item.Value) {
					total += item.Value - item.Key;
				} else if (item.Key > item.Value) {
					total += item.Value;
				}
			}

			Console.WriteLine($"{total}");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 30944
s = input()

t = input()

if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if abs(len(t)) == abs(len(s)) + 1:
                if t == s + t[-1]:
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long GetDigitSum(int long long n){
    if(n < 10){
       return n;
    }
    return GetDigitSum(n/10) + n%10;
} //十進数の桁和
unsigned int long long unsignedGetDigitSum(unsigned int long long n){
    if(n < 10){
       return n;
    }
    return unsignedGetDigitSum(n/10) + n%10;
} //十進数の桁和unsigned
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント


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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstr;
void print() {cout<<'\n';}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<'\n';}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    int ans = 0;
    rep(i, n) {
        rep(j, n){
            if ((i+1) % 2 == 0 and (j+1) % 2 == 1) {
                ans++;
            }
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	int n,maxF=0;
	string s;
	cin >> n;
	map<string, int> mp;
	vector<string> str;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (mp.count(s)) {
			mp[s] += 1;
			maxF=max(maxF, mp[s]);
		}
		else {
			mp.insert(make_pair(s, 0));
		}
	}
	auto begin = mp.begin(), end = mp.end();
	for (auto iter = begin; iter != end; iter++) {
		if (iter->second == maxF) {
			str.push_back(iter->first);
		}
	}
	sort(str.begin(), str.end());
	str.push_back("EOF");
	for (int i = 0; str[i]!="EOF"; i++) {
		cout << str[i] << endl;
	}

}

Measured memory_bytes: 26996
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}
	vector<int> rec(N,0);
	rec[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; i++){
		{
			rec[i] = min(rec[i - 2] + abs(h[i] - h[i - 2]), rec[i - 1] + abs(h[i] - h[i - 1])); 
		}
	}

	cout << rec[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main()
{
	int n,t[100005],i;
	int x[100005],y[100005];
	t[0]=x[0]=y[0]=0;
	while(scanf("%d",&n)!=EOF)
	{
		for( i=1;i<=n;i++)
		{
			scanf("%d",&t[i]);
			scanf("%d",&x[i]);
			scanf("%d",&y[i]);
		}
		for( i=1;i<=n;i++)
		{
			if((x[i]+y[i]-x[i-1]-y[i-1])%2!=0&&(t[i]-t[i-1])%2==0||(x[i]+y[i]-x[i-1]-y[i-1])%2==0&&(t[i]-t[i-1])%2!=0)
				break;
			if((x[i]+y[i]-x[i-1]-y[i-1])%2==0&&(t[i]-t[i-1])%2==0||(x[i]+y[i]-x[i-1]-y[i-1])%2!=0&&(t[i]-t[i-1])%2!=0)
				if(t[i]<x[i]+y[i])
					break;
		}
		if(i==n+1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
 
#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <ll, ll>
 
using namespace std;

int n;
int v[N];

int main()
{
	cin >> n;
	
	for(int i = 1; i <= n; i++) cin >> v[i];
	
	sort(v+1, v+n+1);
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
		for(int h = i+1; h <= n; h++)
			for(int j = h+1; j <= n; j++)
				if(v[i] != v[h] && v[i] != v[j] && v[h] != v[j] && v[i] + v[h] > v[j]) {
					ans ++;
					
					//~ cout << i << " " << h << " " << j << "\n";
				}
	
	cout << ans;
}


Measured memory_bytes: 3192
#include <iostream>
#define int long long

 
int a[200005];
 
signed main()
{
    // Fast I/O
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(false);
 
    // freopen("24c.inp", "r", stdin);
 
    int n;
    std::cin >> n;
 
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a[i];
        if (i > 0 && a[i] - a[i - 1] >= 2)
        {
            std::cout << -1;
            return 0;
        }
    }
    if (a[0] != 0)
    {
        std::cout << -1;
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
        ans += (a[i] - a[i - 1] == 1 ? 1 : a[i]);
    std::cout << ans;
 
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	int first;
	int second;

	Pair(int first, int second) {
		this.first = first;
		this.second = second;
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int n = in.nextInt();
		if (n % 2 == 0) {
			pw.println(n);
		} else {
			int num = __gcd(n, 2);
			int temp = (n * 2) / num;
			pw.println(temp);
		}

	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

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

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

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

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


Measured memory_bytes: 22996
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
current_500 = 0
current_500_100 = 0

for num_500 in range(0, a + 1):
    current_500 = num_500 * 500
    if current_500 > x:
        break
    for num_100 in range(0, b + 1):
        current_500_100 = current_500 + num_100 * 100
        if current_500_100 > x:
            break
        for num_50 in range(0, c + 1):
            if current_500_100 + num_50 * 50 == x:
                count += 1
                break
print(count)


Measured memory_bytes: 3060
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val (n,k) = list()
	val p = list().map {it-1}
	val c = list {toLong()}

	val a = Array(n+1) {LongArray(n)}
	val t = Array(n+1){IntArray(n) {it}}

	for(d in 0 until n) {
		for(i in 0 until n) {
			t[d+1][i] = p[t[d][i]]
			a[d+1][i] = a[d][i]+c[t[d+1][i]]
		}
		//System.err.println(t[d+1].joinToString())
	}

	var r = Long.MIN_VALUE
	for(d in 1..min(n,k))
		r = max(r,a[d].max()!!)
	if(k>n) {
		val db = ((k-1)/n-1)*n
		for(i in 0 until n) {
			val m=(1..n).first {t[it][i]==i}
			//System.err.println(m)

			for(d in db..k) {
				r = max(r,a[d%m][i]+a[m][i]*(d/m))
			}
		}
	}
	println(r)
}


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

template <typename T>
void print(const T &v);

vector<pair<ll, ll>> factorization(ll num)
{
    map<ll, ll> mp;

    ll tmp = num;
    for (ll i = 2; i * i <= num; i++)
    {
        while (tmp % i == 0)
        {
            mp[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1)
    {
        mp[num]++;
    }
    vector<pair<ll, ll>> ret;
    for (auto m : mp)
    {
        ret.push_back(make_pair(m.first, m.second));
    }
    return ret;
}

int main()
{
    ll n;
    cin >> n;
    auto fac = factorization(n);
    ll ans = 0;
    for (auto fa : fac)
    {
        ll cnt = 1;
        while (fa.second >= 0)
        {
            fa.second -= cnt;
            ans++;
            cnt++;
        }
        ans--;
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    auto g = new int[n + 1];
    for (int i = 0; i < m; i++) {
        auto ab = readints;
        int a = ab[0], b = ab[1];
        g[a]++;
        g[b]++;
    }

    foreach (i; 1..n+1) {
        writeln(g[i]);
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int inf = 1012345678;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll x,n,cnt=0,max=pow(10,9);
	cin>>n;
	vector<ll> v;
	REP(i,0,n-1)
	{
		cin>>x;
		v.push_back(x);
		if(v[i]<max)
		{
			max=v[i];
			cnt++;
		}
	}
	cout<<cnt;
}

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

is_success = False
flags = []


for i in range(N):
	D_one, D_two = input().split()
	D_one, D_two = int(D_one), int(D_two)
    
	if D_one == D_two:
		flags.append(True)
	else:
		flags.append(False)

	if len(flags) > 3:
		flags.pop(0)

	if all(flags) and len(flags)==3:
		is_success = True

if is_success:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9192
import scala.util.control.Breaks
object Main extends App {
  val b = Breaks

  b.breakable {
    for (line <- io.Source.stdin.getLines()) {
      if (line.isEmpty) {b.break()}

      val abc = ('a' to 'z').toArray
      for (shift <- 0 until 26) {
        val mapabc = (for (i <- 0 until 26) yield abc(i) -> abc((i + shift) % 26)).toMap
        val decstr = line.map(c => {
          if (abc.contains(c)) mapabc(c) else c
        })
        val pdecstrs = decstr.replace('.',' ').split(' ')

        if (pdecstrs.contains("the") || pdecstrs.contains("this") || pdecstrs.contains("that")) {
          println(decstr)
        }
      }
    }
  }
}


Measured memory_bytes: 50004