akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int ans = 1;
    rep(i, n) ans *= 3;

    int tmp = 1;
    rep(i, n) {
        if (a[i] % 2 == 0) tmp *= 2;
    }
    cout << ans - tmp << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int val[N],w[N],sum[(1<<15)+5],f[(1<<15)+5];
inline int count(int x){
	int cnt=0;while (x) x&=(x-1),cnt++;return cnt;
}
int main (){
	int n;scanf ("%d",&n);
	for (int i=1,u,v,w;i<n;i++){
		scanf ("%d%d%d",&u,&v,&w);
		++u,++v,val[u]^=w,val[v]^=w;
	}
	for (int i=1;i<=n;i++) w[val[i]]++;
	for (int s=0;s<(1<<15);s++)
		for (int i=1;i<=15;i++)
			if (s&(1<<(i-1))) sum[s]^=i;
	int ans=0,to=0;
	for (int s=1;s<=15;s++) ans+=(w[s]>>1),w[s]&=1,to|=w[s]*(1<<(s-1));
	for (int s=1;s<(1<<15);s++){
		if (sum[s]==0) f[s]=count(s)-1;
		else {f[s]=114514;continue;}
		for (int t=s&(s-1);t;t=s&(t-1))
			if (sum[t]==0) f[s]=min(f[s],f[s^t]+f[t]);
	}
	printf ("%d",ans+f[to]);
	return 0;
}


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



int main(){
    int N;
    cin >> N;
    std::vector<string> words(N);

    for(int i=0; i < N; i++){
        cin >> words.at(i);
    }
    std::map<std::string, long> counter;
    string tmp_str;
    long long cnt = 0;
    for(int i=0; i < N; i++){
        tmp_str = words.at(i);
        sort(tmp_str.begin(), tmp_str.end());
            // cnt += counter[tmp_str]; //これだったらAC
            counter[tmp_str] ++;
    }
    for(auto word : counter){
        cnt += word.second*(word.second-1)/2; //これだったらb11がWA
    }
    cout << cnt << endl;
}


Measured memory_bytes: 18176
#include<iostream>
#include<iomanip>

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int c[3][3];
  rep(i,0,3){
    rep(j,0,3){
      cin>>c[i][j];
    }
  }
  int a[3],b[3];
  a[0]=0;
  b[0]=c[0][0],b[1]=c[0][1],b[2]=c[0][2];
  a[1]=c[1][1]-b[1],a[2]=c[2][2]-b[2];

  bool flag=true;
  rep(i,0,3){
    rep(j,0,3){
      if(a[i]+b[j]!=c[i][j]){
        flag=false;
        break;
      }
    }
  }
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    cout << (n % k != 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string s1(ty - sy, 'U');
    string s2(tx - sx, 'R');
    string s3(ty - sy, 'D');
    string s4(tx - sx, 'L');
    
    cout << s1 << s2 << s3 << s4;
    cout << "L" << s1 << "U" << s2 << "RDRD" << s3 << s4 << "LU" << endl;



    return 0;
}


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

#define int long long int
#define ps psuh_back()
#define fi first
#define so second

signed main()
{
    int n,m,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int mn=a[0],c=1;
    for(i=1;i<n;i++) {mn=min(mn,a[i]);if(mn>=a[i]) c++;}
    cout<<c;
}


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

void swap(int &a, int &b){
	int t;
	t = a;
	a = b;
	b = t;
}

int main(){
	const int max = 30;
	int w;
	int n;
	int nums[max + 1];
	cin >> w;
	for(int i = 1; i <= w; i++)
		nums[i] = i;
	cin >> n;
	for(int j = 0; j < n; j++){
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(nums[a], nums[b]);
	}
	for(int k = 1; k <= w; k++)
		cout << nums[k] << endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    String n=new Scanner(System.in).next();
    char[] c=n.toCharArray();
    for(int i=0;i<3;i++){
      switch(c[i]){
        case '1':
          c[i]='9';
          break;
        case '9':
          c[i]='1';
          break;
      }
    }
    System.out.println(String.valueOf(c));
  }
}

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

