akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 101000
#define SWAP( a, b ) do { int tmp; tmp = a; a = b; b = tmp; } while( 0 )

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void insertionSort( int *, int );
void quickSort( int *, int );
void quickSort_body( int *, int, int );
int median( int, int, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 253 );
	}

	return 0;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] > tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];

				j--;
			} while ( j && data[ j - 1 ] > tmp );

			data[ j ] = tmp;
		}
	}
}

void quickSort( int *data, int n ) {
	quickSort_body( data, 0, n - 1 );
}

void quickSort_body( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] );

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			SWAP( data[ i ], data[ j ] );

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort_body( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort_body( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

Measured memory_bytes: 988
n, k = map(int, input().split())

g = 0
ps = 0
for i in range(n):
    g = i+1
    m = 0
    while g < k:
        g = g * 2
        m = m + 1
    p = float(0.5**m / n)
    ps = ps + p

print(ps)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int unsigned long long
#define MOD 1000000007
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int s;
  cin>>s;
  if(s==1000000000000000000LL){
    cout<<"14814814BuzzFizz8981"<<endl;
    return 0;
  }
  int n=19LL;
  vector<int> dit(n,0);
  int tn=10LL;
  for(int i=0;i<n;i++){
    int k=tn-tn/10LL;
    int f=k/3LL;
    int b=k/5LL;
    int fb=k/15LL;
    dit[i]=(i+1LL)*(k-(f+b-fb))+(f+b)*4LL;
    tn*=10LL;
  }

  int sum=0;
  int k=0;
  for(int i=0;i<n;i++){
    if(sum+dit[i]>=s){
	 k=i;
	 break;
    }
    sum+=dit[i];
    dit[i]=sum;
  }
  int ditm=0;
  if(k>0){
    ditm=dit[k-1];
  }

  int ok=pow(10,k+1)-1,ng=pow(10,k)-1,mid;
  while(ok-ng>1){
    mid=(ok+ng)/2LL;
    int t=mid-pow(10LL,k)+1LL;
    int f=t/3LL;
    int b=(k?(t-1LL)/5LL+1LL:t>=5LL);
    int fb=0;
    if(k){
	 int tt=t;
	 if(t>5LL){
	   tt-=6LL;
	   fb++;
	 }
	 fb+=tt/15LL;
    }
    int ms=ditm+(k+1LL)*(t-(f+b-fb))+(f+b)*4LL;
    if(ms>=s)ok=mid;
    else ng=mid;
  }
  int st;
  if(ok==pow(10,k)){
    st=ditm+1;
  }else{
    ok--;
    int t=ok-pow(10LL,k)+1LL;
    int f=t/3LL;
    int b=(k?(t-1LL)/5LL+1LL:t>=5LL);
    int fb=0;
    if(k){
	 int tt=t;
	 if(t>5){
	   tt-=6LL;
	   fb++;
	 }
	 fb+=tt/15LL;
    }
    st=ditm+(k+1LL)*(t-(f+b-fb))+(f+b)*4LL;
    if(ok>1){
	 ok++;
	 st++;
    }
  }

  //  cout<<ok<<" "<<st<<endl;
  string ans="";
  for(int i=0;i<50;i++){
    if((ok+i)%15LL==0){
	 ans=ans+"FizzBuzz";
    }else if((ok+i)%3LL==0){
	 ans=ans+"Fizz";
    }else if((ok+i)%5LL==0){
	 ans=ans+"Buzz";
    }else{
	 ans=ans+to_string(ok+i);
    }
  }
  
  for(int i=0;i<ans.size();i++){
    if((st+i)<s)continue;
    if((st+i)>=s+20)continue;
    cout<<ans[i];
  }
  cout<<endl;
  
  return 0;
}



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

int main(){
    int N,M;
    cin >> N;
    vector<int> T(N);
    for(int i=0;i<N;i++)cin >> T.at(i);
    cin >> M;
    vector<int> P(M),X(M),time(M);
    for(int i=0;i<M;i++)cin >> P.at(i) >> X.at(i);
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            if(j==P.at(i)-1){
                time.at(i) += X.at(i);
                continue;
            }
            time.at(i) += T.at(j);
        }
    }
    for(int i=0;i<M;i++)cout << time.at(i) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            string[] nm = Console.ReadLine().Split();
            long n = long.Parse(nm[0]);
            long m = long.Parse(nm[1]);
            string[] ss = Console.ReadLine().Split();
            string[] ts = Console.ReadLine().Split();
            long[] s = new long[n];
            long[] t = new long[m];
            for(long i=0;i<n;i++){
                s[i] = long.Parse(ss[i]);
            }
            for(long i=0;i<m;i++){
                t[i] = long.Parse(ts[i]);
            }
            long[] dp = new long[n]; //i番目で終わる部分列の個数？
            //(空列？も含みそうなので後で1を足す)
            for(long i=0;i<m;i++){
                long lst = 0;
                long wa = 1;
                long okure = 0;
                for(long j=0;j<n;j++){
                    wa += okure;
                    okure = dp[j];
                    if(t[i]==s[j]){
                        dp[j] = (dp[j] + wa)%1000000007;
                    }
                }
            }

            long ans = 1;
            for(long i=0;i<n;i++){
                ans = (ans + dp[i])%1000000007;
            }
            Console.WriteLine(ans);
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[202][101010];

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

    ll N, X;
    cin >> N >> X;
    vector<ll> S(N);
    REP(i, N) cin >> S[i];
    sort(S.rbegin(), S.rend());

    REP(i, 202)REP(j, 101010) dp[i][j] = 0;
    dp[0][X] = 1;

    REP(i, N){
    	REP(j, 101010){
	    	dp[i+1][j%S[i]] += dp[i][j];
	    	dp[i+1][j%S[i]] %= mod;
	    	dp[i+1][j] += (N-1-i) * dp[i][j] % mod;
	    	dp[i+1][j] %= mod;
	    }
    }

    ll res = 0;
    REP(i, 101010){
    	res += i*dp[N][i]%mod;
    	res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 159616
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m;
char s1[100000];
while(cin>>s1){
  int x[150]={0};
  l=strlen(s1);
  for(i=0;i<l;i++) x[s1[i]]++;
  k=0;
  for(i=0;i<150;i++) if(x[i]>1)k++;
  if(k>0) cout<<"no"<<endl;
  else cout<<"yes"<<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);
        String s = sc.next();
        String[] sp = s.split("");
        int sum = 700;
		for(int i=0; i<3; i++) {
		    if(sp[i].equals("o")) sum += 100;
		}
		System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
using namespace std;
int main(){   
   int x;
   cin>>x;
   
   for(int i=x;i>0;i++){
      int flag=1;
      for(int j=2;j<x;j++){
         if(i%j==0){
            flag=0;
         }
      }
      if(flag==1){
         cout<<i;
         break;
      }
      flag=1;
   }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C;u.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
map<LL,pair<LL,pair<LL,LL > > > vs;
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    for(LL mau=1;mau<=tt;mau++)
    {
        UOSMOY;
        cin>>n;
        if(n==0)
        {
            cout<<1<<endl;
        }
        else
        {
            cout<<0<<endl;
        }
    }
    return 0;
    //IN
    //AL
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N;
  string S;
  cin >> N >> S;
  for (auto &s: S) {
    if (s == 'R') {
      s = 1;
    }
    else if (s == 'G') {
      s = 2;
    }
    else if (s == 'B') {
      s = 3;
    }
  }

  array<vector<int>, 4> a;
  for (int i = 0; S[i]; ++i) {
    a[S[i]].push_back(i);
  }

  llong ans = 0;
  for (int i = 1; i <= 3; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i == j) continue;
      int check = i^j;
      for (int k = 0; k < N; ++k) {
        for (int l = k+1; l < N; ++l) {

          if (S[k] == i && S[l] == j) {
            ans += a[check].end() - lower_bound(ALL(a[check]), l);
            if (auto it = lower_bound(ALL(a[check]), l + l - k); it != a[check].end() && *it == l + l - k) {
              --ans;
            }
          }
        }
      }

    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String x = "";

		char[] c = new char[2];
		c[0] = s.next().charAt(0);
		c[1] = s.next().charAt(0);

		if(c[0] == c[1]) {
			System.out.println('H');
		} else {
			System.out.println('D');
		}

	}
}

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

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;


