akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    rep(i,n){
        while(v[i]%2==0){
            ans++;
            v[i] /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int INF = (int)2e9;
int N;
int A[3];
int L[8];
int pow4[9];
vector<int> use[3];

void input_init(void) {
	cin >> N;
	for (int i = 0; i < 3; ++i)
		cin >> A[i];
	for (int i = 0; i < N; ++i)
		cin >> L[i];
	pow4[0] = 1;
	for (int i = 1; i <= 8; ++i)
		pow4[i] = 4 * pow4[i - 1];
}

int calcu(void) {
	int mp = 0;
	for (int i = 0; i < 3; ++i) {
		int sum = 0;
		if (use[i].size() == 0)
			return INF;
		int join = use[i].size() - 1;
		mp += 10 * join;
		for (int j = 0; j < (int)use[i].size(); ++j) {
			int k = use[i][j];
			sum += L[k];
		}
		mp += abs(sum - A[i]);
	}
	return mp;
}

int solve(void) {
	int ret = INF;
	for (int i = 1; i < pow4[N]; ++i) {
		for (int j = 0; j < 3; ++j)
			use[j].clear();
		int num = i;
		for (int j = N - 1; j >= 0; --j) {
			int r = num / pow4[j];
			if (r != 0)
				use[r - 1].push_back(j);
			num -= r * pow4[j];
		}
		int val = calcu();
		ret = min(val, ret);
	}
	return ret;
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	
	cout << a/b << " " << a%b << " " << flush;
	cout << fixed << setprecision(6) << (double)a/(double)b << endl;

	return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if((a-b)%2==0){
			if(a<b){
				System.out.println((b-a)/2+a);
			}else{
				System.out.println((a-b)/2+b);
			}
		}else{
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp43 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            int x = 800 * N;

            int y = 200 * (N / 15);

            Console.WriteLine(x - y);
        }

    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

typedef unsigned long long ull;


int main(){
	int h,n;
	cin >> h >> n;
	
	vector<int> A(n),B(n);
	for(int i=0;i<n;++i){
		cin >> A[i] >> B[i];
	}
	const int inf = 1000000000;
	vector<int> dp(200000,inf);
	dp[0] = 0;
	for(int i=0;i<n;++i){
		int a = A[i];
		int b = B[i];
		for(int j=0;j<dp.size();++j){
			if(j+a >= dp.size()) break;
			dp[j+a] = min(dp[j+a],dp[j]+b);
		}
	}
	
	int res = inf;
	for(int i=h;i<dp.size();++i){		
		//cout << dp[i] <<endl;
		res = min(res,dp[i]);
	}
	cout << res <<endl;
	
	return 0;
}


Measured memory_bytes: 1024
height, width = (int(x) for x in input().split())
matrix = []

for i in range(height):
  matrix.append(input())

row = [0] * width
column = [0] * height

for i in range(height):
  if '#' in matrix[i]:
    column[i] = 1
    for j in range(width):
      if (matrix[i][j] == '#'):
        row[j] = 1

for i in range(height):
  if (column[i] == 1):
    for j in range(width):
      if (row[j] == 1):
        print(matrix[i][j], end = '')
    print()
        

Measured memory_bytes: 4468
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

// constants for main process
#define num_points_max    10
#define val_dimension_max 10

bool is_GoodDist (signed int val_dist)
{
	for (signed int itr = 0; itr <= val_dist; itr++)
	{
		if (itr * itr == val_dist) { return true; }
	}

	return false;
}

signed int calculate_distance2 (signed int val_dimension, signed int point_origin[], signed int point_target[])
{
	// local variables for this function
	signed int difference;

	// return value of this function
	signed int distance2;

	distance2 = 0;

	for (signed int itr = 0; itr < val_dimension; itr++)
	{
		difference  = point_target[itr] - point_origin[itr];
		distance2  += difference * difference;
	}

	return distance2;
}

signed int calculate_num_GoodDist (signed int num_points, signed int val_dimension, signed int coordinate[num_points_max][val_dimension_max])
{
	// return value of this function
	signed int num_GoodDist;

	// STEP.01
	// initialize the return value
	num_GoodDist = (signed int)0;

	for (signed int itr_po = 0;          itr_po < num_points; itr_po++) {//
	for (signed int itr_pt = itr_po + 1; itr_pt < num_points; itr_pt++) {//
		if ( is_GoodDist( calculate_distance2(val_dimension, coordinate[itr_po], coordinate[itr_pt]) ) )
		{ num_GoodDist += (signed int)1; }
	} }

	// STEP.END
	return num_GoodDist;
}

int main (void)
{

	// variables for main process
	signed int N; // number of points
	signed int D; // dimension of the given data

	// support variables for main process
	signed int rtvl; // store the return value of `scanf`

	// arrays for main process
	signed int X[num_points_max][val_dimension_max]; // data of coordinate

	// STEP.01
	// read out the given data
	rtvl = scanf("%d %d", &N, &D);

	for (signed int itr_p = 0; itr_p < N; itr_p++) {//
	for (signed int itr_d = 0; itr_d < D; itr_d++) {//
		rtvl = scanf("%d", &X[itr_p][itr_d]);
	} }

	// STEP.02
	// output the answer of this task
	printf("%d\n", calculate_num_GoodDist(N, D, X));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		int n = str.length();

		for (int i = 0; i < n; i++) {
			System.out.print("x");
		}
		System.out.println();
	}
}


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

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


   bool j=false;
  for(int i=a;i<=b;i++)
  {
       if(i%k==0)
       {
         j=true;
       }
  }
 
  if(j)
    cout<<"OK"<<endl;
  else
    cout<<"NG"<<endl;

   return 0;
}


Measured memory_bytes: 3588
import sys

N, M = map(int, input().split())
num_map = [None for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if s > N or (num_map[s] is not None and num_map[s] != c) or (s == 0 and c == 0 and N > 1):
        print(-1)
        sys.exit()
    num_map[s] = c
num_map.reverse()

ans = 0
for i, num in enumerate(num_map):
    if num is not None:
        ans += num*(10**i)
    elif i == N-1 and N > 1:
        ans += (10**i)
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string ret = string.Empty;
            ret += Console.ReadLine().ToCharArray()[0];
            ret += Console.ReadLine().ToCharArray()[1];
            ret += Console.ReadLine().ToCharArray()[2];
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        if(A>=13){
            System.out.println(B);
        }else if(A>=6){
            System.out.println(B/2);
        }else{
            System.out.println(0);
        }

    }
}


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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); it++)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