const static int N = 100;
const static int WHITE = 0;
const static int GRAY = 1;
const static int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v = 0; v < n; ++v){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  for(u = 0; u < n; ++u) color[u] = WHITE;
  tt = 0;

  for(u = 0; u < n; ++u){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u = 0; u < n; ++u){
    cout << u+1 << " " << d[u] << " " << f[u] << endl;
  }
}

int main(){
  int u, v, k;

  cin >> n;
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j) M[i][j] = 0;
  }
  
  for(int i=0; i<n; ++i){
    cin >> u >> k;
    --u;
    for(int j=0; j<k; ++j){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  dfs();


  return 0;
}



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


int main()
{
	int h, w, k;
	cin >> h >> w >> k;

	vector<vector<int>> s(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char s_in;
			cin >> s_in;
			s.at(i).at(j) = s_in - '0';
		}
	}

	int ans = h - 1 + w - 1;
	for (int temp = 0; temp < (1 << (h - 1)); temp++) {
		bitset<10> set(temp);

		vector<vector<int>> grp;
		grp.push_back(s.at(0));
		for (int i = 1; i < h; i++) {
			if (set.test(i - 1)) {
				grp.push_back(s.at(i));
			} else {
				for (int j = 0; j < w; j++) {
					grp.at(grp.size() - 1).at(j) += s.at(i).at(j);
				}
			}
		}

		int cut_c = 0;
		int from_c = 0;
		bool ok = true;
		for (int c = 0; c < w; c++) {
			for (auto grp_ele : grp) {
				int sum_c = 0;
				bool first = false;
				for (int i = from_c; i <= c; i++) {
					sum_c += grp_ele.at(i);
					if (i == from_c) {
						first = true;
					} else {
						first = false;
					}
				}
				if (sum_c > k) {
					if (first == true) {
						ok = false;
						break;
					} else {
						cut_c++;
						from_c = c;
					}
				}
			}
			if (ok == false) {
				break;
			}
		}
		if (ok == true) {
			int cut = set.count() + cut_c;
			ans = min(ans, cut);
		}
	}

	cout << ans << endl;

}



