akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        long W = sc.nextLong();
        long ans = 0;
        
        if(H==1 || W==1){
            ans = 1;
        }else{
            ans = H*W;
        }
        
        if(ans%2==0){
            ans = ans/2;
        }else{
            ans = ans/2 + 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i=0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int res =0;
  for (int i=0; i < n; i++) {
    if (x>=a[i]) {
      x -= a[i];
      res++;
    }
    else {
    x = 0;
    break;
    }
  }
  if (res > 0 && x > 0 ) res -= 1;
  cout << res << endl;
}

Measured memory_bytes: 3652
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;
trait BinarySearch<T> {
    fn front_position(&self, x: T) -> usize;
    fn back_position(&self, x: T) -> usize;
    fn bs_position(v: &[T], x: T, is_back: bool) -> usize;
}

impl<T> BinarySearch<T> for Vec<T>
where
    T: Ord,
{
    fn front_position(&self, x: T) -> usize {
        Self::bs_position(self, x, true)
    }

    fn back_position(&self, x: T) -> usize {
        Self::bs_position(self, x, false)
    }

    fn bs_position(v: &[T], x: T, is_front: bool) -> usize {
        let len = v.len();
        if len == 1 {
            return if x < v[0] || (is_front && x == v[0]) {
                0
            } else {
                1
            };
        }
        let i = len / 2;
        if x < v[i] || (is_front && x == v[i]) {
            Self::bs_position(&v[..i], x, is_front)
        } else {
            Self::bs_position(&v[i..], x, is_front) + i
        }
    }
}

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.parse();
    let m = iter.parse();
    let mut v = (0..n).map(|_| iter.parse()).collect::<Vec<_>>();

    let mut vv: Vec<(_, u64)> = (0..m).map(|_| (iter.parse(), iter.parse())).collect();
    vv.sort_by(|a, b| a.1.cmp(&b.1));
    let mut vvv = Vec::with_capacity(n);
    'a: for (b, c) in vv.into_iter().rev() {
        for _ in 0..b {
            vvv.push(c);
            if vvv.len() == n {
                break 'a;
            }
        }
    }

    v.extend(vvv);
    v.sort();
    let sum: u64 = v.into_iter().rev().take(n).sum();
    println!("{}", sum);
}

Measured memory_bytes: 13428
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  string A, B, C;
  cin >> A >> B >> C;
  YES(A.back() == B.front() && B.back() == C.front());
  return 0;
}

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

int a, b;

