akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int D, G; cin >> D >> G;
    vi P(D), C(D); rep(i, D) cin >> P[i] >> C[i];

    int res = INF;
    for (int i = 0; i < 1<<D; i++) {
        vi tmp;
        vi notselected;
        for (int j = 0; j < D; j++) {
            if (i & 1<<j) {
                tmp.push_back(j);
            } else {
                notselected.push_back(j);
            }
        }

        int sum = 0;
        int cnt = 0;
        for (auto ii : tmp) {
            int x = 100 * (ii + 1) * P[ii] + C[ii];
            sum += x;
            cnt += P[ii];
        }
        if (sum >= G) {
            res = min(res, cnt);
            continue;
        }

        sort(notselected.begin(), notselected.end());
        reverse(notselected.begin(), notselected.end());
        int diff = G - sum;
        for (auto ii : notselected) {
            if (diff <= 0) break;
            int x = 100 * (ii + 1) * P[ii] + C[ii];
            if (diff - x > 0) {
                diff -= x;
                cnt += P[ii];
                continue;
            }

            for (int jj = 0; jj < P[ii]; jj++) {
                diff -= 100 * (ii + 1);
                cnt++;
                if (jj == P[ii] - 1) diff -= C[ii];
                if (diff <= 0) break;
            }
        }
        res = min(res, cnt);
    }

    cout << res << endl;
}


Measured memory_bytes: 3636
import itertools

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


l = ['a', 'b', 'c', 'd', 'e']
res = 10 ** 9
for v in itertools.permutations(l):
    tmp = 0
    for i in v:
        if tmp%10 != 0:
            tmp += (10 - tmp%10)
            
        if i == 'a':
            tmp += a
        elif i == 'b':
            tmp += b
        elif i == 'c':
            tmp += c
        elif i == 'd':
            tmp += d
        else:
            tmp += e
            
    res = min(res, tmp)
    
print(res)

Measured memory_bytes: 3064
#include<iostream> 
using namespace std;
int main(){
	long long  n,m,s,l;
		cin>>n;
		m=n%10;
		if(m==2||m==4||m==5||m==7||m==9) cout<<"hon"<<endl;
		if(m==0||m==1||m==6||m==8) cout<<"pon"<<endl;
		if(m==3) cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
void combi(int,int);
void combi(int a,int b){
    int i,j,k,count=0;
    for(i=1;i<=a;i++){
        for(j=1;j<=a;j++){
            for(k=1;k<=a;k++){
                if(i+j+k==b && i!=j && j!=k && i!=k){
                    count++;
                }
            }
        }
    }
    printf("%d\n",count/6);
    return;
}
int main(void){
    int n=0,x=0;
    while(1){
        scanf("%d%d",&n,&x);
        if(n==0 && x==0){
            break;
        }else{
            combi(n,x);
        }
    }
    return 0;
}


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

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

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

        static int N;
        static int[,] F, P;
       

        public static void Input()
        {
            var cin = new Scanner();

            N = int.Parse(Console.ReadLine());
            F = new int[N, 10];
            for(var i = 0; i < N; i++)
            {
                var input = cin.SplitReader();
                for(var j = 0; j < 10; j++)
                {
                    F[i, j] = input[j];
                }
            }

            P = new int[N, 11];
            for(var i = 0; i < N; i++)
            {
                var p = cin.SplitReader();
                for(var j = 0; j < 11; j++)
                {
                    P[i, j] = p[j];
                }
            }
        }

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

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

            long ans = -1 * INF;

            for(var bit = 0; bit < (1 << 10); bit++)
            {
                List<int> use = new List<int>();
                for(var i = 0; i < 10; i++)
                {
                    if ((bit & (1 << i)) != 0)
                    {
                        use.Add(i);
                    }
                }

                if (use.Count() == 0) { continue; }


                int[] cnt = new int[N];
                for(var i = 0; i < N; i++) { cnt[i] = 0; }

                foreach(var x in use)
                {
                   for(var i = 0; i < N; i++)
                    {
                        if (F[i, x] == 1) { cnt[i]++; }
                    }
                }

                long bene = 0;
                for(var i = 0; i < N; i++)
                {
                    bene += P[i, cnt[i]];
                }

                ans = Max(ans, bene);
            }


            Console.WriteLine(ans);

            //Console.Out.Flush();

        }

       
    }

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

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
fun main(args: Array<String>) {
    var a = "Yes"
    val l =(1..readLine()!!.toInt()).map{ readLine()!! }.toMutableList()
    if (l.count() != l.toSet().count()) a = "No"
    for(i in 0 until l.count() - 1){
        if(l[i].last() != l[i + 1].first()) a = "No"
    }
    println(a)
}

