akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) (x).begin(), (x).end()

using namespace __gnu_pbds;
using namespace std;

using ull = unsigned long long;
using ll = long long;
using ld = long double;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            c1++;
        else c2++;
    }

    int ans = 0;
    for (int i = 0; i < c1; i++) {
        ans += (s[i] == 'W');
    }

    cout << min({ans, c2, c1}) << "\n";
    return 0;
}

Measured memory_bytes: 3756
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
aa = inpl()

cnt = 1
for a in aa:
    if a == cnt:
        cnt += 1

if cnt == 1:
    print(-1)
else:
    print(N-cnt+1)


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    array<string,3> s;
    string ans = "";
    for (int i = 0; i < 3; ++i) {
        cin >> s[i];
        ans += toupper(s[i][0]);
    }
    cout << ans << endl;

    return 0;
}


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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }

	    long[] dp = new long[n + 3];
	    dp[0] = 1;
	    for ( int i = 0; i < n; i++ ) {
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
		dp[i + 3] += dp[i];
	    }

	    System.out.println( dp[n] / 3650L + ( dp[n] % 3650L == 0 ? 0 : 1) );
	}
	
    }
    
}

Measured memory_bytes: 17192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#define pb push_back
     
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


void solve(ll casen)
{
    ll res = 0;
    
    cout << "Case #" << casen << ": " << res << endl;
}

int main()
{
    // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp

    // !!! Here, unordered map was too slow!!!
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    
   ull a;
   string b;
   cin >> a >> b;


   ull bb = 0;

   bb += (b[0] - '0');
   bb *= 10;
   bb += (b[2] - '0');
   bb *= 10;
   bb += (b[3] - '0');

   //ull bb = 100ULL*b;

   ull res = a*bb;
   res /= 100;
   cout << res << endl;


   //1000000000000000000
   //1000000000000000000



  

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	char a;
	int x;
	int s[13] = {0};
	int h[13] = {0};
	int c[13] = {0};
	int d[13] = {0};
	for(int i = 0; i < n; i++) {
		cin >> a >> x;
		if(a == 'S') {
			s[x-1]++;
		}
		if(a == 'H') {
			h[x-1]++;
		}
		if(a == 'C') {
			c[x-1]++;
		}
		if(a == 'D') {
			d[x-1]++;
		}
	}
	for(int i = 0; i < 13; i++) {
		if(s[i] == 0) {
			cout << "S " << i+1 << endl;
		}
	}
	for(int i = 0; i < 13; i++) {
		if(h[i] == 0) {
			cout << "H " << i+1 << endl;
		}
	}
	for(int i = 0; i < 13; i++) {
		if(c[i] == 0) {
			cout << "C " << i+1 << endl;
		}
	}
	for(int i = 0; i < 13; i++) {
		if(d[i] == 0) {
			cout << "D " << i+1 << endl;
		}
	}
}


Measured memory_bytes: 3108
#include <stdio.h>
#define N 100

int bubbleSort(int *,int);
void printA(int *,int);
void swap(int *,int *);

int main(){
  int i,n,A[N],count;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  count=bubbleSort(A,n);
  printA(A,n);
  printf("%d\n",count);
  return 0;
} 

int bubbleSort(int A[],int n){
  int i,j,flag = 1,count=0;
  while(flag){
    flag = 0;
    for(j=n-1;j>0;j--){
      if (A[j] < A[j-1]){
	swap(&A[j],&A[j-1]);
	flag = 1;
	count++;
      }
    }
  }
  return count;
}

void printA(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n");
}

void swap(int *p1,int *p2){
  int temp;
  temp=*p1;
  *p1=*p2;
  *p2=temp;
}



Measured memory_bytes: 2048
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    string s;
    string start = "";
    string end = "";
    int q;
    bool endofend = true;
    cin >> s >> q;
    REP(i,q){
        int t;
        int f;
        char c;
        cin >> t;
        if(t == 1){
            endofend ^= true;
        }else if(t == 2){
            cin >> f >> c;
            if(f == 1){
                if(endofend){
                    s.insert(s.begin(),c);
                }else{
                    s.push_back(c);
                }
            }else if(f == 2){
                if(endofend){
                    s.push_back(c);
                }else{
                    s.insert(s.begin(),c);
                }
            }
        }
    }
    if(!endofend)
        reverse(ALL(s));
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 900
N,M = gets.split.map(&:to_i)
a = Array.new
b = Array.new
c = Array.new
d = Array.new
A = Array.new
B = Array.new

for i in 0..N-1
    a[i],b[i] = gets.split.map(&:to_i)
