akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a, b, c, d, e, X, Y ,r;
  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[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'};

  //  a=0;
  scanf("%lld %lld", &a, &b);
  a=a%b;
//  printf("%lld ",a);
  if((long long)(a-b)<0){
    if(a>b-a)X=b-a;
//    printf("%lld ",X);
  }

  else X=a;

  
  
  printf("%lld\n", X);
  
return 0;
}


Measured memory_bytes: 128
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



signed main(){
  int n,k;
  cin>>n>>k;
  int x[101];
  rep(i,n)cin>>x[i];
  int ans=0;
  rep(i,n){
    if(abs(x[i]<abs(k-x[i]))){
      ans+=x[i]*2;
    }else{
      ans+=abs(k-x[i])*2;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<bool> > vvb;
typedef vector<vector<int> > vvi;
typedef map<int, bool> mib;

typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vpll;

typedef vector<string> vs;

typedef long double ld;

#define _GLIBCXX_DEBUG

#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n-1); i >= 0; --i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORED(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << '\n'
#define debug3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << '\n'
#define debugs(s) cerr << s << "\n"
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

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

#define fst first
#define snd second
#define pb push_back
#define mk(x,y) make_pair((x),(y))

// http://ehafib.hatenablog.com/entry/2015/12/23/164137
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qpm(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
// gcd : O(logN)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define sz(v) int(v.size())

// x1, x2ライブラリとの被りを避ける
#define x1 x192837465
#define x2 x123456789
#define y1 y192837465
#define y2 y123456789

// typo
#define itn int
#define reutrn return
#define reutnr return
#define srting string

#define make(type, x) type x; cin>>x;
#define make2(type, x, y) type x, y; cin>>x>>y;
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z;
#define make4(type, x, y, z, t) type x, y, z, t; cin>>x>>y>>z>>t;

int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

#define uniq(v) (v).erase(unique(ALL((v))), (v).end());

// area of (0, 0)(a, b)(c, d)
double area(double a, double b, double c, double d){
    return abs(a * d - b * c) / 2.0;
}

const int PREC = 10;
#define coutf(val) cout << fixed << setprecision(PREC) << (val) << endl;

const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

signed main() {
    make(int, X);

    REP(A, 3000) {
        REP(B, 3000) {
            int a = A * A * A * A * A;
            int b = B * B * B * B * B;
            if (a - b == X) {
                cout << A << " " << B << endl;
                reutrn 0;
            } else if (a + b == X) {
                cout << A << " " << (-B) << endl;
                reutrn 0;
            }
        }
    }


}


Measured memory_bytes: 3616
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int fed = i;
        int st = i + 1;
        function<int(string, string)> calc = [&](string a, string b){
            map<char, int> seen;
            for(auto &x : a){
                seen[x]++;
            }
            set<char> cnt;
            for(auto &x : b){
                if(seen.count(x)){
                    cnt.insert(x);
                }
            }
            return SZ(cnt);
        };
        ans = max(ans, calc(s.substr(0, fed + 1), s.substr(st)));
    }
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto r = readln.chomp.to!real;
  writefln("%f %f", PI * r ^^ 2, 2 * PI * r);
}

Measured memory_bytes: 2548
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;cin>>n;
  double m,u;
  double ans=0,sum=0;
  vector<double>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    sum+=a.at(i);
    
  }
  for(int i=0;i<n;i++)
  {
    ans+=a.at(i);
    if(ans==sum/2)
    {
      cout<<0;
      break;
    }
    if(ans>sum/2)
    {
      m=ans-a.at(i);
      u=sum-m;
      int p=min(abs(m-u),abs(ans*2-sum));
      cout<<p;
      break;
    }
  }
  
  
}
      
    
    
  
 
    


Measured memory_bytes: 1792
N,M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
A_list = A[:M]

vote_sum = sum(A)
ans = 0

for i in A_list:
    if i/vote_sum < 1/(4*M):
        print("No")
        break
    else:
        ans +=1
if ans == M:
    print("Yes")

Measured memory_bytes: 9120
def inpl(): return [int(i) for i in input().split()]

N, P = inpl()
pf={}
for i in range(2,int(P**0.5)+1):
    while P%i==0:
        pf[i]=pf.get(i,0)+1
        P//=i