#define N_MAX 200
#define M_MAX 100

ull n;
char s[N_MAX + 1];

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

int solve(){
	
	int len = strlen(s);

	while (--len) {
		if (len & 1) continue;
		int i, isokay = 1;
		for (i = 0; i < len / 2; i++) {
			if (s[i] != s[i + len / 2]) {
				isokay = 0;
				break;
			}
		}

		if (isokay) break;
	}

	printf("%d\n", len);

	return 0;
}

int main(void){

	scanf("%s", s);

	solve();

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}



//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
*/



int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);


  ll N,M;
  cin>>N>>M;
  
  ll ans=0;
  
  if(N*2<=M){
    ans+=N;
    M-=N*2;
    ans+=M/4;
  }else{
    ans+=M/2;
  }
  cout<<ans<<endl;
  
    
}




Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    lint mod = 1e9 + 7;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    lint ans = 1;
    vector<int> color(3, 0);
    for (int i = 0; i < n; i++) {
        lint cand = 0;
        int target = 0;
        for (int j = 0; j < 3; j++) {
            if (a[i] == color[j]) {
                cand++;
                target = j;
            }
        }
        ans = (ans * cand) % mod;
        color[target]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn calc(t: &mut Vec<u32>, abcd: &Vec<(usize, usize, u32, u32)>) -> u32{
    let mut res = 0;
    for i in abcd.iter(){
        if t[i.1] - t[i.0] == i.2{
            res += i.3;
        }
    }
    res
}

fn dfs(p: usize, x: usize, t: &mut Vec<u32>, n: usize, m: usize, abcd: &Vec<(usize, usize, u32, u32)>) -> u32{
    if p == n{
        return calc(t, abcd);
    }
    let mut res = 0;
    for i in x..=m{
        t[p] = i as u32;
        res = max(res, dfs(p + 1, i, t, n, m, abcd));
    }
    res
}
fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcd: [(Usize1, Usize1, u32, u32); q],
    }
    let mut t = vec![0; 10];
    let ans = dfs(0, 1, &mut t, n, m, &abcd);
    println!("{}", ans);
}

