akhauriyash/Code-Regression huggingface dataset:
/*
 * ITP1_6_C.cpp
 *
 *  Created on: 2016/05/18
 *      Author: suna
 */

#include <iostream>

using namespace std;

int main(void)
{
	int kensu;	//??¶??°
	static char SPACE = ' ';
	static int number_of_rooms_floor = 10; //1????????¢??????????????¨?±???°
	static int kaisu = 3;					//??¬???????????°
	static int munesu = 4;					//??¬???????£???°
	static int min_nyukyosha = 0;			//1??¨?±?????????????????°??????°
	int nyukyosha[munesu][kaisu][number_of_rooms_floor]; //??\?±??????°

	int input_mune;  		//??\?????????????£???????
	int input_kaisu; 		//??\???????????????
	int input_room;  		//??\??????????????¨?±???????
	int input_nyukyosha; 	//??\??????????????\?±??????°

	//??\?±??????°????????????
	for(int i = 0; i < munesu; i++)
	{
		for(int j = 0; j < kaisu; j++)
		{
			for(int k = 0; k < number_of_rooms_floor; k++)
			{
				nyukyosha[i][j][k] = min_nyukyosha;
			}
		}
	}

	//??¶??°??\???
	cin >> kensu;

	//??\?±??????°??\???
	for(int i = 0; i < kensu; i++)
	{
		cin >> input_mune >> input_kaisu >> input_room >> input_nyukyosha;
		nyukyosha[input_mune-1][input_kaisu-1][input_room-1] += input_nyukyosha;
	}

	//??????
	for(int i = 0; i < munesu; i++)
	{
		if(i != 0)
		{
			cout << "####################" << endl;
		}

		for(int j = 0; j < kaisu; j++)
		{
			for(int k = 0; k < number_of_rooms_floor; k++)
			{
				cout << SPACE << nyukyosha [i][j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>

using namespace std;

namespace {

class Dice {
 private:
  enum Face {
    TOP,     // 1
    FRONT,   // 2
    RIGHT,   // 3
    LEFT,    // 4
    BACK,    // 5
    BOTTOM,  // 6
  };

 public:
  Dice(const int* face) { copy(face, face + 6, face_); }

  void west() { rotate(TOP, RIGHT, BOTTOM, LEFT); }

  void east() { rotate(TOP, LEFT, BOTTOM, RIGHT); }

  void north() { rotate(TOP, FRONT, BOTTOM, BACK); }

  void south() { rotate(TOP, BACK, BOTTOM, FRONT); }

  int top() const { return face_[TOP]; }

 private:
  void rotate(Face f1, Face f2, Face f3, Face f4) {
    const int t = face_[f1];
    face_[f1] = face_[f2];
    face_[f2] = face_[f3];
    face_[f3] = face_[f4];
    face_[f4] = t;
  }

  int face_[6];
};

}  // namespace

int main() {
  string ops;
  int face[6];
  for (int i = 0; i < 6; ++i) {
    cin >> face[i];
  }
  cin >> ops;

  Dice d(face);
  for (auto op : ops) {
    switch (op) {
      case 'W':
        d.west();
        break;
      case 'E':
        d.east();
        break;
      case 'N':
        d.north();
        break;
      case 'S':
        d.south();
        break;
    }
  }
  cout << d.top() << endl;

  return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main () {
	string s;
	cin >> s;
	int n = (int)s.size();
	vector<int> a(n+1);
	for (int i=0; i<n; i++) {
		if (s[i] == '<') a[i+1] = max(a[i+1], a[i] + 1);	
	}
	for (int i=n-1; i>=0; i--) {
		if (s[i] == '>') a[i] = max(a[i], a[i+1] + 1);
	}
	long long res = accumulate(a.begin(), a.end(), 0LL);
	cout << res;
	return 0;
}

Measured memory_bytes: 5836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll f(ll n) {
    return n * (n - 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> cnt;
    rep(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    vector<ll> dp(n + 1, 0);
    ll total = 0;
    for(auto x : cnt) {
        dp[x.first] = f(x.second);
        total += dp[x.first];
    }
    rep(i, n) {
        ll ans = total - dp[a[i]] + f(cnt[a[i]] - 1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    ll x = 0;
    for(int d = 40; d >= 0; --d){
        int zero = 0, one = 0;
        for(int i = 0; i < n; ++i){
            if((a[i] >> d) & 1) ++one;
            else    ++zero;
        }
        if(zero > one){
            if(x + (1LL << d) <= k){
                x += 1LL << d;
            }
        }
    }
    
    ll ans = 0;
    for(int i = 0; i < n; ++i)  ans += a[i] ^ x;
    cout << ans << endl;
}

Measured memory_bytes: 1024
{-# OPTIONS_GHC -O #-}
import Control.Monad
import Data.List
import Data.IntSet
import Data.Maybe

d9 = [59049, 6561, 729, 81, 9, 1] :: [Int]
d6 = [46656, 7776, 1296, 216, 36, 6, 1] :: [Int]

bfs c used q =
    case find (==0) q of
        Just _ -> c
        otherwise -> bfs (c+1) (Data.IntSet.union used $ fromList nuse) nuse
            where
                nuse = Data.List.filter (\e -> notMember e used) nexts
                nexts = concat [[n- (fromMaybe undefined $ find (<=n) d9), n- (fromMaybe undefined $ find (<=n) d6)] | n<-q]

main = do
    n <- readLn :: IO Int
    print $ bfs 0 empty [n]


Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
  int N; cin >> N;
  vector<int> p(N);
  rep(i,N){
    cin >> p[i];
  }
  int ans = 0;
  repr(i,1,N-1){
     if(max(p[i-1],max(p[i],p[i+1])) > p[i] && min(p[i-1],min(p[i],p[i+1])) < p[i]) ans++;
  }
  cout <<ans << endl;

}

Measured memory_bytes: 256
A = input()
B = input()

if len(A) > len(B):
    print("GREATER")
elif len(A) < len(B):
    print("LESS")
else:
    i = 0
    while True:
        if A[i] > B[i]:
            print("GREATER")
            break
        elif A[i] < B[i]:
            print("LESS")
            break
        else:
            if i == len(A)-1:
                print("EQUAL")
                break
            else:
                i += 1

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

int main(){
	
    string s,t,u;
    int a,b;

    
	cin >> s >> t;
    cin >> a >> b;
    cin >> u;
	
    if(s == u){
        a--;
    }else if(t == u) {
        b--;
    }

    
	cout << a << " " << b <<endl;	
}
		




Measured memory_bytes: 256
lines = $stdin.read.chomp.split("\n")
N, K = lines.shift.split(" ").map(&:to_i)

trick = (1..N).to_a

lines.each_slice(2) do |xss|
  xs = xss.last.split(" ").map(&:to_i)
  xs.each {|x| trick.delete(x) }
end

puts trick.count

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;
#define INF (INT_MAX / 4)


int main() {
  string S; cin >> S;
  rep(i, S.size()){
    i++;
    if (i % 2 != 0) cout << S[i-1];
  }
  cout << endl;
}

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

int main(){
  string ss;
  cin >> ss;
  int n=0;
  int s=0;
  int w=0;
  int e=0;
  for(int i=0;i<ss.size();i++){
    if(ss.at(i)=='N')n++;
    else if(ss.at(i)=='S')s++;
    else if(ss.at(i)=='W')w++;
    else e++;
  }
  if((n!=0&&s==0)||(n==0&&s!=0)||(w!=0&&e==0)||(w==0&&e!=0)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}
  

Measured memory_bytes: 256
#include<cstdio>
int main(){
	long long int a,b;
	scanf("%lld%lld",&a,&b);
	if(a%b==0){
		printf("-1\n");
	}else{
		for(long long int i=1;0==0;i++){
			if((a*i)%b!=0){
				printf("%lld\n",a*i);
				break;
			}
			if(a*i>1000000000000000000){
				printf("-1\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <deque>

using namespace std;

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

	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int maxR = N / R;
	int maxG = N / G;
	int maxB = N / B;

	long long result = 0;
	for (int i = 0; i <= maxR; i++)
	{
		if (i * R > N) break;
		for (int j = 0; j <= maxG; j++)
		{
			if (i * R + j * G > N) break;

			int left_box = N - (i * R + j * G);
			if (left_box % B == 0)
			{
				result++;
			}
		}
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
   long long  a,b;
   cin>>a>>b;
   long long dif=abs(abs(a)-abs(b));
   if(a>0&&b>0&&a<=b){
       cout<<dif<<endl;
   }
   if(a>0&&b>0&&a>b&&abs(a)<abs(b)){
       cout<<abs(a)+abs(b)+1<<endl;
   }
   if(a>0&&b>0&&abs(a)>abs(b)){
       cout<<dif+2<<endl;
   }
   if(a>0&&b<0){
       cout<<dif+1<<endl;
   }
   if(a<0&&b>0){
       cout<<dif+1<<endl;
   }
   if(a<0&&b<0&&a<=b){
       cout<<dif<<endl;
   }
   if(a<0&&b<0&&a>b){
       cout<<dif+2<<endl;
   }
   if(a==0&&b>=0){
       cout<<dif<<endl;
   }
   if(a==0&&b<0){
       cout<<dif+1<<endl;
   }
   if(b==0&&a<0){
       cout<<dif<<endl;
   }
   if(b==0&&a>0){
       cout<<dif+1<<endl;
   }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct{
	int u,v,co;
}wa;
bool com(const wa& a,const wa& b){
	return a.co<b.co;
}
wa way[1000];
int pa[1000];
int find(int t){
	if(pa[t]==t)
	return t;
	else return find(pa[t]);
}
void uni(int s,int t){
	s=find(s);
	t=find(t);
	pa[s]=t;
}
int same(int x,int y){
	return find(x)==find(y);
}
int main(){
	int n,m,sum;
	while(cin>>n>>m,n||m){
		sum=0;
		for(int i=0;i<m;i++)
			cin>>way[i].v>>way[i].u>>way[i].co;
		for(int i=0;i<n;i++)
			pa[i]=i;
		sort(way,way+m,com);
		for(int i=0;i<m;i++){
			if(!same(way[i].u,way[i].v)){
				uni(way[i].u,way[i].v);
				sum+=way[i].co;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

int n=50;
long long arr[55];

long long ans;

long long inf=10000000000000000ll + 1000ll;
int main(){
	//freopen("out.txt","w",stdout);
	cin>>ans;
	for(int i=0;i<n;i++){
		arr[i]=i;
	}
	while(ans > 0) {
		int ind=0;
		for(int i=1;i<n;i++){
			if(arr[i] < arr[ind]){
				ind = i;
			}
		}
		long long mn=1ll<<60;
		for(int i=0;i<n;i++){
			if(i==ind)continue;
			mn=min(mn,arr[i]);
		}

		long long times = (inf - arr[ind])/n;
		times = min (times, mn );
		times = min (times, ans);

		ans -=times;
		arr[ind] += n * times;
		for(int i=0;i<n;i++){
			if(i==ind)continue;
			arr[i] -= times;
		}
	}
	cout<<n<<endl;
	for(int i=0;i<n;i++){
		if(i==n-1){
			cout<<arr[i]<<endl;
		} else {
			cout<<arr[i]<< " ";
		}
	}
}

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

using namespace std;

int checker(int,int);

int main(){
  int A,B;
  cin >> A >> B;
  
  int ans = 0;
  
  for(int i = A; i <= B; i++){
    ans = checker(i,ans);
  }
  cout << ans << endl;
  return 0;
}

int checker(int x,int ans){
  int z = x;
  int xx[5];
  int ww = 10000;
  for(int i = 0; i< 5 ; i++){
    xx[i] = z / ww;
    z -= xx[i] * ww;
    ww /= 10;
  }

  
  if(xx[0] == xx[4] && xx[1] == xx[3]){
    ans++;
  }
  return ans;
}

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

int LCM(int a, int b) {
    return a / __gcd(a, b) * b;
}

int main() {
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int ans = LCM(a, b);
    for (int i = 0; i < n - 2; i++) {
        cin >> a;
        ans = LCM(ans, a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
s = gets.chomp.bytes
w = 'W'.ord
ans = 0
wc = 0
s.size.pred.downto(0) do |i|
  if s[i] == w
    wc += 1
  else
    ans += wc
    wc -= 0
    wc = 0 if wc < 0
  end
end
puts ans

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

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

  long int sum;
  int a,b,c;

  sum = 0;
  for(int i=1;i<=K;++i){
    for(int j=1;j<=K;++j){
      for(int k=1;k<=K;++k){
        c = 1;
        a = i;
        b = j;
        while(c!=0){
          c = a%b;
          a = b;
          b = c;
          //cout<<"c1="<<c<<endl;
        }
        c = 1;
        b = a;
        a = k;
        while(c!=0){
          c = a%b;
          a = b;
          b = c;
          //cout<<"c2="<<c<<endl;
        }
        //cout<<i<<" "<<j<<" "<<k<<" b="<<b<<endl;
        sum = sum + a;
      }
    }
  }
  
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3644
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC114_A solver = new ABC114_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC114_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            if (x == 3 | x == 5 | x == 7) {
                out.print("YES");
            } else {
                out.print("NO");
            }
        }

    }
}



Measured memory_bytes: 21844
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val r: Double = readLine.d(0)
    val p: Double = scala.math.Pi
    val a: Double = scala.math.pow(r, 2) * p
    val b: Double = r * 2 * p
    println(f"$a%.6f $b%.6f")
  }
}

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

double bit(long long x)
{
  return log(x) / log(2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
	cin >> a[i];
  }
  vector<long long> b(n + 1);
  b[0] = 0;
  for (int i = 1; i <= n; i++) {
	b[i] = b[i - 1] + a[i - 1];
  }
  vector<long long> sums;
  for (int i = 0; i <= n; i++) {
	for (int j = i + 1; j <= n; j++) {
	  sums.push_back(b[j] - b[i]);
	}
  }
  sort(sums.begin(), sums.end(), greater<long long>());
  int mx_bit = floor(bit(sums[0])) + 1;
  long long ans = 0;
  for (int i = mx_bit; i >= 0; i--) {
	int cnt = 0;
	for (int j = 0; j < sums.size(); j++) {
	  if ((1 & (sums[j] >> i)) == 1) cnt++;
	}
	if (cnt >= k) {
	  for (int j = 0; j < sums.size(); j++) {
		if ((1 & (sums[j] >> i)) == 0) sums[j] = 0;
	  }
	  ans += pow(2, i);
	}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = sc.nextInt();
      int[] p = new int[N];
      int max = 0,sum = 0;
      for (int i = 0; i < N; i++) {
        p[i] = sc.nextInt();
        sum += p[i];
        max = Math.max(max, p[i]);
      }
      System.out.println(sum - max / 2);
    }
  }
}

Measured memory_bytes: 21844
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	ll k;
	cin >> s >> k;
	int n = (int)(s.size());
	int f = 1;
	repn(i, 1, n){
		if(s[i] != s[i - 1]){
			f = 0;
			break;
		}
	}
	if(f){
		cout << (n * k) / 2 << endl;
		return 0;
	}
	if(s[0] == s[n - 1]){
		int ind = 1;
		ll cur = 1;
		while(ind < n && s[ind] == s[0]){
			cur++;
			ind++;
		}
		int ind1 = n - 1;
		while(ind1 > 0 && ind1 >= ind && s[0] == s[ind1]){
			cur++;
			ind1--;
		}
		ll ans1 = (cur / 2) * (k - 1);
		ll ans = 0;
		cur = 1;
		repn(i, ind + 1, ind1 + 1){
			if(s[i] == s[i - 1]){
				cur++;
			}
			else{
				ans += cur / 2;
				cur = 1;
			}
		}
		ans += cur / 2;
		cur = 1;
		ind1 = n - 2;
		while(ind1 > 0 && ind1 >= ind && s[n - 1] == s[ind1]){
			cur++;
			ind1--;
		}
		ind = 1;
		ll cur1 = 1;
		while(ind < n && s[ind] == s[0]){
			cur1++;
			ind++;
		}
		ans *= k;
		ans += cur / 2;
		ans += cur1 / 2;
		cout << ans + ans1 << endl;
	}
	else{
		ll ans = 0;
		ll cur = 1;
		repn(i, 1, n){
			if(s[i] == s[i - 1]){
				cur++;
			}
			else{
				ans += cur / 2;
				cur = 1;
			}
		}
		ans += (cur / 2);
		ans *= k;
		cout << ans << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	char s[500002] = {0};
	int L = 200001;
	int R = L;

	string S;
	long long Q;
	cin >> S;
	cin >> Q;
	strcpy(s+L, (const char*)S.c_str());
	R = L + strlen(S.c_str()) -1;
	
	int rev = 0;
	for(int i=1; i<=Q; i++){
		int t, f;
		char c;
		cin >> t;
		if(t == 1){
			rev = (rev + 1) % 2;
		}
		else if(t == 2){
			cin >> f;
			cin >> c;
			if(f == 1){
				if(rev == 0){
					s[L - 1] = c;
					L--;
				}
				else{
					s[R + 1] = c;
					R++;
				}
			}
			else if(f == 2){
				if(rev == 0){
					s[R + 1] = c;
					R++;
				}
				else{
					s[L - 1] = c;
					L--;
				}
			}
		}
	}
	if(rev == 0){
		for(int i=L; i<=R; i++){
			printf("%c", s[i]);
		}
	}
	else if(rev == 1){
		for(int i=R; i>=L; i--){
			printf("%c", s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 4240
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  string ans = "-1 -1 -1";
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      int k = N - j - i;
      if (k < 0) continue;
      if (i * 10000 + j * 5000 + k * 1000 == Y) {
        ans = to_string(i) + ' ' + to_string(j) + ' ' + to_string(k);
        break;
      }
    }
    if (ans != "-1 -1 -1") break;
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int[] vdata = new int[n];
      int[] cdata = new int[n];

      for (int i = 0;i<n;i++ ) {
         vdata[i] = sc.nextInt();
      }
      for (int i = 0;i<n;i++ ) {
         cdata[i] = sc.nextInt();
      }
      System.out.println(Resale(vdata,cdata,n));
    }


      public static int Resale(int[] vdata,int[] cdata,int n){
        int sum = 0;
        for (int i = 0;i<n;i++ ) {
           if (vdata[i]-cdata[i]>0) {
              sum += vdata[i]-cdata[i];
           }
        }
        return sum;
      }
    }


Measured memory_bytes: 21844
#include<stdio.h>

int main()
{
	long int m,n,a;
	while(1)
	{
		a=0;
		scanf("%d",&m);
		if(m==0)
			break;
		for(n=5;n<=m;n*=5)
			a+=m/n;
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll K;
  cin >> K;
  ll m = 0;
  FOR(i, 1, K + 1) {
    m = (10 * m + 7) % K;
    if (m % K == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3524
import sys
import bisect

input = sys.stdin.readline

N, Q = map(int, input().split())

STX_array = [list(map(int, input().split())) for _ in range(N)]

STX_array = sorted(STX_array, key=lambda x: x[2])

Q_array = [int(input()) for _ in range(Q)]

index_array = [i for i in range(Q)]

ans_array = [-1] * Q
for STX in STX_array:
    s, t, x = STX
    index_left = bisect.bisect_left(Q_array, s - 0.5 - x)
    index_right = bisect.bisect_left(Q_array, t - 0.5 - x)
    if index_left != index_right:
        now_index = index_left
        while now_index < index_right:
            if index_array[now_index] == now_index:
                ans_array[now_index] = x
                index_array[now_index] = index_right
                now_index += 1
            else:
                old_index = now_index
                now_index = index_array[now_index]
                index_array[old_index] = now_index




for ans in ans_array:
    print(ans)

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];

  int numOdd=0;
  rep(i,n)if(a[i]%2!=0)numOdd++;
  if(numOdd%2==0)cout << "YES" << endl;
  else cout << "NO" << endl; 
}


Measured memory_bytes: 640
import Data.List  -- sort

height_of_top3 :: [Int] -> [Int]
height_of_top3 = (take 3) . reverse . sort

main = do
  s <- getContents               -- get all input
  let hs = map read . lines $ s  -- break it into [Int]
      ts = height_of_top3 hs     -- the answer
  putStr . unlines . map show $ ts

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 5005; // CAMBIAR ESTE

// GJNM
char A[maxN];
set<string> unq;

int main(){
	int k;
	scanf("%s", A);
	ri(k);
	int n = strlen(A);
	priority_queue<string> pq;
	FOR(i,0,n){
		string s;
		int j = i;
		while(j<n && j-i <=5){
			s += A[j];
			j++;
			if ( unq.count(s) > 0 ){
				continue;
			}
			else{
				unq.insert(s);
			}
			
			if ( pq.size() < k ){
				pq.push(s);
			}
			else{
				if ( s.compare(pq.top()) < 0 ){
					pq.pop();
					pq.push(s);
				}
			}
		}
	}
	cout<< pq.top() << endl;
	return 0;
}

Measured memory_bytes: 2176
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m, d;
    cin >> n >> m >> d;
    cout << fixed << setprecision(20);
    if (d == 0) {
        cout << 1.0 * (m - 1) / n << endl;
    } else {
        cout << 2.0 * (n - d) * (m - 1) / n / n << endl;
    }
}

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

int main(){
  string S;
  cin >> S;
  int n=0,w=0,s=0,e=0;
  for(int i=0;i<S.size();++i){
    if(S.at(i)=='N') ++n;
    else if(S.at(i)=='W') ++w;
    else if(S.at(i)=='S') ++s;
    else ++e;
  }
  bool x=false,y=false;
  if((n==0&&s==0) || (n>0&&s>0)) y=true;
  if((w==0&&e==0) || (w>0&&e>0)) x=true;
  if(x&&y) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
	long long int k;
	cin >> k;
	cout << "50" << endl;
	int i;
	
	for(i=1;i<=50-k%50;i++)
	{
	cout << 49-k%50+k/50 << " ";	
	}
	for(i=1;i<=k%50;i++)
	{
		cout << 50+(50-k%50)+k/50 << " ";
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pa pair<int,int>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
const int maxn=1;

inline char gc(){
	return getchar();
	static const int maxs=1<<16;static char buf[maxs],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxs,stdin),p1==p2)?EOF:*p1++;
}
inline ll rd(){
    ll x=0;char c=gc();bool neg=0;
    while(c<'0'||c>'9'){if(c=='-') neg=1;c=gc();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=gc();
    return neg?(~x+1):x;
}



int main(){
    //freopen("","r",stdin);
    int N,K;
    N=rd(),K=rd();
    if(K==1){puts("0");return 0;}
    printf("%d\n",N-K);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,k,x=1;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        if(x*2>=x+k) x+=k;
        else x*=2;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A.sort()

a=A[-1]/2
tmp=A[-1]
ans=0
for i in range(n):
    if(abs(a-A[i]) < tmp):
        tmp=abs(a-A[i])
        ans=A[i]

print("{} {}".format(A[-1],ans))

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

a=[list(map(int,input().split())) for i in range(M)]
a1=[a[i][0] for i in range(M)]
a2=[a[i][1] for i in range(M)]

ans=max(0,min(a2)-max(a1)+1)
print(ans)

Measured memory_bytes: 29132
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var N = parseInt(input[0][0], 10);
    var X = input[1][0];
    var vec_fn = [];
    var tmp;
    for (var i = 0; i < 200000; i++){
        tmp = (i + 1) % popcount(i + 1);
        if (tmp === 0) vec_fn.push(1);
        else vec_fn.push(vec_fn[tmp - 1] + 1);
    }
    var howMany1 = 0;
    for (var i = 0; i < N; i++){
        if (X.substr(i, 1) === '1') howMany1 ++;
    }

    // 1が増えたとき
    var tmpRemain1 = 1;
    var default_remain1 = 0;
    // 0が増えたとき
    var tmpRemain2 = 1;
    var default_remain2 = 0;

    v_remain1 = [];
    v_remain2 = [];

    for (var i = N - 1; i >= 0; i--){
        v_remain1.push(tmpRemain1);
        v_remain2.push(tmpRemain2);
        if (X.substr(i, 1) === '1'){
            default_remain1 += tmpRemain1;
            default_remain1 %= (howMany1 + 1);
            default_remain2 += tmpRemain2;
            default_remain2 %= (howMany1 - 1);
        }
        tmpRemain1 *= 2;
        tmpRemain1 %= (howMany1 + 1);
        tmpRemain2 *= 2;
        tmpRemain2 %= (howMany1 - 1);
    }
    var v_ans = [];
    for (var i = 0; i < N; i++){
        if (X.substr(i, 1) === '1'){
            if ((howMany1 - 1) === 0) v_ans.push(-1);
            else v_ans.push(mod(default_remain2 - v_remain2[N - i - 1], howMany1 - 1));

        } else {
            v_ans.push(mod(default_remain1 + v_remain1[N - i - 1], howMany1 + 1));
        }
    }
    for (var i = 0; i < v_ans.length; i++){
        if (v_ans[i] === -1) v_ans[i] = 0;
        else if (v_ans[i] === 0) v_ans[i] = 1;
        else v_ans[i] = vec_fn[v_ans[i] - 1] + 1;
    }
    console.log(v_ans.join("\n"));
}

function mod(i, j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}

function popcount(n) {
    var digit = n.toString(2).split("").map(e => parseInt(e, 10));
    return sum(digit);
}

sum  = function(arr) {
    var sum = 0;
    arr.forEach(function(elm) {
        sum += elm;
    });
    return sum;
};

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

Measured memory_bytes: 58196
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll s;cin>>s;
    ll x[3][2];
    x[0][0]=x[0][1]=0;
    x[1][0]=1e+9;
    x[1][1]=1;
    x[2][1] = s/x[1][0]+1;
    x[2][0] = x[1][0] - s%x[1][0];
    if(s==ll(1e+18)){
        x[1][1]--;x[2][1]--;
    }
    rep(i,3){
        rep(j,2){
            cout << x[i][j];
            if(i==2&&j==1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        string s = to_string(i);
        if (s.size() & 0x1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

mask = 0b0
end = 2**(n-1)
ans = 0
for i in range(2**10):
    if(mask >= end):
        break
    word = s[0]
    for j in range(n-1):
        if(mask & 1<<j):
            word += '+'
        word += s[j+1]
    ans += eval(word)
    mask += 1
print(ans)

Measured memory_bytes: 3064
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

int n;
string s;
int A[10];

int dfs(int i,int sum,int tmp_num){
    if(i == n - 1) return sum + tmp_num * 10 + A[i];
    else{
        return dfs(i+1,sum,tmp_num * 10 + A[i]) + dfs(i+1,sum + tmp_num * 10 + A[i],0);
    }
}


signed main(){
    cin >> s;
    n = s.size();
    REP(i,n) A[i] = s[i] - '0';

    cout << dfs(0,0,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  string s;
  cin >> n >> s;
  LL inner = 0ll;
  LL answer = 1;
  REP(i,n*2) {
    if((s[i]+i)&1) {
      answer = answer*inner%p;
      --inner;
      if(inner<0) answer = 0ll;
    } else {
      ++inner;
    }
  }
  if(inner) answer = 0ll;
  REP(i,n) answer = answer*(i+1)%p;
  cout << answer << endl;
  return 0;
}


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

// m[i][j] : 2でi回割り切れ、5でj回割り切れる数
int m[20][20];

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  REP(i,N) {
    // * 10^9 して、全部整数とする
    double a;
    cin >> a;
    ll b = ((a * (double)1000000000) + 0.5);
//    cout << " " << a << "  -> " << b;
    int n2= 0, n5 = 0;
    // 素因数分解したときの2の係数を求める
    while ( b % 2 == 0 ) {
      n2++;
      b /= 2;
    }
    // 素因数分解したときの5の係数を求める
    while ( b % 5 == 0 ) {
      n5++;
      b /= 5;
    }
    n2 = min(n2, 18);
    n5 = min(n5, 18);
//    cout << " " << n2 << " " << n5 << endl;
    for ( int i=18-n2; i < 19; i++ ) {
      for ( int j=18-n5; j < 19; j++ ) {
        ans += m[i][j];
      }
    }
    m[n2][n5]++;
  }
  cout << ans << endl;

}




Measured memory_bytes: 3688
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	string s;
	cin >> s;
	for (size_t i = 0; i < s.size() - 1; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No";
	cout << endl;
}
int main() {
	Solve();
	return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n,m,k,i;
	cin>>n>>m>>k;
	ll a[n],b[m];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<m;i++)
		cin>>b[i];
	for(i=1;i<n;i++)
		a[i]+=a[i-1];
	for(i=1;i<m;i++)
		b[i]+=b[i-1];
	ll ans=(ll)(ub(a,a+n,k)-a);
	ans=max(ans,(ll)(ub(b,b+m,k)-b));
	for(i=0;i<n;i++)
		if(a[i]<=k)
			ans=max(ans,(ll)(i+1+(ub(b,b+m,k-a[i])-b)));
	for(i=0;i<m;i++)
		if(b[i]<=k)
			ans=max(ans,(ll)(i+1+(ub(a,a+n,k-b[i])-a)));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6716
N = int(input())
T, A = map(int, input().split())
hList = list(map(int, input().split()))
closest = 99999999
cIndex = 0

for i, temp in enumerate(hList):
  t = T - 0.006 * temp
  if closest > abs(A - t):
    closest = abs(A - t)
    cIndex = i

print(cIndex + 1)

Measured memory_bytes: 3064
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 10001
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

tprimes = [False for i in range(MAX)]

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

for i in range(2, MAX):
    if primes[i] and primes[i-2]:
        tprimes[i] = True

while True:
    n = int(input())
    if n == 0:
        break

    for i in range(n, -1, -1):
        if tprimes[i]:
            print(i-2, i)
            break



Measured memory_bytes: 5708
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int i,l,j,a[100],b[100],w=0,k=0;
	for(i=0;i<10;i++){
	cin>>a[i];
	}
	for(l=0;l<10;l++){
	cin>>b[l];
	}
	sort(a,a+10);
	sort(b,b+10);
	for(j=9;j>6;j--){
		w+=a[j];
		k+=b[j];
	}
	cout<<w<<" "<<k<<endl;
return 0;
}

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

int main(){
  int N, L;
  cin >> N >> L;
  int s = N*(L+N+L-1)/2;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    int t = s - (L+i);
    if(abs(ans-s) > abs(t-s)) ans = t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
result = []
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        result.append(a+b)
    elif op == '-':
        result.append(a-b)
    elif op == '*':
        result.append(a*b)
    else:
        result.append(a//b)

for i in range(len(result)):
    print(result[i])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b = "No";
	cin >> a;
	int conta =0,contb =0;
	sort(a.begin(), a.end());
	if(a[0] == a[a.size()-1]) cout << "No";
	else
	{
		char x = a[0];char y =a[a.size()-1];
		for(int i =0; i < a.size(); ++i)
		{
			if(x == a[i])conta++;
			if(y == a[i]) contb++;
			if(conta == 2 && contb == 2) b = "Yes";
		}
		cout << b;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int h, w, n; input(h,w,n);
    vector<int> a(n), b(n);
    map<PII, ll> mp;
    int dx[] = {-1,0,1,-1,0,1,-1,0,1}, dy[] = {-1,-1,-1,0,0,0,1,1,1};
    REP(i, n) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        REP(j, 9) {
            int x = a[i] + dx[j], y = b[i] + dy[j];
            if (x > 0 && x < h - 1 && y > 0 && y < w - 1) mp[PII(x, y)]++;
        }
    }
    vector<ll> cnt(10, 0);
    ll sum = 0;
    for (auto p : mp) {
        cnt[p.second]++;
        sum++;
    }
    cnt[0] = (ll)(h - 2)*(w - 2) - sum;
    REP(i, 10) {
        cout << cnt[i] << endl;
    }
    getchar(); getchar();
}

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

int main() {
	int n;cin>>n;
	long long a[n];
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		while(a[i]%2==0){
			ans++;
			a[i]/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    chmax(ans,a*10+b+c);
    chmax(ans,b*10+a+c);
    chmax(ans,c*10+a+b);
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<pair<int, int>> v;
		REP(i, n)
		{
			int m, a, b;
			cin >> m >> a >> b;
			v.push_back(make_pair(a, m));
			v.push_back(make_pair(b, -m));
		}
		sort(v.begin(), v.end());
		ll w = 0;
		bool f = true;
		REP(i, 2*n)
		{
			w += v[i].second;
			if (w > 150) f = false;
		}
		if (f) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int A = 0;
    int B = 0;
    cin >> A >> B;

    int AplusB = A + B;
    if(AplusB % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << AplusB/2 << endl;
    }
    return 0;
}

/**
 cheat sheet

 vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
 sort(v.begin(), v.end());
 => 0 1 2 3 4 5 6 7 8 9

 vector<int> v{ 1, 5, 8, 9, 6, 7, 3, 4, 2, 0 };
 sort(v.begin(), v.end(), greater<int>());
 => 9 8 7 6 5 4 3 2 1 0

 struct A { int x, y; };
 bool comp(A i1, A i2) { return (i1.y < i2.y); }
 vector<A> v { { 6, 8 }, { 1, 9 }, { 2, 4 }, { 4, 7 } };
 sort(v.begin(), v.end(), comp);
 => [1, 9] [2, 4] [4, 7] [6, 8]

 */


Measured memory_bytes: 256