end

for i in 0..M-1
    c[i],d[i] = gets.split.map(&:to_i)
end

for i in 0..N-1
    A[i] = Array.new
    for j in 0..M-1
        A[i][j] = (a[i]-c[j]).abs + (b[i]-d[j]).abs
    end
end

for k in 0..N-1
    B[k] = A[k].index(A[k].min) + 1
end

puts B


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main() {
	string S;
	cin >> S;
	int a=0;
	string SS = "hi";
	int N = S.size();
	if (N % 2 != 0) {
			a = 1;
			}
	else {
		rep(i, N) {

			if (i % 2 == 0 && S[i] != SS[0])a = 1;
			if (i % 2 == 1 && S[i] != SS[1])a = 1;
		}
	}
		if (a == 0)cout << "Yes";
		else cout << "No";
	}
			

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

using ll = long long;

int main()
{
	int N;
	scanf("%d", &N);
	static ll dat[100001];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll A;
		scanf("%lld", &A);
		dat[A]++;
		ans += A;
	}

	int Q;
	scanf("%d", &Q);
	for (int q = 0; q < Q; q++) {
		int B, C;
		scanf("%d%d", &B, &C);
		ll diff = dat[B] * (C - B);
		ans += diff;
		if (B != C) {
			dat[C] += dat[B];
			dat[B] = 0;
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 2456
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N*2];
		int count =0;
		for (int i=0;i<N*2;i++) {
			A[i]= sc.nextInt();
		}
		Arrays.sort(A);
		for (int i=0;i<N*2;i+=2) {
			count +=A[i];
		}
		System.out.print(count);
	}
}

Measured memory_bytes: 35928
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		int key = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > key) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = key;
		for (int i = 0; i < n-1; i++) {
			cout << a[i] << ' ';
		}
		cout << a[n - 1] << '\n';
	}
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, p; cin >> n >> p;
    string s; cin >> s;
    reverse(s.begin(), s.end());

    if (p == 2 || p == 5) {
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if((s[i] - '0') % p == 0) ans += n - i;
        }
        cout << ans << endl;
        return 0;
    }
    
    vector<ll> dp(n + 1);
    dp[1] = 1;
    for (int i = 1; i < n; i++) dp[i + 1] = (dp[i] * 10) % p;
    for (int i = 0; i < n; i++) {
        (dp[i + 1] *= s[i] - '0') %= p;
        (dp[i + 1] += dp[i]) %= p;
    }
    vector<ll> cnt(p);
    for (auto &e: dp) cnt[e]++;

    ll ans = 0;
    for (auto &e: cnt) ans += e * (e - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;

	char ar[n][m+1];
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>ar[i][j];
		}
	}
	
	ll ps1[n][m],ps2[n][m];
	memset(ps1,0,sizeof(ps1)); 
	memset(ps2,0,sizeof(ps2));
	for(i=0;i<m;i++){
		k=0;
		for(j=0;j<n;j++){
			if(ar[j][i]=='.'){
				k++;
			}
			else {
				//cout<<i<<" "<<j<<" "<<k<<endl;
				for(l=j-1;l>=0;l--){
					if(ar[l][i]=='#') break;
					ps1[l][i]=k;
				}
				k=0;
			}
		}
		for(l=j-1;l>=0;l--){
			if(ar[l][i]=='#') break;
			ps1[l][i]=k;
		}
		k=0;
	}
	

	for(i=0;i<n;i++){
		k=0;
		for(j=0;j<m;j++){
			if(ar[i][j]=='.'){
				k++;
			}
			else {
				for(l=j-1;l>=0;l--){
					if(ar[i][l]=='#') break;
					ps2[i][l]=k;
				}
				k=0;
			}
		}
		for(l=j-1;l>=0;l--){
			if(ar[i][l]=='#') break;
			ps2[i][l]=k;
		}
		k=0;
	}
	
	ll mx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			k=ps1[i][j]+ps2[i][j]-1;
			mx=max(mx,k);
		}
	}
	cout<<mx;
	return 0;
}


Measured memory_bytes: 66816
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
vector<string> BubbleSort(vector<string> vs, int n)
{
  int i, j, flag;
  for(i=1; i<n; i++)
  {
    flag = 0;
    for(j=0; j<n-i; j++)
    {
      if(vs[j][1] > vs[j+1][1])
      {
        swap(vs[j], vs[j+1]);
        flag = 1;
      }
    }
    if(flag == 0)
      break;
  }
  return vs;
}

