akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B; cin >> A >> B;
  int k; cin >> k;
  int cnt = 0;
  int div = min(A, B);
  while(1){
    if(A % div == 0 && B % div == 0) {
      cnt++;
    }
    if(cnt == k) {
      cout << div << endl;
      return 0;
      break;
    }
    div--;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC090A
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "";
            for (int i = 0; i < 3; i++)
            {
                string s = Console.ReadLine();
                ans += s[i];
            }

            Console.WriteLine(ans);


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13140
import math

def main():
    N,D = map(int,input().split())
    X = [list(map(int,input().split())) for i in range(N)]
    ans = 0
    for i in range(N):
        temp = X[i][0]**2 + X[i][1]**2
        temp1 = math.sqrt(temp)
        if temp1 <= D:
            ans += 1

    return ans

print(main())


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

void solve(int N, int K, string S)
{
    int n_seg = 1;
    char prev = S.at(0);
    for (int i = 1; i < N; i++)
    {
        if (prev != S.at(i))
        {
            n_seg++;
            prev = S.at(i);
        }
    }
    for (int i = 0; i < K; i++)
    {
        if (n_seg == 1)
            break;
        if (n_seg == 2)
            n_seg -= 1;
        else
            n_seg -= 2;
    }
    cout << N - n_seg << endl;
}

int main()
{
    int N;
    cin >> N;
    int K;
    cin >> K;
    string S;
    cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int bit[100001],n;
int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

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

int main(void){
    int m;cin>>n>>m;
    vector<pair<int,int>> pr(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        pr[i]={b,a};
    }
    sort(pr.begin(),pr.end());
    int res=0;
    rep(i,m){
        //cout<<pr[i].first<<" "<<pr[i].second<<endl;
        int a=pr[i].second,b=pr[i].first;
        ll left=sum(a-1),right=sum(b-1);
        if(right-left==0){
            res++;
            add(b-1,1);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.parseInt(sc.next());
        final int m = Integer.parseInt(sc.next());

        final int[] s = new int[m];
        final int[] c = new int[m];
        final boolean[] flag = new boolean[3];
        final int[] ans = new int[3];
        for (int i = 0; i < m; i++) {
            s[i] = Integer.parseInt(sc.next()) - 1;
            c[i] = Integer.parseInt(sc.next());
            if (flag[s[i]] == false) {
                flag[s[i]] = true;
                ans[s[i]] = c[i];
            } else {
                if (ans[s[i]] != c[i]) {
                    System.out.println(-1);
                    System.exit(0);
                }
            }
        }

        if (n == 3) {
            if (flag[0] == false) {
                ans[0] = 1;
            } else if (ans[0] == 0) {
                System.out.println(-1);
                System.exit(0);
            }
            System.out.print(ans[0]);
            System.out.print(ans[1]);
            System.out.println(ans[2]);
        } else if (n == 2) {
            if (flag[0] == false) {
                ans[0] = 1;
            } else if (ans[0] == 0) {
                System.out.println(-1);
                System.exit(0);
            }
            System.out.print(ans[0]);
            System.out.println(ans[1]);
        } else {
            System.out.println(ans[0]);
        }

        sc.close();
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,m;
pair<int,int> dp[10100];

bool comp(pair<int,int>& a,pair<int,int>& b){
	return a.first>b.first;
}

int main(){
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)break;
		int ans=0;
		REP(i,n){
			int t,s;
			cin>>t>>s;
			dp[i]=make_pair(s,t);
			ans+=s*t;
		}
		sort(dp,dp+n,comp);
		for(int i=0;i<n;i++){
			if(m>dp[i].second){
				m-=dp[i].second;
				ans-=dp[i].first*dp[i].second;
			}else{
				ans-=m*dp[i].first;
				break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
  int n,c;
  cin>>n>>c;
  int val[n+1],w[n+1];
  for(int i=1;i<=n;i++)
    cin>>w[i]>>val[i];
    long long dp[n+5][c+5];
    for(int j=0;j<=c;j++)
        dp[0][j]=0;
  for(int i=1;i<=n;i++)
  {
      for(int j=0;j<=c;j++)
      {
          if(j==0)
            dp[i][j]=0;
          else if(w[i]<=j)
          {
              dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+val[i]);
          }
          else
           dp[i][j]=dp[i-1][j];
      }
  }
  cout<<dp[n][c];
   return 0;
}


Measured memory_bytes: 80256
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	// 真ん中のbを基準にしてlower_bound, upper_bound
	n := nextInt()
	a := nextInts(n)
	b := nextInts(n)
	c := nextInts(n)
	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)
	ans := 0
	for _, bv := range b {
		ai := lower_bound(a, bv)
		ci := upper_bound(c, bv)
		ans += ai * (n - ci)
	}
	fmt.Fprintln(out, ans)
}

func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

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

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

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

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


Measured memory_bytes: 5888
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
 
    let ans = s[..].windows(3).fold(753, |n, w| {
        let num: i32 = (w[0] as i32 - 48) * 100 + (w[1] as i32 - 48) * 10 + (w[2] as i32 - 48);
        min(n, (753 - num).abs())
    });
 
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
    transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
    transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

    cout << s1[0] << s2[0] << s3[0] << endl;
    
    return 0;
}

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

int main()
{
	int a[4], b[4], hit, blow;

	while (1)
	{
		hit = 0;
		blow = 0;

		cin >> a[0];
		if (cin.eof()) break;
		cin >> a[1] >> a[2] >> a[3];
		cin >> b[0] >> b[1] >> b[2] >> b[3];

		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (a[i] == b[j])
				{
					if (i == j)
						hit++;
					else
						blow++;
				}
			}
		}

		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, M;
	cin >> N >> M;

	vector<int> A;
	rep(i, N) {
		int a;
		cin >> a;
		A.pb(a);
	}

	pair<int, int> BC[100000];
	rep(i, M) {
		int b, c;
		cin >> b >> c;
		BC[i] = mp(c, b);
	}
	sort(BC, BC + M);
	reverse(BC, BC + M);

	int kazu = 0;
	rep(i, M) {
		rep(j, BC[i].second) {
			if (kazu >= N) break;
			A.pb(BC[i].first);
			kazu++;
		}
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	ll kotae = 0;
	rep(i, N) {
		kotae += A[i];
	}

	co(kotae);
	
	Would you please return 0;
}

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

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

const ll mod=1e9+7;
const ll inf=1ll<<60;

/*---------------------*/

ll n,k,ans,num;
vector<ll> a,b;

int main(){
    cin>>n>>k;
    a.resize(n);
    b.resize(n);
    rep(i,n){
        cin>>a[i]>>b[i];
        if((k&a[i])==a[i])ans+=b[i];
    }
    rep(i,31){
        if((k>>i)&1==1){
            ll K=k;
            K|=(1<<i)-1;
            K-=(1<<i);
            num=0;
            rep(j,n){
                if((K&a[j])==a[j]){
                    num+=b[j];
                }
            }
            chmax(ans,num);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250005
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define __ template<typename T, typename... Types>
void in() {rt;} __ void in(T &a, Types&... b){cin>>(a); in(b...);}
void o() {rt;}  __ void o(T a, Types... b){cout<<(a);sp; o(b...);}
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
int main()
{
    fast;
    in(n);
       map<pair<ll,pair<ll,ll> >,ll>mp;
    fr(i,1,n)
    {
       k+=(n-1)/i;
    }
    o(k);
}



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  for (int i = 0; i < N; i++)
    cin >> B.at(i);
  for (int i = 0; i < N - 1; i++)
    cin >> C.at(i);
  
  int sum = 0;
  for (int i = 0; i < N; i++)
    sum += B.at(i);
  
  for (int i = 0; i < N-1; i++) {
    if (A.at(i+1) == A.at(i) + 1)
      sum += C.at(A.at(i) - 1);
  }
  
  cout << sum << endl;  
}


Measured memory_bytes: 256
#ACの人のやつ丸パクリです。自分のソースコードがTLEになるので試しに使わせてもらいます。

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力

Measured memory_bytes: 9252
function Main(input) {
  lines = input.split("\n");
  N= lines[0] * 1
  h = lines[1].split(' ').map(function(x) {
      return x * 1
  })
  n = h[0] * 1;
  cnt = 0;
  max = 0;
  for (i = 1; i < h.length; i++) {
      r = h[i] * 1
      if (n >= r) {
          cnt++
      } else {
          if (max < cnt) {
              max = cnt
          }
          cnt = 0
      }
      n = r
  }
  if (max < cnt) {
      max = cnt
  }
  console.log(max)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17816
#include <iostream>
#include <cstdint>
#include <string>

int main() {
  std::int_fast64_t h, w;
  std::cin >> h >> w;
  std::cout << std::string(w + 2, '#') << std::endl;
  for (std::int_fast64_t i = 0; i < h; ++i) {
    std::string s;
    std::cin >> s;
    std::cout << '#' << s << '#' << std::endl;
  }
  std::cout << std::string(w + 2, '#') << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll ma = 1e7;
    vector<ll> v(ma+10,2);
    v[1]=1;

    for(int i=2;i<=ma/2;i++){
        for(int k=2;k*i<=ma;k++){
            v[k*i]++;
        }
    }
    ll n;
    cin>>n;
    ll ans = 0;

    for(int i=1;i<=n;i++){
        ans+=i*v[i];
    }

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


Measured memory_bytes: 81216
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    ll n;
    cin>>n;
   
    vector<double> dp(n+1);
    dp[0]=1;
    
    fori(n){
        double p;
        cin>>p;
        for(ll j=i+1;j>=0;j--){
            dp[j]=(j==0? 0: dp[j-1]*(p))+dp[j]*(1-p);
        }
    }
    double sum=0;
    for(ll i=n/2+1;i<=n;i++){
        sum+=dp[i];
    }
    cout<<sp(15)<<sum;
    
//code ends
    return 0;
}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    
    auto func = [](int k) {
        int res = 0;
        while (k > 0) {
            res += (k % 10);
            k /= 10;
        }
        return res;
    };
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int r = func(i);
        if (a <= r && r <= b) ans += i;
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if ((i + j) % 2) cout << '.';
                else cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;
int main(){
	double a,b,c;
	int n;
	cin >> n >> a >> b >> c;
	vector<double> cal(n);
	double sum_c=c;
	double sum_p=a;
	double ans=sum_c/sum_p;
	for(int i=0; i<n; ++i){
		cin >> cal[i];
	}
	sort(cal.begin(),cal.end(),greater<double>());
	for(int i=0; i<n; ++i){
		sum_c+=cal[i];
		sum_p+=b;
		ans=max(ans,sum_c/sum_p);
	}
	cout << (int)ans << "\n";
	return 0;
}

Measured memory_bytes: 1256
<?php
fscanf(STDIN,"%d",$n);
$A = explode(" ",trim(fgets(STDIN)));
$cnt = 0;
for($i = 0; $i < $n - 1; ++$i){
    $minj = $i;
    for($j = $i + 1; $j < $n; ++$j){
        if($A[$j] < $A[$minj]){
            $minj = $j;
        }
    }
    if($i == $minj) continue;
    $v = $A[$i];
    $A[$i] = $A[$minj];
    $A[$minj] = $v;
    $cnt++;
}
for($i = 0; $i < $n; ++$i){
    if($i) echo " ";
    echo $A[$i];
}
echo "\n";
echo $cnt."\n";

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

int main()
{ 
   int n,x,t;
   cin>>n>>x>>t;
   int p;
    if(n%x == 0)
       p = n/x;
    else
       p = n/x +1;
   cout<<p*t;
  
  return 0;
}

Measured memory_bytes: 3592
N = int(input())
C = input()
num_w = 0
num_r = 0
for i in range(N):
    if C[i] == 'R':
        num_r += 1
ans = 10**10
for i in range(N+1):
    if i == 0:
        ans = min(ans, num_r)
    elif i == N:
        ans = min(ans, num_w)
    else:
        if C[i-1] == 'W':
            num_w += 1
        else:
            num_r -=1 
        ans = min(ans, max(num_r, num_w))
print(ans)

Measured memory_bytes: 9428
#include <stdio.h>

int main() {

  int i, j, m, n;
  int matrix[100][100];
  int vec[100], c[100]={};

  scanf("%d %d", &m, &n);
  for (i = 0; i < m; i++){
    for (j = 0; j < n; j++){
      scanf("%d", &matrix[i][j]);
    }
  }
  for (i = 0; i < n; i++){
    scanf("%d", &vec[i]);
  }
  for (i = 0; i < m; i++){
    for (j = 0; j < n; j++){
      c[i] += matrix[i][j] * vec[j];
    }
  }
  for (i = 0; i < m; i++){
    printf("%d\n", c[i]);
  }

  return 0;

}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int N, K;
        static int[] A;
       

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReader();
            N = input[0];
            K = input[1];
            A = cin.SplitReader();
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            Sort(A);
            List<long> type = new List<long>();
            long cnt = 0;
            long ans = 0;
            for(var i = 0; i < N; i++)
            {
                cnt++;
                if (i == N - 1) { type.Add(cnt); }
                else if (A[i] != A[i + 1])
                {
                    type.Add(cnt);
                    cnt = 0;
                }
            }

            if (type.Count() > K)
            {
                type.Sort();
                for(var i = 0; i < type.Count() - K; i++)
                {
                    ans += type[i];
                }
            }

            Console.WriteLine(ans);
            

            //Console.Out.Flush();

        }

       
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



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

struct Point{bool high;double x,y;};
bool comp(Point a,Point b) {return (a.x==b.x ? a.y<b.y : a.x<b.x);}

Point* Intersection(Point p1,Point p2,Point p3,Point p4){
    double d = (p2.x-p1.x)*(p4.y-p3.y)-(p2.y-p1.y)*(p4.x-p3.x);
    double u = ((p3.x-p1.x)*(p4.y-p3.y)-(p3.y-p1.y)*(p4.x-p3.x))/d;
    double v = ((p3.x-p1.x)*(p2.y-p1.y)-(p3.y-p1.y)*(p2.x-p1.x))/d;
    if(d==0 || u<0 || u>1 || v<0 || v>1)return NULL;
    Point *ret = (Point*) malloc(sizeof(Point));
    ret->x = p1.x+u*(p2.x-p1.x);
    ret->y = p1.y+u*(p2.y-p1.y);
    return ret;
}

int main(void){
    int N,n,o,l;
    cin>>N;
    while(N--){
        Point a,b;
        vector<Point> cross;
        cin>>a.x>>a.y>>b.x>>b.y>>n;
        rep(i,n){
            Point s,t;
            cin>>s.x>>s.y>>t.x>>t.y>>o>>l;
            Point *ret = Intersection(a,b,s,t);
            if(ret!=NULL){
                ret->high = o==l;
                cross.push_back(*ret);
            }
        }

        sort(cross.begin(),cross.end(),comp);
        int cnt=0;
        for(int i=0;i+1<(int)cross.size();i++){
            cnt+=(cross[i].high!=cross[i+1].high);
        }
        cout<<cnt<<endl;
    }

    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    string in;
    unordered_map<string, int> cnt;
    cin >> n;
    while(n--) {
        cin >> in;
        cnt[in]++;
    }
    printf("AC x %d\n", cnt["AC"]);
    printf("WA x %d\n", cnt["WA"]);
    printf("TLE x %d\n", cnt["TLE"]);
    printf("RE x %d\n", cnt["RE"]);
}


Measured memory_bytes: 3748
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h=0,w=0,i=0,j=0;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }
        for(i=0; i<h; i++){
            if(i==0 || i==h-1){
                for(j=0; j<w; j++){
                    printf("#");
                }
            }else{
                for(j=0; j<w; j++){
                    if(j==0 || j==w-1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main(){
  int N,ans=0,mi=200;
  cin >> N;
  vector<int> s(N);
  for(int i=0; i<N; i++){
    cin >> s[i];
    ans+=s[i];
    if(s[i]%10!=0){
      mi=min(mi,s[i]);
    }
  }
  
  if(ans%10!=0){
    cout << ans << endl;
  }
  else if(mi==200){
      cout << 0 << endl;
  }
  else{
    cout << ans-mi << endl;
  }
}

Measured memory_bytes: 256
*a,=map(int,open(0).read().split());print('NYoe s'[any(t<=set(a.index(b)for b in a[10:])for t in({0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}))::2])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int N;
    int ans=0,cnt=1;

    cin >> N;
    for(int i=0; i<N; ++i) {
        int temp;
        cin >> temp;
        if(temp==1) ++cnt;
        else {
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    cout << max(ans,cnt) << endl;
    return 0;
}



Measured memory_bytes: 3092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		// fmt.Println(err)
	}
	return a
}

func scanInt3() (int, int, int) {
	return scanInt(), scanInt(), scanInt()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, X, T := scanInt3()

	if N%X > 0 {
		fmt.Println((N/X + 1) * T)
	} else {
		fmt.Println((N / X) * T)
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define repr2(i, s, n) for(int i = n-1; i >= s; i--)
using namespace std;

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> board(h, vector<int>(w));
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(x, h)rep(y, w){
    // 初期化
    rep(i, h)rep(j, w) board[i][j] = s[i][j] - '0';
    
    // x行y列を消滅させる
    repr2(i, 1, x+1) board[i][y] = board[i-1][y];
    board[0][y] = 0;
    
    int score = 0;
    int step = 0;
    bool flag;
    while(1){
      flag = true;
      // 消滅させる
      rep(i, h){
        int count;
        int prev = -1;
        int now;
        rep(j, w){
          now = board[i][j];
          if (now == 0) count = 0;
          else if (now != prev) count = 1;
          else count++;
          if (count == k){
            flag = false; // 一回でも消滅したらもう一度判定する
            score += pow(2, step) * now * k;
            rep(l, k) board[i][j-l] = 0;
          }
          else if (count > k){
            score += pow(2, step) * now;
            board[i][j] = 0;
          }
          prev = now;
        }
      }
      // 消滅しなかったら終わり
      if (flag) break;

      // 消滅した分、下に下げる
      rep(l, h-1)repr2(i, l+1, h)rep(j, w){
        if (board[i][j] == 0){
          board[i][j] = board[i-1][j];
          board[i-1][j] = 0;
        }
      }
      step++;
    }
    ans = max(ans, score);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char alpha[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	char alpha2[26] = {'X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W'};
	
	char str[1000];
	int i;
	
	scanf("%s",str);
	
	for(i = 0; str[i] != '\0'; i++){
		for(int j = 0; j < 26; j++){
			if(alpha[j] == str[i]){
				printf("%c",alpha2[j]);
			}
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, n;
	cin >> x >> n;
	vector<int> p(n);
	for(int i=0; i<n; ++i) cin >> p[i];
	sort(p.begin(),p.end());
	p.push_back(1e9);

	int ans=0, j=0;
	for(int i=0; i<=101; ++i){
		if(i==p[j]){
			++j;
			continue;
		}
		if(abs(x-i)<abs(x-ans)){
			ans=i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3632
n=int(input())
h=list(map(int,input().split()))
count=0
max=0
for i in range(len(h)-1):
  if h[i]>=h[i+1]:
    count+=1
  else:
    if count>max:
      max=count
    count=0
if count>max:
  max=count
print(max)

Measured memory_bytes: 14224
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	m := make(map[int]bool)
	for i := 0; i < 3; i++ {
		a := readInt()
		m[a] = true
	}
	println(len(m))
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        //k種類の寿司を各種類毎に
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var grouped = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).GroupBy(x => x[0]).Select(x => x.Select(y => y[1]).OrderByDescending(y => y).ToArray()).OrderByDescending(x => x[0]).ToArray();
        var candidate = grouped.SelectMany(x => x.Skip(1)).OrderByDescending(x => x).ToArray();
        int candidatePtr = 0;
        long score = grouped.Take(k).Sum(x => (long)x.First());
        long variousCount = Min(grouped.Length, k);
        int groupPtr = (int)variousCount - 1;
        for (long i = variousCount + 1; i <= k; i++) score += candidate[candidatePtr++];
        while (0 <= groupPtr && candidatePtr < candidate.Length && variousCount * variousCount - (variousCount - 1) * (variousCount - 1) <= candidate[candidatePtr] - grouped[groupPtr][0])
        {
            variousCount--;
            score += candidate[candidatePtr++];
            score -= grouped[groupPtr--][0];
        }
        Console.WriteLine(score + variousCount * variousCount);
    }
}


Measured memory_bytes: 43972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        List<Integer> l = Pattern.compile(" ").splitAsStream(stdin.readLine()).map(Integer::valueOf).sorted().collect(Collectors.toList());
        Collections.sort(l);

        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int a = l.get(i);
                int b = l.get(j);

                int k = Collections.binarySearch(l, a + b, (p, q) -> p.compareTo(q) >= 0 ? 1 : -1);
                if (k < 0) k = (k + 1) * -1;
                ans += Math.max(0, k - (j + 1));
            }
        }
        stdout.println(ans);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 47296
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <unordered_map>
#define int long long
#define INF 1e+9
using namespace std; //575

typedef pair<int,int> P;

int n,a,b,x[100000],y[100000],d,ans = 0;
bool used[100000];
unordered_map<int,vector<P> > es,fs;
unordered_map<int,map<int,int> > emp,fmp;

signed main(){
	cin >> n >> a >> b; a--;b--;
	for(int i = 0;i < n;i++){
		cin >> x[i] >> y[i];
		int e = x[i] + y[i],f = x[i] - y[i];
		es[e].push_back(P(f,i));
		fs[f].push_back(P(e,i));
		if(i != a && i != b){
			emp[e][f] = i;
			fmp[f][e] = i;
		}
	}
	for(auto it = es.begin();it != es.end();it++) sort(it->second.begin(),it->second.end());
	for(auto it = fs.begin();it != fs.end();it++) sort(it->second.begin(),it->second.end());
	d = abs(x[a] - x[b]) + abs(y[a] - y[b]);
	queue<int> que;
	que.push(a);
	que.push(b);
	while(!que.empty()){
		int v = que.front();que.pop();
		used[v] = true;
		int e = x[v] + y[v],f = x[v] - y[v];
		vector<int> vec;
		for(auto it = emp[e - d].lower_bound(f - d);it != emp[e - d].end() && it->first < f + d;it++) vec.push_back(it->second);
		for(auto it = emp[e + d].lower_bound(f - d);it != emp[e + d].end() && it->first < f + d;it++) vec.push_back(it->second);
		for(auto it = fmp[f - d].lower_bound(e - d + 1);it != fmp[f - d].end() && it->first < e + d;it++) vec.push_back(it->second);
		for(auto it = fmp[f + d].lower_bound(e - d);it != fmp[f + d].end() && it->first <= e + d;it++) vec.push_back(it->second);
		for(int p : vec){
			que.push(p);
			e = x[p] + y[p];
			f = x[p] - y[p];
			emp[e].erase(emp[e].find(f));
			fmp[f].erase(fmp[f].find(e));
		}
	}
	for(int i = 0;i < n;i++){
		if(!used[i]) continue;
		int e = x[i] + y[i],f = x[i] - y[i];
		ans += upper_bound(es[e + d].begin(),es[e + d].end(),P(f + d,-1)) - lower_bound(es[e + d].begin(),es[e + d].end(),P(f - d,-1));
		ans += upper_bound(es[e - d].begin(),es[e - d].end(),P(f + d,-1)) - lower_bound(es[e - d].begin(),es[e - d].end(),P(f - d,-1));
		ans += upper_bound(fs[f + d].begin(),fs[f + d].end(),P(e + d,-1)) - lower_bound(fs[f + d].begin(),fs[f + d].end(),P(e - d,-1));
		ans += upper_bound(fs[f - d].begin(),fs[f - d].end(),P(e + d,-1)) - lower_bound(fs[f - d].begin(),fs[f - d].end(),P(e - d,-1));
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 65648
using System;

namespace ABC094A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string ret = string.Empty;

            string s1 = Console.ReadLine();
            string[] ss = s1.Split(' ');

            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            int c = int.Parse(ss[2]);

            ret = "YES";
            if(a > c)
            {
                ret = "NO";
            }
            if(a + b < c)
            {
                ret = "NO";
            }

            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S{ll y,m,d;};
struct Ma{ll b,ka,t,w,ki;};

//12,1,2,3...11
int M[]={31,28,31,30,31,30,31,31,30,31,30,31};

bool check(ll y){return (y%4==0&&(y%100!=0||y%400==0));}

S M2S(ll b,ll ka,ll t,ll w,ll ki){
  ka+=b*20;
  t+=ka*20;
  w+=t*18;
  ki+=w*20;
  S res;
  res.y=2012,res.m=12,res.d=21+ki;
  if(res.d<=31) return res;
  
  while(res.d/(365+check(res.y+1)))res.y++,res.d-=(365+check(res.y));
  if(res.d==0) res.m--,res.d=M[res.m-1]+(check(res.y)&&res.m==2);
  if(res.d<=31) return res;
  res.y++,res.m=1,res.d-=31;
  while(res.d/(M[res.m-1]+(check(res.y)&&res.m==2))){
    res.d-=(M[res.m-1]+(check(res.y)&&res.m==2));
    res.m++;
  }
  if(res.d==0) res.m--,res.d=M[res.m-1]+(check(res.y)&&res.m==2);
  return res;
}

Ma S2M(ll y,ll m,ll d){
  y-=2012;
  if(y) d+=10; 
  else d=(d-21);
  
  for(int i=0;i<m-1&&y;i++) d+=(M[i]+(i==1&&check(y+2012)));
  y--;
  while(y>0)d+=(365+check(y+2012)),y--;

  Ma res;
  d%=13*20*20*18*20;
  res.ki=d;
  res.w =res.ki/20; res.ki%=20;
  res.t =res.w/18;  res.w %=18;
  res.ka=res.t/20;  res.t %=20;
  res.b =res.ka/20; res.ka%=20;
  return res;
}


int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="#")break;
    vector <int> a;
    int i=0,num=0;
    while(str[i]){
      if(str[i]=='.')a.push_back(num),num=0;
      else num=num*10+str[i]-'0';
      i++;
    }
    a.push_back(num);
    
    if(a.size()==5){
      S ans=M2S(a[0],a[1],a[2],a[3],a[4]);
      cout << ans.y<<"."<<ans.m<<"."<<ans.d<<endl;
    }
    else {
      Ma ans=S2M(a[0],a[1],a[2]);
      cout<<ans.b<<"."<<ans.ka<<"."<<ans.t<<"."<<ans.w<<"."<<ans.ki<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;

ll n;
const int MAXN = 1e6+10;
bool isprime[MAXN];
vector<int> prime;

void init() {
  for (int i=0;i<MAXN;i++) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;
  for (int i=2;i<MAXN;i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (int j=i;j<MAXN;j+=i) {
        isprime[j] = false;
      }
    }
  }
}

void solve() {
  int ans = 0;
  ll tmp = n;
  init();

  for (int i=0;i<prime.size();i++) {
    int cnt = 0;
    while (tmp % prime[i] == 0) {
      cnt++;
      tmp /= prime[i];
    }
    int j = 1;
    while (cnt >= j) {
      cnt -= j;
      ans++;
      j++;
    }
    if (tmp == 1) {
      break;
    }
  }
  if (tmp > 1) {
    ans++;
  }
  cout << ans << endl;
}

int main() {
  cin >> n;
  solve();
}


Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	vector<pii> ans;
	int res=0;
	if(a.at(0)<0 && a.at(n-1)>=0){
		for(int i=n-2;i>=0;--i){
			if(a.at(i)>=0){
				ans.pb(mp(a.at(0),a.at(i)));
				a.at(0)-=a.at(i);
			}
			else{
				ans.pb(mp(a.at(n-1),a.at(i)));
				a.at(n-1)-=a.at(i);
			}
		}
		res=a.at(n-1);
	}
	else if(a.at(0)>=0){
		for(int i=1;i<n-1;++i){
			ans.pb(mp(a.at(0),a.at(i)));
			a.at(0)-=a.at(i);
		}
		ans.pb(mp(a.at(n-1),a.at(0)));
		res=a.at(n-1)-a.at(0);
	}
	else{
		for(int i=n-2;i>=0;--i){
			ans.pb(mp(a.at(n-1),a.at(i)));
			a.at(n-1)-=a.at(i);
		}
		res=a.at(n-1);
	}
	cout << res << endl;
	rep(i,n-1) cout << ans.at(i).first << " " << ans.at(i).second << endl;
}

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

#define ll long long
#define MOD 1000000007

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

	string s;
	cin>>s;
	if(s=="ABC") printf("ARC\n");
	else cout<<"ABC"<<endl;	
	
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main(){
  int m,f,r,sum;
  int count = 0;
  int mid[50], fin[50], re[50];
  while(true){
    scanf("%d %d %d",&mid[count],&fin[count],&re[count]);
    if(mid[count] == -1 && fin[count] == -1 && re[count] == -1)break;
    count++;
  }
  for(int i=0; i<count; i++){
    m = mid[i];
    f = fin[i];
    r = re[i];
    sum = m+f;
    //printf("Input: %d %d %d %d\n",m,f,r,count);
    if(m < 0 || f < 0 || sum < 30) printf("F");
    else if((m+f)>=80) printf("A");
    else if(65 <= (m+f) && (m+f) < 80) printf("B");
    else if((50 <= (m+f) && (m+f) < 65) || r >= 50) printf("C");
    else if(30 <= (m+f) && (m+f) < 50) printf("D");
    else if((m+f) < 30) printf("F");
    else printf("Undefined");
    printf("\n");
  }
}



Measured memory_bytes: 2696
S = gets.chomp
n = S.size
res = Array.new(n, 0)

def func(n, str, res, cnt = 0)
  n.times do |i|
    next cnt += 1 if str[i] == 'R'

    res[i] += cnt / 2
    res[i - 1] += (cnt + 1) / 2
    cnt = 0
  end

  res
end

res = func(n, S, res)

n.times { |i| S[i] = (S[i] == 'R') ? 'L' : 'R' }
res = func(n, S.reverse, res.reverse).reverse

puts res.join(' ')


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long a;
    long long b;
    long long tmpa=1;
    long long tmpb=1;
    
    cin >> a >> b;
    
    while(1){
        
        if(a*tmpa==b*tmpb){
            
            break;
            
        } else if(a*tmpa<b*tmpb){
            
            tmpa += 1;
            
        } else {
            
            tmpb += 1;
            
        }
        
    }
    
    cout << a*tmpa << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    const ll len = s.size();
    for (ll i=0; i<len; ++i)
    {
        string ss;
        for (ll j=i; j<len+i; ++j)
            ss += s[j % len]; 

        if (ss == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    r=int(input())
    print(math.pi*r*2)

resolve()


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

string O,E;

int main(){
    cin >> O >> E;

    int o = 0;
    int e = 0;
    string ans;
    for(int i = 0;i < O.length() + E.length();i++){
        if(i % 2 == 0){
            ans += O[o];
            o++;
        }else{
            ans += E[e];
            e++;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
	while ( true )
	{
		int q;
		cin >> q;
		
		if ( q == -1 )
		{
			break;
		}

		double x = q / 2.0;

		while ( q * 0.00001 < abs( pow( x, 3 ) - q ) )
		{
			x -= ( ( pow( x, 3 ) - q ) / ( 3 * pow( x, 2 ) ) );
		}

		printf("%.6lf\n", x );
	}

	return 0;
}

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

int n,m;
vector<vector<P>> dat(101);
vector<int> col(10,-1);
vector<bool> check(10,false);

int main(){
    int n;
    cin>>n;
    col=vector<int>(n+10,-1);
    check=vector<bool>(n+10,false);
    dat=vector<vector<P>>(n+10);
    rep(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        dat[u].push_back(P(v,w));
        dat[v].push_back(P(u,w));
    }
    queue<int> que;
    que.push(1);
    col[1]=0;
    while(que.size()){
        int q=que.front();que.pop();
        check[q]=true;
        for(auto p:dat[q]){
            if(col[p.first]!=-1) continue;
            if(p.second%2==0) col[p.first]=col[q];
            else col[p.first]=abs(1-col[q]);
            if(check[p.first]) continue;
            que.push(p.first);
        }
    }
    rep(i,n){
        cout<<col[i]<<endl;
    }
}

Measured memory_bytes: 9436
#include <stdio.h>
 
int main(void) {
	int a,b,c,i;
	while(scanf("%d %d",&a,&b) != EOF){
		c = a+b;
		for(i = 0;c != 0;i++){
			c = c/10;
		}
		printf("%d\n",i);
	}
	return 0;
}
 

Measured memory_bytes: 600
package main

import (
    "fmt"
    "sort"
    "strconv"
)

func main() {
    var n int
    fmt.Scan(&n)

    // F(A,B) =「10 進表記における、A の桁数と B の桁数のうち大きい方」
    // 2 つの正の整数の組 (A,B) が N=A×B を満たすように動くときの F(A,B) の最小値を出力せよ。
    // for文で、√nまでの約数を全探査
    // ループの中で、n/iで割り切れたときのi(A)と割った結果(B)から、大きい方の桁数を導き出す
    // 導き出した桁数をsliceに保存
    // ループ後、最も少ないsliceをsortで導き出す
    var results []int = make([]int, 0)
    for i := 1; i * i <= n; i++  {
        if n % i == 0 {
            var b int = n / i
            var strA string = strconv.Itoa(i)
            var strB string = strconv.Itoa(b)
            var digitA int = len(strA)
            var digitB int = len(strB)
            if digitA >= digitB {
                results = append(results, digitA)
            } else {
                results = append(results, digitB)
            }
        }
    }
    sort.Ints(results)
    fmt.Println(results[0])

}


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

int main(){
  int N, a;
  cin >> N;
  a = 0;
  for(int i = 0; i < N; i++){
    int b, c;
    cin >> b;
    c = 0;
    while(b % 2 == 0){
      c += 1;
      b /= 2;
    }
    if(i == 0){
      a = c;
    }
    else{
      a = min(a, c);
    }
  }
  cout << a << endl;
}
      

Measured memory_bytes: 256