int main() {
    cin >> a >> b;

    if (a < 6)
    {
        cout << 0 << endl;
    } else if(a < 13){
        cout <<  b/2 << endl;
    } else {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

ll n, x, a[2000], b[10000];

ll btr(ll l, ll r, ll i) {
    if (r - l == 1) return b[i] = a[l];
    b[i] = min(btr(l, (l + r) / 2, i * 2), btr((l + r) / 2, r, i * 2 + 1));
    return b[i];
}

ll rmq_(ll l, ll r, ll i, ll ql, ll qr) {
    if (ql <= l && qr >= r) return b[i];
    ll m = (l + r) / 2;
    ll v = 2000000000;
    if (ql < m) v = min(v, rmq_(l, m, i * 2, ql, qr));
    if (qr > m) v = min(v, rmq_(m, r, i * 2 + 1, ql, qr));
    return v;
}

ll rmq(ll l, ll r) {
    if (l >= r) return min(rmq_(0, n, 1, l, n), rmq_(0, n, 1, 0, r));
    else return rmq_(0, n, 1, l, r);
}

int main() {
    //fstream fs("/home/shinku/1_16.txt", ios_base::in);
    cin >> n >> x;
    for (ll i = 0; i < n; i++) cin >> a[i];
    btr(0, n, 1);
    ll r = INT64_MAX / 2;
    for (ll t = 0; t < n; t++) {
        ll c = t * x;
        for (ll s = 0; s < n; s++) {
            c += rmq((s - t + n) % n, (s + 1) % n);
        }
        r = min(r, c);
    }
    cout << r << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, D; cin >> N >> D && (N|D);) {
    vector<vector<int>> C(N);
    vector<int> idx(N), curr(N);
    rep(i, N) {
      int M; cin >> M;
      C[i].resize(M);
      rep(j, M) cin >> C[i][j], curr[i] += C[i][j];
      reverse(all(C[i]));
    }

    auto getMaxValExceptMe = [&](int idx) {
      int ret = 0;
      rep(i, N) {
        if(i == idx) continue;
        ret = max(ret, curr[i]);
      }
      return ret;
    };

    while(1) {
      int maxMin = -1, maxMinIdx = -1;
      bool ok = 0;
      rep(i, N) {
        if(idx[i] < C[i].size()) {
          ok = 1;
          if(curr[i] - C[i][idx[i]] > maxMin && getMaxValExceptMe(i) - (curr[i] - C[i][idx[i]]) <= D) {
            maxMin = curr[i] - C[i][idx[i]];
            maxMinIdx = i;
          }
        }
      }

      if(!ok) break;

      if(maxMinIdx == -1) {
        cout << "No" << endl;
        goto next;
      }

      curr[maxMinIdx] -= C[maxMinIdx][idx[maxMinIdx]];
      idx[maxMinIdx] ++;
    }

    cout << "Yes" << endl;

    next:;
  }
  
  return 0;
}

Measured memory_bytes: 3144
class Cmber:
    def __init__(self,gensize,mod=10**9+7):
        self.mod = mod
        self.g1=[1,1]
        self.g2 = [1, 1] #逆元テーブル
        self.inverse = [0, 1] #逆元テーブル計算用テーブル
        self.getgen(gensize)
    def getgen(self,N):
        for i in range( 2, N + 1 ):
            self.g1.append( ( self.g1[-1] * i ) % self.mod )
            self.inverse.append( ( -self.inverse[self.mod % i] * (self.mod//i) ) % self.mod )
            self.g2.append( (self.g2[-1] * self.inverse[-1]) % self.mod )
 
    def cmb(self,n, r):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.mod
 
    def cmb_very_high_n(self,n, r):
        if ( r<0 or r>n ):
            return 0
        g1=1
        r = min(r, n-r)
        for i in range(n-r+1,n+1):
            g1*=i
            g1%=self.mod
        return g1 * self.g2[r] % self.mod
def resolve():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    cmber = Cmber(N)
    smp =0
    smm =0
    for i in range(N):
        bef = (cmber.cmb(i,K-1)*A[i]) % cmber.mod
        smp +=bef
        smp %=cmber.mod
    for i in range(N):
        aft = (cmber.cmb(N-i-1,K-1)*A[i]) % cmber.mod
        smm +=aft
        smm %=cmber.mod
    
    sm = smp-smm

    print(sm if sm >=0 else sm+cmber.mod)
    

        



if __name__ == "__main__":
    resolve()

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> L(M);
	vector<int> R(M);

	for (int i = 0; i < M; i++){
		cin >> L.at(i) >> R.at(i);
	}

	sort(L.begin(), L.end(), greater<int>());
	sort(R.begin(), R.end());

	int ans = 0;
	for (int j = L[0]; j <= R[0]; j++) {
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string a, b;
  cin >> a >> b;
  double x = sqrt(stoi(a + b));
  cout << (x == floor(x) ? "Yes" : "No") << endl;
}


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

int N, M, A[1 << 18], B[1 << 18];
double dp[1 << 18];
double dp2[1 << 18], prob2[1 << 18];
vector<int> X[1 << 18];

void init() {
	dp[N] = 0.0;
	for (int i = N - 1; i >= 1; i--) {
		double mul = 1.0 / (double)X[i].size();
		for (int j = 0; j < X[i].size(); j++) {
			dp[i] += (dp[X[i][j]] + 1.0) * mul;
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
	}

	init();

	double ans = dp[1]; prob2[1] = 1.0;
	for (int i = 1; i <= N; i++) {
		// Step #1: 計算を行う
		double dp3[609], prob3[609];

		if (X[i].size() >= 2) {
			double mul = 1.0 / (1.0 * X[i].size() - 1.0);
			for (int j = 0; j < X[i].size(); j++) {
				for (int k = 1; k <= N; k++) dp3[k] = dp2[k];
				for (int k = 1; k <= N; k++) prob3[k] = prob2[k];

				for (int k = 0; k < X[i].size(); k++) {
					if (j == k) continue;
					dp3[X[i][k]] += (dp3[i] + prob3[i]) * mul;
					prob3[X[i][k]] += prob3[i] * mul;
				}
				
				double rem = 0;
				for (int k = i + 1; k <= N; k++) {
					if (prob3[k] < 1e-10) continue;
					rem += prob3[k] * (dp3[k] / prob3[k] + dp[k]);
				}
				ans = min(ans, rem);
			}
		}

		// Step #2: 次への遷移
		double mul = 1.0 / X[i].size();
		for (int j = 0; j < X[i].size(); j++) {
			dp2[X[i][j]] += (dp2[i] + prob2[i]) * mul;
			prob2[X[i][j]] += prob2[i] * mul;
		}
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
const long long maxn=3e5+5;
const long long inf=(1LL<<62);
priority_queue<long long> q;
long long a[maxn],maxv[maxn],minv[maxn],sum=0;
long long ans=-inf;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	for(long long i=1;i<=3*n;i++)
		cin>>a[i];
	long long sum=0;
	for(long long i=1;i<=2*n;i++)
	{
		q.push(-a[i]);
		sum+=a[i];
		if(i>n)
			sum+=q.top(),q.pop();
		maxv[i]=sum;
	}
	while(!q.empty())
		q.pop();
	sum=0;
	for(long long i=3*n;i>=n+1;i--)
	{
		q.push(a[i]);
		sum+=a[i];
		if(i<=2*n)
			sum-=q.top(),q.pop();
		minv[i]=sum;
	}
	for(long long i=n;i<=2*n;i++)
		ans=max(ans,maxv[i]-minv[i+1]);
	cout<<ans<<endl; 
	return 0;
}




Measured memory_bytes: 7412
n=int(input())
a=list(map(int,input().split()))
money=1000
stock=0
flag=True
for i in range(n-1):
  if flag==True and a[i]<a[i+1]:
    stock=money//a[i]
    money%=a[i]
    flag=False
  elif flag==False and a[i]>a[i+1]:
    money+=stock*a[i]
    stock=0
    flag=True
if flag==False:
  money+=stock*a[-1]
print(money)


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

int GCD(int a, int b) {
    while(0!=b) {
        a %=b;
        swap(a, b);
    }
    return a;
}

int main() {
    int a, b;
    cin >>a >>b;
    cout <<GCD(a, b) <<endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;main(){int h,w,d,q,a,l,r,i,j,sum[90001]={};map<int,pair<int,int>>v;cin>>h>>w>>d;for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>a,v[a]=make_pair(i,j);for(i=d+1;i<=h*w;i++)sum[i]=sum[i-d]+abs(v[i].first-v[i-d].first)+abs(v[i].second-v[i-d].second);cin>>q;while(q--)cin>>l>>r,cout<<sum[r]-sum[l]<<'\n';}

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

int main(){
    int N;

    cin >> N;

    char S[N+1];
    char T[N+1];
    char ans[2+N+1];

    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000001
#define PI 3.14159265358979323846
using namespace std;
long long mi=1000000000000000LL;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a+n);
	int sum=0;
	for(int i = 0; i < k; i++)
		sum+=a[i];
	cout << sum << '\n';
}

Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
       int n,bomb;
       char spel;
       int S[13]={},H[13]={},C[13]={},D[13]={};
       scanf("%d",&n);
       for(int i=0;i<=n;i++){
           scanf("%c %d\n",&spel,&bomb);
           if(spel == 'S'){
               S[bomb-1] = 1;
           }else if(spel == 'H'){
               H[bomb-1] = 1;
           }else if(spel == 'C'){
               C[bomb-1] = 1;
           }else if(spel == 'D'){
               D[bomb-1] = 1;
           }
       }
       for(int j=0;j<13;j++){
            if(S[j] == 0){
                printf("S %d\n",j+1);
            }
        }
        for(int j=0;j<13;j++){
            if(H[j] != 1){
                printf("H %d\n",j+1);
            }
        }
        for(int j=0;j<13;j++){
            if(C[j] != 1){
                printf("C %d\n",j+1);
            }
        }
        for(int j=0;j<13;j++){
            if(D[j] != 1){
                printf("D %d\n",j+1);
            }
        }
    return 0;
}


Measured memory_bytes: 2112
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    
    long long X;
    cin >> X;
    
    long long c = 100;
    int i = 0;
    
    while (c < X) {
        i++;
        c = c * 1.01;
    }
    
    cout << i;
    
    return 0;
}


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

int main(){
    int d,t,s;
    cin >> d >> t >> s;

    if(d <= s*t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
  
    
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    ll a, b;
    cin >> a >> b;
    cout << a*b << nl;
}

signed main() {
    judge();
    boost;
    solve();
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	cout<<c SP a SP b<<endl;
	return 0;
}


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



int main(){
  ll n;
  cin >> n;
  ll a,b,c,d;
  a=b=c=d=0;
  for(int i=0; i<n; i++){
    string x;
    cin >> x;
    if(x=="AC") a++;
    if(x=="WA") b++;
    if(x=="TLE") c++;
    if(x=="RE") d++;
  }
  
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
  
  
}
       
        
      
  
    

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            int[] v = new int[N];
            int minV = int.MaxValue;
            int maxV = int.MinValue;

            for (int i = 0; i < N; i++)
            {
                v[i] = int.Parse(s[i]);
                minV = Math.Min(minV, v[i]);
                maxV = Math.Max(maxV, v[i]);
            }

            if (minV == maxV)
            {
                Console.WriteLine(0);
                return;
            }

            int ans = int.MaxValue;
            for (int i = minV; i <= maxV; i++)
            {
                int total = 0;
                for (int j = 0; j < N; j++)
                {
                    int val = v[j] - i;
                    total += val * val;
                }

                ans = Math.Min(ans, total);
            }

            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
const int maxn=4e3+5;
string dp[maxn<<1];
char s[maxn<<1];
int a[maxn],b[maxn],n,A,B,t[maxn<<1],p,fi[maxn<<1];
int cnt,group[maxn<<1];
string ans;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for (int i=1;i<=2*n;i++){
		if (s[i]=='a'){
			a[++A]=i;
			t[i]=A;
			cnt++;
		}else{
			b[++B]=i;
			t[i]=B;
			cnt--;
		}
		group[i]=p;
		if (cnt==0)
			fi[++p]=i+1;
	}
	fi[++p]=n*2+1;
	for (int i=2*n;i>=1;i--){
		int mi=min(a[t[i]],b[t[i]]);
		if (mi != i) continue;
		if (a[t[i]]>b[t[i]]){
			string S="";
			for (int j = i;group[j] == group[i];j++){
				if (b[t[j]] >= i)
					S+=s[j];
			}
			S+=dp[fi[group[i]+1]];
			dp[i]=max(S,ans);
		}else{
			dp[i]=max("ab"+dp[b[t[i]]+1],ans);
		}
		ans=max(ans,dp[i]);
	}
	for (int i=0;i<ans.size();i++){
		if (ans[i]!='a'&&ans[i]!='b')
			break;
		cout << ans[i];
	}
	
	
}

Measured memory_bytes: 14720
#include<stdio.h>
#include<string.h>
int main()
{
    int i,l,j,ck=0;
    char ch[4],ch1[4]="abc",ch2[4]="bac",ch3[4]="cab",ch4[4]="bca",ch5[4]="acb",ch6[4]="cba";
    scanf("%s",ch);
    if(strcmp(ch,ch1)==0 || strcmp(ch,ch2)==0 || strcmp(ch,ch3)==0 || strcmp(ch,ch4)==0 || strcmp(ch,ch5)==0 || strcmp(ch,ch6)==0)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 2e6;
const ll inf = 1e9;
const int sz = 26;
typedef long long ll;


void input(){
    IOS;
    ll k;
    cin >> k;
    ll x = 7;
    ll mul = 1;
    ll num = 0;
    f(i, mx){
        num = (num + x * mul % k) % k;
        if(num == 0){
            cout << i + 1 << endl;
            return;
        }
        mul = (mul * 10LL) % k;
    }
    cout << -1 << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 3616
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < n*2; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += list.get(i*2);
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	const int mod=1e9+7;
	int h,w;
	cin>>h>>w;
	int dp[h+1][w+1];
	for(int i=0;i<=h;i++)
		dp[i][0]=0;
	for(int j=0;j<=w;j++)
		dp[0][j]=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char ch;
			cin>>ch;
			if(ch!='#')
				dp[i][j]=1;
			else
				dp[i][j]=0;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(!(i-1)&&!(j-1))
				continue;
			if(dp[i][j])
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 4224
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		int s,v;
		String t;
		int[] p = new int[12];
		while((t=bf.readLine())!=null){
			String[] d=t.split(",");
			for(int i=0;i<12;i++)p[i]=Integer.parseInt(d[i]);
			s=0;for(int i=0;i<10;i++)s+=p[i];
			v=p[10]+p[11];
			double c=(double)p[10]*s/v;
			for(int i=0;i<10;i++){
				c-=(double)p[i];
				if(c<=0){System.out.println((i+1));break;}
			}
		}
	}
}

Measured memory_bytes: 9360
#!/usr/bin/python3.6
n = int(input())
a = [int(item) for item in input().split()]
aor = 0
axor = 0
for item in a:
    aor |= item
    axor ^= item

rank = 0
ans = 0
for bit in range(61):
    if axor & 1 << (60 - bit):
        ans += 1 << (60 - bit)
        continue
    found_in_bit = False
    for i in range(rank, n):
        if a[i] & 1 << (60 - bit):
            if not found_in_bit:
                a[rank], a[i] = a[i], a[rank]
                # delete bit in upper
                for j in range(rank):
                    if a[j] & 1 << (60 - bit):
                        a[j] ^= a[rank]
                found_in_bit = True
                rank += 1
            else:
                a[i] ^= a[rank-1]
        else:
            continue

ret = 0
for item in a:
    ret ^= item & ~axor
ans += ret * 2
print(ans)

Measured memory_bytes: 16052
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double X=0,Y=0;
	int degree=90;
	double DegToRad = (4.0*atan(1))/180.0;
	while(true){
		int D,A;
		scanf("%d,%d",&D,&A);
		if(D==0 && A==0) break;

		double DX=D*cos(DegToRad*degree),DY=D*sin(DegToRad*degree);
		X+=DX;
		Y+=DY;
		degree-=A;
	}

	out((ll)X);
	out((ll)Y);
	return 0;
}


Measured memory_bytes: 3600
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	int W,H,x,y,r;
	String s = buf.readLine();
	String[] strlAry =s.split(" ");
	for(int i=0;i<strlAry.length;i++){
	}
	W= Integer.parseInt(strlAry[0]);
	H= Integer.parseInt(strlAry[1]);
	x= Integer.parseInt(strlAry[2]);
	y= Integer.parseInt(strlAry[3]);
	r= Integer.parseInt(strlAry[4]);


	if(((x+r) <=W && 0<=(x-r)) && ((y+r) <=H) &&( 0<=(y-r)) ){
			System.out.println("Yes");
	}
	else{
			System.out.println("No");
	}
}
}

Measured memory_bytes: 17088
#include<iostream>

using namespace std;

int n, m, ans;
int a[100], b[100];

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for (int i=1;i<=n;i++)
	{
		cin>>b[i];
		ans += a[i] - b[i] > 0? a[i] - b[i]:0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
vector<int> G[100100];
int main(){
    int n;
    int t,a;
    cin >> n >> t >> a;
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    vector<int> dp(n+10,1e9);
    queue<P> que;
    que.push(P(a,0));
    dp[a] = 0;
    while(!que.empty()){
        P p = que.front();
        que.pop();
        for(auto i:G[p.first]){
            if(dp[i]>p.second+1){
                que.push(P(i,p.second+1));
                dp[i] = p.second+1;
            }
        }
    }
    // 高橋くんからBFSして到達可能な頂点のうち青木くんの距離が最も遠いもの
    que.push(P(t,0));
    vector<int> dpt(n + 10, 1e9);
    dpt[t] = 0;
    int ans = dp[t];
    while(!que.empty()){
        P p = que.front();
        que.pop();
        for(auto i:G[p.first]){
            if(dp[i]<=p.second+1 ){
                continue;
            }
            else if(dpt[i]>p.second+1){
                ans = max(ans,dp[i]);
                dpt[i] = p.second+1;
                que.push(P(i,p.second+1));
            }
        }
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 6784
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, d,n, sum, A[500010], B[200][200], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;
map<ll,ll> m;


int main() {
	//Code Line
cin >> n >> a >> b;
for(int i = 0;i < n;i++){
cin >> A[i];

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

}

for (int bit = 0; bit < (1<<n); ++bit)
    {
ll C[20] ={};check = 1;sum = 0;
        for (int i = 0; i < n; ++i) {

						if (bit & (1<<i)) {
            sum += A[i];

						for(int j = 0;j < a;j++){
						C[j] += B[i][j];
						}
						
            }
						
        }

				for(int i = 0;i < a;i++){
				if(C[i] < b)check=0;
				}
if(check == 1)Min = min(sum,Min);
				
}

if(Min == INFL)cout << -1 << endl;
else cout << Min << endl;

	return 0;
}


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

const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;

int n;
ll a[maxn],cnt2[61];
int cnt[maxn][60],sum[maxn][60];

int main()
{	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cnt2[0] = 1;
	for(int i = 1; i < 60; i++) cnt2[i] = cnt2[i - 1] * 2 % mod;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < 60; j++){
			cnt[i][j] = ((a[i] >> j) & 1ll);
		}
	}
	//cout << cnt[0][1] << " " << cnt[1][1] << " " << cnt[2][1] << endl;
	ll ans = 0;
	for(int i = 0; i < 60; ++i){
		for(int j = n - 1; j >= 0; --j){
			sum[j][i] = sum[j + 1][i] + cnt[j + 1][i];
		}
		//if(i == 0) cout << sum[0][0] << endl;
		//if(i == 1) cout << sum[0][1] << endl;
		for(int j = 0; j < n - 1; ++j){
			if(cnt[j][i] == 0) {
				ans = (ans + 1ll * sum[j][i] * cnt2[i] % mod) % mod;
			}
			else {
				ans = (ans + 1ll * (n - sum[j][i] - 1 - j) * cnt2[i] % mod) % mod;
			}
			//cout << j << " " << i << " " <<  ans << endl;
		}
	}
	//assert(ans < 0);
	//if(ans < 0) while(1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 143232
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x[][] = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = sc.nextInt();
            }
        }

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int sum = 0;
                for (int k = 0; k < d; k++) {
                    sum += Math.pow((x[i][k] - x[j][k]), 2);
                }

                int diss = (int)Math.sqrt(sum);
                if (sum == diss * diss) {
                    count++;
                }
            }
        }

        System.out.println(count);
	}
}


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