Measured memory_bytes: 32156
import java.util.Scanner;
public class Main {
    public static int n;
    public static double ans,sum,ave;
    public static int[] s;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        n=sc.nextInt();
        if(n==0){
            sc.close();
            return;
        }
        s=new int[n];
        for(int i=0;i<n;i++){
            s[i]=sc.nextInt();
            sum+=s[i];
        }
        ave=sum/n;
        sum=0;
        for(int i=0;i<n;i++){
            sum+=(s[i]-ave)*(s[i]-ave);
        }
        ans=Math.sqrt(sum/n);
        System.out.println(ans);
        sum=0;
        }
        
    }
}


Measured memory_bytes: 31068
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= base;
	}
	return ans;
}

static void B_task();

int main()
{
	B_task();

	fflush(stdout);
	return 0;
}

static void B_task()
{
	int N, D;
	get2int(N, D);

	int seqx[10][10] = { 0 };

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			get1int(seqx[i][j]);
		}
	}

	int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int sqSum = 0;
			for (int k = 0; k < D; k++) {
				sqSum += tp_pow<int>(seqx[j][k] - seqx[i][k], 2);
			}
			double root = sqrt(sqSum);
			if ((int)ceil(root) == (int)root) {
				count++;
			}
		}
	}
	printf("%d\n", count);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Points for a Perfect Scorer
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int res = 0;
		for(int i=0;i<10;i++)res+=sc.nextInt();
		System.out.println(res);
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17356
import java.io.*;
import java.util.*;
public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int[]f=new int[n+1];
		for(int i=1;i<=n;i++) {
			for(int j=i;j<=n;j+=i) {
				f[j]++;
			}
		}
		long ans=0;
		for(int i=1;i<=n;i++) {
			ans+=(i*1l*f[i]);
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 72496
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  string  str;
  cin >> str;
  ll l, r; 
  rep(i,str.size()){
    if(str[i] == 'A'){
      l = i;
      break;
    }
  }
  for(ll i = str.size()-1; i>=0 ; i--){
    if(str[i] == 'Z'){
      r = i;
      break;
    }
  }

  cout << r-l+1 << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,ans=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int cur = a[0];
    for(int i=0;i<n;i++){
        if(a[i]<cur){
            ans += (cur-a[i]);
            a[i] = cur;
        } 
        cur = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	ll ans = 0,ans1 = 0;
	for(int i = 0;i<n; i++) cin>>a[i];
	set<int>s,s2;
	for(int i = 0; i<n; i++)
	{
		if(a[i]<400)
			s.insert(400);
		else if(a[i]<800)
			s.insert(800);
		else if(a[i]<1200)
			s.insert(1200);
		else if(a[i]<1600)
			s.insert(1600);
		else if(a[i]<2000)
			s.insert(2000);
		else if(a[i]<2400)
			s.insert(2400);
		else if(a[i]<2800)
			s.insert(2800);
		else if(a[i]<3200)
			s.insert(3200);
		else
			ans++;
	}
	cout<<(s.size()>0?s.size():1)<<" "<<s.size()+ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 1000000007
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string s , t;
ll dp[3000+9][3000+9];
ll solve(int i , int j ){
    if(i == s.size())
        return 0;
    if(j == t.size())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(s[i] == t[j]){
        return dp[i][j] = solve(i+1,j+1)+1;
    }
    return dp[i][j] = max(solve(i+1,j),solve(i,j+1));
}
void print(int i , int j){
    if(i == s.size())
        return ;
    if(j == t.size())
        return ;
    if(s[i] == t[j]){
        cout<<s[i];
        print(i+1,j+1);
        return;
    }
    if(max(solve(i+1,j),solve(i,j+1)) == solve(i+1,j)){
        print(i+1,j);
    }else{
        print(i,j+1);
    }
}
int main() {
    cin>>s>>t;
    memset(dp,-1, sizeof(dp));
    solve(0,0);
    print(0,0);
    return 0;
}


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

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const int x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        *this *= r.pow(p);
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt pow(u64 n) const {
        ModInt res(1), mul(x);
        while (n > 0) {
            if (n & 1) res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        int a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 1e9 + 7;
using mint = ModInt<mod>;

int D;
mint solve(string &s, int k = 0, bool status = 1, int sum = 0) {
    static mint dp[10010][2][100];
    static bool visited[10010][2][100] = {};
    static int max_num = 9;

    if (k == s.size()) {
        return sum == 0;
    }

    mint &res = dp[k][status][sum];
    if (visited[k][status][sum])
        return res;
    else
        res = 0, visited[k][status][sum] = true;

    int r = (status ? s[k] - '0' : max_num);

    for (int i = 0; i <= r; i++) {
        int from = sum - i;
        if (from < 0) from = D - (-from % D);
        from %= D;
        mint cnt = solve(s, k + 1, status && i == r, from);
        res += cnt;
    }
    return res;
}

int main() {
    string K;
    cin >> K >> D;
    cout << solve(K) - 1 << endl;
    return 0;
}

Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, q; cin >> n >> q;
  string s; cin >> s;
  vector<char> t(q), d(q);
  for(int i = 0; i < q; i++){
    cin >> t[i] >> d[i];
  }

  int left = -1, right = n;
  while(right - left > 1){
    int mid = (left + right) / 2;
    int pos = mid;
    for(int i = 0; i < q; i++){
      if(s[pos] == t[i]){
        pos += (d[i] == 'L' ? -1 : 1);
      }
      if(pos == -1 || pos == n) break;
    }
    if(pos == n){
      right = mid;
      continue;
    }
    (pos == -1 ? left : right) = mid;
  }
  int l = right;

  left = -1, right = n;
  while(right - left > 1){
    int mid = (left + right) / 2;
    int pos = mid;
    for(int i = 0; i < q; i++){
      if(s[pos] == t[i]){
        pos += (d[i] == 'L' ? -1 : 1);
      }
      if(pos == -1 || pos == n) break;
    }
    if(pos == -1){
      left = mid;
      continue;
    }
    (pos != n ? left : right) = mid;
  }
  int r = left;
  cout << max(0LL, r - l + 1) << endl;

  return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> y;  int n; ll d;

const int MAXN = 10000;
const int MAXD = 105;
const ll MOD = 1000000007;

ll dp[MAXN + 1][MAXD + 1][2] = {-1};

ll count(int idx, ll sum_so_far,int lo)
{
    int n = y.size();
    if(idx==n)
        return (sum_so_far%d ==0)*1LL;
        
    if(dp[idx][sum_so_far%d][lo]!=-1)
       return dp[idx][sum_so_far%d][lo];

    ll result =0;   
    ll limit = lo==1?9:y[idx];
    for(ll x =0;x<=limit;x++)
    {         
        result=(result + count(idx+1,(sum_so_far+x)%d ,lo||x<y[idx]) )%MOD;
    }
    dp[idx][sum_so_far%d][lo] = result;
    return result; 
}
int main()
{
    string s;
    cin>>s>>d;

    for(int i =0 ;i<s.length(); i++)
        y.push_back(s[i] -'0');
    n = s.length();

    memset(dp , -1, sizeof(dp));
    ll ans = (count(0, 0, false) + (MOD - 1))%MOD;
    cout<<ans<<"\n";

}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> vec(S.size());
  
  for(int i=0; i<S.size(); i++){
    int count = 0;
    int v=0;
    if(S.at(i) == 'R'){
      for(int j=1; j<S.size(); j++){
        count++;
        if(S.at(i+j) == 'L'){
          v = i+j;
          break;
        }
      }
     if(count %2 == 1){
       vec.at(v-1) += (count+1)/2;
       vec.at(v) += count/2;
       i += count-1;
     }
     else{
       vec.at(v) += (count+1)/2;
       vec.at(v-1) += (count+1)/2;
       i += count-1;
     }
    }
    if(S.at(i) == 'L'){
      for(int j=1; j<S.size(); j++){
        count++;
        if(i+j >= S.size()-1){
          count++;
          break;
        }
        if(S.at(i+j) == 'R'){
          break;
        }
      }
     if(i == S.size()-1){
       vec.at(i)++;
     }
     else if(count %2 == 1){
       vec.at(i-1) += count/2;
       vec.at(i) += (count+1)/2;
       if(i+count == S.size()-1){
         break;
       }
       i += count-1;
     }
     else{
       vec.at(i) += (count+1)/2;
       vec.at(i-1) += (count+1)/2;
       if(i+count == S.size()-1){
         break;
       }
       i += count-1;
     }
    }
  }
  for(int x=0; x<S.size(); x++){
    cout << vec.at(x) << endl;
  }
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int n,m;
string s[50],t[50];
bool check1(int a,int b,int x,int y)
{
	return s[a][b]==t[x][y];
}
int check(int a,int b)
{
	bool f=true;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			f&=check1(a+i,b+j,i,j);
		}
	}
	return f;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i<m;i++)cin>>t[i];
	int cnt=0;
	for(int i=0;i<=n-m;i++)
	{
		for(int j=0;j<=n-m;j++)
		{
			cnt+=check(i,j);
		}
	}
	cout<<(cnt?"Yes":"No")<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int inf = INT_MAX;
const static llong INF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
    return a * b / my_gcd(a, b);    
}

void solve() {
    int n;
    cin >> n;
    map<string, int> M;
    rep(i, n) {
        string s;
        cin >> s;
        ++M[s];
    }

    vector<pair<int, string> > P;
    stl_rep(itr, M) {
        P.push_back(make_pair(itr->second, itr->first));
    }
    sort(all(P), greater<pair<int, string> >());

    int max_cnt = P[0].first;
    vector<string> ans;
    stl_rep(itr, P) {
        if (itr->first == max_cnt) ans.push_back(itr->second);
        else break;
    }
    sort(all(ans));
    rep(i, (int)ans.size()) cout << ans[i] << endl;
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}

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

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

    vector<int> a(n);

    for(int i = 0; i < n; ++i)
        cin >> a[i];

    for(int i = 0; i < n - 1; ++i)
        for(int j = i + 1; j < n; ++j)
            res += a[i] * a[j];

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if((a==1 && b==1)||(a==b))
	cout<<"Draw";
	else if(a==1 &&b!=1)
	   	cout<<"Alice";
	 else if(b==1 &&a!=1)  	
        cout<<"Bob";  
	 else if(a>b)
	   cout<<"Alice";
	 else if(a<b)
	   cout<<"Bob";
	   
		return 0;
}

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

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;
const int maxn = 300000  + 123;
int n, m;
pt a[maxn];