Measured memory_bytes: 2172
from collections import defaultdict

N,K = map(int,input().split())
A = list(map(int,input().split()))

D = defaultdict(int)
max_bit = 1
for a in A:
    temp = a
    bit = 1
    for i in range(50):
        if temp%2==1: D[bit]+=1
        temp//=2
        bit*=2
        if temp==0:break
    i+=1
    if i > max_bit: max_bit=i

KD = defaultdict(int)
temp = K
k_bit = 1
for i in range(50):
    if temp%2==1:KD[k_bit]+=1
    temp//=2
    k_bit*=2
    if temp==0:break
k_bit = i+1
            
SD = {}
SDD = []
d = 1
for i in range(max(max_bit,k_bit)):
    #SD[d] = [d*(N-D[d]),d*D[d]]
    SD[d] = [d*(D[d]),d*(N-D[d])]
    if len(SDD)==0:
        SDD.append(max(SD[d]))
    else:
        SDD.append(SDD[i-1]+max(SD[d]))
    d*=2

#print(k_bit,max_bit) #あとでけす
#print(D,KD)
#print(SD,SDD) #あとでけす

allANS = []
ans = 0
p = pow(2,k_bit)
for i in range(k_bit,max_bit):
    ans += SD[p][0]
    p*=2
    
p = int(pow(2,k_bit-1))
for i in range(k_bit)[::-1]:
    if p==0:break
    if KD[p]>0:
        if i>0: #0を選択した場合
            allANS.append(ans+SD[p][0]+SDD[i-1]) 
        else:
            allANS.append(ans+SD[p][0])
        ans += SD[p][1]
    else:
        ans += SD[p][0]
    p//=2
    