if P>1:pf[P]=1
ans = 1
for i , v in pf.items():
    ans *=  i**(v//N)
print(ans)

Measured memory_bytes: 40172
n, k = map(int,input().split())
ans = [0]*n
for i in range(k):
  d = int(input())
  A = list(map(int,input().split()))
  for a in A:
    ans[a-1] += 1
cnt = 0
for a in ans:
  if a == 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 9128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

class AAtCoderCrackers {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n,k;
		in >> n >> k;
		if(n % k == 0)out << 0 << endl;
		else out << 1 << endl;
	}
};


int main() {
	AAtCoderCrackers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int t[n], x[n], y[n];
    rep(i, n) cin >> t[i] >> x[i] >> y[i];

    bool ok = true;
    rep(i, n) {
        int dt, dx, dy;
        if (i == 0)
            dt = t[0], dx = x[0], dy = y[0];
        else {
            dt = t[i] - t[i - 1];
            dx = abs(x[i] - x[i - 1]);
            dy = abs(y[i] - y[i - 1]);
        }
        if (!(dt >= dx + dy && dt % 2 == (dx + dy) % 2)) ok = false;
    }

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 4808
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll dp[3005][3005];
void solve()
{
   dp[0][0]=0;
   string a,b;
   cin>>a>>b;
   ll n=a.size(),m=b.size();
   a="*"+a;
   b="*"+b;
   for(int i=1;i<=n;i++)
   {
   	  for(int j=1;j<=m;j++)
   	  {
   	  	  dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
   	  	  if(a[i]==b[j])
   	  	  {
   	  	  	  dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j]);
   	  	  }
   	  }
   }
   ll i=n,j=m;
   std::vector<char> v;
   while(i>0&&j>0)
   {
   	  if(a[i]==b[j]&&dp[i][j]==dp[i-1][j-1]+1)
   	  {
          v.pb(a[i]);
   	  	  i--;
   	  	  j--;
   	  }
   	  else
   	  {
   	  	  if(dp[i-1][j]==dp[i][j])
   	  	  {
   	  	  	  i--;
   	  	  }
   	  	  else
   	  	  	 j--;
   	  }
   }
   for(int i=0;i<v.size();i++)
   {
   	  cout<<v[v.size()-1-i];
   }

  // cout<<dp[n][m];
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 74100
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  string s;
  int k;
  cin >> k >> s;
  if(s.size()<=k) cout << s << endl;
  else{
    rep(i,k){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    N=N*A;
    if(N>B){
        printf("%d",B);
    }
    else if(N<B){
        printf("%d",N);
    }
    else{
        printf("%d",N);
    }
    return 0;

}


Measured memory_bytes: 128
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

struct ModFactorial {
    fact: Vec<i64>
}

impl ModFactorial {
    fn new(n: i64, m: i64) -> ModFactorial {
        let mut fact = vec![1; n as usize + 1];
        for i in 2..fact.len() {
            fact[i] = (i as i64 * fact[i - 1]) % m;
        }
        ModFactorial { fact: fact }
    }
}

struct ModBinominal {
    bin: Vec<i64>
}

impl ModBinominal {
    fn new(n: i64, m: i64) -> ModBinominal {
        let mod_factorial = ModFactorial::new(n, m);
        let mut bin = vec![1; n as usize + 1];
        for i in 1..mod_factorial.fact.len() - 1 {
            let a2 = mod_factorial.fact[i] % m;
            let a3 = mod_factorial.fact[n as usize - i] % m;
            bin[i] = mod_factorial.fact[n as usize] * mod_inverse(a2 * a3 % m, m) % m;
        }
        ModBinominal { bin: bin }
    }
}

const big_int: i64 = 998244353;

fn main() {
    let v = read_vec::<i64>();
    let (n, a, b, k) = (v[0], v[1], v[2], v[3]);

    let comb = ModBinominal::new(n, big_int).bin;

    let mut ans = 0i64;

    let mut a_coef = 0i64;
    while a * a_coef <= k && a_coef <= n {
        let cur_a_sum = a * a_coef;
        if (k - cur_a_sum) % b == 0 {
            let b_coef = (k - cur_a_sum) / b;
            if b_coef > n {
                a_coef += 1;
                continue;
            }
            ans += comb[a_coef as usize] * comb[b_coef as usize];
            ans %= big_int;
        }
        a_coef += 1;
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 12540
#include <string>
#include <iostream>
using namespace std;
string s;
pair<int, int> solve(int pos, int cnt) {
	if (s[pos] == 'n') {
		if (cnt == 0) return make_pair(0, 1);
		pair<int, int> ret = solve(pos + 5, cnt - 1);
		if (cnt == 1) return make_pair(ret.first - 45, ret.second);
		return make_pair(ret.first * 2 - 45, ret.second * 2);
	}
	if (cnt == 0) return make_pair(90, 1);
	pair<int, int> ret = solve(pos + 4, cnt - 1);
	if (cnt == 1) return make_pair(ret.first + 45, ret.second);
	return make_pair(ret.first * 2 + 45, ret.second * 2);
}
int main() {
	while (true) {
		cin >> s;
		if (s == "#") break;
		int pos = 0, c = 0;
		while (pos < s.size()) {
			if (s[pos] == 'n') pos += 5;
			else pos += 4;
			c++;
		}
		pair<int, int> ret = solve(0, c - 1);
		if (ret.second == 1) {
			printf("%d\n", ret.first);
		}
		else {
			printf("%d/%d\n", ret.first, ret.second);
		}
	}
	return 0;
}

Measured memory_bytes: 3248
import java.util.Scanner;

import java.util.*;
import static java.util.Comparator.*;

public class Main{
	static class V{
		long a;
		long b;
		long a(){
			return a;
		}
		long b(){
			return b;
		}
		V(long a, long b){
			this.a = a;
			this.b = b;
		}
	}
	
	static public void  main(String[] args){
		Scanner scan = new Scanner(System.in);

		int n  = scan.nextInt();
		long m  = scan.nextLong();

		List<V> a = new ArrayList<V>(n);


		for (int i = 0; i < n; i++){
			a.add(new V(scan.nextLong(),scan.nextLong()));
		}

		a.sort(comparing(V::a));
		Iterator<V> it = 		a.iterator();

		long cur = 0;
		long sum = 0;
		while(it.hasNext()){
			V v = it.next();
			//			System.err.println(v.a());
			if(cur + v.b() < m) {
				cur += v.b();
				sum += v.b() * v.a();
			}else{
				sum += (m - cur) * v.a();
				System.out.println(sum);
				return;
			}
		}

	}

}


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

using namespace std;

int main(){
int c500, c5, x, hap=0;
cin >> x;

c500 = x / 500;  
x %= 500;
c5 = x / 5;

hap = 1000*c500 + 5*c5;
  
cout << hap;
return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 118
	// https://atcoder.jp/contests/abc118/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (b % a == 0) {
			System.out.println(a + b);
		} else {
			System.out.println(b - a);
		}
	}
	
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    ll n;
    cin >> n;
    ll res = 0;
    if(n % 2 == 0){
        ll tmp = 10;
        int digit = 0;
        while(tmp <= n){
            res += n / tmp;
            tmp *= 5;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  #define f(i,a,b) for(int i=a;i<b;i++)
  #define ll long long
  #define vll vector<long long>
  #define mll map<ll,ll>
  #define pll pair<long long,long long>
  #define pb(x) push_back(x)
  #define F first
  #define S second
  #define print(v) for(auto it:v)cout<<it<<" "
  #define mod 1000000007   //10^9 +7
  #define sorty(v) sort(v.begin(),v.end())
  #define it(v) v.begin(),v.end()
using namespace std;  

int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  ll hold=n/(a+b);
  ll ans=a*hold;
  ll rest=n%(a+b);
  if(rest>=a)ans+=a;
  else ans+=rest;
  cout<<ans;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  string S;
  int n;
  int res=0;
  cin >> S;

  n = S.length();
  rep(i,n){
    cout << "x";
  }

  cout <<  endl;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.{Scanner, StringTokenizer}

import scala.util.Sorting

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val H = sc.nextInt()
    val W = sc.nextInt()
    val D = sc.nextInt()
    val N = H * W
    val A = Array.ofDim[(Int, Int)](N + 1)
    
    for {
      h <- 1 to H
      w <- 1 to W
    } {
      val x = sc.nextInt()
      A(x) = (h, w)
    }

    def move(s: (Int, Int), t: (Int, Int)) = math.abs(s._1 - t._1) + math.abs(s._2 - t._2)

    // (1 to D-1) から xまでのコスト
    val cost = Array.ofDim[Int](N + 1)
    (1 to D) foreach { d =>  // 最初の地点dから
      (0 until (N / D) + (if(d <= N % D) 1 else 0)) foreach { j =>  // j回移動する
        if (j == 0) cost(d) = 0
        else {
          val next = d + D * j
          val prev = d + D * (j - 1)
          cost(next) = cost(prev) + move(A(prev), A(next))
        }
      }
    }

    val Q = sc.nextInt()
    (0 until Q) foreach { _ =>
      val L = sc.nextInt()
      val R = sc.nextInt()
      println(cost(R) - cost(L))
    }
  }

  def main(args: Array[String]): Unit = {
    solve()
  }

  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
  }
}


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

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

	int ans = 0, min = INT_MAX;
	for (int i = 0; i < n; i++) {
		cin >> p;
		if (p < min) {
			ans++;
			min = p;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
int high[100005],a[100005];
int main()
{
	int n,m;
	sc(n);sc(m);
	rep(i,1,n)sc(high[i]);
	rep(i,1,m){
		int u,v;
		sc(u);sc(v);
		if(high[u]>high[v])a[v]=1;
		else if(high[v]>high[u])a[u]=1;
		else a[u]=a[v]=1;
	}int cou=0;
	rep(i,1,n)if(a[i]==0)cou++;
	pf("%d\n",cou);
}


Measured memory_bytes: 4608
#include<stdio.h>
int main(){
	int x1,y1,x2,y2,x3,y3,x4,y4,dx,dy;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	dx=x2-x1;
	dy=y2-y1;
	printf("%d %d %d %d\n",(x2-dy),(y2+dx),(x2-dy-dx),(y2+dx-dy));
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Map<String, Integer> map = new HashMap<>();


        for (int i=0; i<n; i++){
            String s = sc.next();
            if (map.containsKey(s)){
                int tmp = (int)map.get(s);
                map.put(s, tmp+1);
            }else {
                map.put(s, 1);
            }
        }


        List<String> list = new ArrayList<>();


        String maxStr = ((TreeMap<String, Integer>)sortByValues( map)).firstKey();
        int max = map.get(maxStr);

//        System.out.print(map.getClass());

        for (String key: map.keySet()){
            if (map.get(key)==max){
                list.add(key);
            }
        }

        Collections.sort(list);
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<list.size(); i++){
            sb.append(list.get(i)+"\n");
        }
        System.out.print(sb.toString());
//        System.out.print(sortByValues(map));
    }

    public static <K, V extends Comparable<V>> Map<K, V>
    sortByValues(final Map<K, V> map) {
        Comparator<K> valueComparator =
                new Comparator<K>() {
                    public int compare(K k1, K k2) {
                        int compare =
                                map.get(k2).compareTo(map.get(k1));
                        if (compare == 0)
                            return 1;
                        else
                            return compare;
                    }
                };

        Map<K, V> sortedByValues =
                new TreeMap<K, V>(valueComparator);
        sortedByValues.putAll(map);
        return sortedByValues;
    }
}


Measured memory_bytes: 87372
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    str t; cin>>t;
    ll x = 0;
    for(char c : t){
        if(c=='.') continue;
        x = x*10+c-'0';
    }
    a *= x;
    cout<<a/100;
}

