akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt=0;
int main(){
	cin>>s;
	string bef="",now="";
	for(int i=0;i<(int)s.size();i++){
		now+=s[i];
		if(now!=bef){
			cnt+=(int)now.size()-1;
			bef=now;
			now="";
		}
	}
	if(now!=""){
		if(now!=bef){
			cnt+=(int)now.size()-1;
		}else{
			cnt+=(int)now.size();
		}
	}
	cout<<(int)s.size()-cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
const ll inf = 1000000007;
int main() {
  ll n,c,k; cin>>n>>c>>k;
  vector<ll> t(n);
  rep(i,n) cin>> t[i];
  sort(all(t));
  ll ans=0;
  ll key=1;
  ll lowest=t[0];
  rep2(i,1,n){
    //cout <<ans<<key<<lowest<<endl;
    key++;
    if(i==n-1){
    if(lowest+k<t[i]){
      ans+=2;
      key=1;
      lowest=t[i];
      continue;
    }
    if(key-1==c){
      ans+=2;
      key=1;
      lowest=t[i];
      continue;
    }
      ans++;
    }else{
      if(lowest+k<t[i]){
      ans++;
      key=1;
      lowest=t[i];
      continue;
    }
    if(key-1==c){
      ans++;
      key=1;
      lowest=t[i];
      continue;
    }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static int n;
    static int[] x,y;
    static double sum;
    static boolean[] used;
    static int[] num;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());
        x =new int[n];
        y = new int[n];
        for(int i=0;i<n;i++){
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        sum = 0.0;
        used = new boolean[n];
        num = new int[n];
        int number = 1;
        for(int i=n;i>=1;i--){
            number*=i;
        }
        calc(0);
        System.out.println(sum/number);
    }

    public static void calc(int count){
        if(count == n){
            int xdiff,ydiff;
            for(int i=1;i<n;i++){
                xdiff = x[num[i]]-x[num[i-1]];
                ydiff = y[num[i]]-y[num[i-1]];
                sum+=Math.sqrt(xdiff*xdiff+ydiff*ydiff);
            }
        }else {
            for(int i=0;i<n;i++){
                if(!used[i]){
                    used[i] = true;
                    num[count] = i;
                    calc(count+1);
                    used[i] =false;
                }
            }
        }
    }
    
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

bool judge1d(int, int);

int main(){
    //cout << (-1 % 2 == 1 % 2) << endl;
    int n;
    cin >> n;

    vector<int> x, y, t;
    int temp;

    t.push_back(0);
    x.push_back(0);
    y.push_back(0);
    for (int i = 0; i < n; i++){
      cin >> temp;
      t.push_back(temp);
      cin >> temp;
      x.push_back(temp);
      cin >> temp;
      y.push_back(temp);
    }

    bool success = false;
    for (int i = 0; i < n; i++){
      success = false;
      for (int j = 0; j <= (t[i+1] - t[i]); j++){
        if(judge1d(x[i+1] - x[i], j) && judge1d(y[i+1] - y[i], t[i+1] - t[i] - j)) {
          success = true;
          break;
        }
      }
      if(!success) break;
    }
  if (success) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

bool judge1d(int x, int n){
  if (x <= n && x >= (-1)*n){
    if (abs(x) % 2 == n % 2) return true;
    else return false;
  }else{
    return false;
  }
}

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

int main() {
	string t;
	cin >> t;
	int len = t.size();
	for(int i = 0;i < len;i++){
		if(t[i] == '?'){
			t[i] = 'D';
		}
	}
  
  cout << t << endl;
}

Measured memory_bytes: 3752
import java.util.*;
 
import java.io.*;
 
public class Main{

    public static long Combination(long n, long r){
        long A = 1;
        long B = 1;
        for(long i = 0; i < r; i++){
            A = A*(n-i);
            B = B*(r-i);
        }
        if(A == 0) return 0;
        return A/B;
    }

    public static long solve(int i, int j, boolean check, int N, String S){
        if(i == N){
            if(j == 0){
                return 1;
            }else{
                return 0;
            }
        }

        if(j == 0) return 1;

        if(check){
            return Combination(N-i, j)*(long)Math.pow(9, j);
        }else{
            if(S.charAt(i) == '0') return solve(i+1, j, false, N, S);
            long Z = solve(i+1, j, true, N, S);
            long A = solve(i+1, j-1, true, N, S)*(S.charAt(i)-'1');
            long P = solve(i+1, j-1, false, N, S);
            return Z+A+P;
        }


    }
    
    public static long Dflag(long a){
        if(a == 1) return 1;
        long h = Dflag(a/2);
        return h + h + 1;
    }
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        long H = s.nextLong();
        

        System.out.println(Dflag(H));
	}
} 

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c), eat;
    REP(i, a) cin >> p[i];
    REP(i, b) cin >> q[i];
    REP(i, c) cin >> r[i];
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    REP(i, x) eat.push_back(p[i]);
    REP(i, y) eat.push_back(q[i]);
    sort(eat.begin(), eat.end());
    // REP(i, p.size()) printf("%d ", p[i]); cout << endl;
    // REP(i, q.size()) printf("%d ", q[i]); cout << endl;
    // REP(i, eat.size()) printf("%d ", eat[i]); cout << endl;
    REP(i, c) {
        if (eat[i] < r[i]) {
            eat[i] = r[i];
        } else {
            break;
        }
    }
    ll ans = 0;
    REP(i, x+y) ans += eat[i];
    OUT(ans);
    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B / 2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = readInt()
	}

	max := getMax(x)
	min := getMin(x)

	minLife := 100000000
	for i := min; i <= max; i++ {
		life := 0
		for j := 0; j < n; j++ {
			life += (x[j] - i) * (x[j] - i)
		}
		if life < minLife {
			minLife = life
		}
	}
	fmt.Println(minLife)
}

