akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,j,k,a,b,M=1e9,d[510][510],r;
  char s[510][1010];
  while(scanf("%d %d",&n,&m),n||m){
    scanf("%s %s %s",s[0],s[1],s[2]);
    r=3;
    for(i=0;i<n*n;i++)d[i/n][i%n]=M;
    for(i=0;i<n;i++)d[i][i]=0;
    while(m--){
      scanf("%s",s[r]);
      for(i=0;strcmp(s[r],s[i]);i++);
      if(i==r)r++;
      scanf("%s %d %d",s[r],&a,&b);
      for(j=0;strcmp(s[r],s[j]);j++);
      if(j==r)r++;
      d[i][j]=d[j][i]=a/40+b;
    }
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	for(k=0;k<n;k++)d[j][k]=MIN(d[j][k],d[j][i]+d[i][k]);
      }
    }
    printf("%d\n",d[0][1]+d[1][2]);
  }
  return 0;
}

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

using namespace std;

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

    int ans = INT_MAX;
    while (n--) {
        int a;
        cin >> a;
        ans = min(ans, __builtin_ctz(a));
    }

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int K; cin >> K;
	int A, B; cin >> A >> B;
	for (int i = A; i <= B; ++i) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>

#pragma warning(disable: 4996)

int m, n, px[200], py[200], sx[1000], sy[1000];

int main()
{
	while (true)
	{
		scanf("%d", &m);

		if (m == 0) { break; }

		for (int i = 0; i < m; i++)
		{
			scanf("%d", &px[i]);
			scanf("%d", &py[i]);
		}

		scanf("%d", &n);

		for (int i = 0; i < n; i++)
		{
			scanf("%d", &sx[i]);
			scanf("%d", &sy[i]);
		}

		for (int i = 0; i < n; i++)
		{
			int fx = sx[i];
			int fy = sy[i];
			int gx = px[0];
			int gy = py[0];
			int hx = fx - gx;
			int hy = fy - gy;

			bool ok[200];

			for (int i = 0; i < m; i++)
			{
				ok[i] = false;
			}

			ok[0] = true;

			for (int j = 1; j < m; j++)
			{
				for (int k = 0; k < n; k++)
				{
					if (px[j] + hx == sx[k] && py[j] + hy == sy[k])
					{
						ok[j] = true;
					}
				}
			}

			for (int i = 0; i < m; i++)
			{
				if (ok[i] == false)
				{
					goto Exit;
				}
			}

			printf("%d %d\n", hx, hy);

		Exit:;
		}
	}

	return 0;
}

Measured memory_bytes: 2684
ans = 0
n,m = map(int,input().split())
dis = [[float('inf') for i in range(n)] for j in range(n)] #各点距離を最初∞に設定
abt = []
for i in range(m):
    abt.append(list(map(int,input().split()))) #入力
for a,b,t in abt:
    dis[a-1][b-1] = t #頂点aからbへの距離がt
    dis[b-1][a-1] = t # 逆も同様
for i in range(n):
    for j in range(n):
        for k in range(n):
            dis[k][j] = min(dis[k][j], dis[k][i] + dis[i][j])
for a,b,t in abt:
    if t > dis[a-1][b-1]:
        ans +=1
print(ans)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < int > inp(n);
    int i,xtag=0,sum=0;
    for (i=0;i<n;i++)
        cin>>inp[i];
    sort(inp.begin(),inp.end());
    for (i=0;i<n;i++)
        sum+=inp[i];
    if (sum%10) cout<<sum;
    else
    {
        for (i=0;i<n;i++)
            if ((sum-inp[i])%10) {xtag=1;sum-=inp[i];break;}
        if (xtag) cout<<sum;
        else cout<<0;
    }
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; ++i)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] input_int = new int[3];
            for (int j = 0; j < 3; j++)
            {
                input_int[j] = int.Parse(input[j]);
            }
            Array.Sort(input_int);

            if (input_int[2] * input_int[2] == input_int[0] * input_int[0] + input_int[1] * input_int[1])
            {
                Console.WriteLine("YES");
    
        }
            else
            {
                Console.WriteLine("NO");
  
        }

        }

    }
}



Measured memory_bytes: 9168
import math

def gcd3(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)

n = int(input())
s = sum([gcd3(a, b, c) for a in range(1, n + 1) for b in range(1, n + 1) for c in range(1, n + 1)])
print(s)


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

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