Measured memory_bytes: 3648
L[2001],j,k,s;main(i){for(;~scanf("%d",L+k++););for(qsort(L+1,i=*L,4,"\x8b\7+\6Ð");i;i--)for(j=i;--j;)for(k=j;--k;)s+=L[i]<L[j]+L[k];printf("%d",s);}

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

int main()  {
    int n,k,x;
    cin>>n>>k;
    vector<int> a(10,0);
    for(int i=0;i<k;i++){
        cin>>x;
        a[x]=1;
    }
    while(true) {
        int cnt=0,digit,temp=n;
        while(temp>0)   {
            digit=temp%10;
            if(a[digit]!=0) {
                cnt++;
                break;
            }
            temp/=10;
        }
        if(cnt==0)
            break;
        n++;
    }
    cout<<n;
    return 0;
}


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

#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
#define ld long double

const int mod = 1000000007;
const ld PI = acosl(-1.0);
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int p[n + 1], c[n + 1];
    f1(i, 1, n + 1)
    cin>>p[i];
    f1(i, 1, n + 1)
    cin>>c[i];

    int final_ans = INT_MIN;
    f1(i, 1, n + 1)
    {
        // cout<<i<<endl;
        int sum = 0, count = 0;
        int curr = i;
        while(1)
        {
            curr = p[curr];
            sum += c[curr];
            count++;
            if(curr == i)
            break;
        }
        int circle =  k / count;
        circle = max(0ll, circle - 1);
        sum = sum * circle;
        // cout<<count<<gp<<circle<<gp<<sum<<endl;
        count = k - count * circle;
        curr = p[i];
        int temp = 0, ans = INT_MIN;
        while(count--)
        {
            temp += c[curr];
            ans = max(ans, temp);
            curr = p[curr];
        }
        ans = max(ans, ans + sum);
        final_ans = max(final_ans, ans);
        // cout<<ans<<endl;
    }
    cout<<final_ans<<endl;
    return 0;
}

