akhauriyash/Code-Regression huggingface dataset:
import Debug.Trace

charToCode :: Char -> String
charToCode c = case c of
    ' ' ->"101"
    '\''->"000000"
    ',' ->"000011"
    '-' ->"10010001"
    '.' ->"010001"
    '?' ->"000001"
    'A' ->"100101"
    'B' ->"10011010"
    'C' ->"0101"
    'D' ->"0001"
    'E' ->"110"
    'F' ->"01001"
    'G' ->"10011011"
    'H' ->"010000"
    'I' ->"0111"
    'J' ->"10011000"
    'K' ->"0110"
    'L' ->"00100"
    'M' ->"10011001"
    'N' ->"10011110"
    'O' ->"00101"
    'P' ->"111"
    'Q' ->"10011111"
    'R' ->"1000"
    'S' ->"00110"
    'T' ->"00111"
    'U' ->"10011100"
    'V' ->"10011101"
    'W' ->"000010"
    'X' ->"10010010"
    'Y' ->"10010011"
    'Z' ->"10010000"

codeToChar :: String->Char
codeToChar s = case s of
    "00000"->'A'
    "00001"->'B'
    "00010"->'C'
    "00011"->'D'
    "00100"->'E'
    "00101"->'F'
    "00110"->'G'
    "00111"->'H'
    "01000"->'I'
    "01001"->'J'
    "01010"->'K'
    "01011"->'L'
    "01100"->'M'
    "01101"->'N'
    "01110"->'O'
    "01111"->'P'
    "10000"->'Q'
    "10001"->'R'
    "10010"->'S'
    "10011"->'T'
    "10100"->'U'
    "10101"->'V'
    "10110"->'W'
    "10111"->'X'
    "11000"->'Y'
    "11001"->'Z'
    "11010"->' '
    "11011"->'.'
    "11100"->','
    "11101"->'-'
    "11110"->'\''
    "11111"->'?'

solve :: String -> String
solve s = solve' code'
    where code = concat $ map charToCode s
          mod5 = (length code) `mod` 5
          n0 = if mod5==0 then 0 else (5-mod5)
          code' = code ++ (take n0 $ repeat '0')

solve' :: String -> String
solve' "" = ""
solve' code' = (codeToChar x):(solve' xs)
    where x = take 5 code'
          xs = drop 5 code'

main :: IO ()
main = do
    str <- getContents
    mapM_ putStrLn $ map solve $ lines $ str

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

typedef long long ll;

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

    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);

    for(int i = 0; i < N; i++) {
        cin >> x[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> y[i];
    }

    int mx = *max_element(x.begin(), x.end());
    int my = *min_element(y.begin(), y.end());

    if(X < Y && X < my && mx < Y && mx < my) {
        cout << "No War" << endl;
        return 0;
    }

    cout << "War" << endl;
}

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