Measured memory_bytes: 384
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	b := make([]int, n)
	p, q := n/2, n/2-1
	f := true
	for i := 0; i < n; i++ {
		if f {
			b[p] = a[i]
			f = false
			p++
		} else {
			b[q] = a[i]
			f = true
			q--
		}
	}

	if f {
		for i := 0; i < n; i++ {
			fmt.Fprint(wr, b[i], " ")
		}
	} else {
		for i := n - 1; i >= 0; i-- {
			fmt.Fprint(wr, b[i], " ")
		}
	}
	fmt.Fprintln(wr)

}


Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int x;cin>>x;
    rep2(i,1,361){
        if((x*i)%360==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int r,D,x;
    cin >> r >> D >> x;
    for(int i=1;i<=10;i++){
        x = r*x-D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Data.Vector as V

m :: Int
m = 1000000

main = do
  s <- readLn
  let v = V.replicate m 0
      v' = v // [(s,1)]
  print $ solve s v' 0 + 2

f :: Int -> Int
f n = if n `mod` 2 == 0 then n `div` 2 else 3*n+1

solve :: Int -> Vector Int -> Int -> Int
solve a v cnt= 
  if v ! b == 1 
    then cnt
    else solve b v' (cnt+1)
  where b = f a
        v' = v // [(b,1)]


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main() {
	int N; cin >> N;
	vector<ll> A(N), B(N);
	vector<pair<ll, pair<ll, ll>>> d(N);

	rep(i, N) {
		cin >> A[i] >> B[i];
		d[i] = mp(A[i] + B[i], mp(A[i], B[i]));
	}
	sort(ALL(d)); reverse(ALL(d));

	ll sa = 0, sb = 0;

	rep(tt, N) {
		bool f = (tt & 1);
		ll a = d[tt].se.fi, b = d[tt].se.se;
		if (!f) {
			sa += a;
		} else {
			sb += b;
		}
	}
	cout << sa - sb << endl;

	return 0;
}

Measured memory_bytes: 4096
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ 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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{a:[i64;3], n:i64};
    let mut ans = 0i64;
    for r in 0..3001 {
        for g in 0..3001 {
            let b = n - (a[0]*r) - (a[1]*g);
            if b < 0 || b%a[2]!=0 { continue; }
            //debug!(r,g,b);
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.*;

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

   while((x + y) != 0){
    if(x < y){
        System.out.println(x + " " + y);
    }
    else{
        System.out.println(y + " " + x);
    }
    x = sc.nextInt();
    y = sc.nextInt();
   }
 }
}

Measured memory_bytes: 36000
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int n,b[110];
  cin >> n;
  for(int i = 0; i < n-1; i++)
    cin >> b[i];

  b[n-1] = 110000;
  int sum = 0;
  for(int i = n-1; i > 0; i--)
    sum += min(b[i], b[i-1]);
  
  cout << sum + b[0] << endl;
}

Measured memory_bytes: 3572
package main

import "fmt"

func main() {
	var w string
	fmt.Scan(&w)
	m := make(map[rune]int)
	for _, s := range w {
		m[s]++
	}

	for _, v := range m {
		if v%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  //direction arrays
  int dx[8]={0,0,-1,+1,+1,-1,+1,-1};
  int dy[8]={+1,-1,0,0,+1,-1,-1,+1};
  int h,w;
  char v[100][100];
  int dfs(int i,int j)
  {
    int x,y,ans=0;
    //cout<<h<<w<<" h w here is \n";
    for(int k=0;k<=7;k++)
    {
      //cout<<dx[k]<<" d.arrays "<<dy[k]<<"\n";
          x=i+dx[k];
          y=j+dy[k];
          //cout<<x<<" "<<y<<"outside if "<<endl;
          if(x>=0 and x<h and y>=0 and y<w)
          {
            //cout<<x<<" "<<y<<endl;
             if(v[x][y]=='#')
              ans++;
          }
    }
    //cout<<ans<<" "<<"for i j is "<<i<<j<<endl;
    return ans;
  }
  int32_t main()
  { 
   /* #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    //Atcoder Minesweeper Problem
    IOS
    cin>>h>>w;
    
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      cin>>v[i][j];
    }
    //cout<<"H is"<<h<<w<<endl;
    /*for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
        cout<<v[i][j];*/
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
        if(v[i][j]=='.')
          {int cnt=dfs(i,j);
            cout<<cnt;
          }
          else
            cout<<v[i][j];

      }
      cout<<endl;
    }

    return 0;
  }
    

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n: int):
        self.__n = n
        self.__par = list(range(self.__n))
        self.__size = [1 for _ in range(self.__n)]

    def root(self, x: int) -> int:
        if self.__par[x] == x:
            return x
        self.__par[x] = self.root(self.__par[x])
        return self.__par[x]

    def merge(self, x: int, y: int) -> bool:
        rx, ry = self.root(x), self.root(y)
        if rx == ry: return False

        if self.__size[rx] < self.__size[ry]:
            rx, ry = ry, rx

        self.__size[rx] += self.__size[ry]
        self.__par[ry] = rx
        return True

    def check(self, x: int, y: int) -> bool:
        return self.root(x) == self.root(y)

    def size(self, x: int) -> int:
        return self.__size[self.root(x)]


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

ans = 0
for i in range(M):
    uf = UnionFind(N + 1)
    for j in range(M):
        if i == j: continue
        a, b = ABm[j]
        uf.merge(a, b)

    if uf.size(1) != N:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<stdlib.h>
using namespace std;
int main()
{
   int n,i,j;
   cin>>n;
   vector<int> a(n);
   for(i=0;i<n;i++)
   {
   	cin>>a[i];
   }
   vector<int> dp(n,1000000005);
   dp[0]=0;
   for(i=0;i<n;++i)
   {
   	  for(j:{i+1,i+2})
   	  {
   	  	if(j<n)
   	      {
   	  	    dp[j]=min(dp[j],(dp[i]+abs(a[i]-a[j])));
   	      }
   	  }
   }
   cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#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>
#include <string.h>
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	long long a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	long long cnt=LLINF;
	if(c*2<=(a+b)){
		for(int i=min(x,y);i<=max(x,y);i++){
			long long ans=0;
			ans+=c*2*i;
			long long p=x;
			long long n=y;
			p-=i;
			n-=i;
			ans+=max(1LL*0,p)*a;
			ans+=max(1LL*0,n)*b;
			cnt=min(cnt,ans);
		}
		cout<<cnt;
		return 0;
	}
	cnt=0;
	cnt+=a*x+b*y;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc154/tasks/abc154_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int a = s.length();

		for(int i=1;i<=a;i++) {
			System.out.print("x");
		}
	}

}