Measured memory_bytes: 3688
/*
    ALWAYS REMMEMBER:
        NEVER GIVE UP !
        DON'T MESS WITH ME !!!
        "" THE EXPERT IN ANYTHING WAS ONCE A BEGINNER ""
*/

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;

void solve()
{
    ll p,n,d;
    cin >> p >> n;
    vll a(n);

    f(i,0,n-1)
    {
        cin >> a[i];        
    }
    
    d=a[n-1]-a[0];
    
    f(i,1,n-1)
        d = min(d, p - a[i] + a[i-1]);
    
    cout << d << endl;

}

int32_t main()
{
    FIO
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, bool> PIB;
typedef vector<int> VI;
typedef VI::iterator VII;

int n, m, ans = 0;
VI target, target2;

int main()
{
  while(true){
    scanf("%d%d", &n, &m);
    if(!n && !m)
      break;
    target.clear();
    target2.clear();
    ans = 0;

    target.push_back(0);
    for(int i = 0; i < n; i++){
      int p;
      scanf("%d", &p);
      target.push_back(p);
    }
    
    for(int i = 0; i < target.size(); i++)
      for(int j = 0; j < target.size(); j++)
	target2.push_back(target[i] + target[j]);
    
    sort(target2.begin(), target2.end());

    for(int i = 0; i < target2.size(); i++){
      VII p = upper_bound(target2.begin(), target2.end(), m - target2[i]);
      if(p != target2.begin())
	ans = max(ans, target2[i] + *(p - 1));
    }
    
    printf("%d\n", ans);
  }
  return 0;
}

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

#define OnlineJudge1

#define loop(a,n) for(int i = a;i<n;i++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)


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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

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

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

//    int powres[] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912};

ll power(ll b, ll p){
    if(p == 0)return 1;
    ll res = power(b,p/2);
    res *= res;
    if(p & 1)res *= b;
    return res;
}

set<ll> factors;
set<ll> divisors;

void divide(ll n){
    for(ll i = 2;i * i <= n;i++){
        if(n % i == 0){
            divisors.insert(i);
            divisors.insert(n/i);

        }
    }
}

void factorize(ll n){
        for(ll i = 2;i * i <= n;i++){
        if(n % i == 0){
            factors.insert(i);
            while(n % i == 0)n /= i;
        }
    }
    if(n != 1)factors.insert(n);
}

int Max = 1e7 + 5;
int prime[(int)1e7+7];

void sieve(){
    prime[0] = prime[1] = 1;
    for(ll i = 1;i<=Max;i++){
        if(prime[i])
            continue;
        else{
            for(ll j = i*i;j<=Max;j+=i)
                prime[j] = 1;
        }
    }
}

int main(){
    init();
    int n, k;
    cin >> n >> k;
    int arr[n],dp[n] = {0};
    for(int i = 0;i < n;i++){
        cin >> arr[i];
    }
    for(int i = 1;i < n;i++){
        dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
        for(int j = 2;j <= k;j++){
            if(i - j >= 0)
                dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));

        }
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
   long long int a = 0, b = 0, c = 0, d = 0, e = 0,f=0, mini= 1000000007;
	int reset = 0,w=0;
	std::vector<long long int> vec{};
	char hairetu[200] = {};
	int number[10000000] = {}, price[10000] = {}, sort[100000] = {}, kisu[10000] = { 100000 }, gusu[10000] = { 100000 };
	using namespace std;
	int x = 0, y = 0, z = 0, play[200] = {}, acount = 0, bcount = 0;
	std::string toki, tokit, fun,funt;

	
	int main()
	{
		bool okada = true;
		cin >> a>>b;
		for (long long int i = 0; i < a; i++) {
			cin >> c;
			vec.push_back(c);
		}
		std::sort(vec.begin(), vec.end());
		for (long long int i = 0; i < a-b+1; i++) {
			if (vec[i + b-1] - vec[i] < mini) {
				mini = vec[i + b-1] - vec[i];
			}
		
		}
		cout << mini << endl;
	}

Measured memory_bytes: 1400
#include <stdio.h>

const int conv[8] = {0, 1, 2, 3, 5, 7, 8, 9};

int main(void)
{
	int n;
	int f;
	int x;
	int i;
	
	while (scanf("%d", &n), n != 0){
		f = 0;
		for (i = 27; i >= 0; i -= 3){
			x = n >> i & 7;
			if (x != 0){
				f = 1;
			}
			if (f){
				printf("%d", conv[x]);
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	if(k==1||k==2*n-1)cout<<"No"<<endl;
	else{
		int x=2;
		cout<<"Yes"<<endl;
		for(int i=0;i<2*n-1;i++){
			if(i==n)cout<<"1"<<endl;
			if(i==n-1)cout<<k<<endl;
			if(i==n-2)cout<<2*n-1<<endl;
			if(i>n||i<n-2){
				if(x==k)x++;
				cout<<x<<endl;
				x++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1536
n=int(input())
a=list(map(int,input().split()))
import collections
l=collections.Counter(a)
q=int(input())
s=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    s+=(c-b)*l[b]
    l[c]+=l[b]
    l[b]=0
    print(s)

Measured memory_bytes: 23960
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

solve :: Int -> [(Int,Int)] -> IO (Int,Int)
solve wl ts = do
    arr <- newArray (0,wl) 0 :: IO (IOUArray Int Int)
    forM_ ts $ \(v,w) -> do
        forM_ [wl,wl-1..w] $ \i -> do
            max <$> ((+v) <$> readArray arr (i-w)) <*> readArray arr i >>= writeArray arr i
    res <- getAssocs arr
    return $ maximumBy (comparing snd <> flip (comparing fst)) res


main = sub 1

sub i = do
    w <- getInt
    unless (w==0) $ do
        n <- getInt
        ts <- map (apply2 (,) . map readInt . wordsBy (==',')) <$> replicateM n getLine
        (rw,rv) <- solve w ts
        putStr "Case " >> putStr (show i) >> putStrLn ":"
        print rv
        print rw
        sub (i+1)


Measured memory_bytes: 5648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N;
  cin >> N;
  for(int i = 0; i <= N; i++) {
    if((N - 4 * i) >= 0 && (N - 4 * i) % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

	return 0;
}


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

#define PI acos(-1)
#define int long long int
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 501
#define MAXL 20
#define mod 1000000007

signed main()
{
  long double a, b;
  cin >> a >> b;
  long double ans = floor(a * b);
  int kappa = ans;
  cout << kappa << endl;
  return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
string s,t; 
int main(){
	cin>>s>>t;
	if(s[0]<t[0]) cout<<"<";
	else if(s[0]==t[0]) cout<<"=";
	else cout<<">";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
AB = list(map(int, input().split()))

limit = 1000000000000000000

sum = 1
for i in range(N):
    if (limit < sum or sum == -1):
        sum = -1
    else:
        sum *= AB[i]
    if (AB[i] == 0):
        print(0)
        exit()

if (limit < sum):
    sum = -1

print(sum)



Measured memory_bytes: 84672
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int from,to,cost;};
vector<edge> G;
double pi = 3.141592653589793;
P sg[10];
int a[55],b[55];
int n,m;
int d[16][16];
int dp[55][55]={};//i番目までの数でj個選んだ状態のsum
signed main(){
    int n;cin>>n;
    string s[114514];
    int  t[5]={};
    rep(i,0,n){
        cin>>s[i];
        if(s[i][0]=='M')t[0]++;
        if(s[i][0]=='A')t[1]++;
        if(s[i][0]=='R')t[2]++;
        if(s[i][0]=='C')t[3]++;
        if(s[i][0]=='H')t[4]++;
    }
    int ans=0;
    rep(i,0,3){
        rep(j,i+1,4){
            rep(k,j+1,5){
                if(i==j||j==k)continue;
                ans+=t[i]*t[j]*t[k];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6272
import std.stdio;
import std.string;
import std.conv;

void main() {
    
    string[][100] str;
    int line = 0;
    
    // input
    for(int i=0; ; ++i) {
        
        if(stdin.eof) {
            break;
        }
        
        str[i] = readln().split;
        
        ++line;
    }
    
    for(int i=0; i<line; ++i) {
        
        double[100] arr;
        int len;
        
        bool flag = false;
        
        for(int j=0; j<str[i].length; ++j) {
            
            try {
                
                arr[len] = to!int(str[i][j]);
                ++len;
                flag = true;
                
            } catch(Exception e) {
                
                final switch(str[i][j]) {
                    case "+":
                        arr[len-2] = arr[len-2] + arr[len-1];
                        break;
                       
                    case "-":
                        arr[len-2] = arr[len-2] - arr[len-1];                       
                        break;
                        
                    case "*":
                        arr[len-2] = arr[len-2] * arr[len-1];
                        break;
                      
                    case "/":
                        arr[len-2] = arr[len-2] / arr[len-1];
                        break;
                }
                
                len -= 1;
                
            }
            
        }
        
        if(flag)
            writefln("%.8f", arr[0]);
    }
    
}

Measured memory_bytes: 2564
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=int;
using DArray=vector<Weight>;
using DMatrix=vector<DArray>;

static const Weight INF=1<<29;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

struct UnionFindTree {
    size_t n;
    vector<int> tree;
    UnionFindTree(size_t n): n(n) {
        tree = vector<int>(n, -1);
    }
    int find_root(size_t v) {
        if (tree[v] < 0) return v;
        return tree[v] = find_root(tree[v]);
    }
    bool unite(size_t x, size_t y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return false;
        if (rank(x) < rank(y)) swap(x, y);
        tree[x] += tree[y];
        tree[y] = x;
        return true;
    }
    bool has_same_root(size_t x, size_t y) {
        return find_root(x) == find_root(y);
    }
    size_t rank(size_t v) {
        return -tree[find_root(v)];
    }
};

pair<Weight, Edges> minimum_spanning_forest(const Graph &g) {
    /* Kruskal */
    size_t V=g.size();
    UnionFindTree tree(V);
    gp_queue<Edge> q;
    for (size_t u=0; u<V; ++u)
        for (const Edge &e: g[u])
            if (u < e.dst) q.push(e);

    Weight total=0;
    Edges F;
    while (F.size()<V-1 && !q.empty()) {
        Edge e=q.top(); q.pop();
        if (tree.unite(e.src, e.dst)) {
            F.push_back(e);
            total += e.weight;
        }
    }

    return make_pair(total, F);
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Graph g(n);
    for (size_t i=0; i<n; ++i)
        for (size_t j=0; j<n; ++j) {
            Weight a;
            scanf("%d", &a);

            if (a > -1)
                connect(g, i, j, a);
        }

    printf("%d\n", minimum_spanning_forest(g).first);
    return 0;
}

Measured memory_bytes: 2904
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int mod = 1e9 + 7;

int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, ll b)
{
	int ret = 1;
	while (b > 0) {
		if (b & 1) {
			ret = 1LL * ret * a % mod;
			a = 1LL * a * a % mod;
			b >>= 1;
		}
	}
	return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
	int n = b.size();
	Vec ret(n, 0);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ret[i] = add(ret[i], mul(a[i][j], b[j]));
		}
	}
	return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
	int n = a.size();
	Mat ret(n, Vec(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
			}
		}
	}
	return ret;
}
Mat fastpow(Mat x, ll n)
{
	Mat ret(x.size(), Vec(x.size(), 0));
	for (int i = 0; i < x.size(); i++) {
		ret[i][i] = 1;
	}
	while (0 < n) {
		if (n % 2 == 0) {
			x = mulMatMat(x, x);
			n >>= 1;
		} else {
			ret = mulMatMat(ret, x);
			n--;
		}
	}
	return ret;
}

int main(int argc, char *argv[])
{
	int N;
	ll K;
	int a[55][55];

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}

	Mat m(N, Vec(N, 0));
	Vec v(N, 1);

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			m[i][j] = a[i][j];
		}
	}
	m = fastpow(m, K);
	v = mulMatVec(m, v);

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += v[i];
	}
	cout << ans % mod << endl;

	return 0;
}

Measured memory_bytes: 384