#define fi first
#define se second

void ReadData() {
    cin >> n >> m;
    For(i,1,n) cin >> a[i].first >> a[i].second;
}

bool cmp(pt a, pt b) {
    if (a.second == b.second) return a.first > b.first;
    return a.second > b.second;
}

class segmentTree{
public:
    int l[maxn * 4], h[maxn * 4];
    int it[maxn * 4];
    int lazy[maxn * 4];

    void buildTree(const int x, const int lo, const int hi, int val = 0) {
        l[x] = lo; h[x] = hi;
        lazy[x] = 0;
        if (lo == hi) {
            it[x] = lo;
            if (val) it[x] = 0;
        } else {
            int mid = (lo + hi) >> 1;
            buildTree(LL(x), lo, mid,val);
            buildTree(RR(x),mid + 1, hi,val);
            it[x] = min(it[LL(x)], it[RR(x)]);
        }
    } 

    void add(const int x, const int val) {
        it[x] += val;
        lazy[x] += val;
    }

    void pushDown(const int x) {
        if (lazy[x] != 0) {
            add(LL(x), lazy[x]);
            add(RR(x), lazy[x]);
            lazy[x] = 0;
        }
    } 

    void update(const int x, const int u, const int v, const int val) {
        if (l[x] > v || h[x] < u) return;
        if (u <= l[x] && h[x] <= v) {
            add(x,val);
            return;
        }
        pushDown(x);
        update(LL(x),u,v,val);
        update(RR(x),u,v,val);
        it[x] = min(it[LL(x)], it[RR(x)]);
    }