vector<string> SelectionSort(vector<string> vs, int n)
{
  int i, j, minv;
  for(i=0; i<n-1; i++)
  {
    minv = i;
    for(j=i+1; j<n; j++)
    {
      if(vs[j][1] < vs[minv][1])
        minv = j;
    }
    swap(vs[i], vs[minv]);
  }
  return vs;
}

int pri(vector<string> vs, int n)
{
  for(int i=0; i<n; i++)
  {
    if(i)
      cout << " ";
    cout << vs[i];
  }
  cout << endl;
}

int isstable(vector<string> vsb, vector<string> vss, int n)
{
  for(int i=0; i<n; i++)
  {
    if(vsb[i] != vss[i])
    {
      printf("Not stable\n");
      return 0;
    }
  }
  printf("Stable\n");
  return 0;
}
int main()
{
  int n;
  scanf("%d", &n);
  vector<string> input, vsb, vss;
  for(int i=0; i<n; i++)
  {
    string temp;
    cin >> temp ;
    input.push_back(temp);
  }
  vsb = vss = input;
  vsb = BubbleSort(vsb, n);
  vss = SelectionSort(vss, n);
  pri(vsb, n);
  printf("Stable\n");
  pri(vss, n);
  isstable(vsb, vss, n);
  return 0;
}



Measured memory_bytes: 3216
A,B,C = map(int, input().split())

can_choose = True
work = C
while True:
    work += B
    work = work % A
    if work == 0:
        break
    elif work == (C % A):
        can_choose = False
        break

if can_choose:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9180
package main
import "fmt"

func main(){
    var s string
    fmt.Scan(&s)
    for i, char := range s {
        if i%2 == 0 { // 奇数
            if char == 76 { // L 
                fmt.Println("No")
                return
            }
        } else {
            if char == 82 { // R
                fmt.Println("No")
                return
            }
        }
    }
    fmt.Println("Yes")
}


Measured memory_bytes: 512
//AOJ ITP1_2_A

using System;

class sample
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        double a = double.Parse(str[0]);
        double b = double.Parse(str[1]);

        if (a > b) Console.WriteLine("a > b");
        else if (a < b) Console.WriteLine("a < b");
        else Console.WriteLine("a == b");
    }
}

Measured memory_bytes: 9232
//2018.09.21

#include <iostream>
using namespace std;


int main() {

    int a,b;
    cin >> a >> b;

    int a_state = b-a-1;
    int a_tall;

    if((a_state+1)%2==0) a_tall =(a_state+1)/2*a_state;
    else a_tall =(a_state+1)/2*(a_state+1);


    cout <<  a_tall - a << endl;

    return 0;
}

Measured memory_bytes: 256
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end
 
  cross_points = {}
  ans = n * n * n - k * n
  points.combination(2).each do |a, b|
    c = a.zip(b)
    next if c.any?{ |p, q| p == 0 && q == 0 }
    if c.any?{ |p, q| p == q }
      cp = c.map{ |p, q| [p, q].max }
      if !cross_points[cp] || cross_points[cp] < 2
        ans += 1
      end
      cross_points[cp] ||= 0
      cross_points[cp] += 1
    end
  end
  puts ans
end

Measured memory_bytes: 8744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];
    int hmax = (h[0] == 1) ? h[0] : h[0] - 1;
    rem(i, 1, n)
    {
        if (h[i] > hmax)
            hmax = h[i] - 1;
        else if (h[i] < hmax)
        {
            cout << "No"
                 << "\n";
            return 0;
        }
    }

    cout << "Yes"
         << "\n";

    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

button = [0] * N
button[0] = 1
next_button = 1
i = 0

while True:
  button[next_button - 1] = 2
  next_button = A[next_button - 1]
  if button[next_button - 1] == 2:
    print("-1")
    break
  elif next_button == 2:
    i += 1
    print(i)
    break
  else:
    button[next_button - 1] = 1
    i += 1



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, M;
	cin >> N >> M;
	map<int, int> K;
	int ac = 0, wa = 0;
	fx(M) {
		int p;
		string S;
		cin >> p >> S;
		if (S=="WA") {
			if (K[p]>=0) {
				K[p]++;
			}

		}
		else if(K[p]>=0){
			ac++;
			wa += K[p];
			K[p] = -1;
		}
	}
	doublece(ac,wa)

    return 0;
}



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

ll mod = 1e9+7;
ll f[1005];

void ff(int n)
{
	while(n%2 == 0)
	{
		f[2]++;
		n/=2;
	}

	for(int i = 3; i*i <= n; i+=2)
	{
		while(n%i == 0)
		{
			f[i]++;
			n/=i;
		}
	}

	if(n > 2)
		f[n]++;
}