func getMax(x []int) int {
	max := 0
	n := len(x)
	for i := 0; i < n; i++ {
		if x[i] > max {
			max = x[i]
		}
	}
	return max
}

func getMin(x []int) int {
	min := 100
	n := len(x)
	for i := 0; i < n; i++ {
		if x[i] < min {
			min = x[i]
		}
	}
	return min
}


Measured memory_bytes: 640
#include <stdio.h>

unsigned long long lim = 1e9 + 7;

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

unsigned long long fctl(int a) {
    unsigned long long i = 1, j = 1;
    while(j <= a) { i *= j; j++; i %= lim; }
    return i;
}

int main(void) {
    int n, m;
    unsigned long long ans;
    scanf("%d %d", &n, &m);
    if(abs1(n, m) == 1) { 
        ans = (fctl(n)%lim) * (fctl(m)%lim) % lim;
    }
    else if(abs1(n, m) == 0) {
        ans = 2 * (fctl(n)%lim) * (fctl(m)%lim) % lim;
    }
    else {
        ans = 0;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a = 0;
  bool flag = false;
  while(true){
    flag = false;
    for(int i=s.size()-2; i>=0; i--){
      if(s.substr(i,2) == "ST"){
        s.erase(i,2);
        flag = true;
        if(s.size() == 0){
          cout << 0 << endl;
          return 0;
        }
      }
    }
    if(flag == false){
      cout << s.size() << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
	
		
		if(b%a==0) {
			System.out.println(a+b+"");
		}else {
			System.out.println(b-a+"");
		}
		
		
		
		s.close();
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int l = 0; int r = 1000000001;
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        ll cnt = 0;
        for (int i = 0; i < N; i++) {
            if (cnt > K) break;
            cnt += (A[i] + m - 1) / m - 1;
        }
        if (cnt <= K) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << "\n";
    return 0;
}

Measured memory_bytes: 4408
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }

fn main() {
    input! { n, d, a, mut xh: [(usize, usize); n] };
    let mut ans = 0;
    let mut acc = vec![0; n + 1];
    let dist = 2 * d;
    let mut ii = 0;
    xh.sort();
    for i in 0..n {
        let (x, h) = xh[i];
        while ii < n && xh[ii].0 + dist < x {
            ii += 1;
        }
        let dm = acc[i] - acc[ii];
        if h > dm {
            let c = (h - dm + a - 1) / a;
            ans += c;
            acc[i + 1] = acc[i] + c * a;
        } else {
            acc[i + 1] = acc[i];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 15608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

lf dp[3010][3010];
lf a[3010];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        cout<<pset(10);
        cin>>n;
        rep1(i, 1, n)
            cin>>a[i];

        dp[0][0] = 1.0;
        for(i=1;i<=n;i++)
            dp[0][i] = dp[0][i-1]*(1.0-a[i]);

        for(i=1;i<=n;i++)
            for(j=1;j<=i;j++)
                dp[j][i] = dp[j][i-1]*(1.0-a[i]) + dp[j-1][i-1]*a[i];

        lf ans = 0.0;
        for(i=n/2+1;i<=n;i++)
            ans += dp[i][n];
        cout<<ans<<endl;

    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 141568
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int D,G; cin>>D>>G;
	vector<int> p(D), c(D);
	for (int i=0; i<D; i++)
		cin>>p[i]>>c[i];
	int ret=INT_MAX;
	for (int bt=0; bt<(1<<D); bt++) {
		int cur=0, val=0;
		for (int i=0; i<D; i++)
			if(bt&(1<<i))
				cur+=p[i], val+=p[i]*(i+1)*100+c[i];
		int diff=max(0,G-val);
		for (int i=D-1; i>=0; i--) {
			if(bt&(1<<i))
				continue;
			int pt=(i+1)*100;
			int tmp=min((diff+pt-1)/pt,p[i]-1);
			cur+=tmp; diff=max(0,diff-pt*tmp);
		}
		if(diff>0)
			continue;
		ret=min(ret,cur);
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, s; cin >> n >> m >> s;

    vvll distcur(n, vll(n, HIGHINF)), distmv(n, vll(n, HIGHINF));
    for (ll i = 0; i < m; i++) {
        ll u, v, a, b; cin >> u >> v >> a >> b;
        u--, v--;
        distcur[u][v] = distcur[v][u] = -a, distmv[u][v] = distmv[v][u] = b;
    }
    for (ll i = 0; i < n; i++) {
        ll c, d; cin >> c >> d;
        distcur[i][i] = c, distmv[i][i] = d;
    }

    vvll dp(n, vll(2505, HIGHINF));
    dp[0][min(s, 2500LL)] = 0;
    for (ll ttttt = 0; ttttt < 100; ttttt++) {
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < 2501; j++) {
                for (ll toi = 0; toi < n; toi++) {
                    if (i == toi) {
                        chmin(dp[i][min(2500LL, j + distcur[i][i])], dp[i][j] + distmv[i][i]);
                    } else {
                        if (distcur[i][toi] != HIGHINF && j + distcur[i][toi] >= 0) {
                            chmin(dp[toi][j + distcur[i][toi]], dp[i][j] + distmv[i][toi]);
                        }
                    }
                }
            }
        }
    }

    vll ans(n, HIGHINF);
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < 2501; j++) chmin(ans[i], dp[i][j]);
    }

    for (ll i = 1; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 4256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

bool isprime(int n){
    if(n<=1) return false;
	for(int i=2;i*i<=n;i++){
              if(n%i==0) return false;
	}
	   return true;
}

int main(void){
	          int i;

	          cin.tie(0);  ios_base::sync_with_stdio(false);

	          int X;
	          cin >> X;

	          for(i=2;i<200000;i++){
	        	  if(i>=X && isprime(i)){
	        		  cout << i << endl;
	        		  return 0;
	        	  }
	          }







	          return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 998244353LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807LL

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args) {
    return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args) {
    using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
    return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

int solve() {
	string S;
	cin >> S;

	if (S[S.size() - 1] == 's') {
		S += "es";
	}
	else {
		S += "s";
	}

	RET(S);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


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

public class Main {
    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();

    }

    private void solve() {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] ns = new int[N];
        for (int i = 0; i < N; i++) {
            ns[i] = sc.nextInt();
        }
        Arrays.sort(ns);
        int ans = 0;
        for (int i = 1; i <= K; i++) {
            ans += ns[N - i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vint c(26);
    REP(i,4){
        c[s[i]-'A']++;
    }
    REP(i,26){
        if(c[i]==0||c[i]==2){

        }else{
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  def isPrime(n:Int):Boolean = (2 to Math.sqrt(n).toInt).forall(n%_ != 0)

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count { _ => isPrime(readInt) })
  }
}

Measured memory_bytes: 121856
#include <cstdio>
#include <algorithm>
using namespace std;
int N, X[101];
int main() {
  scanf("%d", &N);
  int l = 101, r = 0;
  for(int i = 1; i <= N; ++i) {
    scanf("%d", &X[i]);
    l = min(l, X[i]);
    r = max(r, X[i]);
  }
  int ans = 1e9;
  for(int p = l; p <= r; ++p) {
    int sum = 0;
    for(int i = 1; i <= N; ++i) {
      sum += (X[i]-p)*(X[i]-p);
    }
    ans = min(ans, sum);
  }
  printf("%d\n", ans);
}

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

int a,b,c,x;

int main() {
    cin >> a >> b >> c >> x;
    int cnt=0;
    for (int i=0;i<=a;++i){
        for (int j=0;j<=b;++j){
            for (int k=0;k<=c;++k){
                if (i*500+j*100+k*50==x) ++cnt;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};

int main(){
    int N;cin>>N;
    vector<int> A(N),cnt(1e6+1,0);
    vector<bool> ok(1e6+1,false);
    for(int i=0;i<N;++i){
        cin>>A[i];
        cnt[A[i]]++;
        ok[A[i]]=true;
    }
    for(int i=0;i<=1e6;++i)if(ok[i]){
        if(cnt[i]>=2) ok[i]=false;
        for(int j=i*2;j<=1e6;j+=i) ok[j]=false;
    }
    int ans=0;
    for(int i=0;i<=1e6;++i)if(ok[i]) ans++;
    cout<<ans<<endl;
    return 0;
}

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

 int main()
 {
   ios::sync_with_stdio(!cin.tie(0));
   int n,k,c=0;
   cin>>n>>k;
   
   int ar[n+1]={};
   ar[0]=1;
   while(k--)
   {   
   int d;
   cin>>d;
   for(int i=1;i<=d;i++)
   { int num;
     cin>>num;
     ar[num]++;
   }
  }
   for(int i=1;i<=n;i++)
   {
     if(ar[i]==0) c++;
   }
   cout<<c;
   return 0;
 }

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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

    string s;
    cin >> s;
    if(s[s.length() - 1] == 's') s += "es";
    else s += "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<set>
#include<vector>
using namespace std;
#define PI acos(-1.0)
#define pppp cout<<endl;
#define EPS 1e-8
#define LL long long
#define ULL unsigned long long     //1844674407370955161
#define INT_INF 0x3f3f3f3f      //1061109567
#define LL_INF 0x3f3f3f3f3f3f3f3f //4557430888798830399
// ios::sync_with_stdio(false);
// 那么cin, 就不能跟C的 scanf，sscanf, getchar, fgets之类的一起使用了。
const int dr[]={0, 0, -1, 1, -1, -1, 1, 1};
const int dc[]={-1, 1, 0, 0, -1, 1, -1, 1};
int read()//输入外挂
{
    int ret=0, flag=0;
    char ch;
    if((ch=getchar())=='-')
        flag=1;
    else if(ch>='0'&&ch<='9')
        ret = ch - '0';
    while((ch=getchar())>='0'&&ch<='9')
        ret=ret*10+(ch-'0');
    return flag ? -ret : ret;
}
int a[205];
int main()
{
    //freopen("D:\\chnegxubianji\\inORout\\in.txt", "r", stdin);
    //freopen("D:\\chnegxubianji\\inORout\\out.txt", "w", stdout);
    string s;
    cin>>s;
    int len=s.length();
    bool flag=false;
    //保证字串中相同字符的数量多余其余字符，就一定会有相邻的相同的或者间隔一个相同的，不然相同的数量不会多余其他的
    for(int i=0;i<len;++i)
    {
        if(s[i]==s[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            flag=true;
            break;
        }
        else if(i<len-2&&s[i]==s[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            flag=true;
            break;
        }
    }
    if(!flag)
        cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define ll long long
#define int ll

signed main() {
	int N; cin >> N;
	vi a(N);
	rep(i, N) cin >> a[i];
	vvi vec(N, vi(3)); //{株の数，現金，時価総額｝
	vec[0] = { 1000 / a[0],1000 % a[0],1000 };

	for (int i = 1; i < N; i++) {
		int stock_num = vec[i - 1][0];
		int money = vec[i - 1][1];
		int tot = vec[i - 1][2];

		if (a[i] > a[i-1]) {
			tot = a[i] * stock_num + money;
			vec[i] = { tot / a[i],tot % a[i],tot };
		}
		else {
			vec[i] = { tot / a[i],tot % a[i],tot };
		}
	}

	int M1 = vec[N - 1][2];

	cout << M1 << endl;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k; cin>>n>>k;
    if(n<k)
    {
        cout<<min(n,k-n);
    }
    else if(n%k==0)
    {
        cout<<0;
    }
    else
    {
        ll t=n/k;
        n-=k*t;
        cout<<min(n,k-n);
    }
    return 0;
}



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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	ll n = N;
	int total = 0;
	while(N > 0) {
		total += N % 10;
		N /= 10;
	}

	if(n % total == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

		
}


Measured memory_bytes: 256
a,b,m=map(int,input().split())
f=list(map(int,input().split()))
w=list(map(int,input().split()))
money=min(f)+min(w)
for i in range(m):
    x,y,c=map(int,input().split())
    if f[x-1]+w[y-1]-c<money:
        money=f[x-1]+w[y-1]-c
print(money)

Measured memory_bytes: 24636
S=int(input())

kizon=[]
#print(kizon)
cnt=1

while (S not in kizon):
    kizon.append(S)
    if S%2==0:
        S=S//2
        #print(kizon)
        cnt+=1
    else:
        S=3*S+1
        cnt+=1

print(cnt)

Measured memory_bytes: 2940
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    char ch;
    cin >> ch;
    if (isupper(ch)) {
        cout << "A\n";
    } else {
        cout << "a\n";
    }

    return 0;
}

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

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++)
  {
    if (i%2 == 0 && a[i]%2 == 1)
    {
      ans++;
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
N,M=map(int,input().split())
ac=[0]+[0]*N
wa=[0]+[0]*N

for _ in range(M):
    number,ans=input().split()
    number=int(number)
    if ans=='AC':
        ac[number]=1
    elif ac[number]==0:
        wa[number]+=1

print(sum(ac),sum(c for i,c in enumerate(wa) if ac[i]==1))

Measured memory_bytes: 5364
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    int k; cin >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a.at(i);
    }

    cout << (n+k-3)/(k-1) << endl;

}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
    long k,a,b,c;
    cin >> k >> a >> b;
    c = k;
    for(int i=0;i*2<=k;i++){
        long x = k-2*i;
        if(x+1>=a) c = max(c,x+1+i*(b-a));
    }
    cout << c << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    string s;
    int Q;
    cin >> s >> Q;
    deque<char> dq(s.size());
    for (int i = 0; i < s.size(); ++i)  dq[i] = s[i];
    bool rev = false;
    for (int i = 0; i < Q; ++i) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
            continue;
        }
        int f;
        char c;
        cin >> f >> c;
        if (f == 1) {
            if (!rev) dq.push_front(c);
            else dq.push_back(c);
        }
        if (f == 2) {
            if (rev) dq.push_front(c);
            else dq.push_back(c);
        }
    }
    if (rev) reverse(dq.begin(), dq.end());
    for (auto c : dq) cout << c;
    cout << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int main(){
    double h,g;
    int n,NO;
    while(cin>>n,n){
        double s=10000;
        int sNO;
        while(n--){
            cin>>NO>>h>>g;
            h/=100;
            double bmi=22-g/(h*h*1.0);
            if(bmi<0)bmi*=-1;
            if(s>bmi){
                s=bmi;
                sNO=NO;
            }
            else if(s==bmi&&sNO>NO)sNO=NO;
        }
        cout<<sNO<<endl;
    }
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    getline(cin,s);
    sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[3])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int N, A, B;
int main () {
  cin >> N >> A >> B;

  cout << min(A*N, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=2e5+9;
ll a[N];
vector<int>v[N];
bool visited[N];
void dfs(ll x){
    visited[x]=1;
    for (int i=0;i<v[x].size();i++){
        if (!visited[v[x][i]]){
            a[v[x][i]]+=a[x];
            dfs(v[x][i]);
        }
    }
}
int main()
{
    FASTINOUT;
    ll x,q,l,r;
    cin>>x>>q;
    for (int i=0;i<x-1;i++){
        cin>>l>>r;
        v[l].push_back(r);
        v[r].push_back(l);
    }
    while (q--){
        cin>>l>>r;
        a[l]+=r;
    }
    dfs(1);
    for (int i=1;i<=x;i++)
        cout<<a[i]<<" ";
    return 0;
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    bool p = true;
    int x;
    for(int i = 0; i<n ;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            if(x%3>0)
            {
                if(x%5==0)
                {
                    continue;
                }
                p = false;
                cout<<"DENIED";
                break;
            }

        }

    }
    if(p)
    {
        cout<<"APPROVED";
    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        for(int i = 0; i < 26; i++){
            boolean b = false;
            
            switch(i){
                case 0:
                    b = (t.equals(s + "a"));
                    break;
                case 1:
                    b = (t.equals(s + "b"));
                    break;
                case 2:
                    b = (t.equals(s + "c"));
                    break;
                case 3:
                    b = (t.equals(s + "d"));
                    break;
                case 4:
                    b = (t.equals(s + "e"));
                    break;
                case 5:
                    b = (t.equals(s + "f"));
                    break;
                case 6:
                    b = (t.equals(s + "g"));
                    break;
                case 7:
                    b = (t.equals(s + "h"));
                    break;
                case 8:
                    b = (t.equals(s + "i"));
                    break;
                case 9:
                    b = (t.equals(s + "j"));
                    break;
                case 10:
                    b = (t.equals(s + "k"));
                    break;
                case 11:
                    b = (t.equals(s + "l"));
                    break;
                case 12:
                    b = (t.equals(s + "m"));
                    break;
                case 13:
                    b = (t.equals(s + "n"));
                    break;
                case 14:
                    b = (t.equals(s + "o"));
                    break;
                case 15:
                    b = (t.equals(s + "p"));
                    break;
                case 16:
                    b = (t.equals(s + "q"));
                    break;
                case 17:
                    b = (t.equals(s + "r"));
                    break;
                case 18:
                    b = (t.equals(s + "s"));
                    break;
                case 19:
                    b = (t.equals(s + "t"));
                    break;
                case 20:
                    b = (t.equals(s + "u"));
                    break;
                case 21:
                    b = (t.equals(s + "v"));
                    break;
                case 22:
                    b = (t.equals(s + "w"));
                    break;
                case 23:
                    b = (t.equals(s + "x"));
                    break;
                case 24:
                    b = (t.equals(s + "y"));
                    break;
                case 25:
                    b = (t.equals(s + "z"));
                    break;
            }
            if(b){
                System.out.println("Yes");
                System.exit(0);
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 27068
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 998244353;

vector<ll> fac, inv, finv;

void COMInit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll i = 2; i < 200010; ++i)
  {
    fac[i] = i * fac[i - 1] % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll repeatSquaring(ll n, ll p)
{
  if (p == 0)
    return 1;
  if (p % 2 == 0)
  {
    ll t = repeatSquaring(n, p / 2);
    return t * t % MOD;
  }
  return n * repeatSquaring(n, p - 1) % MOD;
}

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long K;
  scanf("%lld", &K);
  fac.assign(200010, 0);
  inv.assign(200010, 0);
  finv.assign(200010, 0);
  COMInit();
  ll sum = 0;
  for (ll i = 0; i <= K; ++i)
  {
    sum = (sum + (COM(N - 1, i) * M) % MOD * repeatSquaring(M - 1, N - i - 1) % MOD) % MOD;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 7668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  bool ok = 1;
  REP(i, 0, s.length()) {
    char c = s[i], d = s[s.length() - 1 - i];
    ok &= (c + d == 'b' + 'd') || (c + d == 'p' + 'q');
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
program name

    implicit none
    character(len=10) A,B,C
    integer lena,lenb
    read*, A,B,C
    lena = len_trim(a)
    lenb = len_trim(b)
    if ((A(lena:lena) == B(1:1)) .and. (B(lenb:lenb)==C(1:1))) then
        print*, "YES"
    else
        print*, "NO"
    end if

end program

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

int main() {
  long long int n,x;
    cin >> n >> x;
  long long int a[2010],b[2010];
  long long int ans =0 ;
  
  for(int i=0;i<n;i++)
    cin >> a[i] ;
  
 for(int i=0;i<n;i++){
   b[i] = a[i];
   ans += a[i];
 }
  
  for(int i=1;i<n;i++){
   long long int res = i*x;
    
    for(int j=0;j<n;j++){
     b[j] = min(b[j],a[(j+n-i)%n]);
      res += b[j];
    }
    
  ans = min(res,ans);
  }
  cout << ans << endl;
}
      
      


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void solve(){
        Scanner scan = new Scanner(System.in);
        int n, q, i, t;
        String[] names = new String[100001];
        int[] times = new int[100001];
        Queue<Integer> processList = new LinkedList<>();
        n = scan.nextInt();
        q = scan.nextInt();
        
        for(i=0;i<n;i++){
            names[i] = scan.next();
            times[i] = scan.nextInt();
            processList.add(i);
        }
        t = 0;
        while(!processList.isEmpty()){
            int x = processList.remove();
            if(times[x]> q){
                times[x] -= q;
                t+=q;
                processList.add(x);
            }else if(times[x] == q){
                t+=q;
                System.out.println(names[x] + " " + t);
            }else{
                t += times[x];
                System.out.println(names[x] + " " + t);
            }
        }
    }
    
    public static void main(String[] args) {
        solve();
    }
}



Measured memory_bytes: 77128
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	int p, q;
	cin >> p >> q;
	set<pair<int, int>> divisors;
	divisors.insert(mp(1, 0));
	divisors.insert(mp(0, 1));
	divisors.insert(mp(-1, 0));
	divisors.insert(mp(0, -1));
	divisors.insert(mp(p, q));
	divisors.insert(mp(-q, p));
	divisors.insert(mp(-p, -q));
	divisors.insert(mp(q, -p));

	int hoge = p * p + q * q;

	//-99,0

	for (int i = 1; i * i <= hoge; ++i) {
		if (hoge % i == 0) {
			{
				int Sum = hoge / i;
				for (int m = 1; m * m <= Sum; ++m) {
					int n = sqrt(Sum - m * m);
					if (n * n + m * m == Sum) {
						REP(tea, 4) {
							if ((m * p + n * q + Sum * 1000000LL) % Sum == 0 && (m * q - n * p + Sum * 1000000LL) % Sum == 0) {
								divisors.insert(mp(m, n));
							}
							if (tea & 1) {
								m *= -1;
							}
							else {
								n *= -1;
							}
						}
					}
				}
			}
			{
				int Sum = i;
				for (int m = 1; m * m <= Sum; ++m) {
					int n = sqrt(Sum - m * m);
					if (n * n + m * m == Sum) {
						REP(tea, 4) {
							if ((m * p + n * q + Sum * 1000000LL) % Sum == 0 && (m * q - n * p + Sum * 1000000LL) % Sum == 0) {
								divisors.insert(mp(m, n));
							}
							if (tea & 1) {
								m *= -1;
							}
							else {
								n *= -1;
							}
						}
					}
				}
			}
		}
	}
	if (divisors.size() == 8) {
		cout << "P" << endl;
	}
	else {
		cout << "C" << endl;
	}

}

#undef int
int main() {
	init();
	int t;
	cin >> t;
	REP(tea, t) {
		solve();
	}
}


Measured memory_bytes: 3144
#include <stdio.h>

int main() {
    int i, j, buf, array[10] = {};
    for (i=0; i<10; i++) scanf("%d", &array[i]);
    for (i=0; i<10; i++) {
        for (j=i+1; j<10; j++) {
            if (array[i] < array[j]) {
                buf = array[i];
                array[i] = array[j];
                array[j] = buf;
            }
        }
    }
    printf("%d\n%d\n%d\n", array[0], array[1], array[2]);
    return 0;
}


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

#define ll long long
#define endl '\n'

ll step[200005];
int dest[200005];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> dest[i];
    ll x = 0;
    ll curr = 1;
    while (++x <= k) {
        if (!step[curr]) {
            step[curr] = x;
            curr = dest[curr];
        } else
            break;
    }
    if (x <= k) {
        ll cycle = x - step[curr];
        k = (k - (step[curr] - 1)) % cycle;
        x = 0;
        while (++x <= k) {
            curr = dest[curr];
        }
    }
    cout << curr << endl;
    return 0;
}


Measured memory_bytes: 6000
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

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

    cout << max(a+b, max(a-b,a*b)) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int x, a, b, c ;

	cin >> x;
  	a = x /100;
    b = (x - a*100) / 10;
    c = x - a*100 - 10 *b;
	cout << a + b +c << endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s = read!string;
    // writeln(s.substitute(',', ' '));
    writeln(s.replace(",", " "));
}


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

using namespace std;

int N;
int TeamInfo[101];

void solve() {
	int ranking;

	for (int i = 1; i <= N; ++i) {
		ranking = 1;
		for (int j = 1; j <= N; ++j) {
			if (TeamInfo[i] < TeamInfo[j]) {
				++ranking;
			}
		}
		cout << ranking << endl;
	}
}

int main() {
	int cnt, a, b, c, d;

	cin >> N;
	cnt = N*(N - 1) / 2;
	for (int i = 0; i < cnt; ++i) {
		cin >> a >> b >> c >> d;
		if (c > d) {
			TeamInfo[a] += 3;
		}
		else if (c < d) {
			TeamInfo[b] += 3;
		}
		else {
			++TeamInfo[a];
			++TeamInfo[b];
		}
	}
	solve();

	return 0;
}


Measured memory_bytes: 3088