    int get(const int x, const int u, const int v) {
        if (l[x] > v || h[x] < u) return maxn;
        if (u <= l[x] && h[x] <= v) {
            return it[x];
        }
        pushDown(x);
        return min(get(LL(x),u,v), get(RR(x),u,v));
    }
} tree, tree2;

void Process() {
    tree.buildTree(1,0,200000);
    tree2.buildTree(1,0,200000,1);
    int minVal = maxn;
    sort(a + 1, a + 1 + n, cmp);
    For(i,1,n) {
        tree.update(1, a[i].first, 200000, -1);
        tree2.update(1, a[i].first, 200000, -1);

        minVal = min(minVal, tree.get(1,0,a[i].second - 1) + m - a[i].second + 1);
        minVal = min(minVal, tree2.get(1,a[i].second,200000) + m);
    }

    if (minVal >= 0) minVal = 0;
    cout << -minVal << endl; 
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
  //  freopen("input.inp" , "r", stdin);
    ReadData();
    Process();

	return 0;

}			

Measured memory_bytes: 35200
import heapq

INF = 10 ** 9
V, E, r = map(int, input().split())
edge_list = [[] for _ in range(V)]
dist_list = [INF] * V
for _ in range(E):
  s, t, d = map(int, input().split())
  edge_list[s].append((t, d))