int main()
{

	ll n;cin>>n;

	for(int i = 0; i < 1005; i++)
		f[i] = 0;

	for(int i = 2; i <= n; i++)
		ff(i);

	ll ans = 1;

	for(int i = 1; i < 1005; i++)
		ans =(ans%mod*(f[i]+1)%mod)%mod;


	cout<<ans<<"\n";


	return 0;
}

Measured memory_bytes: 256
while true
a,op,b = gets.chomp.split
  case op
  when "+"
    puts a.to_i + b.to_i
  when "-"
    puts a.to_i - b.to_i
  when "*"
    puts a.to_i * b.to_i
  when "/"
    puts a.to_i / b.to_i
  when "?"
          break
  end
end

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int h, w;
  vector<string> s;
  Solver(int h, int w) : h(h), w(w), s(h){};

  inline int nextCombination(int comb) {
    int x = comb & -comb, y = comb + x;
    return (((comb & ~y) / x) >> 1) | y;
  }
  void yes() {
    cout << "YES" << endl;
    exit(0);
  }
  void no() {
    cout << "NO" << endl;
    exit(0);
  }
  bool check(vector<int>& perm) {
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        grid[i].push_back(s[i][perm[j]]);
      }
    }
    vector<int> used(h);
    for (int i = 0; i < h; ++i) {
      if (used[i]) continue;
      string tmp = grid[i];
      reverse(tmp.begin(), tmp.end());
      for (int j = i + 1; j < h; ++j) {
        if (tmp == grid[j]) {
          used[i] = used[j] = 1;
          break;
        }
      }
    }
    if (h % 2 == 1) {
      if (accumulate(used.begin(), used.end(), 0) < h - 1) return false;
      int rest = 0;
      for (int i = 0; i < h; ++i) {
        if (used[i] == 0) {
          rest = i;
          break;
        }
      }
      string restRow = grid[rest], rev = restRow;
      reverse(rev.begin(), rev.end());
      return restRow == rev;
    } else {
      return accumulate(used.begin(), used.end(), 0) == h;
    }
  }
  void dfs(int used, int l, int pos, vector<int> perm) {
    DBG(perm)

    if (pos == -1) {
      if (w % 2 == 1) {
        for (int i = 0; i < w; ++i) {
          perm[w / 2] = i;
          dfs(1 << i, 0, 0, perm);
        }
      } else {
        dfs(used, 0, 0, perm);
      }
      return;
    }

    if (pos == w / 2) {
      if (check(perm)) yes();
      return;
    }
    if (((used >> l) & 1)) {
      dfs(used, l + 1, pos, perm);
      return;
    }
    for (int i = l + 1; i < w; ++i) {
      if (((used >> i) & 1) == 0) {
        perm[pos] = l;
        perm[w - pos - 1] = i;
        dfs(used | (1 << l) | (1 << i), l + 1, pos + 1, perm);
      }
    }
  }
  void solve() {
    for (int i = 0; i < h; ++i) {
      cin >> s[i];
    }
    vector<int> perm_col(w);

    dfs(0, 0, -1, perm_col);
    no();
  }
};  // namespace Problem
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  long long h = 0, w;
  std::cin >> h >> w;
  Problem::Solver sol(h, w);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

class BubbleSort{
private:
    std::vector<int> dataSet;
    int changeCount;
public:
    BubbleSort(std::vector<int> vec);
    void dataSort();
    void showVector();
    int getChangeCount();
};

BubbleSort::BubbleSort(std::vector<int> vec){
    this->dataSet = vec;
    this->changeCount = 0;
}

void BubbleSort::dataSort(){
    bool swapped = true;
    while(swapped){
        swapped = false;
        for(int i = 1;i < dataSet.size();i++){
            if(dataSet[i - 1] > dataSet[i]){
                int tmp = dataSet[i];
                dataSet[i] = dataSet[i - 1];
                dataSet[i - 1] = tmp;
                swapped = true;
                changeCount++;
            }
        }
    }
}

void BubbleSort::showVector(){
    for(int i = 0;i < dataSet.size();i++){
        std::cout << (i ? " " : "") << dataSet[i];
    }
    std::cout << std::endl;
}

int BubbleSort::getChangeCount(){
    return this->changeCount;
}