allANS.append(ans)
#print(allANS) #あとでけす

print(max(allANS))

Measured memory_bytes: 15004
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    for(ll i = 0; i<n; i++){
        cin>>p[i];
    }
    ll ans = 0;
    ll curmin = 1e9;
    
    for(ll i = 0; i<n; i++){
        curmin = min({curmin, p[i]});
        if(curmin == p[i]){
            ans ++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N=IN;
    int L=0,R=N;
    cout<<0<<endl;
    string a;
    cin>>a;
    if(a[0]=='V') return 0;
    while(R-L>1) {
        int M=(L+R)/2;
        cout<<M<<endl;
        string t;
        cin>>t;
        if(t[0]=='V') return 0;
        if((a[0]==t[0] && (M-L)%2) || (a[0]!=t[0]) && (M-L)%2==0) {
            R=M;
        } else {
            L=M;
            a=t;
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n;
LL a[3005];
LL dp[3005][3005] = {0};

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		scanf("%lld",&a[i]);
		if(n & 1) dp[i][i] = a[i];
		else dp[i][i] = -a[i];
	}
	for(LL l = 1;l < n;l ++){
		for(LL i = 1;i < n;i ++){
			LL j = i + l; if(j > n) break;
			if((n - l - 1) & 1) dp[i][j] = min(dp[i + 1][j] - a[i],dp[i][j - 1] - a[j]);
			else dp[i][j] = max(dp[i + 1][j] + a[i],dp[i][j - 1] + a[j]);
		}
	}
	printf("%lld\n",dp[1][n]); 
	return 0;
}

Measured memory_bytes: 70016
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static int mod = 1000000007;

    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.equals("ARC")){
                System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }

    }

}