q = []
heapq.heapify(q)
heapq.heappush(q, (0, r))
dist_list[r] = 0

while len(q) != 0:
  dist, node = heapq.heappop(q)
  for to, cost in edge_list[node]:
    if dist + cost < dist_list[to]:
      dist_list[to] = dist + cost
      heapq.heappush(q, (dist + cost, to))

for dist in dist_list:
  if dist == INF:
    print("INF")
  else:
    print(dist)


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int main() {
    int n;
    cin >> n;
    double ans = 0.0;
    rp(i, 0, n){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N;
	int sum = 0, max = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		max = std::max(l, max);
		sum += l;
	}
	if (2*max < sum) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 256
local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n = io.read("*n", "*l")
local s = io.read()
local m_cnt = {}
local d_pos = {}
local c_pos = {}
local ss = ""
local mc = 0LL
for i = 1, n do
  ss = s:sub(i, i)
  if ss == "D" then
    table.insert(d_pos, i)
  elseif ss == "C" then
    table.insert(c_pos, i)
  elseif ss == "M" then
    mc = mc + 1LL
  end
  m_cnt[i] = mc
end
local m_sum_per_c = {}
for i = 1, #c_pos do
  local ic = c_pos[i]
  if i == 1 then
    m_sum_per_c[i] = m_cnt[ic]
  else
    m_sum_per_c[i] = m_sum_per_c[i - 1] + m_cnt[ic]
  end
end

local function llprint(llnumber)
  local str = tostring(llnumber):gsub("LL", "")
  print(str)
end

local cposall = {}
for i = 1, 2 * n do
  cposall[i] = lower_bound(c_pos, i)
end
local mmi = math.min
local q = io.read("*n")
for i = 1, q do
  local k = io.read("*n")
  local ret = 0LL
  for id = 1, #d_pos do
    local dp = d_pos[id]
    local c_from = cposall[dp]
    local c_to = cposall[dp + k] - 1
    if 1 <= c_to then
      ret = ret + m_sum_per_c[c_to] - (c_to - c_from + 1) * m_cnt[dp]
      if 1 < c_from then
        ret = ret - m_sum_per_c[c_from - 1]
      end
    end
  end
  llprint(ret)
end


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

int main() {
  int w, d;
  while(cin >> w >> d) {
    if(w == 0 && d == 0) break;
    vector<int> x(w), y(d);
    rep(i, w) cin >> x[i];
    rep(i, d) cin >> y[i];
    map<int, int> s, t;
    rep(i, w) s[x[i]]++;
    rep(i, d) t[y[i]]++;
    int ans = 0;
    for(auto& p : s) {
      int k = max(p.second, t[p.first]);
      ans += k * p.first;
      p.second = 0;
      t[p.first] = 0;
    }
    for(auto& p : t) {
      int k = max(p.second, s[p.first]);
      ans += k * p.first;
      p.second = 0;
      s[p.first] = 0;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3012
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

X = inputI()

a = X//500

r = X%500

b = r//5

print(a*1000+b*5)


Measured memory_bytes: 65004
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vp ans;
  if(N % 2 == 0) {
    rep(i,N) {
      srep(j,i+1,N) {
        int a = i+1;
        int b = j+1;
        if(a+b != N+1) {
          ans.push_back(P(a,b));
        }
      }
    }
  } else {
    rep(i,N) {
      srep(j,i+1,N) {
        int a = i+1;
        int b = j+1;
        if(a+b != N) {
          ans.push_back(P(a,b));
        }
      }
    }
  }
  cout << sz(ans) << endl;
  rep(i,sz(ans)) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 384
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N, A, B =  map(int, sys.stdin.readline().split())
print(min(N * A, B))

Measured memory_bytes: 64748
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  ll a[N]; rep(i, N) cin >> a[i];

  ll diff = 0; rep(i, N) diff += a[i];
  ll result = LLINF;
  rep(i, N-1) {
    diff -= a[i] * 2;
    result = min(result, abs(diff));
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
   int n;
   cin >> n;
   vector<int> a(n);
   for (auto& el : a) {
       cin >> el;
   }
   int lst = 0;
   for (auto el : a) {
       if (lst + 1 == el) {
           ++lst;
       }
   }

    if (lst == 0) {
        lst = n + 1;
    }
   cout << n - lst << "\n";


}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

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

using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;

  if ((a!=b && b==c) || (a!=c && a==b) || (b!=c && a==c))
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';

  return 0;
}



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

int v1, v2, v3, v4, v5;
vector<int> v;
int T;

int order_time(int x){
    for (int i = 0; i <= 65; i++){
        if (x <= 10*i){
            x = 10*i;
            break;
        }
    }
    return x;
}

vector<int> det_turn(vector<int> x){
    for (int i = 1; i <= 9; i++){
        for (int j = 0; j < 5; j++){
            if (x[j] % 10 == i){
                swap(x[j], x[4]);
                goto end_loop;
            }
        }
    }
    end_loop:
    return x;
}

int main(){
    cin >> v1 >> v2 >> v3 >> v4 >> v5;
    vector<int> v = {v1, v2, v3, v4, v5};
    if (*min_element(v.begin(), v.end()) < 1 || *max_element(v.begin(), v.end()) > 123){
        exit(0);
    }
    
    v = det_turn(v);
    for (int i = 0; i < 4; i++){
        T += order_time(v[i]);
    }
    T += v[4];
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}





///////////////////////////


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

	cout << N / 3;

	system("PAUSE");

}


Measured memory_bytes: 504
# https://kmjp.hatenablog.jp/entry/2020/03/22/0930

mod = 998244353

n, s = gets.to_s.split.map{|e| e.to_i }
a = gets.to_s.split.map{|e| e.to_i }

ans = 0
dp = [0] * (s+1)
a.each_with_index do |t, i|
  (s-t).downto(0) do |j|
    if j == 0
      dp[t] += i + 1
    else
      dp[t+j] += dp[j]
      dp[t+j] %= mod
    end
  end
  ans += dp[s]
end

puts ans % mod

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
#define int long long int

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

signed main() {
    int N; cin >> N;
    vector<int> A(N);
    int sum = 0;
    for(auto&& a: A) {
        cin >> a;
        sum += 2 * a;
    }

    vector<int> x(N);
    x[N - 1] = sum / 2;
    // x[N-1]求める
    for (int i = 0; i < N - 1; i += 2) {
        x[N - 1] -= (2 * A[i]);
    }
    x[0] = 2 * A[N - 1] - x[N - 1];

    for (int i = 0; i < N - 2; i++) {
        x[i + 1] = 2 * A[i] - x[i];
    }

    for (int i = 0; i < N; i++) {
        cout << x[i] << endl;
    }
}


Measured memory_bytes: 2944
public class Main {

  private static void solve() {
    int n = ni();
    long[] a = nal(n);

    int mod = (int) 1e9 + 7;

    long sum = 0;
    long sum2 = 0;
    for (long v : a) {
      sum += v;
      sum %= mod;
      sum2 += v * v % mod;
      sum2 %= mod;
    }

    System.out.println((sum * sum % mod - sum2 + mod) % mod * invl(2, mod) % mod);
  }

  private static long invl(long a, long mod) {
    long b = mod;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + mod : p;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 58920
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    while(n != 0) {
        double a[n], sum = 0, ave, a_2;
        for(int i = 0; i < n; i++) {
            scanf("%lf", &a[i]);
            sum += a[i];
        }
        ave = sum/n;
        sum = 0;
        for(int i = 0; i < n; i++) {
            double tmp = a[i]-ave;
            sum += tmp*tmp;
        }
        a_2 = sum/n;
        printf("%lf\n", sqrt(a_2));
        scanf("%d", &n);
    }
}


Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pii>>Y(N);
	vector<pii>V(M);
	for (int i = 0; i < M; ++i) {
		int p, y;
		cin >> p >> y;
		Y[p-1].push_back(pii(y, i));
	}
	for (int i = 0; i < N; ++i) {
		sort(Y[i].begin(), Y[i].end());
		for (int j = 0; j < Y[i].size(); ++j) {
			V[Y[i][j].second] = pii(i, j);
		}
	}
	for (int i = 0; i < M; ++i) {
		V[i].first++; V[i].second++;
		string s, t;
		s = to_string(V.at(i).first);
		t = to_string(V.at(i).second);
		for (int j = 0; j < 6 - s.size(); ++j) {
			cout << 0;
		}
		cout << V.at(i).first;
		for (int j = 0; j < 6 - t.size(); ++j) {
			cout << 0;
		}
		cout << V.at(i).second << endl;
	}
	return 0;
}


Measured memory_bytes: 7808
import sys
input = sys.stdin.readline

N = int(input())
A = 0 #直前にAを選んだときの最大値
B = 0 #直前にBを選んだときの最大値
C = 0 #直前にCを選んだときの最大値

a, b, c = map(int, input().split())
A = a
B = b
C = c
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    A, B, C = max(B, C) + a, max(C, A) + b, max(A, B) + c

print (max(A, B, C))

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
 	int a, b, c;
  	cin >> a >> b >> c;
  	if(a==b && b!=c){
      cout << "Yes";
    }else if(b==c && c!=a){
      cout << "Yes";
    }else if(c==a && a!=b){
      cout << "Yes";
    }else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int 
#define pb push_back
#define xx first
#define yy second


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;
	t=1;
	while(t--)
	{
	    ll n;
	    cin>>n;
	    ll a[n],i,ans=0;
	    for(i=0;i<n;i++)
	    cin>>a[i];
	    
	    for(i=1;i<n;i++)
	    {
	        if(a[i]<a[i-1])
	        {
	            ans+=a[i-1]-a[i];
	            a[i]=a[i-1];
	        }
	    }
	    
	    cout<<ans;
	}
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int n;
vector<string>v;
void dfs(string s,char used) {
	if(s.size()==n) {
		v.push_back(s);
		return;
	}
	for(char i=used+1;i>='a';i--) dfs(s+i,max(used,i));
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	dfs("a",'a');
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++) cout<<v[i]<<endl;
	return 0;
}

Measured memory_bytes: 7796
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::io::stdin;
 
#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let n: usize = scan.next();
    let mut a = vec![0; n];
    let mut prev = 0;
    for idx in 0..n-1 {
        let b = scan.next::<u64>();
        a[idx+1] = b;
        if idx > 0 {
            a[idx] = min(b, prev);
        } else {
            a[idx] = b;
        }
        prev = b;
    }
    // println!("{:?}", a);
    let result: u64 = a.iter().sum();
    println!("{}", result);
}


Measured memory_bytes: 4352
N = int(input())
S = input()
li_E = [0]
li_W = [0]
cost = 10**8
num = 0

for i in S:
    if(i=='E'):
        li_E+=[1+li_E[-1]]
        li_W+=[li_W[-1]]
    else:
        li_E+=[li_E[-1]]
        li_W+=[1+li_W[-1]]
for i in range(1,N+1):
    c = 10**8
    c=li_W[i-1]+li_E[-1]-li_E[i]
    if(cost>c):
        cost = c
        num = i

print(cost)


Measured memory_bytes: 17644