int main()
{
    int n;
    int cnt=0,cnt2=0;
    cin>>n;
    int arr[n+1];
    for(int i=0;i<n;i++) cin>>arr[i];
    //sort(arr,arr+n);
    sort(arr, arr+n, greater<int>());
    for(int i=0;i<n;i++)
    {
        if(i%2==0) cnt+=arr[i];
        else cnt2+=arr[i];
    }
    cout<<cnt-cnt2<<endl;
}


Measured memory_bytes: 256
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int main()
{
    int a,b,t;
    int s;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&t);
    s = t/a;
    b = b*s;
    printf("%d",b);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N, M;
  int x[100010];
  vector<int> a;

  cin >> N >> M;

  for (int i = 0; i < M; ++i) cin >> x[i];
  sort(x, x+M);

  for (int i = 1; i < M; ++i) a.push_back(x[i] - x[i-1]);
  sort(ALL(a), greater<int>());


  i64 sum = 0;
  i64 big = 0;

  for (int i = 0; i < N-1 && i < a.size(); ++i) {
    big += a[i];
  }
  for (int i = 0; i < a.size(); ++i) {
    sum += a[i];
  }

  cout << sum - big << endl;


  return 0;
}



Measured memory_bytes: 1276
object Main extends App {
  import scala.math._
  