const int MAX_V = 1000;
const int INF = INT_MAX/3;

struct edge{
    int to, cap, rev;
    edge(int to, int cap, int rev): to(to), cap(cap), rev(rev) {}
};

struct graph{
    vector<edge> G[MAX_V];
    int prev[MAX_V];
    int edge_num[MAX_V];

    void add_edge(int from, int to, int cap){
        G[from].push_back((edge){to, cap, G[to].size()});
        G[to].push_back((edge){from, 0, G[from].size()-1});
    }

    int Edomonds_Karp(int s, int t){
        int flow = 0;
        int f = 1;
        while(f!=0){
            memset(prev, -1, sizeof(prev));
            memset(edge_num, -1, sizeof(edge_num));
            f = bfs(s, t);
            flow += f;
        }
        return flow;
    }

    int bfs(int s, int t){
        queue<int> que;
        que.push(s);
        prev[s] = -2;
        edge_num[s] = -2;
        int flow = INF;
        while(que.size()){
            int v = que.front();
            que.pop();
            for(int i=0;i<G[v].size();i++){
                edge e = G[v][i];
                if(prev[e.to]==-1 && e.cap>0){
                    prev[e.to] = v;
                    edge_num[e.to] = i;
                    que.push(e.to);
                }
            }
        }
        if(prev[t]==-1) return 0;
        vector<pii> path;
        int now = t;
        while(now!=s){
            path.push_back(make_pair(prev[now], edge_num[now]));
            now = prev[now];
        }
        reverse(path.begin(), path.end());
        int f = INF;
        for(int i=0;i<path.size();i++){
            f = min(f, G[path[i].first][path[i].second].cap);
        }
        for(int i=0;i<path.size();i++){
            edge &e = G[path[i].first][path[i].second];
            e.cap -= f;
            G[e.to][e.rev].cap += f;
        }
        return f;
    }

    void print_graph(int V){
        for(int i=0;i<V;i++){
            printf("vertex: %d\n", i);
            for(int j=0;j<G[i].size();j++){
                printf("to: %d, cap: %d\n", G[i][j].to, G[i][j].cap);
            }
            cout << endl;
        }
    }
};

int main(){
    int V, E;
    cin >> V >> E;
    graph g;
    for(int i=0;i<E;i++){
        int from, to, cap;
        cin >> from >> to >> cap;
        g.add_edge(from, to, cap);
    }
    cout << g.Edomonds_Karp(0, V-1) << endl;
    return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL MOD = 1e9+7;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main(){
    int H,W;cin >>H >> W;
    vector<string> vec;
    queue<pair<LL,pair<int,int>>> que;
    for(int a = 0;a < H;a++){
        string str;cin >> str;
        vec.push_back(str);
    }
    vector<vector<LL>> ans(H, vector<LL>(W, 1e18));    
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(vec.at(i).at(j) == '#'){
                que.push(make_pair(0, make_pair(i, j)));
                ans.at(i).at(j) = 0;
            }
        }
    }
    while(!que.empty()){
        auto p = que.front();
        que.pop();
      //  if(p.first > ans.at(p.second.first).at(p.second.second))continue;
       // ans.at(p.second.first).at(p.second.second) = min(p.first, ans.at(p.second.first).at(p.second.second));
        for(int index = 0;index < 4;index++){
            if(0 <= p.second.first + dx[index] && p.second.first + dx[index] < H && 0 <= p.second.second + dy[index] && p.second.second + dy[index] < W){
                if(ans.at(p.second.first + dx[index]).at(p.second.second + dy[index]) == 1e18){
                    que.push(make_pair(p.first+1, make_pair(p.second.first+dx[index], p.second.second + dy[index])));
                    ans.at(p.second.first + dx[index]).at(p.second.second + dy[index]) = p.first+1;
                }
            }
        }
    }
    LL tans = 0;
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            //if(tans == 1e18)abort();
            tans = max(tans, ans.at(a).at(b));
        }
    }
    cout<<tans<<endl;
}





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