Measured memory_bytes: 23892
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, x;
  cin >> N >> x;
  vec<ll> a(N);
  REP(i, N) cin >> a[i];

  sort(ALL(a));
  ll i = 0;
  for (; i < N; i++) {
    if (x - a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    } else if (x - a[i] < 0) {
      cout << i << endl;
      return 0;
    } else {
      x = x - a[i];
    }
  }
  cout << i - 1 << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string.h>
using namespace std;

int main(){
  char s[4];
  char t[4];
  char u[3];
  int i;
  cin >> s;
  if(strlen(s) == 3){
    for(i=0; i<3; i++){
      t[i] = s[2-i];
    }
    t[3] = '\0';
    cout << t << "\n";
  }else{
    for(i=0; i<2; i++){
      u[i] = s[i];
    }
    u[2] = '\0';
    cout << u << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!
    val INF = 1e15.toLong()
    val steps = TreeMap<Int, Int>()
    steps[N] = 0
    val minE = TreeMap<Int, Int>()
    minE[0] = N

    for (i in N - 1 downTo 0) {
        if (S[i] == '1') continue

        val e = steps.floorEntry(i + M)

        e?.let {
            steps[i] = e.value + 1

            minE[e.value + 1] = i
        }
    }

    if (steps.contains(0)) {
        val a = ArrayList<Int>()
        for (i in 0 .. steps[0]!!) {
            a.add(minE[i]!!)
        }
        a.reverse()

        val b = ArrayList<Int>()
        for (i in 0 until a.size - 1) {
            b.add(a[i + 1] - a[i])
        }
        println(b.joinToString(" "))
    } else {
        println(-1)
    }
}


Measured memory_bytes: 63728
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	int a[500];
	int s[500];
	int k[500];
	f(i, 500){
		a[i] = 0;
		s[i] = 0;
		k[i] = 0;
	}

	int n, m;
	int x, y, z;


	scanf("%d", &n);
	f(i, n-1){
		scanf("%d %d %d", &a[i],&s[i],&k[i]);
	}

	f(i, n){
		x = 0;
		for (int j = i; j < n - 1; j++){
			if (x < s[j]){
				x = s[j] + a[j];
			}
			else{
				y = x%k[j];
				if (y == 0)x = x + a[j];
				else x = x + (k[j] - y) + a[j];
			}
		}
		printf("%d\n", x);
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a),end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": "  << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i  < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

const int MAXN = 305;

ld dp[MAXN][MAXN][MAXN];
ld prob[MAXN][MAXN][MAXN];

lli n, U, V, W;

ld solve(int u, int v, int w) {
    ld &ans = dp[u][v][w];
    if(ans != -1) return ans;
    ans = 0;
    prob[u][v][w] = 0;
    lli tot = u + v + w;
    if(tot > n or u > U or v > U + V) return 0;
    ld z = (ld)(w + (ld)1) / (tot + ld(1));
    ans += solve(u, v, w + 1) * z;
    prob[u][v][w] += prob[u][v][w + 1] * z;
    if(w > 0) {
        z = (ld)(v + (ld)1) / tot;
        ans += solve(u, v + 1, w - 1) * z;
        prob[u][v][w] += prob[u][v + 1][w - 1] * z;
    }
    if(v > 0) {
        z = (ld)(u + (ld)1) / tot;
        ans += solve(u + 1, v - 1, w) * z;
        prob[u][v][w] += prob[u + 1][v - 1][w] * z;
    }
    if(tot > 0) {
        ld cycle = (ld)(n - tot) / (ld)(n);
        cycle = (cycle) / ((ld)(1) - cycle) + 1;
        ans += prob[u][v][w] * cycle;
    }
    return ans;
}

int main()
{   _
    fore(i, 0, MAXN) fore(j, 0, MAXN) fore(k, 0, MAXN) dp[i][j][k] = prob[i][j][k] = -1;
    cin >> n;
    lli x;
    vector<int> rep(4, 0);
    fore(i, 0, n) {
        cin >> x;
        ++rep[x];
    }
    W = rep[1];
    V = rep[2];
    U = rep[3];
    dp[U][V][W] = (ld)1;
    prob[U][V][W] = (ld)1;
    cout << setprecision(10) << fixed << solve(0, 0, 0) << ENDL;
    ///fore(i, 0, 4) cout << dp[0][0][i] << ENDL;
    return 0;
}


Measured memory_bytes: 890564
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const s = input[0].split(' ')[0];
  const t = input[0].split(' ')[1];

  console.log(`${t}${s}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    cnt = min(n, m // 2)
    n -= cnt
    m -= (cnt * 2)
    if m != 0:
        cnt += (m // 4)
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

lli bin_pow(lli a, lli b)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1)
            ret *= a;
        b >>= 1;
        a *= a;
    }
    return ret;
}

int main()
{
    lli n, p, d, curr, ans, pow, arr[200005];
    string s;
    cin >> n >> p;
    cin >> s;
    curr = 0, ans = 0;
    memset(arr, 0, sizeof(arr));
    arr[curr]++;
    // pow=1;

    if (p == 2)
    {
        for (lli i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 2 == 0)
                ans += (i + 1);
        }
    }
    else if (p == 5)
    {
        for (lli i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 5 == 0)
                ans += (i + 1);
        }
    }
    else
    {
        lli po = 1;
        for (lli i = n - 1; i >= 0; i--)
        {
            curr = curr + ((s[i] - '0') * po);
            curr = curr % p;
            // if (curr < 0)
            //     curr += p;
            po = (po * 10) % p;
            ans += arr[curr];
            arr[curr]++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5316
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// エラトステネスの篩(sieve of eratosthenes)を用いて素数判定テーブルを作成する
// O(n loglog n) worst time, O(n) word space
vector<bool> MakePrimeChecker(const Int size) {
    vector<bool> table(size, true);
    table[0] = false;
    table[1] = false;
    Int loop = sqrt(size);
    for (Int i = 2; i <= loop; ++i) {
        if (table[i] == true) {
            Int j = 2;
            while (i * j < size) {
                table[i * j] = false;
                ++j;
            }
        }
    }
    return table;
}

int main(void) {
    Int x;
    cin >> x;
    const Int TABLE_SIZE = 100004;
    vector<bool> prime_table = MakePrimeChecker(TABLE_SIZE);
    for (Int i = x; i < TABLE_SIZE; ++i) {
        if (prime_table[i] == true) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 5000

int n;
map<int, int> mb, mw;
int data[N*2];

void add(int k, int x) {
  while(k <= 2*n) {
    data[k] += x;
    k += k & -k;
  }
}
int get(int k) {
  int s = 0;
  while(k > 0) {
    s += data[k];
    k -= k & -k;
  }
  return s;
}

vector<int> aw, ab;
int cb[N][N], cw[N][N], dp[N][N];

int main() {
  cin >> n;
  rep(i, n*2) {
    char c; int a;
    cin >> c >> a;
    if(c == 'W') {
      mw[a] = i;
      aw.push_back(a);
    } else {
      mb[a] = i;
      ab.push_back(a);
    }
  }
  sort(ALL(aw));
  sort(ALL(ab));

  rep(i, 2*n) {
    add(i+1, 1);
  }

  rep(i, n+1) {
    rep(j, n+1) {
      if(i < n) {
        cw[i][j] = get(mw[aw[i]]+1)-1;
      }
      if(j < n) {
        cb[i][j] = get(mb[ab[j]]+1)-1;
        add(mb[ab[j]]+1, -1);
      }
      //cout << i SP j SP cw[i][j] SP cb[i][j] << endl;
    }
    rep(j, n) {
      add(mb[ab[j]]+1, 1);
    }
    if(i < n) {
      add(mw[aw[i]]+1, -1);
    }
  }

  rep(i, n+1) rep(j, n+1) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n+1) {
    rep(j, n+1) {
      int v = dp[i][j];
      if(i > 0) {
        v = mind(v, dp[i-1][j] + cw[i-1][j]);
      }
      if(j > 0) {
        v = mind(v, dp[i][j-1] + cb[i][j-1]);
      }
      dp[i][j] = v;
    }
  }
  cout << dp[n][n] << endl;
  return 0;
}


Measured memory_bytes: 122496
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[101][100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n;long W;cin>>n>>W;
    long v[n+1]={0};
    long w[n+1]={0};
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=W;j++){
            if(w[i]>j){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
            }
        }
    }
    cout<<dp[n][W];


}


Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <complex>
#include <cstdio>
using namespace std;
typedef complex<double> P;

const double inf = 1e100;

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double getAngle(P a, P b) {
  return acos(dot(a,b)/(abs(a)*abs(b)));
}

const int MAXN = 401;

int N;
P ps[MAXN];
bool used[MAXN];

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    fill(used, used+MAXN, false);
    P s(0,-1);
    P t(0,0);
    double sum = 0;
    for(int tc = 0; tc < N; ++tc) {
      int j = -1;
      for(int i = 0; i < N; ++i) {
        if(used[i]) continue;
        if(j == -1) {
          j = i; continue;
        }
        P p = ps[i];
        P q = ps[j];
        if(cross(t-s,p-s) > 0.0) continue;
        if(cross(q-t,p-t) > 0.0 ||
           cross(q-t,p-t) == 0.0 && norm(q-t) > norm(p-t)) {
          j = i;
        }
      }
      used[j] = true;
      P u = ps[j];
      sum += abs(u-t);
      s = t;
      t = u;
    }
    printf("%.1f\n", sum);
  }
  return 0;
}

Measured memory_bytes: 1264
// AtCoder Begginer Contest 136 C - Build Stairs
// https://atcoder.jp/contests/abc136/tasks/abc136_c

#include<iostream>
#include<string>
#include<vector>
using namespace std;
using uint = unsigned int;

int main() {
	string S;
	cin >> S;
	
	uint len = S.length();
	vector<uint> H(len, 0);
	
	uint stop;
	uint diff;

	for(uint i=0; i<len; i++) {
		if(S.substr(i, 1) == "R") {
			stop = i;
		} else {
			diff = i - stop;
			if (diff % 2 == 0) {
				H[stop]++;
			} else {
				H[stop+1]++;
			}
		}
	}
	
	for(int i=len-1; 0<=i; i--) {
		if(S.substr(i, 1) == "L") {
			stop = i;
		} else {
			diff = stop - i;
			if (diff % 2 == 0) {
				H[stop]++;
			} else {
				H[stop-1]++;
			}
		}
	}
	
	
	for(uint i=0; i<len; i++) {
		cout << H[i] << " ";
	}
	
	return 0;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll v = max(a, max(b, c));
    rep(i, k) v *= 2;
    put(v + a + b + c - max(a, max(b, c))) 
    return 0;
}

Measured memory_bytes: 3584
n, d = map(int,input().split())
x = [list(map(int,input().split())) for i in range (n)]

ans = 0

for i in range(n):
    for j in range(i+1,n):
        t = 0
        for k in range(d):
            t += (x[i][k] - x[j][k])**2
        t = t**(1/2)
        if t.is_integer():
            ans += 1
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    vector<int> B(A.size());
    copy(A.begin(), A.end(), B.begin());
    sort(B.begin(), B.end());
    vector<int> unique, count;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            unique.push_back(B[i]);
            count.push_back(1);
            continue;
        }
        if (B[i] == B[i - 1]) {
            count[count.size() - 1] += 1;
        } else {
            unique.push_back(B[i]);
            count.push_back(1);
        }
    }
    unordered_map<int, int> num_count;
    unordered_map<int, int> count_num;
    ll base = 0LL;
    for (int i = 0; i < unique.size(); i++) {
        // cout << unique[i] << count[i] << endl;
        num_count[unique[i]] = count[i];
        count_num[count[i]] = unique[i];
        ll c = (ll) count[i];
        base += c * (c - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        ll c = (ll) num_count[A[i]];
        // cout << "A[i]: " << A[i] << "c: " << c << endl;
        ll ans = base;
        ans -= (c - 1);
        // ans -= c * (c - 1) / 2;
        // ans += (c - 1) * (c - 2) / 2;
        cout << ans << endl;
    }
    return 0;
}

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

int n,m,c,s,g;
int p[30], q[30][60], r[30][60];

int d_dist[30][110][110];
int d_final[110][110];

const int inf = 1e9;

int getcost(int dist, int *q, int *p){
    if(dist == inf) return inf;
    int res = 0;
    rep(i,1000000){
        if(dist <= q[i+1]){
            res += (dist-q[i]) * p[i];
            break;
        } else {
            res += (q[i+1]-q[i]) * p[i];
        }
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*
      ?????¢????????§???????????¨???WF 1
      ?????¢???????????§????????¨????????????
      ??????????????§WF 3
     */
    while(cin >> n >> m >> c >> s >> g && n){
        --s, --g;
        rep(ic,c)rep(i,n)rep(j,n) d_dist[ic][i][j] = inf;
        rep(i,n)rep(j,n) d_final[i][j] = inf;
        rep(i,c)rep(j,n) d_dist[i][j][j] = 0;
        rep(i,n) d_final[i][i] = 0;

        rep(i,m){
            int x,y,d,c;
            cin >> x >> y >> d >> c;
            --x, --y, --c;
            d_dist[c][x][y] = min(d_dist[c][x][y], d);
            d_dist[c][y][x] = min(d_dist[c][y][x], d);
        }

        rep(i,c) cin >> p[i];
        rep(i,c){
            q[i][0] = 0;
            rep(j,p[i]-1) cin >> q[i][j+1];
            q[i][p[i]] = inf*2;
            rep(j,p[i]) cin >> r[i][j];
        }

        rep(ic,c) rep(k,n)rep(i,n)rep(j,n) {
            d_dist[ic][i][j] = min(d_dist[ic][i][j], d_dist[ic][i][k] + d_dist[ic][k][j]);
        }
        rep(ic,c)rep(i,n)rep(j,n){
            d_final[i][j] = min(d_final[i][j], getcost(d_dist[ic][i][j], q[ic], r[ic]));
        }
        rep(k,n)rep(i,n)rep(j,n){
            d_final[i][j] = min(d_final[i][j], d_final[i][k] + d_final[k][j]);
        }
        int ans = d_final[s][g];
        cout << (ans == inf ? -1 : ans) << '\n';
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    string s;
    cin >> N >> s;
    ll r = 0;
    iter(c, s) r += c == 'R';
    if(r > N / 2) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


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

int main() {
	int N, T, A;
	double closest_diff = 1000000;
	int closest_id;

	cin >> N >> T >> A;

	for (int i = 0; i < N; i++) {
		int tmp_height;

		cin >> tmp_height;
		double tmp_diff = fabs((double)T - (double)tmp_height * 0.006 - A);

		if (tmp_diff < closest_diff) {
			closest_diff = tmp_diff;
			closest_id = i + 1;
		}
	}

	cout << closest_id << endl;

	return 0;
}

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

int n;
string S,T;
int main(){
	cin >> n;
	set<string> s;
	for(int i=1;i<=n;i++){
		cin >> S >> T;
		if(S=="insert") s.insert(T);
		else{
			decltype(s)::iterator it = s.find(T);
			if(it!=s.end()) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 32540
package main

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

func main() {
	sc := NewScanner()
	A := sc.NextIntArray()
	for i, v := range A {
		if v == 0 {
			fmt.Println(i + 1)
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){

    string s; cin >> s;
    for(char c : s){
        if(c == 'A') cout << 'T';
        else if(c == 'T') cout << 'A';
        else if(c == 'C') cout << 'G';
        else cout << 'C';
    }
    cout << endl;

	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int n; cin >> n; 
  cout << (n-1)/2+1 << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, L;
	while (cin >> n >> L, n | L){
		vector<int> vi;
		vector<int> vi2;
		vi2.push_back(n);
		int nc = n;
		int count = 0;
		while(nc!=0){
			vi.push_back(nc % 10);
			nc /= 10;
			count++;
		}
		REP(i, L - count)
			vi.push_back(0);
		count=0;
		
		int ansi=0,ans;
		while (1){
			SORT(vi);
			int maxn=0;
			REP(i, L)maxn+=vi[i] * (int)(pow(10,i));
			RSORT(vi);
			int minn=0;
			REP(i, L)minn+=vi[i] * (int)(pow(10, i));
			vector<int>::iterator it = find(vi2.begin(), vi2.end(), maxn - minn);
			if (it != vi2.end()){
				ansi = it-vi2.begin();
				ans = maxn - minn;
				break;
			}else{
				vi2.push_back(maxn - minn);
				vi.clear();
				int nc2 = maxn - minn;
				int count2 = 0;
				while (nc2 != 0){
					vi.push_back(nc2 % 10);
					nc2 /= 10;
					count2++;
				}
				REP(i, L - count2)
					vi.push_back(0);
			}
			count++;
		}
		cout << ansi << " " << ans << " " << count - ansi+1 << endl;
	}
}

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

int main() {
    int n, Y;
    cin >> n >> Y;

    for (int x=0; x<=n; x++) {
        for (int y=0; y<=n; y++) {
            if (x + y <= n) {
                int z = n - x - y;
                int total = 10000*x + 5000*y + 1000*z;
                if (total == Y && x + y == n - z) {
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
l = list(map(int, input().split()))
x = 0
y = 0
z = 0
for i in range(n):
    if l[i] <= a:
        x += 1
    elif a + 1 <= l[i] <= b:
        y += 1
    elif b + 1 <= l[i]:
        z += 1
print(min(x,y,z))

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

using namespace std;

using ll = long long;

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

    int n;
    string s;
    cin >> n >> s;

    int num_r = 0, num_b = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') ++num_r;
        else ++num_b;
    }
    if (num_r > num_b) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
//#include"../bits/stdc++.h"
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N != 0) {
        N /= K;
        ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <cassert>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int w, h;

#define MAX 70
char brd[MAX][MAX];

string memo[MAX][MAX];

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

class num {
public:
	string n;

	num():n("") {}
	num(string n):n(f(n)) {}

	string f(string s)
	{
		if (s[0] == '0' && s.size() > 1) return f(s.substr(1));
		return s;
	}

	bool operator<(const num &r) const {
		if (n.size() == r.n.size())
			return n < r.n;
		return n.size() < r.n.size();
	}
};

string dfs(int y, int x)
{
	if (memo[y][x] != "")
		return memo[y][x];

	string ans = "";
	rep(d, 2) {
		int ty = y+dy[d], tx = x+dx[d];
		if (!(0 <= ty && ty < h)) continue;
		if (!(0 <= tx && tx < w)) continue;
		if (!isdigit(brd[ty][tx])) continue;
		string ret = brd[y][x] + dfs(ty, tx);
		if (ans.size() == ret.size())
			ans = max(ans, ret);
		else if (ans.size() < ret.size())
			ans = ret;
	}
	if (ans == "") ans = brd[y][x];
	return memo[y][x] = ans;
}

int main(void)
{
	while (cin >> w >> h, w|h) {
		rep(j, MAX) rep(i, MAX)
			memo[j][i] = "";

		rep(j, h) rep(i, w) cin >> brd[j][i];

		num ans = num();
		rep(j, h)
			rep(i, w)
				if (isdigit(brd[j][i]))
					ans = max(ans, num(dfs(j, i)));

		cout << ans.n << endl;
	}
	return 0;
}

Measured memory_bytes: 1392