Measured memory_bytes: 35688
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int k, x;
    cin>>k>>x;
    int st = x-k+1;
    int en = x+k;
    while(st!=en){
        if(st>=-1000000LL && st<=1000000LL){
            cout<<st<<" ";
        }
        st++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
int ans = 10000;
int main(){
	cin >> s >> t;	
	for(int i = 0;i + t.size() <= s.size();i++){
		int cnt = 0;
		for(int j = 0;j < t.size();j++)
			if (s[i + j] != t[j])
				cnt++;
		ans = min(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3560
#include<iostream>
using namespace std;
int main(){
  int n,b[110000];
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  int sum=b[0]+b[n-2];
  for(int i=0;i<n;i++){
    if(b[i]<=b[i+1]) sum+=b[i];
    else sum+=b[i+1];
  }
  cout<<sum;
}


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

int prime_factorization(int n, vector<int> &p)
{
    int buf = n;
    if(buf % 2 == 0)
    {
        if(p[2] != 0)return 1;
        p[2]++;
        buf /= 2;
    }
    while (buf % 2 == 0)
    {
        buf /= 2;
    }
    for (int i = 3; i * i <= n; i += 2)
    {
        if(buf % i == 0)
        {
            if(p[i] != 0)return 1;
            p[i]++;
            buf /= i;
        }
        while (buf % i == 0)
        {
            buf /= i;
        }
    }
    if(buf != 1)
    {
        if(p[buf] != 0)return 1;
        p[buf]++;
    }
    return 0;
}

int main()
{
	int n;
    cin >> n;
    vector<int> a(n);

    vector<int> prime(1000000, 0);

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

    bool pc = true;
    for (int i = 0; i < n; i++)
    {
        if(prime_factorization(a[i], prime))
        {
            pc = false;
            break;
        }
    }
    
    int allgcd = a[0];
    for (int i = 0; i < n; i++)
    {
        allgcd = gcd(a[i], allgcd);
    }

    if(pc)
    {
        cout << "pairwise coprime" << endl;
    }
    else if(allgcd == 1)
    {
        cout << "setwise coprime" << endl;
    }
    else
    {
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 11028
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN (LL)-3223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N;
int mid;
LL D;
LL X[30],Y[30];
LL ans;

vector<pair<LL,LL> > mae;
void mae_search(int now, LL f, LL s){
	if(now == mid){
		mae.push_back(MP(f,s));
		return;
	}
	mae_search(now+1, f, s);
	mae_search(now+1, f-X[now], s-Y[now]);
	mae_search(now+1, f+X[now], s+Y[now]);
}

vector<pair<LL,LL> > ato;
void ato_search(int now, LL f, LL s){
	if(now == N){
		ato.push_back(MP(f,s));
		return;
	}
	ato_search(now+1, f, s);
	ato_search(now+1, f-X[now], s-Y[now]);
	ato_search(now+1, f+X[now], s+Y[now]);
}

int main() {
	iostream::sync_with_stdio(false);

	cin >> N >> D;
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i];

	mid = N/2; //減らすと前が減る

	mae_search(0, 0, 0);
	sort(mae.begin(), mae.end());
	ato_search(mid, 0, 0);
	sort(ato.begin(), ato.end());
	reverse(ato.begin(), ato.end());

	ans = 0;
	int l = 0; int r = -1;
	deque<LL> que;
	deque<LL> mque;
	for(int i=0; i<mae.size(); i++){
		while(r != ato.size()-1 && ato[r+1].first + mae[i].first >= -D){
			r++;
			que.push_back(ato[r].second);
			while(mque.size() > 0 && mque.back() < ato[r].second) mque.pop_back();
			mque.push_back(ato[r].second);
		}
		while(l <= r && ato[l].first + mae[i].first > D){
			if(mque.front() == que.front()) mque.pop_front();
			que.pop_front();
			l++;
		}
		if(mque.size() == 0) continue;
		ans = max(ans, mae[i].second + mque.front());
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 489188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;
int a[100005];
int b[100005];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int s=0;
        int min1=inf;
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            if(min1>b[i])
            {
                min1=b[i];
                s=a[i];
            }
        }
        printf("%d\n",s+min1);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, a, b, r[3030], c[3030], dp[3030][3030];
string s;

signed main() {
	cin >> n >> m >> s;
	rep(i,n) c[i+1] = s[i]-'0' + (i ? c[i] : 0);
	rep(i,3030) r[i] = i;
	rep(i,m) {
		cin >> a >> b;
		reps(j,a,b+1) chmax(r[j],b);
	}
	dp[0][0] = 1;
	reps(i,1,n+1) rep(j,min(c[r[i]],i)+1) {
		// [0,r[i]] 0-count
		if (r[i]-c[r[i]]<i-j) continue;
		// i文字目を0に
		dp[i][j] = dp[i-1][j];
		// i文字目を1に
		if (j) (dp[i][j] += dp[i-1][j-1]) %= mod;
	}
	cout << dp[n][c[n]] << endl;
}

Measured memory_bytes: 34048
from math import gcd
 
k = int(input())
sum_ = 0
for a in range(1, k + 1):
  for b in range(1, k + 1):
    gcd_ab = gcd(a, b)
    for c in range(1, k + 1):
      sum_ += gcd(c, gcd_ab)
print(sum_)

Measured memory_bytes: 9120
#include <iostream>
using namespace std;
typedef long long ll;
ll GCD(ll a, ll b) {
    return (a == 0) ? b : GCD(b % a, a);
}
ll LCM(ll a, ll b) {
    if (a > b) {
        a ^= b; b = a xor b; a = a xor b;
    }
    return a*b/GCD(a, b);
}
int main() {
    int a[3], m[3];
    while (1) {
        cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2];
        if (!a[0]) {
            break;
        }
        int move[3];
        for (int i=0; i<3; ++i) {
            int val = 1;
            for (int j=1; j<=m[i]; ++j) {
                val = a[i] * val % m[i];
                if (val == 1) {
                    move[i] = j; break;
                }
            }
        }
        ll ans = LCM(LCM(move[0], move[1]), move[2]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;
    string s;
    cin >> n >> s;
    vi a(n,0);
    rep(i,s.size()){
        if(i==0) a[i] = (s[i]=='('? 1 : -1);
        else a[i] = a[i-1] + (s[i]=='('? 1 : -1);
    }
    //for(auto t : a) cout << t << " ";
    int right = 0;
    int left = 0;
    for(int i=0;i<n;i++){
        if(a[i] < 0){
            rep(j,n) ++a[j];
            ++left;
        }
    }
    if(a[n-1] < 0) left += -a[n-1];
    else if(a[n-1] > 0) right += a[n-1];
    string ans = string(left,'(') + s + string(right,')');
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const int MAX = 510000;
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;
}

ll my_pow(ll m, ll n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return my_pow(m*m, n/2)%MOD; }
    return (my_pow(m, n-1) * m)%MOD;
}
//cout << fixed << setprecision(10);

int main() {
    ll N,K;
    cin >> N >> K;
    COMinit();
    for(int i=1;i<=K;i++){
        //cout << (my_pow(i,K-i)*COM(i+1+N-K-(i-1),N-K-(i-1)))%MOD << endl;
        ll blue_num=COM(K-i+i-1,i-1);
        ll red_num=COM(N-K-(i-1)+(i+1)-1,i);
        cout << (blue_num*red_num)%MOD<< endl;
    }

    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int Q;
  cin >> Q;
  while(Q--){
	int c, a, n;
	cin >> c >> a >> n;

	int ans = 0;
	REP(i1,1001) REP(i2,1001){
	  int cc = c - i1 * 2 - i2 * 3;
	  int aa = a - i1 * 1;
	  if(cc < 0 || aa < 0) continue;
	  maxi(ans, i1+i2+min({aa,cc,n}));
	}
	cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3152
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println(z +" "+ x + " "+ y);
	}
	
	
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,d; cin>>n>>d; d=d*2+1;
	cout<<(n+d-1)/d<<"\n";
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let m: usize = read();
    let a: Vec<Vec<char>> = (0..n).map(|_| read::<String>().chars().collect()).collect();
    let b: Vec<Vec<char>> = (0..m).map(|_| read::<String>().chars().collect()).collect();

    for i in 0..n - m + 1 {
        for j in 0..n - m + 1 {
            let mut count = 0;
            for k in 0..m {
                for l in 0..m {
                    if a[i + k][j + l] == b[k][l] {
                        count += 1;
                    }
                }
            }
            if count == m * m {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}

Measured memory_bytes: 4352
n = int(input())
l = [int(input()) for _ in range(n)]
l.sort()
c = 1
ans = 0
for i in range(1, n):
  if l[i-1] == l[i]:
    c += 1
  else:
    ans += c%2
    c = 1
if c != 1:
  ans += c%2
else:
  ans += 1
print(ans)

  

Measured memory_bytes: 7388
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	l := iSScan(n)
	sort.Sort(sort.Reverse(sort.IntSlice(l)))
	fmt.Println(sum(l[:k]))
}


Measured memory_bytes: 1772
#include<stdio.h>
#include<string.h>
 
int main(){
	char s[101];
	scanf("%s",s);
	int i;
	for(i=0;s[i]!='\0';i++){}
	printf("%c%d%c",s[0],i-2,s[i-1]);
	return 0;
}

Measured memory_bytes: 128
import java.util.*


fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    var S: Long
    S = sc.nextLong()
    solve(S)
}

fun f(n: Long) = n in 1..12

fun solve(S: Long) {
    val a = S / 100
    val b = S % 100

    if (f(a) && f(b)) {
        println("AMBIGUOUS")
    } else if (f(a)) {
        println("MMYY")
    } else if (f(b)) {
        println("YYMM")
    } else {
        println("NA")
    }
}


Measured memory_bytes: 31260
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

struct Rectangle{
  int H, W, D;
  Rectangle(int h, int w, int d){
    H = h, W = w, D = d;
  }
};

bool compare(Rectangle a, Rectangle b){
  if(a.D == b.D) return a.H < b.H;
  return a.D < b.D;
}

int main(){
  vector<Rectangle> R;
  for(int i = 1 ; i <= 150 ; i++){
    for(int j = i+1 ; j <= 150 ; j++){
      R.push_back(Rectangle(i, j, i*i+j*j));
    }
  }
  sort(R.begin(), R.end(), compare);
  
  int H, W;
  while(cin >> H >> W, H|W){
    int D = H*H+W*W;
    for(int i = 0 ; i < (int)R.size() ; i++){
      if(R[i].D == D){
	if(R[i].H > H){
	  cout << R[i].H << ' ' << R[i].W << endl;      
	  break;
	}
      }
      
      else if(R[i].D > D){
	cout << R[i].H << ' ' << R[i].W  << endl;
	break;
      } 
    }
  }
  return 0;
}

Measured memory_bytes: 1328
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            int sum  = 0;
            int[] nint = intLine(sc, 3);
            Arrays.sort(nint);

            out.println(nint[2]-nint[0]);

        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int main(){
    long long a,b,c;
    cin >>a >> b >> c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
    }else{
        cout<<min({a*b,b*c,c*a})<<endl;
    }
}

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

using namespace std;
int sen[10000];

int main(){
  int r,c,cc;
  while(true){
		scanf("%d %d",&r,&c);
		if (!r&&!c)break;
		for(int i=0;i<c;i++)
			sen[i] = 0;
		
		for(int j=0;j<r;j++){
			for(int i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		
		int s,n,sum = 0,smax = 0,k=1;
		k <<= r;
		for(int i=0;i<k;i++){
			sum = 0;
			for(int j=0;j<c;j++){
				s = sen[j]^i;
				for(n=0;s>0;s >>= 1)n+=s&1;
				sum += max(n,r-n);
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

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

int main() {
  int N;
  int count = 0;
  string S;
  cin >> N >> S;
  for(int i = 0; i < N-2 ; i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
      count++;
    }
  }
    cout << count << endl;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<18|3,mo=998244353,inv2=(mo+1)/2;
int n,a[N],all,g[N],f[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
inline void fwt(int *a, int n){
	for(int j=2;j<=n;j<<=1)
		for(int k=0;k<n;k+=j)rep(i,0,(j>>1)-1){
			int x=a[k+i],y=a[k+i+(j>>1)];
			a[k+i]=x+y<mo?x+y:x+y-mo;a[k+i+(j>>1)]=x-y>=0?x-y:x-y+mo;
		}
}
inline void ifwt(int *a, int n){
	fwt(a,n);int ni=power(n,mo-2);
	rep(i,0,n-1)a[i]=1LL*a[i]*ni%mo;
}
int main() {
	read(n);all=(1<<n)-1;
	int tot=0;rep(i,0,all)read(a[i]),tot=(tot+a[i])%mo;
	tot=power(tot,mo-2);rep(i,0,all)a[i]=1LL*a[i]*tot%mo;
	rep(i,0,all)a[i]=mo-a[i];a[0]++;
	rep(i,0,all)g[i]=1;g[0]=(g[0]-(1<<n)+mo)%mo;
	fwt(g,1<<n);fwt(a,1<<n);
//	rep(i,0,all)printf("%d:%d %d\n",i,g[i],a[i]);
	rep(i,0,all)g[i]=1LL*g[i]*power(a[i],mo-2)%mo;
	g[0]=0;rep(i,1,all)g[0]=(g[0]-g[i]+mo)%mo;
	ifwt(g,1<<n);
	rep(i,0,all)printf("%d\n",(g[i]+mo)%mo);
	return 0;
}


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

int main()
{
    string S, T;
    cin >> S;
    cin >> T;

    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var s = int.Parse(input[0]);
            var w = int.Parse(input[1]);

            if (w >= s)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }
        }
    }
}


Measured memory_bytes: 17884
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


set <string> s1, s2, s3;

int main() {
   

    ll n;
    cin >> n;
    string s;
    cin >> s;
    for(ll i=0;i<s.length();i++){
        string tmp = {s[i]};
//        cout << tmp << endl;
        for(auto itr = s2.begin(); itr != s2.end(); itr++){
            string tmp3 = *itr + tmp;
            s3.insert(tmp3);
        }
        for(auto itr = s1.begin(); itr != s1.end(); itr++){
            string tmp2 = *itr + tmp;
            s2.insert(tmp2);
        }
        s1.insert(tmp);
    }
//    for (auto itr = s3.begin(); itr != s3.end(); itr++){
//        cout << *itr << endl;
//    }
    cout << s3.size() << endl;
}

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

int n, a[10000];

int po(int l)
{
  int r = l + 1;
  int cnt = n;
  while (1){
    int c = a[l], d = 0;
    while (a[l] == c && l >= 0){
      l--;
      d++;
    }
    while (a[r] == c && r < n){
      r++;
      d++;
    }

    if (d < 4) return cnt;
    cnt -= d;
  }
}

int main()
{
  while (cin >> n, n) {
    for (int i = 0; i < n; i++){
      cin >> a[i];
    }

    int ans = 1e9;
    for (int i = 0; i < n; i++){
      for (int j = 1; j <= 3; j++){
        swap(j, a[i]);
        ans = min(ans, po(i));
        swap(j, a[i]);
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 3124
Base = [[1, 2, 3, 4, 5, 6], [1, 3, 5, 2, 4, 6], [1, 5, 4, 3, 2, 6], [1, 4, 2, 5, 3, 6], [5, 1, 3, 4, 6, 2], [5, 3, 6, 1, 4, 2], [5, 6, 4, 3, 1, 2], [5, 4, 1, 6, 3, 2], [6, 5, 3, 4, 2, 1], [6, 3, 2, 5, 4, 1], [6, 2, 4, 3, 5, 1], [6, 4, 5, 2, 3, 1], [2, 6, 3, 4, 1, 5], [2, 3, 1, 6, 4, 5], [2, 1, 4, 3, 6, 5], [2, 4, 6, 1, 3, 5], [4, 1, 5, 2, 6, 3], [4, 5, 6, 1, 2, 3], [4, 6, 2, 5, 1, 3], [4, 2, 1, 6, 5, 3], [3, 5, 1, 6, 2, 4], [3, 1, 2, 5, 6, 4], [3, 2, 6, 1, 5, 4], [3, 6, 5, 2, 1, 4]]

class Dice

def initialize(arr)
@all = []
Base.each{|b|
temp = Array.new(6)
for j in 1..6
temp[j-1] = arr[ b[j-1] -1 ]
end
@all.push(temp)
}
end

def getall()
    return @all
  end

end


first = Dice.new(gets.split.map(&:to_i)).getall()

n = gets.to_i

n.times do

p, q = gets.split.map(&:to_i)

first.each{|arr|
if arr[0] == p && arr[1] == q then
puts arr[2]
break
end
}

end




Measured memory_bytes: 6880