bool match(string const& a, string const& b){
    if(a.size()!=b.size()) return false;
    int n=a.size();
    rep(i,n){
        if(a[i]=='*') continue;
        if(a[i]!=b[i]) return false;
    }
    return true;
}

int main(){
    int n,m;
    while(cin>>n>>m &&  n|m){
        vs s(n);
        vi a(n);
        rep(i,n) cin >> s[i] >> a[i];
        long long int ans = 0;
        rep(i,m){
            string t; cin>>t;
            rep(i,n){
                if(match(s[i],t)){
                    ans+=a[i];
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(){
    int d;
    scanf("%d", &d);

    if (d == 25)
        printf("Christmas");
    if (d == 24)
        printf("Christmas Eve");
    if (d == 23)
        printf("Christmas Eve Eve");
    if (d == 22)
        printf("Christmas Eve Eve Eve");

    return 0;
}

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

#define ll long long int

int main()
{
	ll	N, M, Q;
	cin >> N >> M >> Q;
	
	ll	Li, Ri;
	vector<ll>	vKukan[N + 1];
	
	for (ll i = 0; i < M; i++) {
		cin >> Li >> Ri;
		vKukan[Li].push_back(Ri);
	}
	
	for (ll i = 0; i < (N + 1); i++) {
		sort(vKukan[i].begin(), vKukan[i].end());
	}
	
	for (ll i = 0; i < Q; i++) {
		ll pi, qi;
		cin >> pi >> qi;
		ll ansNum = 0;
		for (ll j = pi; j <= qi; j++) {
			vector<ll> ::iterator	it=upper_bound(vKukan[j].begin(), vKukan[j].end(), qi);
			ansNum += (it - vKukan[j].begin());
		}
		cout << ansNum << endl;
		
	}
	return (0);
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,a,b;
  cin>>n>>a>>b;
  for(ll i=a;i<=b;i++){
    if(i%n==0){
      cout<<"OK\n";
      return 0;
    }
  }
  cout<<"NG\n";
  return 0;
}

Measured memory_bytes: 3640
//Moh_K_Imar .......
//24/08/2020  ... 5,35 .
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string s,t;
    cin>>s>>t;
    ll a,b;
    cin>>a>>b;
    string c;
    cin>>c;
    if(c==s){
        cout<<a-1<<" "<<b<<endl;
    }
    else {
        cout<<a<<" "<<b-1<<endl;
    }

    return 0;
}



Measured memory_bytes: 3624
#include <stdio.h>
int main()
{
  int S[10000], T[500], n, q, i, j, count = 0;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for (i = 0; i < q; i++){
    scanf("%d",&T[i]);
    j = 0;
    while (S[j] != T[i] && j < n)
      j++;
    if (j < n)
      count++;
  }
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2108
n = gets.strip.to_i
xs = [0] + gets.strip.split.map(&:to_i)
count = 0
ans = []

xsmax = xs[1...xs.length].max
xsmin = xs[1...xs.length].min
if xsmax > 0 and xsmin < 0 then
  if xsmax.abs >= xsmin.abs then
    ind = xs.index(xsmax)
    (1...xs.length).each {|i| xs[i] += xsmax}
    (1...xs.length).each {|i| ans << "#{ind} #{i}"; count += 1}
  else
    ind = xs.index(xsmin)
    (1...xs.length).each {|i| xs[i] += xsmin}
    (1...xs.length).each {|i| ans << "#{ind} #{i}"; count += 1}
  end
end

if xs[1] > 0 then
  for i in 2...xs.length do
    xs[i] += xs[i-1]
    ans << "#{i-1} #{i}"
  end
else
  xs = xs + [0]
  for i in (2..(xs.length-2)).to_a.reverse do
    xs[i-1] += xs[i]
    ans << "#{i} #{i-1}"
  end
end

puts ans.length
puts ans.join("\n")

Measured memory_bytes: 1788
s=input()

a=0
ab=0
abc=0
q=1
m=10**9+7

for i in range(len(s)):
  if s[i]=="A":
    a=(a+q)%m
  elif s[i]=="B":
    ab=(ab+a)%m
  elif s[i]=="C":
    abc=(abc+ab)%m
  else:
    abc=(abc*3+ab)%m
    ab=(ab*3+a)%m
    a=(a*3+q)%m
    q=(q*3)%m
print(abc)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order_sl(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}



int main() {
  int n,m;
  cin>>n>>m;
  nvec(long,a,n);
  vector<pair<int,long>> v(m);for(size_t i=0;i<m;i++){cin>>v[i].first>>v[i].second;}
  sort(all(a));
  sort(all(v),order_sl(s.second>l.second));
  int k=0;
  FOR(i,m){
    if(k==n||a[k]>=v[i].second) break;
    FOR(j,v[i].first){
      if (a[k]>=v[i].second) break;
      a[k]=v[i].second;
      k++;
      if(k==n) break;
    }
  }
  cout<<accumulate(all(a),0l);
}

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

using Poly = vector<int>;
int n;
int a[3000];

long expmod(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return expmod(b, e - 1) * b % n;
  long t = expmod(b, e / 2);
  return t * t % n;
}

long inv(long k) {
  return expmod(k, n - 2);
}

void add(Poly& a, const Poly& b) {
  for (int i = 0; i < n; ++i) {
    a[i] = (a[i] + b[i]) % n; 
  }
}

Poly mul(const Poly& a, const Poly& b) {
  Poly ret(a.size() + b.size() - 1);
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < b.size(); ++j) {
      ret[i + j] = (ret[i + j] + a[i] * b[j]) % n;
    }
  }
  return ret;
}

Poly div(const Poly& a, int d) {
  Poly tmp = a;
  Poly ret(a.size() - 1);
  for (int i = (int)a.size() - 2;  i >= 0; --i) {
    int c = tmp[i + 1];
    ret[i] = c;
    tmp[i + 1] = 0;
    tmp[i] = (n * n + tmp[i] - d * c) % n;
  }
  return ret;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  Poly fact(1, 1);
  for (int i = 0; i < n; ++i) {
    fact = mul(fact, { (n - i) % n, 1 });
  }
  
  Poly sum(n);
  for (int i = 0; i < n; ++i) {
    int denom = 1;
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      denom = denom * (n + i - j) % n;
    }
    int coeff = a[i] * inv(denom) % n;
    Poly term = mul(div(fact, (n - i) % n), { coeff });
    add(sum, term);
  }
  for (int i = 0; i < n; ++i) {
    cout << sum[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 384
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()


    for i in range(len(s)//2):
        if s[i] != s[len(s)-1 -i]:
            print('No')
            return
    
    print('Yes')

solve()


Measured memory_bytes: 3060
N, K = map(int, input().split())
S = input()

# S[K-1] = S[K-1].lower()
ans = N * [None]
for i in range(N):
    if i == K-1:
        ans[i] = S[i].lower()
    else:
        ans[i] = S[i]

print("".join(ans))

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

int main(){
	
  	int a,b,c,d;
  	int ab = 0, ac = 0 , bc = 0;
  	cin >> a >> b >> c >> d;
  	if(abs(a-b)<=d)ab = 1;
  	if(abs(a-c)<=d)ac = 1;
  	if(abs(b-c)<=d)bc = 1;
  	if(ac || (ab&&bc)) cout << "Yes"<<endl;
  	else cout << "No" << endl;
  
	return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	string a,b;
	cin >> a >> b;
	b = b + a;
	cout << b;
}



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

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


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

int main(){
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<int64_t, int64_t>> XH(N);
    for(int i=0; i<N; i++){
        int64_t x, h;
        cin >> x >> h;
        XH[i] = {x, h};
    }
    sort(XH.begin(), XH.end());
    vector<int64_t> xs(N), hs(N);
    for(int i=0; i<N; i++){
        xs[i] = XH[i].first;
        hs[i] = XH[i].second;
    }

    vector<int64_t> imos(N+1);
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        int64_t r = xs[i] + 2*D;
        int rp = upper_bound(xs.begin(), xs.end(), r) - xs.begin();
        int64_t c = max(int64_t(0), (hs[i]+A-1)/A - imos[i]);
        ans += c;
        imos[i] += c;
        imos[rp] -= c;
        imos[i+1] += imos[i]; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void)
{
	long long A, B,X;
	long long count = 0;
	long long out = 1;

	cin >> A >> B;

	if (B == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	X = A - 1;
	while(1)
	{
		out += X;
		count++;
		if (out >= B)
			break;
	}

	cout << count << endl;

	return 0;
}

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

int main()
{
	int a[5];
	while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
		map<int,int> count;
		sort(a,a+5);
		for(int i=0;i<5;i++){
			count[a[i]]++;
		}
		int times[13],times2[13];
		for(int i=1;i<=13;i++)
			times2[i-1]=count[i];
		sort(times2,times2+13);
		for(int i=0;i<13;i++)
			times[i]=times2[12-i];
		if(times[0]==4) cout << "four card" << endl;
		else if(times[0]==3 && times[1]==2) cout << "full house" << endl;
		else if( (a[1]==a[0]+1 &&a[2]==a[1]+1 &&a[3]==a[2]+1 &&a[4]==a[3]+1) || 
			(a[0]==1 && a[1]==10 && a[2]==a[1]+1 &&a[3]==a[2]+1 &&a[4]==a[3]+1) ) cout << "straight" <<endl;
		else if(times[0]==3 ) cout << "three card" << endl;
		else if(times[0]==2 && times[1]==2) cout << "two pair" << endl;
		else if(times[0]==2) cout << "one pair" << endl;
		else cout << "null" << endl;
	}


	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N[5];
    int d[5];
    for(int i = 0; i < 5; i++)
    {
        cin >> N[i];
    }
    for(int i = 0; i < 5; i++)
    {
        if (N[i]%10==0) {
            d[i] = 0;
        }else
        {
            d[i] = 10 - N[i]%10;
        }
        
    }
    
    for (int i=0; i<5; i++) 
    {
        for (int j=i+1; j<5; j++) {
            if (d[i] > d[j]) 
            {
            int tmp =  d[i];
            d[i] = d[j];
            d[j] = tmp;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < 5; i++)
    {
        ans += N[i]+d[i];
    }
    ans -= d[4];
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, ans,a,pOdd=1;
	std::cin >> n;
	ans = powl(3, n);

	rep(i, 0, n) {
		std::cin >> a;
		if (a % 2 == 0) {
			pOdd *= 2;
		}
	}

	ans -= pOdd;
	outn(ans);

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for (int i=1; i<=N; i++){
        string S = to_string(i);
        if(S.size() % 2 == 1) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	var n = parseInt(input[0][0],10);
	var v_rc = [];
	for (var i = 0; i < n; i++){
		v_rc.push(parseInt(input[i + 1][0], 10));
	}
	v_rc.push(parseInt(input[n][1], 10))
	dp = [];
	for (var i = 0; i < n; i++){
		dp.push([]);
		for (var j = 0; j < n; j++){
			dp[i].push([-1]);
		}
	}
	// console.log(dp);

	console.log(kukanDP(v_rc, 0, n - 1)[0]);
	// console.log(dp);

}

function kukanDP(w, l, r){
	// console.log("lr", l, r);
    //既に計算済み？
    if(dp[l][r][0] !== -1) return dp[l][r];

    //lとr同じなら0
    if(l === r) {
		return dp[l][r] = [0, w[l], w[l + 1]];
	}

	if(Math.abs(l - r) === 1) {
		return dp[l][r] = [w[l] * w[r] * w[Math.max(l, r) + 1], w[Math.min(l, r)], w[Math.max(l, r) + 1]].slice();
	}

	let res = Infinity;
	let tmp, tmpL, tmpR;
    //区間を分ける
    for(let mid = l; mid <= r - 1; mid++){
		tmpL = kukanDP(w, l, mid);
		tmpR = kukanDP(w, mid + 1, r);
		// console.log("here", tmpL, tmpR,  "lr", l ,r, mid);
		tmp = tmpL[0] + tmpR[0] + tmpL[1] * tmpL[2] * tmpR[2];
		if (tmp < res){
			res = tmp;
		}
	}
	// console.log("2",l,r, dp);
    return dp[l][r] = [res, w[l], w[r + 1]];
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));




Measured memory_bytes: 17472
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long ll;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const double PI = 3.1415926535897932;
const int i_INF = 2147483647;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
}

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

int main() {
    int N; cin >> N;
    map<int, int> m;
    rep(i, N){
        int a; cin >> a;
        m[a-1]++;
        m[a]++;
        m[a+1]++;
    }

    int ans = 0;
    for(auto p : m){
        auto value = p.second;
        ans = max(ans, value);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7956
#define MOD_TYPE 2

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
#pragma endregion

int main()
{
  init_main();

  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));
  ll Min = LINF;
  for (int l = 0, r = k - 1; r < n; l++, r++)
  {
    chmin(Min, h[r] - h[l]);
  }
  cout << Min << "\n";
  return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		ArrayList<String> str = new ArrayList<String>();
		while(scan.hasNext()){
			str.add(scan.nextLine());
		}
		Collections.sort(str);
		String be = "";
		int count = 0;
		String nt = "";
		for(int i = 0;i < str.size();i++){
			String[] ts = str.get(i).split(" ");
			if(ts[0].equals(be)){
				nt += " " + ts[1];
				count++;
				continue;
			}
			if(count > 1){
				String[] a = nt.split(" ");
				int[] b = new int[count];
				for(int j = 0;j < count;j++){
					b[j] = Integer.parseInt(a[j]);
				}
				Arrays.sort(b);
				for(int j = 0;j < count;j++){
					System.out.print(b[j]+((j == count-1)?"\n":" "));
				}
				count = 1;
				System.out.println(ts[0]);
				be = ts[0];
				nt = ts[1];
			}else{
				if(count != 0){
					System.out.println(nt);
				}
				System.out.println(ts[0]);
				be = ts[0];
				nt = ts[1];
				count = 1;
			}
		}
		if(count > 1){
			String[] a = nt.split(" ");
			int[] b = new int[count];
			for(int j = 0;j < count;j++){
				b[j] = Integer.parseInt(a[j]);
			}
			Arrays.sort(b);
			for(int j = 0;j < count;j++){
				System.out.print(b[j]+((j == count-1)?"\n":" "));
			}
		}else{
			System.out.println(nt);
		}
	}
}

Measured memory_bytes: 17584
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	n3 := n / 3 * 3
	n5 := n / 5 * 5
	n15 := n / 15 * 15

	fmt.Fprintln(stdout, (n*(n+1)/2 - (n3+3)*(n3/3)/2 - (n5+5)*(n5/5)/2 + (n15+15)*(n15/15)/2))
}


Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n;
    double ans = 0,x;
    string u;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> x >> u;
        if(u == "JPY"){ans += x;}
        else{ans += x * 380000;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		Pair a[]=new Pair[n+1];
		long ans=0;
		for(int i=1;i<=n;i++)
			a[i]=new Pair(nextInt(),i);
		Arrays.sort(a,1,n+1,new Comparator<Pair>(){
			public int compare(Pair a,Pair b){
				return a.first-b.first;
			}
		});
		int pos[]=new int[n+1];
		for(int i=1;i<=n;i++)
			pos[a[i].second]=i;
		for(int i=1;i<=n;i++)
			if(pos[i]%2!=i%2)
				ans++;
		out.println(ans/2);
	}
	class Pair{
	    int first,second;
	    Pair(int a,int b){
	        first=a;
	        second=b;
	    }
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 39420
n = int(input())
*l, = map(int,input().split())
#print(l)
f = 0
for i in range(len(l)-2):
  if l[i]<l[i+1] and l[i+1]<l[i+2]:
    f += 1
  elif l[i]>l[i+1] and l[i+1]>l[i+2]:
    f += 1
print(f)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<utility>
#include<iomanip>
#define mod 998244853 
using namespace std;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int x;
    cin >> x;
    for(int i = 1; i <= 9; i++)
    {
        if(x%i==0 && x/i <= 9)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

static  const int MAX = 100;

int d[MAX][MAX];
int n;
void floyd() {
	rep(k,n){
		rep(i, n) {
			if (d[i][k] == INF) continue;
			rep(j, n) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
			}
		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	int v, e, u, c;
	cin >> n >> e;
	//自分へのコストは0にする
	rep(i,n) {
		rep(j, n) {
			d[i][j] = ((i == j) ? 0 : INF);
		}
	}

	rep(i, e) {
		cin >> u >> v >>c;
		d[u][v] = c;
	}

	floyd();
	bool negative = false;
	rep(i, n) if (d[i][i] < 0) negative = true;
	if (negative)
		cout << "NEGATIVE CYCLE\n";
	else
	{
		rep(i, n) {
			rep(j, n) {
				if (j) cout << ' ';
				if (d[i][j] == INF) cout << "INF";
				else
					cout << d[i][j];
			}
			cout << '\n';
		}
	}
	return 0;
}


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

int main() {
  int N, M, A, Sum=0;
  cin >> N >> M;
  rep(i, M){
    cin >> A;
    Sum+=A;
  }
  cout << max(-1, N-Sum) << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pii, int > a, pair < pii, int > b)//true for a before b
{
	if(a.F.F/900 < b.F.F/900)
		return 1;
	if(a.F.F/900 > b.F.F/900)
		return 0;
	if(a.F.S <= b.F.S)
		return 1;
	return 0;
}

const int N = (2e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 8000;



void solve()
{
	int n;
	cin >> n;
	if(n < 1200)
		cout << "ABC";
	else if(n < 2800)
		cout << "ARC";
	else
		cout << "AGC";
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	// cout << fixed << setprecision(6);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int N,i;
    int a[N],b[2];
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d ",&a[i]);
    }
    int k = 0;
    for(i = 0;i < N;i++){
        if(a[i] != i + 1){
            b[k] = a[i];
            k++;
        }
    }
    if(k > 2)printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;
typedef long long ll;
typedef vector<long> vl;
typedef vector<string> vs;

int main(){
  int a=0,n,c=0;
  c(n);
  int h[n];
  rep(i,0,n){
    c(h[i]);
    if(h[i]>=a){
      c++;
      a=h[i];
    }
  }
  co(c);
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int a,b;
	while(cin >> a >> b){
		cout << gcd(a,b) << " " << lcm(a,b) << endl;
	}
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, R, r[8], d[200][200], INF = 1e8;

int main() {
	cin >> n >> m >> R;
	inc(i, R) { cin >> r[i]; r[i]--; }
	
	inc(i, n) {
	inc(j, n) {
		d[i][j] = INF;
	}
	}
	
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	
	inc(k, n) {
	inc(i, n) {
	inc(j, n) {
		setmin(d[i][j], d[i][k] + d[k][j]);
	}
	}
	}
	
	sort(r, r + R);
	int ans = INF;
	do {
		int sum = 0;
		inc(i, R - 1) { sum += d[r[i]][r[i + 1]]; }
		setmin(ans, sum);
	} while(next_permutation(r, r + R));
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
	// your code goes here
	long long int n;
	cin>>n;
	vector<long long int>arr(n+1,1);
	for(long long int i=2;i<=n;i++){
	    for(long long int j=i;j<=n;j+=i){
	        arr[j]++;
	    }
	}
	long long int ans=0;
	for(long long int i=1;i<=n;i++){
	    ans=ans+(i*arr[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 81400
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner ob = new Scanner(System.in);
		String patt = ob.next();
		int result = 0;
		
		for(int i = 0; i < patt.length(); i++) {
			int temp = 0;
			for(int j = i; j < patt.length(); j++) {
				if(patt.charAt(j) == 'R'){
					temp++;
				}else {
					break;
				}
			}
			result = Math.max(result, temp);
		}
		System.out.println(result);
		ob.close();
	}

}


Measured memory_bytes: 35604
function Main(input) {

	input = input.split(" ");
	
	var A = parseInt(input[0]);
	var P = parseInt(input[1]);
	
	var apple = A * 3 + P;
	
	console.log(Math.floor(apple/2));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=105;
int a,b,x[N*5],y[N*5],tot;
char s[N][N];
int main()
{
	//freopen("b.out","w",stdout);
	scanf("%d%d",&a,&b);
	for(int i=1;i<=50;i++)
	  for(int j=1;j<=100;j++)
		s[i][j]='.',s[i+50][j]='#';
	for(int i=1;i<=10;i++){
		for(int j=2;j<=100;j+=2)
		  x[++tot]=i*2,y[tot]=j;
	}
	//for(int i=1;i<=10;i++) cout<<x[i]<<' '<<y[i]<<endl;
	a--; b--;
	for(int i=1;i<=a;i++)
	  s[x[i]+50][y[i]]='.';
	for(int i=1;i<=b;i++)
	  s[x[i]][y[i]]='#';
	printf("100 100\n");
	for(int i=1;i<=100;i++)
      printf("%s\n",s[i]+1);
	return 0;
}

Measured memory_bytes: 256
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
x = int(input())
for i in range(x,x+10000):
    if len(factorize(i)) == 1:
        print(i)
        break

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> input
    where input = do
            c <- getChar
            if isDigit c
                then (c :) <$> input
                else return []

main = do
    [a, b] <- replicateM 2 readInt
    let s = a * b
        t = (a + b) * 2
    putStrLn $ show s ++ " " ++ show t



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

int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  
  int i;
  i = 1;
  while (true){
    if (B*i >= C){
      cout << "Yes" << endl;
      break;
    }
    else if (D*i >= A){
      cout << "No" << endl;
      break;
    }
    i ++;
  }

}


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

using namespace std;

#define mod(a, b) ((((a)%(b))+(b))%(b))
#define pb push_back
#define sz(c) int((c).size())

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main(){
   int a, b; cin >> a >> b;
   cout << ((a * b % 2) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
while (!std::cin.eof()){
int a,b,c,i=0;
std::cin >> a >> b;
if(std::cin.eof())
break;
c=a+b;

while(c/=10)
i++;

std::cout << i+1 << std::endl;
}
return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;



// 考察
//
// a1 a2 ... ai ...  aj ... an-1 an
//
// 初手で終わらせる場合の解は、
//  max(|an-1 - an|, |an-1 - w|)
// x が aiを取ったとし、その後 y が aj を取ったとする
// x の次の一手は、n-1/n 以外を取った場合は↑に戻る。n-1/nを取った時は、
// max(|an-1 - an|, |an-1 - aj|)
// ここで、|an-1 - aj| が |an-1 - w| より大きくなるような aj を y がとるはずがない
// よって、x が ai を取った場合のスコアは高々 |an-1 - an| となる。
// なので、初手で終わらせる方が w によっては特になる場合は初手で終わらせるべきだし、そうでない場合も結局は初手で終わらせた場合と同じ結果になる
int main() {
    lli n,z,w;
    cin3(n,z,w);
    lli a[n+1];
    ncin1(n,a);

    if (n == 1)
        cout << abs(a[0] - w) << endl;
    else
        cout << max(abs(a[n-2] - a[n-1]), abs(a[n-1] - w)) << endl;

}


Measured memory_bytes: 256
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = "a"
while(1):
    if turn == "a":
        if len(Sa)==0:
            print("A")
            break
        else:
            turn = Sa.pop(0)
    elif turn == "b":
        if len(Sb)==0:
            print("B")
            break
        else:
            turn = Sb.pop(0)
    else:
        if len(Sc)==0:
            print("C")
            break
        else:
            turn = Sc.pop(0)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	int a, b;
	
	scanf("%d %d", &a, &b);
    if(a > b){
        printf("a > b\n");
    }
	else if(a < b){
        printf("a < b\n");
    }
	else{
        printf("a == b\n");
    }
    return (0);
}

Measured memory_bytes: 580