int n;
long long k, a[100005];
int main()
{
	std::cin >> n >> k;
	long long m = 0;
	for (int i = 0; i < n; ++i) {
		std::cin >> a[i];
		m = std::max(m, a[i]);
	}

	long long x = 0;
	for (long long i = 40; i >= 0; --i) {
		if ((1LL << i) + x > k)
			continue;
		int yes = 0;
		for (int j = 0; j < n; ++j) {
			if (((a[j] >> i) & 1) == 1)
				++yes;
		}
		if (yes < n - yes)
			x += 1LL << i;
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i)
		ans += a[i] ^ x;

	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
import kotlin.*


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (n, k) = sc.intList()
        val imos = Array(2 * k + 1) { Array(3 * k + 1) { 0 } }
        for (i in 1..n) {
            var x = sc.nextInt()
            val y = sc.nextInt()
            val c = sc.nextChar()
            if (c == 'B') {
                x += k
            }

            val dx = x / k
            val mx = x % k

            val dy = y / k
            val my = y % k

            if (dx % 2 == dy % 2) {
                imos[mx][my]++
                imos[mx + k][my]--
                imos[mx][my + k]--
                imos[mx + k][my + k]++
            } else {
                imos[mx][my + k]++
                imos[mx + k][my + k]--
                imos[mx][my + 2 * k]--
                imos[mx + k][my + 2 * k]++
            }
        }

        for (i in 0..2 * k) {
            for (j in 0 until 3 * k) {
                imos[i][j + 1] += imos[i][j]
            }
        }

        for (i in 0 until 2 * k) {
            for (j in 0..3 * k) {
                imos[i + 1][j] += imos[i][j]
            }
        }


        var ans = 0
        for (i in 0 until k) {
            for (j in 0 until k) {
                ans = Math.max(ans, imos[i][j] + imos[i + k][j + k] + imos[i][j + 2 * k])
                ans = Math.max(ans, imos[i + k][j] + imos[i][j + k] + imos[i + k][j + 2 * k])
            }
        }

        println(ans)
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        while (l.size <= ptr) {
            l = readLine()!!.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        return readLine()!!.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 181748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rnd;
#define F first
#define S second
#define pb push_back
#define pii pair<int,int>

const int maxn = 1e5 + 10;
int n,m;
vector<int> g[maxn], gin[maxn];
int dp[maxn] = {};
vector<int> path;
vector<int> topsort;
set<int> notused;
int posints[maxn];

void findpath(int v) {
    path.pb(v);
    if (g[v].size()==0) {
        return;
    }
    else {
        for (auto to : g[v]) {
            if (notused.count(to)==0) continue;
            findpath(to);
            break;
        }
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);  cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL

    cin >> n >> m;
    for (int i=1; i<=m; i++) {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        gin[b].pb(a);
    }

    for (int i=1; i<=n; i++) notused.insert(i);
    for (int i=1; i<=n; i++) {
        if (path.size()==0) {
            auto it = notused.begin();
            findpath(*it);
        }
        int r = path[path.size()-1];
        path.pop_back();
        findpath(r);

        topsort.pb(path[path.size()-1]);
        notused.erase(path[path.size()-1]);
        path.pop_back();
    }
    reverse(topsort.begin(),topsort.end());
    // edges in topsort go from left to right
    for (int i=0; i<n; i++) {
        posints[topsort[i]] = i+1;
    }

    for (int i=2; i<=n; i++) {
        for (auto in : gin[topsort[i-1]]) {
            dp[i] = max(dp[i], dp[posints[in]] + 1);
        }
    }
    int ans=0;
    for (int i=1; i<=n; i++) ans = max(ans, dp[i]);
    cout << ans;

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL
}


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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if((A+B)>(C+D)){
    cout<<"Left"<<endl;
  }
  else if ((A+B)<(C+D)){
    cout<<"Right"<<endl;
  }
  else if ((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        ss: [chars;n]
    }
    let mut sx = Vec::new();
    for s in ss {
        let mut s = s.clone();
        s.sort();
        sx.push(s);
    }
    sx.sort();

    let mut v = Vec::new();
    let mut c = 1;
    for i in 0..n-1 {
        if sx[i] == sx[i+1] {
            c += 1;
        } else {
            v.push(c);
            c = 1;
        }
    }
    v.push(c);

    let mut res: u64 = 0;
    for x in v {
        res += x * (x-1) / 2;
    }
    println!("{}", res);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 19940
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct cell{
 char name[11];
 int data;
 int time;
 struct cell *next;
}cell;

typedef struct que{
 cell* front;
 cell* rear;
}que;




cell* makecell(char str[11],int data){

cell *new=(cell*)malloc(sizeof(cell));
strcpy(new->name,str);
new->data=data;
new->next=NULL;

return new;
}

void enque(que *Q,cell *new){
 if((Q->front)==NULL){Q->front=new;Q->rear=new;}/*要素1つ*/
 else{Q->rear->next=new;Q->rear=new;}
 return;
}

void deque(que *Q){
 if(Q->front->next==NULL){Q->front=NULL;Q->rear=NULL;}
 else{Q->front=Q->front->next;}

return;
}




int main(){
int n,i,q,temp;
int tmax=0;
int t;
char str[11];
cell *new;
cell *p;
que Q1,Q2;
Q1.front=NULL;
Q1.rear=NULL;
Q2.front=NULL;
Q2.rear=NULL;

scanf("%d %d",&n,&q);

for(i=0;i<n;i++){
 scanf("%s %d",str,&temp);
 tmax+=temp;
 new=makecell(str,temp);
 enque(&Q1,new);
}

t=0;
while(t<tmax){
 if((Q1.front)->data==q){
  t+=q;
  (Q1.front)->time=t;
  enque(&Q2,Q1.front);
  deque(&Q1);
 }
 else if((Q1.front)->data < q){
  t+=(Q1.front)->data;
  (Q1.front)->time=t;
  enque(&Q2,Q1.front);
  deque(&Q1);
 }
 else if((Q1.front)->data > q){
  t+=q;
  (Q1.front)->data-=q;
  enque(&Q1,Q1.front);
  deque(&Q1);

 }


}





p=Q2.front;

while(p!=NULL){
 printf("%s %d\n",p->name,p->time);
 if(p->time==tmax){break;}
 p=p->next;
 
}

return 0;
}


Measured memory_bytes: 4048
package main

import (
        "fmt"
)

func solution(n int, w []string) string {
        memo := make(map[string]bool, n)
        memo[w[0]] = true

        pre := w[0][len(w[0])-1]
        for i := 1; i < n; i++ {
                if _, ok := memo[w[i]]; ok || pre != w[i][0] {
                        return "No"
                }
                pre = w[i][len(w[i])-1]
                memo[w[i]] = true
        }
        return "Yes"
}

func main() {
        var n int
        fmt.Scan(&n)
        w := make([]string, n)
        for i := range w {
                fmt.Scan(&w[i])
        }
        fmt.Println(solution(n, w))
}

Measured memory_bytes: 512
#pragma region Imports
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion

//cout<<"Case #"+to_string(tc+1)+": "+to_string(z)<<endl;
ll d[3001][3001];
ll f(int a[],int n,int s,int e){
  if(s>e)
    return 0;
  if(d[s][e]==-1)
    d[s][e]=max(a[s]-f(a,n,s+1,e),a[e]-f(a,n,s,e-1));
  return d[s][e];
}
int main() {
  fio
  int n;
  in>>n;
  int a[n];
  ia(a,n)
  fb(i,3001)
    fb(j,3001)
    d[i][j]=-1;
  out<<f(a,n,0,n-1);
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++)
		cin >> A[i];
	
	sort(A,A+n);
	int sum;
	sum = A[n-1] - A[0];
	cout << sum << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main(){

  int N,M;
  while(1){
    cin>>N>>M;
    if(N==0&&M==0) break;
    
    vector<pair<int,int> > PD(N);

    unsigned long long prob;
    
  for(int i=0; i<N;i++) {
    cin>>PD[i].second>>PD[i].first;
    }

  sort(PD.begin(),PD.end());

    
  int k=N-1;
  
  while(M>=0 && k>=0){

    if (PD[k].second<=M) { 
      M-=PD[k].second;
      PD[k].second=0;
      }
    
    else {
      PD[k].second-=M;
      M=-1;
    }
    k--;
  }
  
  prob=0;
  for(int i=0;i<N;i++) prob+=PD[i].first*PD[i].second;
  cout<<prob<<endl;
  }
  return 0;}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi p(n); for(auto& e : p) cin >> e;

    rep(i, n){
        if(p[i] != i+1){
            rep(j, i+1, n){
                if(p[j] != j+1){
                    swap(p[i], p[j]);
                    break;
                }
            }
            break;
        }
    }

    rep(i, n){
        if(p[i] != i+1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W, M;
    cin >> H >> W >> M;
    vint h(M), w(M);
    vint cntH(H), cntW(W);
    set<pair<int, int>> bombs;

    for (size_t i = 0; i < M; i++)
    {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        cntH[h[i]]++;
        cntW[w[i]]++;
        bombs.insert({h[i], w[i]});
    }
    int maxH = *max_element(all(cntH));
    int maxW = *max_element(all(cntW));
    int ans = maxH + maxW - 1;
    vint maxHs, maxWs;

    for (int i = 0;i<H;i++)
    {
        if(cntH[i]==maxH)maxHs.push_back(i);
    }
    for (int j = 0;j<W;j++)
    {
        if(cntW[j]==maxW)maxWs.push_back(j);
    }
    for (auto &&i : maxHs)
    {
        for (auto &&j : maxWs)
        {
            if (bombs.count({i, j}) == 0)
            {
                ans++;
                cout << ans;
                return 0;
            }
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 26172
from itertools import combinations

N = int(input())
data = list(map(int, input().split()))
data.sort()
c = 0
for tri in combinations(data, 3):
  if tri[0] < tri[1] < tri[2] and tri[0] + tri[1] > tri[2] and tri[0] + tri[2] > tri[1] and tri[2] + tri[1] > tri[0]:
    c += 1
print(c)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int a[5];
  rep(i,5) cin >> a[i];
  
  int ten[5] = {0};
  int max = 0,maxnum = 0;
  int cou = 0;
  for(int i = 0; i < 5; i++){
    while((a[i] + cou)  % 10 != 0){
      ten[i]++;
      cou++;
    }
    if(ten[i] > max){
      max = ten[i];
      maxnum = i;
    }
    cou = 0;
  }
  
  int ans = 0;
  rep(i,5){
    ans += a[i];
    if(i != maxnum){
      ans += ten[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = 0;
        r = sc.nextDouble();
        
        System.out.printf("%.10f  %.10f",r * r * Math.PI, (2 * r) * Math.PI);
        
    }
    
}



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

int N, M, ans;
string s[100], t;
map<string, int> mp;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> s[i];
        mp[s[i]]++;
    }
    cin >> M;
    rep(i, M) {
        cin >> t;
        mp[t]--;
    }

    rep(i, N) {
        ans = max(ans, mp[s[i]]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    cities = []
    for i in range(M):
        P, Y = map(int, input().split())
        cities.append((i, P, Y))
    cities.sort(key=lambda t: t[2])
    count = defaultdict(int)
    ans = {}
    for i, P, _ in cities:
        count[P] += 1
        ans[i] = str(P).zfill(6) + str(count[P]).zfill(6)
    for i in range(M):
        print(ans[i])


main()


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    ll P[100001];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        if(P[P[i]] == i){
            cnt++;
        }
    }
    cout << cnt/2 << endl;
}

Measured memory_bytes: 4380
def main(num_1, num_2, num_3):
    if (num_3 > num_1 and num_3 > num_2) or (num_3 < num_1 and num_3 < num_2):
        return 'No'
    else:
        return 'Yes'


if __name__ == "__main__":
    num_1, num_2, num_3 = list(map(int, input().split()))
    print(main(num_1, num_2, num_3))


Measured memory_bytes: 38384
#include <stdio.h>

typedef struct Node{
  int parent;
  int left;
  int right;
}Tree;

Tree T[1000000];

void TreePrint(int);

int main(){
  int n, i, j, k ,l, id, child;

  scanf("%d",&n);
  for(i = 0;i <n;i++){
    T[i].parent = T[i].left = T[i].right = -1;
  }
  
  for(i = 0;i <n;i++){
    scanf("%d%d",&id, &k);
    
    for(j = 0;j < k;j++){
      scanf("%d",&child);
      
      T[child].parent = id;
      
      if(j == 0){
	T[id].left = child;
      }
      else if(j >0){
	T[l].right = child;
      }
      l = child;
    }
  }
  for(i = 0;i < n;i++){
    TreePrint(i);
  }
      return 0;
}

void TreePrint(int n){
  int i = T[n].parent;
  int dep = 0;

  while(i != -1){
    i = T[i].parent;
    dep++;
  }

  if(dep == 0){
    printf("node %d: parent = %d, depth = %d, root, ",n ,T[n].parent, dep);
  }

  else if(T[n].left == -1){
    printf("node %d: parent = %d, depth = %d, leaf, ",n ,T[n].parent, dep);
  }

  else{
    printf("node %d: parent = %d, depth = %d, internal node, ",n ,T[n].parent, dep);
  }

  i = T[n].left;
  printf("[");
  if(i != -1){

    printf("%d",i);
  }

  while(i != -1){
    i = T[i].right;

    if(i != -1){
      printf(", %d",i);
    }
  }
  printf("]\n");
}

Measured memory_bytes: 1788
#include <map>
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int p[100];
int t[100];
int v[100];

double rui[100];
double ruitmp[100];
double ans[100];

int main(){
  int n,m,l;
  scanf("%d%d%d", &n, &m, &l);

  REP(i,n) scanf("%d%d%d", p+i, t+i, v+i);
  REP(i,n) rui[i] = ans[i] = 0.0;

  vector<pair<double,pair<int,int> > > vv;
  map<double, int> cnt;

  REP(i,n) REP(j,m + 1){
    double tm = (double)l / v[i] + t[i] * j;
    vv.push_back(make_pair(tm, make_pair(i, j)));
    cnt[tm]++;
  }

  sort(vv.begin(), vv.end());
  vector<pair<int, double> > buff;

  REP(i,vv.size()){
    {
      int id = vv[i].second.first;
      int rest = vv[i].second.second;
      
      double rp = 1.0; // p^rest * (1-p)^(m-rest) * m C rest
      REP(j,rest){
	rp *= (p[id] / 100.0);
	rp *= (double)(m - j) / (rest - j);
      }
      REP(j,m-rest){
	rp *= 1 - (p[id] / 100.0);
      }

      ruitmp[id] += rp;

      buff.push_back(make_pair(id, rp));
      rui[id] += rp;
    }

    if(i == vv.size() - 1 || vv[i].first != vv[i+1].first){
      REP(ii, buff.size()){
	double rp = buff[ii].second;
	int id = buff[ii].first;
	double prob = 1.0;
	REP(j,n) if(id != j){
	  prob *= (1.0 - rui[j]);
	}
	ans[id] += prob * rp;	
      }
      buff.clear();
    }
  }

  REP(i,n) printf("%.6f\n", ans[i]);

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define forn(i,n) for(i=0;i<n;i++)
#define FORN(i,k,n) for(i=k;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define set(a,s) memset(a,s,sizeof(a))

int main()
{
	fast;
	int n,i,j;
	cin>>n;
	vi v(n);
	forn(i,n)
	cin>>v[i];
	int maxi=0;
	int count;
	forn(i,n)
	{
		count=1;
		for(j=i+1;j<n+1;j++)
		{
			if(j==n)
			{
				if(count>maxi)
				maxi=count;
				goto here;
			}
			if(v[j]>v[j-1])
			{
				if(count>maxi)
				maxi=count;
				i=j-1;
				break;
			}
			else
			count++;
		}
	}
	here:
	cout<<maxi-1<<'\n';
	return 0;
}


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

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

    double prob;
    int coin = 0;
    for (int i = 1; i <= min(n, k-1); i++) {
        coin = ceil(log(k / (double) i) / log(2));
        prob += pow(0.5, coin);
    }
    // cout << coin << endl;
    if (n > k-1)
        prob += n - k + 1;
    prob /= n;
    cout << setprecision(12) << prob << endl;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int a;
string b;

int main(){
    cin >> a >> b;
    rep(i,b.size()) {
        a = a*10+(b[i]-'0');
    }
    for (int i = 0; i <= a; i++) {
        if (i*i == a) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}
































Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int k;
string s;

int32_t main(){_

   cin>>n;
   cin>>s>>k;

   --k;

   for (int i = 0; i < n; ++i)
   {
      if(s[i] != s[k])s[i] = '*';
   }

   cout<<s;
   

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = pow(10,5)+10;

int main() {
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int now = INF;
  vector<int> ml;
  for(int i=N-1; i>=0; i--) {
    if (i==N-1) { ml.push_back(A[i]); continue; }
    if (*(ml.end()-1)<=A[i]) { ml.push_back(A[i]); continue; }
    *(upper_bound(ml.begin(), ml.end(), A[i])) = A[i];
  }
  // rep(i,ml.size()) cout << ml[i] << " "; cout << endl;
  int result = ml.size();
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1276
import sys

# import re
import math
import collections
# import decimal
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    pos = []
    for i in range(n):
        x, y = ns()
        pos.append((x, y))

    res = dict()
    for i in range(n):
        for j in range(n):
            if i == j: continue
            tmp_key = (pos[j][0] - pos[i][0], pos[j][1] - pos[i][1])
            if tmp_key in res.keys():
                res[tmp_key].append((pos[i], pos[j]))
            else:
                res[tmp_key] = [(pos[i], pos[j])]

    ans = 0
    for k in res.keys():
        ans = max(ans, len(res[k]))

    print(n-ans)


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  string s;
  cin>>s;
  n=s.size();
  vector<int>ans(n);
  rep(ri,2){
    {//solve R
      int cnt =0;
      rep(i,n){
        if(s[i]=='R')cnt++;
        else{
          ans[i]+=cnt/2;
          ans[i-1]+=(cnt+1)/2;
          cnt=0;
        }
      }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    rep(i,n){
      if(s[i]=='L')s[i]='R';
      else s[i]='L';
    }
  }
  rep(i,n){
    printf("%d%c",ans[i],i==n-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
main()
{
	int n,t,di=0;
	scanf("%d",&n);
	t=n;
	while(t)
	{
		t/=10;
		di++;
	}
if(di==1)
{
	printf("%d",n);
}
else if(di==2)
{
	printf("9");
}
else if(di==3)
{
	printf("%d",9+(n-100)+1);
}
else if(di==4)
{
	printf("909");
}
else if(di==5)
{
	printf("%d",910+(n-10000));
}
else
{
	printf("90909");
}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
int n, W, w[123456], v[123456];
int dp[110][123456];
signed main() {
	cin >> n >> W;
	for (int i = 1; i <= n; i++)cin >> w[i] >> v[i];
	for (int j = 1; j <= W; j++)dp[0][j] = -1;
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= W; j++)dp[i][j] = dp[i - 1][j];
		for (int j = 0; j <= W - w[i]; j++)
			if (dp[i - 1][j] > -1)
				dp[i][j + w[i]] = max(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
	}
	int ans = 0;
	for (int j = 0; j <= W; j++)ans = max(ans, dp[n][j]);
	cout << ans << endl;
}

Measured memory_bytes: 100224
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
using namespace std;

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


const long long INF = 1LL << 60;
long long c[30][10010];
long long dp[30][10010];


//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//

int main(){
    int n,k,x,y; cin >> n >> k >> x >> y;
    int res = 0;
    for(int i=0; i<n; ++i){
        if(i<k) res+=x;
        else res+=y;
    }
    cout << res <<endl;
}

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

void fnInsertionSort(vector<int> &argviSort, int argiGap, int &argiSortCnt)
{
  for (int ixSorting = argiGap; ixSorting < argviSort.size() ; ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - argiGap;

    while (ixSorted >= 0              &&
           iTarget < argviSort[ixSorted])
    {
      argviSort[ixSorted + argiGap] = argviSort[ixSorted];
      ixSorted -= argiGap;

      argiSortCnt++;
    }
    argviSort[ixSorted + argiGap] = iTarget;
  }
}

void fnShellSort(vector<int> &argviSort, vector<int> &argviGap, int &argiSortCnt)
{

  for (int iGap = 1; iGap < argviSort.size(); iGap = 3 * iGap + 1)
    argviGap.push_back(iGap);
  
  for (int i = argviGap.size() - 1; i >= 0; i--)
    fnInsertionSort(argviSort, argviGap[i], argiSortCnt);
}

void fnOutput(const vector<int> &argviSort, const vector<int> &argviGap, int argiSortCnt)
{
  if (argviGap.size() == 0)
  {
    cout << 1 << endl;                  // argviGap.size() ??? 1 ??¨??¨???
    cout << 1 << endl;                  // argviGap[0]     ??? 1 ??¨??¨???
  }
  else
  {
    cout << argviGap.size() << endl;

    for (int i = argviGap.size() - 1; i >= 0; i--)
    {
      if (i != argviGap.size() - 1) cout << " ";
      cout << argviGap[i];
    }
    cout << endl;
  }

  cout << argiSortCnt << endl;

  for (int i = 0; i < argviSort.size(); i++)
    cout << argviSort[i] << endl;
}

int main()
{
  vector<int> viSort;
  vector<int> viGap;
  int iSortCnt = 0;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnShellSort(viSort, viGap, iSortCnt);
  fnOutput(viSort, viGap, iSortCnt);

  return 0;
}

Measured memory_bytes: 6728
#include <bits/stdc++.h> 
using namespace std;
void solution(int a, int b, int h)
{
	int r=(a+b)*h/2;
	cout<<r<<endl;
}
main()
{
	int a,b,h;
	cin>>a;
	cin>>b;
	cin>>h;
	solution(a,b,h);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int flag=0;
    for(int i=n-2;i>=0;i--){
        if(arr[i]>arr[i+1]+1){
            flag=1;
          //  cout<<i<<endl;
            break;
        }
        if(arr[i]>arr[i+1]) arr[i]--;
    }
    if(flag==1) cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 640
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
dp = [[float("inf")] * w for i in range(h)]
dp[0][0] = 1 if s[0][0] == "#" else 0
d = [(-1, 0), (0, -1)]
for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            pass
        else:
            m = float("inf")
            for k in d:
                x = i + k[0]
                y = j + k[1]
                if 0 <= x < h and 0 <= y < w:
                    if s[i][j] == "#" and s[x][y] == ".":
                        m = dp[x][y] + 1
                    else:
                        m = dp[x][y]
                dp[i][j] = min(dp[i][j], m)
print(dp[h - 1][w - 1])

Measured memory_bytes: 3188
//ITP 1_6_C
#include <iostream>
using namespace std;

int main(){

  int n;
  cin >> n;

  int num[4][3][10] = {};
  for(int i=0;i<n;i++){
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    num[b-1][f-1][r-1] += v;
  }  
  
  for(int i=0;i<4;i++){
    if(i) cout << "####################" << endl;
    for(int j=0; j<3; j++){
      for(int k=0; k<10; k++){
        cout << " " << num[i][j][k];
      }
      cout<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3116
from itertools import product


def solve(string):
    n, *xy = map(int, string.split())
    *xy, = zip(*[iter(xy)] * 2)
    return str(
        sum(((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
            for i, j in product(range(n), repeat=2)) / n)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 3188
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				int h = sc.nextInt();
				int w = sc.nextInt();
				if(h==0&&w==0) break;
				for(int j=0; j<w; j++) {
					System.out.print("#");
				}
				System.out.println();
				for(int i=0; i<h-2; i++) {
					System.out.print("#");
					for(int j=0; j<w-2; j++) {
						System.out.print(".");
					}
					System.out.println("#");
				}
				for(int j=0; j<w; j++) {
					System.out.print("#");
				}
				System.out.println();
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 37508
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, Q, K;
vector<pair<int, int>> G[100010];
int dis[100010];

void dfs(int v, int pv, int d) {
    dis[v] = d;
    for (auto e : G[v]) if (e.first != pv) {
        dfs(e.first, v, d + e.second);
    }
}

void _main() {
    cin >> N;
    REP (i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    cin >> Q >> K;
    dfs(K - 1, -1, 0);
    REP (i, Q) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dis[x] + dis[y] << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 14336
import sys
import math
import itertools
import collections
from collections import deque
 
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
 
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
 
def main():
    N = NI()
    h = NLI()
    
    dp = [0 for _ in range((10**5)+10)]
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    
    for n in range(2,N):
        dp[n] = min(dp[n-2]+abs(h[n]-h[n-2]),dp[n-1]+abs(h[n]-h[n-1]))
    print(dp[N-1])
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 21112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		try (Scanner sc = new Scanner(System.in)) {
			int x, a;
			x = sc.nextInt();
			a = sc.nextInt();
			
			if (x <a) System.out.println("0");
			else System.out.println("10");
			
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int a = sc.nextInt(),
				b = sc.nextInt(),
				x = Math.max(a, b),
				y = Math.min(a, b),
				count = 0;
			if (a == 0 && b == 0) break;
			while (y != 0)
			{
				x = x % y;
				int tmp = x;
				x = y;
				y = tmp;
				count++;
			}
			System.out.printf("%d %d\n", x, count);
		}
	}
}

Measured memory_bytes: 13000
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ratioA = sc.nextInt();
    int ratioB = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    int sumA = 0;
    int sumB = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
      sumA += a[i];
      sumB += b[i];
    }
    int[][][] dp = new int[401][401][N];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          dp[j][k][i] = -1;
        }
      }
    }
    dp[a[0]][b[0]][0] = c[0];
    for(int i = 1; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          if(a[i] <= j && b[i] <= k) {
            int m = Integer.MAX_VALUE;
            if(a[i] == j && b[i] == k) {
              m = c[i];
            } else {
              if(dp[j - a[i]][k - b[i]][i - 1] != -1) m = c[i] + dp[j - a[i]][k - b[i]][i - 1];
            }
            if(dp[j][k][i - 1] == -1) {
              if(m == Integer.MAX_VALUE) {
                dp[j][k][i] = -1;
              } else {
                dp[j][k][i] = m;
              }
            } else {
              dp[j][k][i] = Math.min(m, dp[j][k][i - 1]);
            }
          } else {
            dp[j][k][i] = dp[j][k][i - 1];
          }
        }
      }
    }
    int cost = Integer.MAX_VALUE;
    for(int i = 1; i <= Math.min(sumA / ratioA, sumB / ratioB); i++) {
      if(dp[ratioA * i][ratioB * i][N - 1] != -1) {
        cost = Math.min(cost, dp[ratioA * i][ratioB * i][N - 1]);
      }
    }
    int res = 0;
    if(cost != Integer.MAX_VALUE) {
      res = cost;
    } else {
      res = -1;
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 41508
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;

const double EPS=1e-10;
const double INF=1e10;

// 点オブジェクト
// ベクトルを表すのにも使う
struct Point {
    double x, y;
    Point(double x=0, double y=0) : x(x), y(y) {}
    double distance (const Point &o) const {
        return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
    }

    Point operator+(const Point &o) const {
        return Point(x+o.x, y+o.y);
    }

    Point operator-(const Point &o) const {
        return Point(x-o.x, y-o.y);
    }

    Point operator*(const double m) const {
        return Point(x*m, y*m);
    }

    // 外積
    double cross(const Point &o) const {
        return x * o.y - y * o.x;
    }

    // 内積
    double dot(const Point &o) const {
        return x * o.x + y * o.y;
    }

    // ベクトルがx軸となす角
    double atan() const {
        return atan2(y, x);
    }

    // ベクトルの長さの二乗
    double norm() const {
        return dot(*this);
    }
};

// 点の進行方向
// 戻り値:
//     +1: 反時計回り
//     -1: 時計回り
//     +2: c, a, bの順に一直線上
//     -2: a, b, cの順に一直線上
//      0: a, c, bの順に一直線上
int ccw(Point a, Point b, Point c) {
    b = b-a, c = c-a;
    if (b.cross(c) > EPS) return +1; 
    if (b.cross(c) < -EPS) return -1;
    if (b.dot(c) < 0) return +2;
    if (b.norm() < c.norm()) return -2;
    return 0;
}

// 多角形
struct Polygon {
    vector<Point> vertex;

    Polygon() {}
    Polygon(vector<Point> vertex) : vertex(vertex) {}

    inline void add_vertex(Point v) {
        vertex.push_back(v);
    }

    Point next(int v) const {
        return vertex[(v+1) % vertex.size()];
    }
    Point prev(int v) const {
        return vertex[(v-1+vertex.size()) % vertex.size()];
    }

    double area() const {
        double ret = 0;
        for (int i = 0; i < vertex.size(); i++) {
            ret += vertex[i].cross(next(i));
        }
        return abs(ret) * 0.5;
    }
};

int main() {
    double x, y;
    char d;
    Polygon p;
    while (cin >> x >> d >> y) {
        p.add_vertex(Point(x, y));
    }
    printf("%.8f\n", p.area());
    return 0;
}

Measured memory_bytes: 0
n = [input() for i in range(5)]
flag = 1
ans = 0
l = []
while flag:
    flag = 0
    for i in range(len(n)-1,0,-1):
        if n[i][-1] < n[i-1][-1]:
            n[i],n[i-1] = n[i-1],n[i]
            flag = 1
for i in range(len(n)):
    if n[i][-1] != '0':
        n[i] = int(n[i])
        l = n.pop(i)
        break
for i in range(len(n)):
    n[i] = int(n[i])
for i in range(len(n)):
    while n[i]%10 != 0:
        n[i] += 1
    ans += n[i]
if l:
    ans += l
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int semi[55][55]={};
  int sum[55][55]={};
  int h,w;
  int i,j;
  char n;

  cin>>h>>w;

  rep(i,h+1)
    sum[i][0]=INF;
  rep(j,w+1)
    sum[0][j]=INF;

  for(i=1;i<=h;i++)
    for(j=1;j<=w;j++){
      cin>>n;
      semi[i][j]=n-'0';
      if(i==1 && j==1)
	sum[i][j]=0;
      else 
	sum[i][j]=min(sum[i-1][j],sum[i][j-1])+semi[i][j];
  }
  cout<<sum[h][w]<<endl;
}

Measured memory_bytes: 1180
N, K = map(int, input().split())
S = "1" + input() + "1"
arr = []
cnt = 0
flg = 1
for s in S:
    if s == "1" and 1 - flg:
        flg = 1
        arr.append(cnt)
        cnt = 1
    elif s == "0" and flg:
        flg = 0
        arr.append(cnt)
        cnt = 1
    else:
        cnt += 1
arr.append(cnt)
csum = [0] * (len(arr)+1)
for i in range(len(arr)):
    csum[i + 1] = csum[i] + arr[i]
ans = 0
tmp = 0
for i in range(0, len(csum), 2):
    l = i
    r = min(i + 2*K + 1, len(csum) - 1)
    tmp = csum[r] - csum[l] - (r == len(csum) - 1) - (l == 0) - (l == 1)
    ans = max(ans, tmp)
if len(csum) == 2:
    print(csum[1] - 2)
else:
    print(ans)


Measured memory_bytes: 46320
#pragma region Macros
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7904