int main(){
    
    int content;

    std::cin >> content;

    std::vector<int> vec;

    for(int i = 0;i < content;i++){
        int num;
        std::cin >> num;
        vec.push_back(num);
    }

    BubbleSort bs = BubbleSort(vec);
    bs.dataSort();
    bs.showVector();
    std::cout << bs.getChangeCount() << std::endl;

    return 0;
    
}

Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	int  a = 0, b = 0;
	rep(i, n) {
		if ((i + 1) % k == 0)a++;
		else if (k % 2 == 0 && (i + 1) % k == k / 2)b++;
	}
	cout << a * a*a + b * b*b << endl;
	return 0;
}

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

int main(){
  vector<vector<int> > glid(3, vector<int>(3,0));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> glid[i][j];
    }
  }
  for(int i = 0; i < 3; i++){
    int sub = glid[i][0];
    for(int j = 0; j < 3; j++){
      glid[i][j] -= sub;
    }
  }
  if(glid[0] == glid[1] && glid[0] == glid[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{	
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}


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

int main()
{
    int a[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    int ans;
    for(int i=0;i<5;i++){
        if(a[i]==0){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;


int main(){
    int a,b,c;cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define maxn 15
#define maxm 1005

using namespace std;
typedef long long ll;
int n, m, k, cur[maxn][maxm];
char s[maxn][maxm];

int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", s[i] + 1);
  int ans = n + m;
  for (int S = 0; S < (1 << (n - 1)); S++) {
    int res = __builtin_popcount(S);
    for (int i = 1; i <= m; i++) {
      cur[n - 1][i] = cur[n - 1][i - 1] + (s[n - 1][i] == '1');
      for (int j = n - 2; j >= 0; j--) {
        cur[j][i] = cur[j][i - 1] + (s[j][i] == '1');
        if (!(S & (1 << j))) cur[j][i] += cur[j + 1][i] - cur[j + 1][i - 1];
      }
      bool ok = true;
      for (int j = 0; j < n; j++) ok &= (cur[j][i] <= k);
      if (!ok) {
        res++;
        for (int j = 0; j < n; j++) cur[j][i] -= cur[j][i - 1];
      }
      ok = true;
      for (int j = 0; j < n; j++) ok &= (cur[j][i] <= k);
      if (!ok) {
        res = n + m;
        break;
      }
    }
    ans = min(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  vector<ll> vec(3);
  rep (i, 3) cin >> vec[i];
  sort(vec.begin(), vec.end());
  cout << vec[0] << " ";
  cout << vec[1] << " ";
  cout << vec[2] << endl;
}

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



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

const int N = 200233;
int n, c[N];
vector<int> G[N];

int reach(int x, int fa, int lim) {
  int ret = 0;
  for (auto y : G[x]) if (y != fa) {
    if (y < lim) {
      ret += reach(y, x, lim) + 1;
    }
  }
  return ret;
}
void dfs(int x, int fa, int m0, int m1) {
  if (x > m1) {
    c[x] = c[fa] + 1 + reach(x, fa, m0);
  } else if (m0 > m1) {
    c[x] = c[fa] + reach(x, fa, m0) - reach(x, fa, m1);
  } else {
    c[x] = c[fa];
  }
  for (auto y : G[x]) if (y != fa) {
    dfs(y, x, max(m0, x), max(m1, fa));
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  c[1] = 0;
  dfs(1, 0, 1, 1);
  for (int i = 2; i <= n; i++) {
    printf("%d ", c[i]);
  }
}


Measured memory_bytes: 25856
using System;

namespace tes
{
    class Program
    {
        static void Main(string[] args)
        {

            int a = 0;
            int i = 0;
            int[] box = new int[10000];


            while (a < 30)
            {
                
                int x = int.Parse(Console.ReadLine());
                if (x != 0)
                {
                    box[i] = x;
                    i++;
                }
                else
                {
                    break;
                }
            }


            for (int z = 0; z < i; z++)
            {
                Console.WriteLine("Case " + (z+1) + ": " + box[z]);
            }

    

        }
    }
}

Measured memory_bytes: 9308
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


template<typename T>
class BIT{
    public:
        vector<T> x_list;
        ll n;

        BIT(ll n=1, T fill_value=0): n(n){
            x_list.resize(n+1);
            fill(x_list.begin(), x_list.end(), fill_value);
        }

        void add(ll idx, T v){
            for(ll x=idx; x<= n;x += (x & -x)){
                x_list[x] += v;
            }
        }

        ll get_sum(ll idx){
            T v = 0;
            for(ll x=idx;x>0;x-=(x & -x)){
                v += x_list[x];
            }
            return v;
        }
};

void Main(){
    ll N, Q, c, l, r;
    cin >> N >> Q;
    vector<ll> as(N);
    vector<vector<pll>> qs(N);
    // vector<pll> qs_org(Q);
    vector<ll> ans(Q);
    rep(i, N){
        cin >> as[i];
    }

    rep(i, Q){
        cin >> l >> r;
        -- l;
        -- r;
        qs[r].emplace_back(l, i);
        // qs_org[i] = make_pair(r, l);
    }

    // sort(qs.begin(), qs.end());

    map<ll,ll> color_best;
    // ll now_r = qs[0].first;

    BIT<ll> bitree(N, 0);

    rep(i, N){
        // if(color_best[as[i]]<=i){
            // continue;
        // }
        if(color_best.find(as[i])!=color_best.end() ){
            if(color_best[as[i]]<i){
                bitree.add(color_best[as[i]]+1, -1);
                bitree.add(i+1, 1);
                color_best[as[i]] = i;
            }
        }else{
            bitree.add(i+1, 1);
            color_best[as[i]] = i;
        }
        if(qs[i].size() == 0){
            continue;
        }
        for(auto q:qs[i]){
            ans[q.second] = bitree.get_sum(i+1) - bitree.get_sum(q.first);
        }
    }
    rep(i, Q){
        cout << ans[i] <<endl;
    }

}

int main(){
    Main();
}

Measured memory_bytes: 71624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

      final int numMax = 999_999;
      String line;
      int num;
      int result;

      List<Integer> prime = new ArrayList<>(100_000);
      prime.add(2);
      for ( Integer i = 3; i != numMax; i+=2 ) {
        if( isPrime(i,prime) ) {
          prime.add(i);
        }
      }

      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 1;
        for ( Integer i = 3; i <= num; i+=2 ) {
          if( isPrime(i,prime) ) {
            result += 1;
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(Integer num,List<Integer> prime) {
    Integer k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(Integer i: prime) {
      if ( num % i == 0 ) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 95828
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    int n,d;std::cin >> n>>d;
    
    std::cout << (n+d+d)/(d+d+1) << std::endl;
    
}


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

int main(){
  int n,b,a=1;cin>>n;
  for(int i=2;i*i<=n;i++){
    b=i*i;
    while(b<=n){
      a=max(a,b);
      b*=i;
    }
  }
  cout<<a;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>

using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,b) for(int i=0;i<int(b);i++)
typedef pair<int,int> pii;

int S(pii const& p){
    return p.first*p.second;
}

int main(){
    int n,W,H;
    while (cin>>n>>W>>H && W){
        vector<pii> cake;
        cake.push_back(pii(W,H));
        rep(_,n){
            int p,s;
            cin >> p >> s;
            pii t = cake[p-1];
            int w,h,r;
            tie(w,h) = t;
            r = s%(w+h);
            cake.erase(cake.begin() + (p-1));
            pii a,b;
            if (r<w){
                a=pii(r,h);
                b=pii(w-r,h);
            } else {
                r -= w;
                a = pii(w,r);
                b = pii(w,h-r);
            }
            if (S(a) > S(b)) swap(a, b);
            cake.push_back(a);
            cake.push_back(b);
        }
        vector<int> ans;
        rep(i,cake.size()){
            ans.push_back(S(cake[i]));
        }
        sort(all(ans));
        rep(i,ans.size()){
            printf("%d%c", ans[i], i==ans.size()-1 ? '\n':' ');
        }
    }
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

void solve(int N,int M,vi& l,vi& r) {
    int sq = sqrt(M); // 316
    bool just = (sq*sq == M);

    vi a(M+2, 0);

    vi left;
    left.reserve(sq+1);

    rep(i,N){ // 3e5
        double li=l[i], ri=r[i];
#ifdef DEBUG
        fprintf(stderr, "i=%d (%g..%g)\n", i, li, ri);
#endif
        a[l[i]]++; a[r[i]+1]--;
#ifdef DEBUG
        fprintf(stderr, "  [%g %g]\n", li, ri);
#endif
        int last_lo = li;
        left.clear();
        left.pb(1);
        for (int x=2; x<=sq; ++x) { // 316 ; < 9.5e7
            int lo=ceil(li/x), hi=floor(ri/x);
            hi = min(last_lo-1, hi);
            if (lo <= hi) {
#ifdef DEBUG
                fprintf(stderr, "  [%d %d]*%d\n", lo, hi, x);
#endif
                a[lo]++; a[hi+1]--;
                left.pb(x);
                last_lo = lo;
            }
        }
        if (just && sq < last_lo) {
            a[sq]++; a[sq+1]--;
            last_lo = sq;
#ifdef DEBUG
            fprintf(stderr, "  [%d] // sq\n", sq);
#endif
        }
#ifdef DEBUG
        cerr << "left=" << left << last_lo << endl;
#endif
#if 1
        for (int x : left) {
            if (x >= last_lo) break;
#ifdef DEBUG
            fprintf(stderr, "  [%d]\n", x);
#endif
            a[x]++; a[x+1]--;
        }
#endif
        // rep(i,M+1) a[i+1] += a[i];
        // cerr << i << ") " << a << endl;
        // a.assign(M+2, 0);
    }

    rep(i,M+1) a[i+1] += a[i];

    for (int i=1; i<=M; ++i) {
        cout << a[i] << endl;
    }
}

int main() {
    char buf[128];
    int N, M;
    // cin >> N >> M;
    scanf("%d %d", &N, &M);
    vi l(N),r(N);
    rep(i, N) {
        // cin >> l[i] >> r[i];
        scanf("%d %d", &l[i], &r[i]);
    }
    solve(N,M,l,r);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin >> n >> l;
	string s;
	vector<string> vs;
	for(int i=0;i<n;i++){
		cin >> s;
		vs.push_back(s);
	}
		sort(vs.begin(),vs.end());
		for(int i=0;i<n;i++){
			cout << vs[i];
	}
	cout << endl;

	return 0;
}

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

signed main(){
  string S;
  cin>>S;
  int SS=S.size();
  rep(i,SS){
    if(i==SS-1){
      if(S[SS-1]=='?'){
        S[SS-1]='D';
        break;
      }
    }
    if(i==0&&S[0]=='?'){
      if(S[i+1]=='P'){
        S[i]='D';
      }else{
        S[i]='P';
      }
      continue;
    }  
    if(S[i]=='?'){
      if(S[i-1]=='P'){
        S[i]='D';
        continue;
      }
      if(S[i+1]=='D'){
        S[i]='P';
        continue;
      }
      if(S[i+1]=='?'){
        S[i]='P';
        continue;
      }
      if(S[i-1]=='D'){
        S[i]='D';
      }
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
 
int main()
{
  ll a, b;
  cin >> a >> b;
  if ((a+b)%2==1) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (a+b)/2 << endl;
  return 0;
}

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

signed main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int& x : B) cin >> x;
    reverse(B.begin(), B.end());

    int ans = 0;
    for (auto it = B.begin(); it != B.end(); it++) {
        auto t = next(it, 1);
        if (t == B.end()) {
            t = it;
        }
        ans += min(*it, *t);
    }
    ans += B.front();
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define NUM 13
  
int main(){
 int num[NUM*4-1],ncmp,n,i,j;
 char pcmp;
 for(i=0; i<NUM; i++){
  num[NUM*0+i] = i+1;
  num[NUM*1+i] = i+1;
  num[NUM*2+i] = i+1;
  num[NUM*3+i] = i+1;
 }
 scanf("%d", &n);
 for(i=0; i<n; i++){
  scanf(" %c %d",&pcmp,&ncmp);
  for(j=0; j<NUM; j++){
   switch(pcmp){
    case 'S': if(ncmp==num[NUM*0+j]){num[NUM*0+j] = -1;} break;     
    case 'H': if(ncmp==num[NUM*1+j]){num[NUM*1+j] = -1;} break;
    case 'C': if(ncmp==num[NUM*2+j]){num[NUM*2+j] = -1;} break;
    case 'D': if(ncmp==num[NUM*3+j]){num[NUM*3+j] = -1;} break;
    defult:break;
   }
  }
 }
 for(i=0; i<NUM*4; i++){
  if(num[i]!=-1){
   if(i<NUM){printf("S %d\n", num[i]);}
   else if(NUM*1<=i&&i<NUM*2){printf("H %d\n", num[i]);}
   else if(NUM*2<=i&&i<NUM*3){printf("C %d\n", num[i]);}
   else if(NUM*3<=i&&i<NUM*4){printf("D %d\n", num[i]);}
  }
 }
 return 0;
}

Measured memory_bytes: 596
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

char field[12][12];

void dfs(int x, int y){
	field[x][y] = '0';
	for(int dx=-1; dx<=1; ++dx){
		for(int dy=-1; dy<=1; ++dy){
			if(dx != 0 && dy != 0) continue;
			int nx = x+dx, ny = y+dy;
			if(0 <= nx && nx < 12 && 0 <= ny && ny < 12 && field[nx][ny] == '1'){
				dfs(nx,ny);
			}
		}
	}
}

int main(void){
	while(1){
		if(cin >> field[0][0] == 0) break;
		for(int i=0; i<12; ++i){
			for(int j=0; j<12; ++j){
				if(i==0&&j==0)continue;
				cin >> field[i][j];
			}
		}
			
		int count = 0;

		for(int i=0; i<12; ++i){
			for(int j=0; j<12; ++j){
				if(field[i][j] == '1'){
					dfs(i, j);
					count++;
				}
			}
		}

		cout << count << endl;

	}
	return 0;
}

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

int main(int argc, char *argv[])
{
    map<char, vector<int>> cards;
    vector<char> marks = {'S', 'H', 'C', 'D'};
    for (char c : marks)
    {
        vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
        cards.insert(make_pair(c, v));
    }

    int input_num = 0;
    cin >> input_num;

    char m;
    int n;
    for (int i = 0; i < input_num; i++)
    {
        cin >> m >> n;
        cards[m][n - 1] = 0;
    }

    for (char c : marks)
    {
        for (int i : cards[c])
        {
            if (i != 0)
            {
                cout << c << " " << i << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll N, A, B; cin >> N >> A >> B;
  if((B-A) % 2 == 0) {
    cout << (B-A) / 2 << endl;
  } else {
    cout << min(A-1, N-B) + 1 + (B-A-1)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import itertools

H, W, K = map(int, input().split())
c = [list(str(input())) for i in range(H)]

ans = 0
for i in itertools.product(range(2), repeat=H+W):
    cnt = 0
    for j in itertools.product(range(H), range(W)):
        if i[j[0]]:
            continue
        if i[H+j[1]]:
            continue
        if c[j[0]][j[1]] == '#':
            cnt += 1
    if cnt == K:
        ans += 1

print(ans)

Measured memory_bytes: 73896
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			int w = sc.nextInt();
			int h = sc.nextInt();
			if( (n|w|h) == 0) break;
			
			LinkedList<Rect> rects = new LinkedList<Rect>();
			rects.add(new Rect(w, h));
			for(int i=0;i<n;i++) {
				int p = sc.nextInt()-1;
				int s = sc.nextInt();
				Rect rect = rects.remove(p);
//				debug(rect.w, rect.h, s);
				Rect[] next = rect.cut(s);
				for(Rect tmp: next) rects.addLast(tmp);
			}
			int[] area = new int[n+1];
			for(int i=0;i<n+1;i++) {
				Rect tmp = rects.removeFirst();
				area[i] = tmp.w * tmp.h;
			}
			sort(area);
			System.out.print(area[0]);
			for(int i=1;i<n+1;i++) {
				System.out.print(" " + area[i]);
			}
			System.out.println();
		}
	}
	
	class Rect {
		int w, h;
		Rect(int w, int h) {
			this.w = w;
			this.h = h;
		}
		
		Rect[] cut(int s) {
			Rect[] rects = new Rect[2];
			s = s % (w+h);
			if(s < w) {
				rects[0] = new Rect(s, h);
				rects[1] = new Rect(w-s, h);
			}
			else {
				rects[0] = new Rect(w, s-w);
				rects[1] = new Rect(w, h-(s-w));
			}
			if( rects[0].w * rects[0].h > rects[1].w * rects[1].h ) {
				Rect tmp = new Rect(rects[0].w, rects[0].h);
				rects[0].w = rects[1].w; rects[0].h = rects[1].h;
				rects[1].w = tmp.w; rects[1].h = tmp.h;
			}
			return rects;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
vector<int> num;
string s;






//サブ関数
//入力
void input()
{
	cin >> s;
	for (auto c : s) {
		num.push_back(c - 'a');
	}
}


//計算
void calc()
{
	const int size = 26;
	if (s.size() != size) {
		vector<bool> exist(26, false);
		for (auto c : s) {
			exist[c - 'a'] = true;
		}
		REP(i, 26) {
			if (!exist[i]) {
				s += ('a' + i);
				break;
			}
		}
		cout << s << endl;
	}
	else {
		for (int l = size; l >= 0; l--) {
			int minc = INF;

			for (int r = size - 1; l < r; r--) {
				if (s[l] < s[r]) {
					minc = min(minc, (int)s[r]);
				}
			}
			if (minc != INF) {
				s[l] = minc;
				REP(i, l+1) {
					cout << s[i];
				}
				cout << endl;
				return;
			}
		}
		cout << -1 << endl;
		return;

	}

}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int j;
  int i;
  int H;
  int W;

  while(1){
      scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) break;
    for(i = 0; i < H; i++){
      for(j = 0; j < W; j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2104