  val n = readInt
  val dp = Array.fill[Int](n+1)(Int.MaxValue)
  dp(0) = 0
  
  for (i <- 0 until n) {
    dp(i+1) = min(dp(i+1),dp(i)+1) //1円引き出す
    
    var j = 1
    var p = pow(6,j).toInt
    while(i+p <= n) {//6のべき乗円引き出す
      dp(i+p) = min(dp(i+p),dp(i)+1)
      j += 1
      p = pow(6,j).toInt
    }
    
    j = 1
    p = pow(9,j).toInt
    while(i+p <= n) {//9のべき乗円引き出す
      dp(i+p) = min(dp(i+p),dp(i)+1)
      j += 1
      p = pow(9,j).toInt
    }
  }
  
  println(dp(n))
}

Measured memory_bytes: 27644
#include "bits/stdc++.h"
using namespace std;
const int maxn = 111;
int g[maxn][13], p[maxn][13];
int qtd[maxn];
int main(){
    int n;
    cin >> n;
    for(int e = 0; e < n; e++){
        for(int f = 0; f < 10; f++) cin >> g[e][f];
    }
    for(int e = 0; e < n; e++){
        for(int f = 0; f <= 10; f++) cin >> p[e][f];
    }
    int ans = INT_MIN/2;
    for(int e = 1; e < (1<<10); e++){
        memset(qtd, 0, sizeof(qtd));
        for(int f = 0; f < n; f++){
            for(int t = 0; t < 10; t++){
                if(e&(1<<t)){
                    if(g[f][t]) qtd[f]++;
                }
            }
        }
        int res = 0;
        for(int f = 0; f < n; f++) res += p[f][qtd[f]];
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args) {
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();
        String s = stdIn.next();

        k--;

        char[] cs = s.toCharArray();
        if(cs[k] == 'A'){
            cs[k] = 'a';
        }else if(cs[k] == 'B'){
            cs[k] = 'b';
        }else if(cs[k] == 'C'){
            cs[k] = 'c';
        }

        s = "";
        for(int i=0; i<n; i++){
            s += cs[i];
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 21204
s = input()
hint = input()
s_l = len(s)
h_l = len(hint)
not_q_ind = [i for i in range(s_l) if s[i] != "?"]
t_li = [ "?"*i + hint + "?"*(s_l-h_l - i) for i in range(s_l-h_l+1)]
t_li_l = len(t_li)

new_t_li = []
for i in range(t_li_l):
  f = 0
  for ind in not_q_ind:
    if (t_li[i][ind] == "?") or (t_li[i][ind] == s[ind]):
      t_li[i] = t_li[i][:ind] + s[ind] + t_li[i][ind+1:]
    else:
      f = 1
  if f == 0:
    new_t_li.append(t_li[i])
    
length = len(new_t_li)
if length == 0:
  print("UNRESTORABLE")
else:
  for i in range(length):
    new_t_li[i] = new_t_li[i].replace("?", "a")
  print(sorted(new_t_li)[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	string s;
	cin >> s;
	char c;
	int num_g=0, num_p=0;
	for(char& c  : s){
		if(c == 'g') num_g++;
		else num_p++;
	}
	int stock = num_g - num_p;
	int score_one = stock/2;
	stock -= 2 * score_one;
	cout << score_one << '\n';
	
	return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
N=int(input())

log=[]
for _ in range(N):
    X,L=map(int,input().split())
    log.append([X,X-L,X+L])
    
log.sort(key=lambda x:x[2])

ans=N
pre=log[0][2]
for i in range(N-1):
    if log[i+1][1]-pre<0:
        #print(pre,log[i+1][2])
        if log[i+1][2]<pre:#前の方が幅取る場合
            pre=log[i+1][2]
        ans-=1
    else:#ぶつからない場合
        pre=log[i+1][2]
    
print(ans)

Measured memory_bytes: 24536
n,m = map(int,input().split())
sc = [[int(i) for i in input().split()] for j in range(m)]

if m == 0:
    if n == 3:
        print(100)
        exit()
    elif n == 2:
        print(10)
        exit()
    elif n== 1:
        print(0)
        exit()

ans = [10 for i in range(n)]

sc.sort()

ini_pos = sc[0][0]
ini_val = sc[0][1]
ans[ini_pos-1] = ini_val

for i in range(m-1):
    if sc[i+1][0] == ini_pos:
        if sc[i+1][1] != ini_val:
            print(-1)
            exit()
    else:
        ini_pos = sc[i+1][0]
        ini_val = sc[i+1][1]
        ans[ini_pos-1] = ini_val

if ans[0] == 0:
    if n == 1:
        print(0)
        exit()
    else:
        print(-1)
        exit()

value = 0

for i in range(n):
    if i == 0:
        if ans[i] == 10:
            value += 10 ** (n-i-1)
            continue
    if ans[i] != 10:
        value += ans[i] * 10 ** (n-i-1)

print(value)

Measured memory_bytes: 38512
import collections

N=int(input())
S=[input() for _ in range(N)]
max=0
l=[]
c=collections.Counter(S)
values=list(c.values())
key=list(c.keys())

for i in range(len(key)):
    l.append([key[i],values[i]])

x=sorted(l,key=lambda x:x[0])
x.sort(key=lambda x:x[1],reverse=True)
max=x[0][1]
i=0
#print(x)
while True:
    if (x[i][1]==max):
        print(x[i][0])
        i=i+1
        if i+1>len(x):
            break
    else:
        break

Measured memory_bytes: 126160
from fractions import gcd

A, B, C, D = map(int, input().split())
# print(A, B, C, D)
CD = C * D // gcd(C, D)
ans1 = B // CD - (A - 1) // CD
ans2 = B // C - (A - 1) // C
ans3 = B // D - (A - 1) // D
print(B - A + 1 - (ans2 + ans3 - ans1))


Measured memory_bytes: 66028
using System;
    class Program
    {
    	static void Main(string[] args)
    	{
    		// スペース区切りの整数の入力
    		string[] input = Console.ReadLine().Split(' ');
    		int a = int.Parse(input[0]);
    		int b = int.Parse(input[1]);
    		//出力
    		Console.WriteLine(a * b);
    	}
    }

Measured memory_bytes: 27496
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	int h = ri();
	int w = ri();
	char s[h][w+1];
	FOR(i,h) scanf("%s", s[i]);
	
	FOR(i,h) {
		FOR(j,w) {
			if (s[i][j] == '#') {
				if (i > 0 && s[i-1][j] == '#') continue;
				if (i < h-1 && s[i+1][j] == '#') continue;
				if (j > 0 && s[i][j-1] == '#') continue;
				if (j < w-1 && s[i][j+1] == '#') continue;
				printf("No");
				return 0;
			}
		}
	}
	
	printf("Yes");
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000
void push(int);
int pop(void);
int top;
int S[MAX];
int main(){
  char str[199];
  int i,x,y;
  top = 0;
  while( scanf("%s",str) != EOF ){
    switch(str[0]){
    case '+':
      x = pop();
      y = pop();
      push(x + y);
      break;
    case '-':
      y = pop();
      x = pop();
      push(x - y);
      break;
    case '*':
      x = pop();
      y = pop();
      push(x * y);
      break;
    default:
      push(atoi(str));
      break;
    }
  }
    printf("%d\n",pop());
    return 0;
}
void push(int x){
  S[++top] = x;
}
int pop(){
  top--;
  return S[top+1];
}



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

const int DIM = 1e5 + 5;

int main( void ) {
    
    int n;
    cin >> n;
    
    long long ans = 0, sum = 0;
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        if( x == 0 ) {
            ans += sum / 2;
            sum = 0;
        }
        else
            sum += x;
    }
    
    cout << ans + sum / 2 << endl;
    return 0;
}

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

/*
各a[i]について、集合を管理し
・集合の最小値よりも小さければ追加
・そうでなければ、その値を超えない最小の要素をa[i]に置換
*/

void solve(){
    ll n;
    cin >> n;
    ll a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    multiset<int> st;
    st.insert(a[0]);
    for(ll i=1; i<n; i++){
        if(a[i]<=*st.begin()) st.insert(a[i]);
        else{
            auto it = st.lower_bound(a[i]);
            --it;
            st.erase(it);
            st.insert(a[i]);
        }
    }

    cout << st.size() << endl;

}

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

Measured memory_bytes: 5760
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);CIN(k);CIN(x);CIN(y);
    if(n<=k){COUT(n*x);}
    else COUT(k*x+(n-k)*y);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
n = int(input())
h = list(map(int, input().split()))
h.reverse()
limit = h[0]
r = 'Yes'
for i in range(n-1):
    if h[i] < limit:
      limit = h[i]
    if h[i+1] > limit + 1:
      r = 'No'
      break
    
print(r)

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] + a[1] << endl;
  return 0;
}


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

int main(){
  long long n, c;
  cin >> n >> c;
  vector<long long> x(n+2), v(n+1);
  x[0] = 0; v[0] = 0; x[n+1] = c;
  for (int i = 1; i <= n; i++) {
    scanf("%lld  %lld", &x[i], &v[i]);
  }
  vector<long long> a(n+1), b(n+1);
  a[0] = 0; b[0] = 0;
  for (int i = 1; i <= n; i++) {
    a[i] += a[i-1] + v[i] - (x[i] - x[i-1]);
    if (i == 1) b[i] += b[i-1] + v[n+1-i] - (c - x[n+1-i]);
    else b[i] += b[i-1] + v[n+1-i] - (x[n+2-i] - x[n+1-i]);
    //printf("%lld, %lld\n", a[i], b[i]);
  }
  //printf("\n");
  for (int i = 1; i <= n; i++) {
    a[i] = max(a[i-1], a[i]);
    b[i] = max(b[i-1], b[i]);
    //printf("%lld, %lld\n", a[i], b[i]);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, a[i] + b[n-i] - x[i]);
    ans = max(ans, b[i] + a[n-i] - (c - x[n+1-i]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int matrix[][]=new int[n][m];
        int vector[]=new int[m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++) {
                matrix[i][j]=sc.nextInt();
            }
        }
        for(int i=0;i<m;i++){
            vector[i]=sc.nextInt();
        }

        for(int i=0;i<n;i++){
            int sum=0;
            for(int j=0;j<m;j++) {
                sum+=matrix[i][j]*vector[j];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 40740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=200050;
ll n=50,k,a[MAX];
vector<int> conn[MAX];
queue<int> ret;
int main(){
    scanf("%lld",&k);
    for(int i=0;i<n;i++) a[i]=k/n+(n-1)-k%n;
    for(int i=0;i<k%n;i++) a[i]+=n+1;
    printf("%lld\n",n);
    for(int i=0;i<n;i++) printf("%lld ",a[i]);
    printf("\n");
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(a+b == c|| a+c == b || b+c == a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256