int main()
{
  int N;
  cin >> N;
  std::vector<int> X;
  for (int i=0; i < N; i++) {
    int n;
    cin >> n;
    X.push_back(n);
  }
  std::vector<int> Y = X;
  std::sort(X.begin(), X.end());

  int  mid_idx = N/2;
  int default_median = X[mid_idx];
  int small_median = X[mid_idx - 1];

  for (int i = 0; i < N; i++) {
    if (Y[i] < default_median) {
      cout << default_median << endl;
    } else {
      cout << small_median << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3828
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var x = 1000 - (n % 1000);
        return x==1000 ? 0 : x;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27244
#include <stdio.h>
#include <string.h>

void swap(char *x, char *y){
  char t[3];
  strcpy(t, x);
  strcpy(x, y);
  strcpy(y, t);
}

int main(){
  int n, i, j, f, min;
  char in[37][3], bs[37][3];
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%s", in[i]);

  for(i = 0; i < n; ++i) strcpy(bs[i], in[i]);

  for(i = 0; i < n; ++i)
    for(j = n - 1; j > i; --j)
      if(bs[j][1] < bs[j - 1][1])
	swap(bs[j], bs[j - 1]);

  for(i = 0; i < n; ++i) printf(i != 0 ? " %s" : "%s", bs[i]);
  printf("\nStable\n");

  for(i = 0; i < n; ++i){
    min = i;
    for(j = i + 1; j < n; ++j)
      if(in[j][1] < in[min][1]) 
	min = j;
    if(min != i)
      swap(in[min], in[i]);
  }
  f = 0;
  for(i = 0; i < n; ++i){
    printf(i != 0 ? " %s" : "%s", in[i]);
    if(in[i][0] != bs[i][0]) f = 1;
  }
  puts("");
  puts(f ? "Not stable" : "Stable");
  return 0;
}

Measured memory_bytes: 612
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Build and provide the list of prime numbers.
class PrimeList {
 public:
  // Construct the list.
  PrimeList(int64_t);
  // Return true if queue is prime.
  bool IsPrime(int);
  // Used to access the vector of prime numbers. 0-indexed.
  int64_t operator[](int);
  // Get the size of prime numbers list.
  int64_t GetSize(void);

 private:
  // number list saved as std::vector. good for sequencial access.
  std::vector<int64_t> vec_;
  // number list saved as std::unordered_set. good for random access.
  std::unordered_set<int64_t> set_;
  // Log of the number which is thrown to constructor.
  int64_t searched_value_;
};

PrimeList::PrimeList(int64_t max) {
  if (max > 1000000) {
    std::cerr << "PrimeList::PrimeList() Error: Size is too large\n";
    std::cerr << "Note: Maximum size is 1000000\n";
    abort();
  }
  searched_value_ = max;
  std::unordered_set<int> searchlist(max);
  for (int i = 2; i <= max; i++) {
    searchlist.insert(i);
  }
  int top = 2;
  while (top <= std::pow(max, 0.5)) {
    // cout << top << endl;
    vec_.push_back(top);
    set_.insert(top);
    for (int i = top; i <= max; i += top) {
      searchlist.erase(i);
    }
    for (int i = top + 1; i <= max; i++) {
      if (searchlist.find(i) != searchlist.end()) {
        top = i;
        break;
      }
    }
  }
  for (int i = std::pow(max, 0.5); i <= max; i++) {
    if (searchlist.find(i) != searchlist.end()) {
      vec_.push_back(i);
      set_.insert(i);
    }
  }
}

int64_t PrimeList::operator[](int queue) {
  if (queue >= vec_.size()) {
    std::cerr << "PrimeList::operator[](int) Error: Queue is too large\n";
    std::cerr << "Note: Maximum value is " << vec_.size() - 1 << "\n";
    abort();
  }
  return vec_[queue];
}

bool PrimeList::IsPrime(int queue) {
  if (queue >= searched_value_) {
    std::cerr << "PrimeList::IsPrime(int) Error: Queue is too large\n";
    std::cerr << "Note: Maximum value is " << searched_value_ << "\n";
    abort();
  }
  return (set_.find(queue) != set_.end());
}

int64_t PrimeList::GetSize(void) {
  return vec_.size();
}

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int64_t f(int64_t a, int64_t b) {
  cerr << "\033[93m" << a << " " << b << "\033[m" << endl;
  int64_t n  = std::max(a, b);
  int result = 1;
  while (n >= 10) {
    result++;
    n /= 10;
  }
  return result;
}

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

  PrimeList list(100000);
  int64_t n;
  cin >> n;
  int64_t result = f(n, 1);
  for (int64_t a = 1; a <= std::pow(n, 0.5) + 1; a++) {
    if (n % a == 0) {
      int64_t b = n / a;
      result    = std::min(result, f(a, b));
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
list<int> cards;
list<int>::iterator itr;
int n,m,temp;

void Kcut(int K){
 for(int i = 2 * n; i > K ; i--){
    int hoge = cards.back(); //cardsの最後の要素を前にもってくる、そして前のを消す
    cards.push_front(hoge);
    cards.pop_back();
 }
}

void shaf(void){
 for(int i = 0; i < n; i++){
  auto it1 = cards.begin(),it2 = cards.begin();
  advance(it1, n+i);
  advance(it2,i+i+1);
  cards.insert(it2, *it1);
  cards.erase(it1);

 }
}
int main(){
 cin >> n >> m;
 for(int i = 1;i <= 2 * n;i++) cards.push_back(i);/*listに入力*/

 for(int i = 0;i < m;i++){
    cin >> temp;
    if(temp){
		 Kcut(temp);
		}

    else shaf();
 }

 for(itr = cards.begin(); itr != cards.end(); itr++) cout << *itr << endl;
 return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    deque<char> q;
    REP(i, S.size())
    {
        q.push_back(S[i]);
    }
    bool r = false;
    REP(i, Q)
    {
        ll T;
        cin >> T;
        if (T == 1)
        {
            r = !r;
        }
        else
        {
            ll F;
            char C;
            cin >> F >> C;
            if (F == 1 and !r or F == 2 and r)
            {
                q.push_front(C);
            }
            else
            {
                q.push_back(C);
            }
        }
    }
    string ans = "";
    ll N = q.size();
    REP(i, N)
    {
        ans.push_back(q.front());
        q.pop_front();
    }
    if (r)
    {
        reverse(ALL(ans));
    }
    OUT(ans);
}

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

using namespace std;

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)cout << "Left";
	else if (a + b < c + d)cout << "Right";
	else cout << "Balanced";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<vector<char>>a(N,vector<char>(N));
    vector<bool>ok(N),ok2(N);
    bool OK = false;
    for(int i = 0; i < N; i++) {
        bool flag = true;
        for(int j = 0; j < N; j++) {
            cin >> a[i][j];
            if(a[i][j] == '#') {
                ok[j] = true;
                ok2[i] = true;
            }
            else {
                flag = false;
            }
        }
        if(flag) {
            OK = true;
        }
    }
    int ans = INF;
    for(int i = 0; i < N; i++) {
        int cnt = 0,res = 0;
        bool flag2 = false;
        for(int j = 0; j < N; j++) {
            if(a[i][j] == '#') {
                cnt++;
            }
            else {
                if(ok[i] == false && ok2[i] == false) {
                    goto END;
                }
                else if(ok[i] == false) {
                    flag2 = true;
                }
            }
        }
        if(flag2) {
            res++;
        }
        res += N-cnt;
        for(int j = 0; j < N; j++) {
            bool flag = false;
            for(int I = 0; I < N; I++) {
                if(a[i][j] == '.') {
                    if(!OK) {
                        flag = true;
                    }
                }
                else {
                    if(a[I][j] == '.') {
                        flag = true;
                    }
                }
            }
            if(flag) {
                res++;
            }
        }
        ans = min(ans,res);
    END:;
    }
    if(ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3876
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
use input::*;
fn main() {
    let mut s = input_line_str();
    let mut sp = s.split(" ");
    println!("A{}C", sp.nth(1).unwrap().chars().collect::<Vec<_>>()[0]);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

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

int main() {
	int n ,m, d;
	cin >> n >> m >> d;
	if(d>0) printf("%.7f", (m-1)*((n-d)*2/((double)n*n)));
	if(d==0) printf("%.7f",(m-1)/(double)n);
	return 0;
}


Measured memory_bytes: 256
inp = input()

N = len(inp)

s1 = inp[0:(N-1)//2]
s2 = inp[(N+1)//2:N]

if (s1 == s1[::-1]) and (s2 == s2[::-1]):
    if (inp == inp[::-1]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 38424
program main
  implicit none
  integer(16)::N,A,B
  integer(16),allocatable,dimension(:,:)::C
  integer(16),allocatable,dimension(:)::v
  integer(16)::i
  integer(16),parameter::mo=10**9+7_16
  real(16)::ANS1
  integer(16)::ANS2
  integer(16)::cnt,cnt2
  read*,N,A,B
  allocate(v(N))
  read*,v
  call heapsort(N,v)
  ANS1=0
  do i=N,N-A+1,-1
   ANS1=ANS1+v(i)
  end do
  ANS1=ANS1/real(A)
  print"(f0.20)",ANS1
  call comb_table(N)

  if(v(N)/=v(N-A+1))then
   cnt=count(v(1:n) == v(n-a+1))
   cnt2 = count(v(n-a+1:n) == v(n-a+1))
   ANS2=C(cnt,cnt2)
  else
   cnt=A
   do i=N-A,1,-1
      if(v(i)/=v(N))exit
      cnt=cnt+1
   end do
   ANS2=0
   do i=A,B
      ANS2=ANS2+C(cnt,i)
   end do
  endif
  print"(i0)",ANS2
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer(16)::i,k,j,l
  integer(16):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
subroutine comb_table(N)
   integer(16)::N
   integer(16)::i,j
   allocate(C(0:N,0:N))
   C=0
   do i=0,N
      do j=0,i
         if(j==0 .or. j==i)then
            C(i,j)=1
         else
            C(i,j)=C(i-1,j-1)+C(i-1,j)
         endif
      end do
   end do
end subroutine
end program main

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

// 左づめでの10進数xをdigits桁のN進数vectorにしてを返す
vector<int> baseNumber(int N, int digits, int x) {
  vector<int> ret(digits, 0);
  // 商
  int quotient = x;
  int counter = 0;
  while (quotient > 0) {
    // 余り
    int remainder = quotient % N;
    quotient /= N;
    ret[counter] = remainder;
    counter++;
  }

  return ret;
};

// n-1までのN進数を上記のbaseNumberで返したvectorのvector
vector<vector<int>> baseNumbers(int n, int N, int digits) {
  vector<vector<int>> ret(n, vector<int> (digits));
  for (int i = 0; i < n; i++) {
    ret[i] = baseNumber(N, digits, i);
  }

  return ret;
};


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

  vector<int> k(m);
  vector<vector<int>> s(m, vector<int> (10));
  vector<int> p(m);

  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }

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

  vector<vector<int>> dfs = baseNumbers((int)pow(2, n), 2, n);

  int ans = 0;
  for (int i = 0; i < dfs.size(); i++) {
    vector<int> bn = dfs[i];
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int ons = 0;
      for (int l = 0; l < k[j]; l++) {
        if (bn[s[j][l] - 1] == 1) ons++;
      }
      if (!(ons % 2 == p[j])) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }

  cout << ans << endl;
};


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int a,b,c;
	cin >> a >> b >> c;
	if(a+b>=c && c>=a){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;

int main() {
 
int N,ans=0;
cin >>N;N*=2;
 vector<int> A(N);
 for(int i=0; i<N; i++){cin>>A[i];} 
// vector<vector<int>> A(N,vector<int>(M));
// for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
sort(A.begin(),A.end());
  for(int i=0; i<N; i++){if(i%2==0)ans+=A[i];}
cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        long N, A, B;
        N = cin.nextLong();
        A = cin.nextLong() - 1;
        B = cin.nextLong() - 1;

        long ans = 0;
        if ((B - A) % 2 == 0) ans = (B - A) / 2;
        else
        {
            ans = Math.Min(A + B + 1, (N - 1 - B) * 2 + 1 + (B - A)) / 2;
        }
        Console.WriteLine(ans);


    }



}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


class XRand
{
    uint x, y, z, w;


    public XRand()
    {
        init();
    }

    public XRand(uint s)
    {
        init();
        init_xor128(s);
    }

    void init()
    {
        x = 314159265; y = 358979323; z = 846264338; w = 327950288;

    }

    public void init_xor128(uint s)
    {
        z ^= s;
        z ^= z >> 21; z ^= z << 35; z ^= z >> 4;
        z *= 736338717;
    }

    uint next()
    {
        uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
    }

    public long nextLong(long m)
    {
        return (long)((((ulong)next() << 32) + next()) % (ulong)m);
    }

    public int nextInt(int m)
    {
        return (int)(next() % m);
    }

    public int nextIntP(int a)
    {
        return (int)Math.Pow(a, nextDouble());
    }

    public int nextInt(int min, int max)
    {
        return min + nextInt(max - min + 1);
    }


    public double nextDouble()
    {
        return (double)next() / uint.MaxValue;
    }

    public double nextDoubleP(double a)
    {
        return Math.Pow(a, nextDouble());
    }
}



Measured memory_bytes: 11092
n, k = map(int, input().split())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 6 
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)
for i in range(1, k+1):
  print(cmb(n-k+1, i, p) * cmb(k-1, i-1, p) % p)

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  ll res;
  if (a > b) {
    res = 0;
  } else if (n == 1 && a != b) {
    res = 0;
  } else {
    res = ((ll) (n - 1) * b + a) - ((ll) (n - 1) * a + b) + 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = 0;
      a=sc.nextInt();
      int b = 0;
      b=sc.nextInt();
      int c = 0;
      c=sc.nextInt();
      System.out.println(c+" "+a+" "+b);
    }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//UF
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    vl a(N);
    rep(i,N)cin>>a[i];
    sort(all(a));
    ll MAX=a[N-1];
    ll r=(MAX+1)/2;
    ll d=INF;
    ll A;
    rep(i,N-1){
        ll x=abs(r-a[i]);
        if(x<d){
            d=x;
            A=a[i];
        }else{
            cout<<MAX<<" "<<A<<endl;
            return 0;
        }
        if(i==N-2){
            cout<<MAX<<" "<<A<<endl;
        }
    }
}

Measured memory_bytes: 1024
S = input()
l = len(S)
d = {}

m = 0

ans = 0
for i in range(l):
    m  = (m + int(S[l-1-i]) * pow(10,i,2019)) % 2019
    if m in d:
        d[m] += 1
    else:
        d[m] = 1

for k, v in d.items():
    if v >= 2:
        ans += int(v * (v-1)/2)
    if k == 0:
        ans += v
print(ans)



Measured memory_bytes: 68472
#include <stdio.h>

using namespace std;

int main(void) {
  int x, y, result;
  char op;

  while(1) {
    scanf("%d %c %d", &x, &op, &y);
    switch (op) {
      case '+':
        result = x + y;
        break;
      case '-':
        result = x - y;
        break;
      case '*':
        result = x * y;
        break;
      case '/':
        result = x / y;
        break;
      default:
        return 0;
    }
    printf("%d\n", result);
  }
}



Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,mod=1e9+7,ans=1;cin>>n;
  lvector v(26,1);
  string s;cin>>s;
  rep(i,s.length()) v[s[i]-'a']+=1;
  rep(i,26) {ans*=v[i];ans%=mod;}
  print(ans-1);
  return 0;
}

Measured memory_bytes: 512
while True:
    try:
        m, f, r = list(map(int, input().split()))
        if m == -1 and f == -1 and r == -1:
            break
        if m == -1 or f == -1 or m+f < 30:
            print('F')
        elif m+f >= 80:
            print('A')
        elif m+f >= 65:
            print('B')
        elif m+f >= 50 or r >= 50:
            print('C')
        elif m+f >= 30:
            print('D')
    except:
        break


Measured memory_bytes: 5596
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    println(inOutExec(scanner))
}

fun inOutExec(scanner: Scanner): String {
    val (numOfPref, numOfCity) = readLine()!!.split(" ").map { it.toInt() }

    val citiesIn = mutableListOf<Pair<Int, Int>>()
    repeat(numOfCity) {
        val (pref, year) = readLine()!!.split(" ").map { it.toInt() }
        citiesIn.add(Pair(pref, year))
    }

    val cityCodeMap = citiesIn
            .asSequence()
            .groupByTo(mutableMapOf()) { it.first }
            .flatMap { entry -> entry.value // List<Pair<Int, Int>>
                    .asSequence()
                    .sortedBy { info -> info.second }
                    .mapIndexed { index, pair ->
                        pair to "%06d%06d".format(pair.first, index + 1) }
                    .toList()
            } // Pair<Pair<Int, Int>, String>
            .toMap()

    return citiesIn.joinToString(separator = "\n", postfix = "\n") { cityCodeMap[it]!! }
}


Measured memory_bytes: 157384
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    string s;
    cin >> s;
    if (s[0] != 'A') {
        puts("WA"); return 0;
    }
    int cnt = 0;
    int p = -1;
    for (int i = 2; i < s.size() - 1; i++){
        if (s[i] == 'C') {
            cnt++;
            p = i;
        }
    }
    if (cnt != 1) {
        puts("WA"); return 0;
    }
    for (int i = 1; i < s.size(); i++){
        if (i == p) continue;
        if (s[i] >= 'A' && s[i] <= 'Z') {
            puts("WA"); return 0;
        }
    }
    puts("AC");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int n; string s;
  cin>>n; cin>>s;
  
  if(n%2!=0){cout<<"No";}
  else{
    if(s.substr(0,n/2)==s.substr(n/2,n/2)){cout<<"Yes";}
    else{cout<<"No";}
  }
  
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int cnt=0;
    int tmp=0;
    for(int i=0;i<n;i++){
        if(tmp<vec.at(i)){
            tmp=vec.at(i);
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

const long long INF = 1LL << 60;

int main() {
	int n, k;
	cin >> n >> k;
	long long h[100010];
	rep(i, n) cin >> h[i];

	long long dp[100100];
	rep(i, 100100) dp[i] = INF;
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));

		}
	}

	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1792
/*input

*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,K;cin>>N>>K;
	vector<long int> a(N+1);
	for(int i=1;i<=N;i++) cin>>a[i];
	for(int i=K+1;i<=N;i++) cout<<(a[i]>a[i-K]?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 4840
#include<stdio.h>

int main()
{
    char str1[30]  ;
    char str2[30] ;
    
    scanf("%s",&str1);
    int i=0,len=0,j ;
    while(str1[i]!='\0')

    {
        i++ ;
        len++ ;
    }
    for(j = 0,i = len-1;i >= 0 ; i--,j++)
    {
       str2[j] = str1[i] ;
    }
    str2[j]='\0' ;
    printf("%s\n",str2);
    
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int N;
    cin >> N;
    vl A(N);
    in(N,A);
    
    vvl B(N,vl(61,0)),C(N,vl(61,0));
    rep(i,N){
        bitset<61> b(A[i]);
        rep(j,61) if(b[j] == 1) B[i][j] = 1;
    }
    
    //outmat(B);
    rep(i,61) C[0][i] = B[0][i];
    reps(i,1,N) rep(j,61) C[i][j] = C[i-1][j] + B[i][j];
    
    
    ll aa = 1;
    ll ans = 0;
    rep(i,N-1){
        aa = 1;
        rep(j,61){
            if(B[i][j] == 1){
                ans += (((ll)(N-i-1) - (C[N-1][j] - C[i][j])) * aa)%mod;
                ans %= mod;
                
            }else{
                ans += ((C[N-1][j] - C[i][j]) * aa)%mod;
                ans %= mod;
                
            }
            
            aa *= 2;
            aa %= mod;
        }
    }
    
    cout << ans%mod << endl;

    return 0;
}


Measured memory_bytes: 310196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll n;
//ld ;
//string s;

int main() {
    cin >> n;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        string vtemp;
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll count = 1;
    for(int i = 0; i < n-1; i++){
        //cout << (v[i] != v[i+1]) << endl;
        if(v[i] != v[i+1])count++;
    }
    cout << count << endl;
    return 0;
}


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

int N;
string S;
int MOD = 1.0e9 + 7;

int main() {
    cin >> N >> S;

    map<char, ll> mp;
    for (int i = 0; i < S.length(); i++) {
        mp[S[i]]++;
    }

    ll ans = 1;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        int val = itr->second;

        ans *= (val + 1);
        ans %= MOD;
    }
    ans--;

    cout << ans % MOD << endl;

    return 0;
}


Measured memory_bytes: 512
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())

    digit = 0
    cur = 0

    while cur < N:
        digit += 1
        cur = K ** digit - 1

    print(digit)


if __name__ == '__main__':
    main()


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

int main()
{
    int N, K;
    cin >> N>> K;
    char tmp;
    vector<char> S(N);

    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    for (int i = 0; i < N; i++){
        if(i==K-1){
            tmp = S.at(i) + 0x20;
            cout << tmp;
        }
        else {
            cout << S.at(i);
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define int long long
#define mod 1000000007
 main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,w;
	cin>>h>>w;
	string a[h];
	int dp[h][w];
	rep(i,0,h) cin>>a[i];
	int ans = 0;
	rep(i,0,h) rep(j,0,w) cin>>a[i][j],dp[i][j] = 0;
	rep(i,0,h)
	{
		rep(j,0,w)
		{
			if(a[i][j]=='#')
			{
				dp[i][j] = 0;continue;
			}
			if(i==0 and j==0)
			{
				dp[i][j] = 1;continue;
			}
			dp[i][j] = 0;
			if(i>0) dp[i][j] += dp[i-1][j];
			dp[i][j]%=mod;
			if(j>0) dp[i][j] += dp[i][j-1];
			dp[i][j]%=mod;

		}
	}
	cout<<dp[h-1][w-1]<<endl;



}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <cstdio>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;

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

#define ii(n) int n; cin>>n;
#define vi(v,n) vector<int> v(n); REP(i,n) cin>>v[i];
#define ss(x) string x; cin>>x;
#define sl(x) string y; cin>>y; char x[]; x = y.c_str();
#define iout(n) cout<<n<<endl;
#define sout(s) cout<<s<<endl;
#define vmin(v) *std::min_element(v.begin(), v.end())
#define vmax(v) *std::max_element(v.begin(), v.end())
#define vave(v) 1.*accumulate(v.begin(), v.end(), 0) / v.size()

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

	ss(st)
	ii(k)
	for (int j = 0; j < st.size(); j++){
	    if (k >= 'z'+1-st[j] && st[j]!='a'){
	        k -= 'z'+1-st[j];
	        st[j]='a';
	    }
	}
	k=k%26;

	st[st.size()-1] = 'a'+(st[st.size()-1]-'a'+k)%26;
	cout << string(st)<<endl;



	return 0;
}


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> r(0),g(0),b(0);
    rep(i,n){
        if(s[i]=='R') r.push_back(i);
        if(s[i]=='G') g.push_back(i);
        if(s[i]=='B') b.push_back(i);
    }
    ll ans=r.size()*g.size()*b.size();
    for(auto i:r){
        for(auto j:g){
            if(i%2==j%2){
                if(s[(i+j)/2]=='B') ans--;
            }
            if(0<=2*i-j && 2*i-j<n){
                if(s[2*i-j]=='B') ans--;
            }            
            if(0<=2*j-i && 2*j-i<n){
                if(s[2*j-i]=='B') ans--;
            }            
            
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3620
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
    exit()
if m==0:
    print(0,0)
    exit()
if m==1:
    if k==0:
        print(0,0,1,1)
    else:
        print(-1)
    exit()
ans=[]
for i in range(2**m):
    if i==k:
        continue
    ans.append(i)
ans.append(k)
for i in range(2**m-1,-1,-1):
    if i==k:
        continue
    ans.append(i)
ans.append(k)
print(*ans)


Measured memory_bytes: 59268
#include <bits/stdc++.h>
#define fi first
#define se second
#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORD(i, a, b) for(int i = (a); i > (b); --i)
#define REPD(i, a, b) for(int i = (a); i >=(b); --i)
#define TR(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define unmap unordered_map
#define pq priority_queue
#define lb lower_bound //first pos >= val
#define ub upper_bound // first pos > val
#define bp __builtin_popcount
#define debug(a) cout << a << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef pair <ll, ld> pld;
typedef pair <ll, pll> pllp;
typedef pair <pll, ll> ppll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <pii> vpii;
typedef string BigNum;

const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int baseHash = 331;
const int bigNumLength = 5000;
const ld PI = acos(-1);

//Remember limit for IT, etc..., and +1 in limit of any array
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;
//If TLE let's use int instead of ll because it's as slow as your WPM :)))

/*----IMPORTANT THINGS----*/
pll dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
/*------------------------*/

ll n;
vll g[limit];
bool visited[limit];
ll ans = -1;

void bfs() {
    queue <pll> q;
    q.push({1, 0});
    visited[1] = true;

    while(!q.empty()) {
        auto t = q.front();
        q.pop();

        if (t.fi == 2) ans = t.se;

        for (auto it : g[t.fi]) if (!visited[it]) {q.push({it, t.se + 1}); visited[it] = true;}
    }
}

void solveProblem() {
    bfs();

    cout << ans << endl;
}

void fastInput() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void readInput() {
    cin >> n;
    REP(i, 1, n) {
        ll v;
        cin >> v;
        g[i].pb(v);
    }
}

int main() {
    fastInput();
    readInput();
    solveProblem();
}



Measured memory_bytes: 11460
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<< min( ab(a,b)+ab(b,c) ,  min(ab(a,c)+ab(b,c) , ab(a,b)+ab(a,c))  )<<endl;
}


Measured memory_bytes: 256