akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    puts!("AB{}\n", if n >= 1000 { "D" } else { "C" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        int[][] grid = new int[3][3];
        for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) grid[r][c] = in.intNext();
        int n = in.intNext();
        Map<Integer, Boolean> seen = new HashMap<>();
        for (int t = 0; t < n; t++) seen.put(in.intNext(), true);

        out.println(solve(grid, seen));

        out.close();
    }

    static String solve(int[][] grid, Map<Integer, Boolean> seen) {
        for (int r = 0; r < 3; r++) {
            if (seen.containsKey(grid[r][0]) && seen.containsKey(grid[r][1]) && seen.containsKey(grid[r][2])) return "Yes";
            if (seen.containsKey(grid[0][r]) && seen.containsKey(grid[1][r]) && seen.containsKey(grid[2][r])) return "Yes";
        }
        if (seen.containsKey(grid[0][0]) && seen.containsKey(grid[1][1]) && seen.containsKey(grid[2][2])) return "Yes";
        if (seen.containsKey(grid[2][0]) && seen.containsKey(grid[1][1]) && seen.containsKey(grid[0][2])) return "Yes";
        return "No";
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


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

#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(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;

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

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, l, r, a, c, o;
pair<int,pii> p[334334];

int bit[114514];

int sum(int i) {
	int s = 0;
	while (i>0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x) {
	while (i<=m) {
		bit[i] += x;
		i += i & -i;
	}
}

signed main() {
	cin >> n >> m;
	rep(i,n) {
		cin >> l >> r;
		p[i] = {r-l+1, {l, r}};
	}
	// 区間を長さで分類
	sort(p, p+n);
	repst(d,1,m) {
		// 累積和の準備
		while (c<n && p[c].fi<d) {
			add(p[c].se.fi, 1);
			add(p[c].se.se+1, -1);
			c++;
		}
		// d駅ごとに停まる場合、区間の長さがd以上の駅には必ず停まる
		a = n-c;
		// d未満の駅はシミュレート
		for (int i = 0; i <= m; i += d) a += sum(i);
		cout << a << ln;
	}
}

Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int n;
int sx,sy,gx,gy;
int xa[SIZE],ya[SIZE],xb[SIZE],yb[SIZE],h[SIZE];

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8;

//??????
double dot(P a, P b) {
  return (a * conj(b)).real();
}

//??????
double cross(P a, P b) {
  return (a * conj(b)).imag();
}

double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < P_eps ) return abs(c-a);
  if ( dot(a-b, c-b) < P_eps ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

/* ?????????????????? */
bool IntersectionSS(P a1, P a2, P b1, P b2){
    
  //??????a ??¨ ??´???b
  P_type a = cross(b1-b2,a1-b1);
  P_type b = cross(b1-b2,a2-b1);
  
  //??????b ??¨ ??´???a
  P_type c = cross(a1-a2,b1-a1);
  P_type d = cross(a1-a2,b2-a1);
  
  if((a<0)^(b<0) && (c<0)^(d<0))  // T?????????????????? -P_eps
    return true;
  else
    return false;
}

bool check(double r){
  
  P l_s = P(sx,sy);
  P l_g = P(gx,gy);
  
  for(int i=0;i<n;i++){
    P p[4];
    p[0] = P(xa[i],ya[i]);
    p[1] = P(xa[i],yb[i]);
    p[2] = P(xb[i],yb[i]);
    p[3] = P(xb[i],ya[i]);
    double H = min((double)h[i],r);
    double R = sqrt(r*r - (r-H)*(r-H));

    for(int j=0;j<4;j++){
      double dis = distance_ls_p(l_s, l_g, p[j]);
      bool is = IntersectionSS(l_s,l_g,p[j],p[(j+1)%4]);
      bool in = (xa[i] <= sx && sx <= xb[i] && ya[i] <= sy && sy <= yb[i]) ||
        (xa[i] <= gx && gx <= xb[i] && ya[i] <= gy && gy <= yb[i]);
      
      if(dis < R || is || in){
        return false;
      }
    }
  }
  
  for(int i=0;i<n;i++){
    P p[4];
    p[0] = P(xa[i],ya[i]);
    p[1] = P(xa[i],yb[i]);
    p[2] = P(xb[i],yb[i]);
    p[3] = P(xb[i],ya[i]);
    double H = min((double)h[i],r);
    double R = sqrt(r*r - (r-H)*(r-H));

    for(int j=0;j<4;j++){
      double dis1 = distance_ls_p(p[j],p[(j+1)%4],l_s);
      double dis2 = distance_ls_p(p[j],p[(j+1)%4],l_g);
      
      if(dis1 < R || dis2 < R){
        return false;
      }
    }

  }
  
  return true;
}

bool solve(){
  
  
  scanf("%d",&n);

  if(n == 0) return false;

  scanf("%d%d%d%d",&sx,&sy,&gx,&gy);

  for(int i=0;i<n;i++){
    scanf("%d%d%d%d%d",xa+i, ya+i, xb+i, yb+i, h+i);
  }

  double l=0, r=1000;

  while(r-l > 1e-8){
    double mid = (l+r)/2;

    if(check(mid)){
      l = mid;
    }else{
      r = mid;
    }
  }

  printf("%.7lf\n",l);
  
  return true;
}

int main(){

  while(solve());
  
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += min(x.at(i), k - x.at(i)) * 2;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
$n=<>;$h[$|--]{$_}--for glob<>;
($a,$b)=map[sort{$$_{$a}-$$_{$b}}keys%$_],@h;
($u,$x)=map$h[0]{$_},@$a;
($v,$y)=map$h[1]{$_},@$b;
print$n+($$a[0]-$$b[0]?$u+$v:$u+$y<$v+$x?$u+$y:$v+$x)

Measured memory_bytes: 30208
x, y = map(int, input().split())

group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]

if x in group_a and y in group_a:
  print('Yes')
elif x in group_b and y in group_b:
  print('Yes')
elif x ==2 and y == 2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v;
  for(int i=0;7*i+1<=300000;i++){
    int a=7*i+1;
    int f=0; 
    for(int j=2;j*j<=a;j++){
      if(a%j)continue;
      if(j%7==1||j%7==6)f=1;
      int b=a/j;
      if(b%7==1||b%7==6)f=1;
    }
    if(!f)v.push_back(a);
    a=7*i+6;
    f=0; 
    for(int j=2;j*j<=a;j++){
      if(a%j)continue;
      if(j%7==1||j%7==6)f=1;
      int b=a/j;
      if(b%7==1||b%7==6)f=1;
    }
    if(!f)v.push_back(a);
  }
  int n;
  while(cin>>n,n!=1){
    cout<<n<<':';
    for(int i=0;i<v.size();i++)
      if(n%v[i]==0&&v[i]!=1)cout<<" "<<v[i];
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

int main(void){
    string a, b;
    cin >> a >> b;
    int n = stoi(a+b);
    REP(i,1000){
        if(i*i == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

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

int main() {

  int ans = 0;
  int L,R,d;
  cin >> L >> R >> d;
  int j=L;
  while (j <= R) {
    if(j%d==0){
        ans++;
    }
    j++;
  }

cout << ans << endl;

}


Measured memory_bytes: 3592
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;

int a[1010][1010];
int dp[1010][1010];

int main(void){

	while(1){
	int H,W,N;
	cin >> H >> W >> N;
	if(H==0 && W==0 && N==0) break;
	int i,j;
	for(i=1;i<=1000;i++) for(j=1;j<=1000;j++) a[i][j]=0;
	for(i=1;i<=1000;i++) for(j=1;j<=1000;j++) dp[i][j]=0;
	for(i=1;i<=H;i++) for(j=1;j<=W;j++) cin >> a[i][j];
	dp[1][1]=N-1;
	for(i=1;i<=H;i++) for(j=1;j<=W;j++){
		if(i!=1 || j!=1){
		if(dp[i-1][j]%2==1 && a[i-1][j]==0) dp[i][j]+=(dp[i-1][j]+1)/2;
		if(dp[i-1][j]%2==1 && a[i-1][j]==1) dp[i][j]+=(dp[i-1][j]-1)/2;
		if(dp[i-1][j]%2==0) dp[i][j]+=dp[i-1][j]/2;
		if(dp[i][j-1]%2==1 && a[i][j-1]==0) dp[i][j]+=(dp[i][j-1]-1)/2;
		if(dp[i][j-1]%2==1 && a[i][j-1]==1) dp[i][j]+=(dp[i][j-1]+1)/2;
		if(dp[i][j-1]%2==0) dp[i][j]+=dp[i][j-1]/2;
		}
	}

	int x=1,y=1;
	while(x<=H && y<=W){
		if(dp[x][y]%2==0 && a[x][y]==0) x++;
		else if(dp[x][y]%2==0 && a[x][y]==1) y++;
		else if(dp[x][y]%2==1 && a[x][y]==0) y++;
		else if(dp[x][y]%2==1 && a[x][y]==1) x++;
	}

	cout << x << ' ' << y << endl;

	}

	return 0;
}

Measured memory_bytes: 9092
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split();
            var S = input[0];
            var T = input[1];

            var ans = string.Empty;
            for (int i = 0; i < N; i++)
            {
                ans = string.Join("", ans, S[i], T[i]);
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,k,r,s,p; string t;

int main(){
  cin >> n >> k >> r >> s >> p >> t;
  map<char,int> mp;
  vector<bool> win(n,false);

  rep(i,n){
    if(i>=k){
      if(t[i] == t[i-k]){
        if(!win[i-k]){
          mp[t[i]]++;
          win[i] = true;
        }
      }else{
        mp[t[i]]++;
        win[i] = true;
      }
    }else{
      mp[t[i]]++;
      win[i] = true;
    }
  }
  int ans = 0;
  
  ans += p * mp['r'];
  ans += r * mp['s'];
  ans += s * mp['p'];
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    
    cout << a+b+c - max({a,b,c}) << endl;
    
    return 0;
}

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

int main(){
    string s;
    cin >> s;

    string t1 = "dream";
    string t2 = "dreamer";
    string t3 = "erase";
    string t4 = "eraser";

    reverse(s.begin(), s.end());
    reverse(t1.begin(), t1.end());
    reverse(t2.begin(), t2.end());
    reverse(t3.begin(), t3.end());
    reverse(t4.begin(), t4.end());

    long long n = s.size();
    long long i = 0;

    while(i < n){
        if(s[i] == 'm'){
            if(i + 4 < n and s.substr(i, 5) == t1) i += 5;
            else{
                printf("NO\n");
                return 0;
            }
        }
        else if(s[i] == 'e'){
            if(i + 4 < n and s.substr(i, 5) == t3) i += 5;
            else{
                printf("NO\n");
                return 0;
            }
        }
        else if(i + 1 < n and s[i] == 'r' and s[i+1] == 'e'){
            if(i+2 < n and s[i+2] == 'm'){
                if(i + 6 < n and s.substr(i, 7) == t2) i += 7;
                else{
                    printf("NO\n");
                    return 0;
                }
            }
            else if(i + 2 < n and s[i+2] == 's'){
                if(i + 5 < n and s.substr(i, 6) == t4) i += 6;
                else{
                    printf("NO\n");
                    return 0;
                }
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
        else{
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 3752
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  var p = 0
  var ans = 0
  for (c <- s) {
    c match {
      case 'g' =>
        if (p > 0) {
          p -= 1
          ans += 1
        } else {
          p += 1
        }
      case 'p' =>
        if (p > 0) {
          p -= 1
        } else {
          p += 1
          ans -= 1
        }
    }
  }
  println(ans)
}

Measured memory_bytes: 55632
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];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int a2 = 0;
		int a4 = 0;
		int e = 0;
		for(int i = 0 ; i < n ; i++) {
			if(a[i] % 4 == 0) a4++;
			else if(a[i] % 2 == 0) a2++;
			else e++;
		}
		if((a4 >= n / 2 && e >= 1 && a2 == 0) || a2 == n || a2 >= 1 && a4 - 1 >= (n - a2 - 1) / 2 && a4 >= 1 && e >= 1 || e == 0 && a2 % 2 == 0 && a4 >= 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
deque<int> Era(int n) {
    deque<int> arr(n+1,1);
    deque<int> prime;
    arr[0]=0;
    arr[1]=1;
    for (int i=2;i*i<n;i++) {
        if (arr[i]==1) {
            for (int j=i*i;j<n;j+=i) {
                arr[j]=0;
            }
        }
    }
    for (int k=2;k<=n;k++) {
        if (arr[k]==1) {
            prime.emplace_back(k);
        }
    }
    return prime;
}
int main(void){
    std::deque<int> deq;
    deq=Era(1300000);
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            if (find(deq.begin(),deq.end(),n)!=deq.end()) {
                cout<<0<<endl;
            } else {
                auto back=lower_bound(deq.begin(),deq.end(),n);
                auto front=back--;
                cout<<*front-*back<<endl;
            }
        }
    }
}



Measured memory_bytes: 8612
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MX = 100000;
bool isprime[MX];

vector<int> getPrimes() {
    vector<int> ret;
    fill_n(isprime, MX, true);
    isprime[0] = isprime[1] = false;
    for (int i=2; i<=MX; ++i) {
        if ( ! isprime[i]) continue;
        ret.push_back(i);
        for (int j=i*i; 0<j && j<=MX; j+=i) {
            isprime[j] = false;
        }
    }
    return ret;
}

int main() {
    vector<int> primes = getPrimes();
    long long m, a, b;
    while (1) {
        cin >> m >> a >> b;
        if (!m && !a && !b) break;
        long long pq = 0;
        pair<int,int> ans;
        for (int i=0; i<(int)primes.size(); ++i) {
            long long p = primes[i];
            if (p * p > m) break;
            for (int j=i; j<(int)primes.size(); ++j) {
                long long q = primes[j];
                if (p * q > m || a * q > b * p) break;
                if (pq < p * q) {
                    pq = p * q;
                    ans.first = p;
                    ans.second = q;
                }
            }
        }
        cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1420
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  long long N,x;cin>>N>>x;
  long long l[N];
  long long mi=0,cnt=0;;
  for (int i=0;i<N;i++){
    int a;cin>>l[i];
  }

  for(int i=0;i<N-1;i++){
    if(x<(l[i]+l[i+1])){
        cnt+=l[i]+l[i+1]-x;
        mi=l[i]+l[i+1]-x;
        l[i+1]=l[i+1]-mi;
        l[i+1]=max(0LL,l[i+1]);
    }
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
int x[maxn];
ll dp[maxn];
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) cin>>x[i];
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+min(1LL*a*(x[i]-x[i-1]),1LL*b);
	}
	cout<<dp[n]<<endl;

}


Measured memory_bytes: 1408
import sys
n,m = map(int,input().split())
ans = 0

if m < 2:
    print(ans)
    sys.exit()

    
if m < 2 * n:
    ans += m // 2
    print(ans)
    
    
else:
    ans += n
    x = m - 2 * n
    ans += x//4
    print(ans)

Measured memory_bytes: 3060
n = input()
if(n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9'):
    print('hon')
elif(n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8'):
    print('pon')
else:
    print('bon')

Measured memory_bytes: 61612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n + 1), b(n);
  REP(i, n + 1) { cin >> a[i]; }
  REP(i, n) { cin >> b[i]; }

  REP(i, n) {
    if (b[i] <= a[i])
      ans += b[i];
    else {
      ans += a[i] + min((b[i] - a[i]), a[i + 1]);
      a[i + 1] -= min((b[i] - a[i]), a[i + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main (){
    int n;
    bool flag=false;
    int sw=0;
    cin >> n;
    rep(i,n){
        int p;
        cin >> p;
        if(i+1==p) {
            if(flag==true) flag=false;
            else {
                sw++;
                flag=true;
            }
        }
        else flag=false;
    }
        
    cout << sw << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		string s=to_string(i);
		string t=s;
		reverse(s.begin(),s.end());
		if(s==t){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int a, b;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else if(a == b){
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String strs = sc.next();
		int ans=700;
		for(int i=0;i<3;i++){
			if (strs.charAt(i)=='o'){
				ans=ans+100;
			}		
		}
	System.out.println(ans);	
	}
}

Measured memory_bytes: 21844
using System;
using System.Linq;

namespace ARC067
{
    class D
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long A = input[1];
            long B = input[2];

            long[] X = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long[] Res = new long[N];
            long distance = 0;
            for (int i = 0; i < N - 1; i++)
            {
                if (B <= A) { Res[i] = B; }
                else
                {
                    distance = X[i + 1] - X[i];
                    Res[i] = Math.Min(A * distance, B);
                }
            }
            Console.WriteLine(Res.Sum());
        }
    }
}


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

int n, m, l, r;
main() {
    cin >> n >> m;
    vector<int> v(n+10);
    for (int i = 1; i <= m; ++i) {
        cin >> l >> r;
        ++v[l]; --v[r+1];
    }

    int c{};
    for (int i = 1; i <= n; ++i) {
        v[i] += v[i-1];
        if (v[i] == m) ++c;
    }

    cout << c << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define MAX 500001

int H;

void maxHeapify(int *A,int i){
    int l,r,largest,change;
    
    l = i*2;
    r = i*2+1;
    
    if((l<=H)&&(A[l]>A[i])){
        largest = l;
    }else{
        largest = i;
    }
    if((r<=H)&&(A[r]>A[largest])){
        largest = r;
    }
    
    if(largest!=i){
        change = A[i];
        A[i] = A[largest];
        A[largest] = change;
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int *A){
    int i;
    
    for(i=H/2;i>=1;i--){
        maxHeapify(A,i);
    }
}

int main(){
    int i;
    int A[MAX];
    
    scanf("%d",&H);
    for(i=1;i<=H;i++){
        scanf("%d",&A[i]);
    }
    
    buildMaxHeap(A);
    
    for(i=1;i<=H;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n;
  cin>>h>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<n;i++){
    h-=a.at(i);
  }
  if(h<=0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>

using namespace std;

struct Parser 
{
  string str, val;
  Parser(string str, string val): str(str), val(val) {;};
};

string minus_(string x)
{
  if (x == "0") return "2";
  if (x == "1") return "1";
  if (x == "2") return "0";
}

string mul(string x, string y)
{
  if (x == "0" || y == "0") return "0";
  if (x == "1" || y == "1") return "1";
  return "2";
}

string add(string x, string y)
{
  if (x == "2" || y == "2") return "2";
  if (x == "1" || y == "1") return "1";
  return "0";
}

Parser formula(string str)
{
  if (str.size() == 0) {
    return Parser("", "");
  }

  string l = str.substr(0, 1);
  string r = str.substr(1);
  // -<formula>
  if (l == "-") {
    Parser ps = formula(r);
    return Parser(ps.str, minus_(ps.val));
  } else if (l == "("){

    Parser lhs = formula(r);
    string op = lhs.str.substr(0, 1);
    Parser rhs = formula(lhs.str.substr(1));

    if (op == "+") {
      // (<formula>+<formula>)
      return Parser(rhs.str.substr(1), add(lhs.val, rhs.val));
    } else {
      // (<formula>*<formula>)
      return Parser(rhs.str.substr(1), mul(lhs.val, rhs.val));
    }
  }

  // 0 | 1 | 2
  return Parser(str.substr(1), str.substr(0, 1));
}


int main()
{
  string str;
  while (cin >> str && (str != ".")) {
    int res = 0;
    for (int i = 0; i < 3; i++) { // P
      for (int j = 0; j < 3; j++) { // Q
        for (int k = 0; k < 3; k++) { // R
          char P = '0' + i, Q = '0' + j, R = '0' + k;
          string expr = str;
          for (int s = 0; s < expr.size(); s++) {
            if (expr[s] == 'P') expr[s] = P;
            if (expr[s] == 'Q') expr[s] = Q;
            if (expr[s] == 'R') expr[s] = R;
          }

          Parser ps = formula(expr);
          if (ps.val == "2") res++;
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 924
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"


using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	cout << min(M, K) << " " << max(0LL, M + K - N) << endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  long long ans = 0;
  for(int i = 0; i < N-1; ++i) {
    ans += 2LL*min(1LL*i+1LL, N-1LL-i) * (A[i+1]-A[i]);
  }

  if(N % 2 == 0) ans -= (A[N/2]-A[N/2-1]);
  else {
    ans -= min(A[N/2]-A[N/2-1], A[N/2+1]-A[N/2]);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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;}



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll x[4];
    x[0] = a*c;
    x[1] = a*d;
    x[2] = b*c;
    x[3] = b*d;

    ll m = x[0];
    REPS(i,3){
        chmax(m,x[i]);
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    ll n,x,y,c,d;
    cin >> n >> x >> y >> c >> d;
    bool ans = false;
    for(ll i=(n-1);i>=0;i--){
        if((n-1-i)*c-i*d <= y-x && y-x <= (n-1-i)*d-i*c){
            ans = true;
        }
    }
    if(ans){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }
    return 0;
}


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

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

Measured memory_bytes: 57216
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var points = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Select(x => (x[0], x[1])).ToArray();
        {
            var count = points.Count(x => (x.Item1 + x.Item2) % 2 == 0);
            if (count != 0 && count != n)
            {
                Console.WriteLine(-1);
                return;
            }
        }
        var parity = (points[0].Item1 + points[0].Item2) % 2;
        List<int> arms = new List<int>();
        for (int i = 30; i >= 0; i--)
            arms.Add(1 << i);
        if (parity == 0) arms.Add(1);
        Console.WriteLine(arms.Count);
        Console.WriteLine(string.Join(" ", arms));
        (int, int) getPos(string s)
        {
            int y = 0;
            int x = 0;
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case 'U':
                        y += arms[i];
                        break;
                    case 'D':
                        y -= arms[i];
                        break;
                    case 'R':
                        x += arms[i];
                        break;
                    case 'L':
                        x -= arms[i];
                        break;
                }
            }
            return (y, x);
        }
        foreach (var (x, y) in points)
        {
            long curY = y, curX = x;
            string res = "";
            foreach (var arm in arms)
            {
                var min = long.MaxValue;
                char minOp = '#';
                long minY = 0, minX = 0;
                void Update(long y, long x, char c)
                {
                    var diff = Abs(y) + Abs(x);
                    if (diff < min) { minOp = c; minY = y; minX = x; min = diff; }
                }
                Update(curY - arm, curX, 'U');
                Update(curY + arm, curX, 'D');
                Update(curY, curX - arm, 'R');
                Update(curY, curX + arm, 'L');
                (curY, curX) = (minY, minX);
                res += minOp;
            }
            var pos = getPos(res);
            if (res.Length != arms.Count || pos != (y, x)) throw new Exception();
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 31244
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#include<vector>
#include<queue>
#include<limits>
template<typename T>
vector<T>dijkstra(int s,const vector<vector<pair<int,T> > >&G,T INF=numeric_limits<T>::max())
{
	int n=G.size();
	vector<T>d(n,INF);
	vector<int>parent(n,-1);
	priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
	d[s]=0;
	P.push(make_pair(d[s],s));
	while(!P.empty())
	{
		pair<T,int>p=P.top();P.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(const pair<int,T>&e:G[v])
		{
			int u=e.first;
			T cost=d[v]+e.second;
			if(d[u]>cost)
			{
				d[u]=cost;
				parent[u]=v;
				P.push(make_pair(d[u],u));
			}
		}
	}
	return d;
}
int n,m,s,t;
main()
{
	cin>>n>>m>>s>>t;
	s--,t--;
	vector<vector<pair<int,int> > >G(n);
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(make_pair(b,1));
		G[b].push_back(make_pair(a,1));
	}
	vector<int>ds=dijkstra(s,G);
	vector<int>dt=dijkstra(t,G);
	int lim=ds[t];
	vector<int>cnts(lim,0),cntt(lim,0);
	for(int i=0;i<n;i++)
	{
		if(ds[i]<lim)cnts[ds[i]]++;
		if(dt[i]<lim)cntt[dt[i]]++;
	}
	long ans=0;
	for(int i=0;i<lim-1;i++)
	{
		ans+=1LL*cnts[i]*cntt[lim-i-2];
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 11968
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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 min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = ll(1e18)+1;

int main(){
   int x, y, z;
   cin >> x >> y >> z;
   cout << z << " " << x << " " << y << endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n+m==0){
				return;
			}
			int[] taro = new int[n];
			int taroSum = 0;
			for(int i=0;i<n;i++){
				taro[i] = stdIn.nextInt();
				taroSum+=taro[i];
			}
			int[] hana = new int[m];
			int hanaSum = 0;
			for(int i=0;i<m;i++){
				hana[i] = stdIn.nextInt();
				hanaSum+=hana[i];
			}
			int changeSumMin = -1;
			int taroChange = -1;
			int hanaChange = -1;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					int taroAfter = taroSum-taro[i]+hana[j];
					int hanaAfter = hanaSum-hana[j]+taro[i];
					if(taroAfter==hanaAfter){
						int changeSum = taro[i]+hana[j];
						if(changeSumMin==-1||changeSum<changeSumMin){
							changeSumMin = changeSum;
							taroChange = taro[i];
							hanaChange = hana[j];
						}
					}
				}
			}
			if(changeSumMin!=-1){
				System.out.println(taroChange+" "+hanaChange);
			}
			else{
				System.out.println("-1");
			}
		}
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << "\n";
	return 0;
}

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

using namespace std;

int main(void){

	int n;
	int x[8],y[8];
	int i;
	double r[8][8];
	int j;
	int index[8];
	double dx,dy;
	double sum;
	double p;
	p = 1;


	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
		index[i] = i+1;
//		p *= i + 1;
	}

	sum = 0;

	for(i=0;i<n;i++){
//		printf("%d : ", i);
		for(j=0;j<n;j++){
			dx = x[i] - x[j];
			dy = y[i] - y[j];
			r[i][j] = sqrt( dx * dx + dy * dy);
//			printf("%4.1lf ",r[i][j]);
			sum += r[i][j];
//			printf("%lf\n",sum);
		}
//		printf("\n");
	}

/*
	do {

		for( i = 0;i<n-1;i++){

		}

        for (int i = 0; i < n; i++) {
            printf("%d ",index[i]);
        }
		printf("\n");
    }while (next_permutation(index, index + n));


	*/

//	printf("%lf\n",sum);
//	printf("%lf\n",n);

	printf("%lf\n",sum / n);



	return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	S := ""
	fmt.Scan(&S)
	ans := make([]int, len(S))
	n := 0
	lpos := 0
	for i := 0; i < len(S); i++ {
		if S[i] == 'L' {
			if n > 0 {
				lpos = i
				ans[i] = (n + 2) / 2
				ans[i-1] = (n + 1) / 2
				n = 0
			} else {
				if (i-lpos)%2 == 1 {
					ans[lpos-1]++
				} else {
					ans[lpos]++
				}
			}
		} else {
			n++
		}
	}
	PrintOut(ans, " ")
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

bool match(char a, char b) {
    return (a==b || a=='?' || b=='?');
}

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    int na=a.size();
    int nb=b.size();
    int nc=c.size();
    vector<int> ab(20001),ac(20001),bc(20001);
    int mid=10000;
    rep(i,na) {
        rep(j,nb) {
            if (!match(a[i],b[j])) ab[i-j+mid]=1;
        }
        rep(j,nc) {
            if (!match(a[i],c[j])) ac[i-j+mid]=1;
        }
    }
    rep(i,nb) {
        rep(j,nc) {
            if (!match(b[i],c[j])) bc[i-j+mid]=1;
        }
    }
    int sum=na+nb+nc;
    int ans=sum;
    repr(i,-4000,4001) {
        repr(j,-4000,4001) {
            if (!ab[mid+i] && !ac[mid+j] && !bc[mid-i+j]) {
                int tans=max(na,max(i+nb,j+nc))-min(0,min(i,j));
                ans=min(ans,tans);
            }
        }
    }

    cout << ans << endl;
    
}

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

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

	int ans = 0;
	ans += max(a, b);
	if (a > b) a--;
	else b--;
	ans += max(a, b);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string s, t;
  int n;
  cin >> n;
  cin >> s >> t;

  string ans;
  rep(i, s.length()){
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256