akhauriyash/Code-Regression huggingface dataset:
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}

/*		START		*/
$a=getq();
$b=getq();
$c=getq();
$d=getq();
$ans=0;
if($a<$b){
	$ans+=$a;
}else{
	$ans+=$b;
}
if($c<$d){
	$ans+=$c;
}else{
	$ans+=$d;
}
echo $ans."\n";
?>

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

using namespace std;
using ll = long long;
#define int ll

#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) \
	sort(all(v)); \
(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f)                  \
	if ((f))                      \
{                             \
	cout << (TRUE__) << endl; \
}                             \
else                          \
{                             \
	cout << FALSE__ << endl;  \
}
#define RS resize
#define CINV(v, N)             \
	do                         \
{                          \
	v.RS(N);               \
	rep(i, N) cin >> v[i]; \
} while (0);
#define RCINV(v, N)             \
	do                          \
{                           \
	v.RS(N);                \
	rrep(i, N) cin >> v[i]; \
} while (0);
	template <typename T>
inline T GET()
{
	T val;
	cin >> val;
	return val;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int H, W, N;
map<pair<int, int>, int> m;
map<pair<int, int>, int> cnt;
int res[10];

void init()
{
	cin >> H >> W >> N;
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		m[MP(a, b)] = 1;
	}
}

int calc(int r, int c)
{
	if (r <= 0 || r >= H-1 || c <= 0 || c >= W-1) {
		return 0;
	}
	int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1, 0};
	int dc[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
	int x = 0;
	rep(i, 9) {
		x += m.count(MP(r+dr[i], c+dc[i]));
	}
	res[x]++;
	return x;
}

void solve()
{
	for (auto x : m) {
		int a, b;
		a = x.first.first;
		b = x.first.second;
		int dr[] = {-1, -1, 0, 1, 1, 1, 0, -1, 0};
		int dc[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
		rep(i, 9) {
			if (cnt[MP(a+dr[i], b+dc[i])] == 0) {
				cnt[MP(a+dr[i], b+dc[i])] = calc(a+dr[i], b+dc[i]);
			}
		}
	}
	int sum = 0;
	rep(i, 10) {
		sum += res[i];
	}
	res[0] = (H - 2) * (W - 2) - sum;
	rep(i, 10) {
		cout << res[i] << endl;
	}
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,x,y,ans[2005]={0};
int main()
{
	cin>>n>>x>>y;
	x--;y--;
	rep(i,n) rep2(j,i+1,n) ans[min(abs(i-x)+abs(j-y)+1,j-i)]++;
	rep2(i,1,n) cout<<ans[i]<<endl;
	return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int N,K;
    cin >> N >> K;
    string s; cin >> s;
    int M = 0;
    for(size_t i = 1; i < s.size(); ++i){
        M += (s[i -1] != s[i]);
    }
    cout  <<  N - (M + 1)  + min(2 * K , M) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

using namespace std;

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

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

	int min = 10000000;
	int max = -10000000;
	long long total = 0;

	for (int i = 0; i < n; i++) {
		if (min > a[i]) {
			min = a[i];
		}
		if (max < a[i]) {
			max = a[i];
		}
		total += a[i];
	}

	printf("%d %d %lld\n", min, max, total);

	return 0;
}

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

int main(){
  int a,b,c,d,ans;
cin>>a>>b>>c>>d;
ans=0;
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
      for(int u=0;u<c+1;u++){
      if(500*i+100*j+50*u==d){
        ans++;
      }
      }
    }
    
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
function Main(input) {
  input = input.split(' ');
  var r = input[0];
  var D = input[1];
  var x2000 = input[2];
  current = x2000
  for(var i = 0; i < 10; i++){
    current = r* current - D;
    console.log(current);
  }
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	// your code goes here

    int n,m;
    cin>>n>>m;
    long dp[n][m];
   // memset(dp,1,sizeof(dp));
    vector<string> v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i==0 && j==0) continue;
            if(i==0||j==0)
            {
                if(v[i][j]=='.') {
                    if((i!=0 && dp[i-1][j]==1)||(j!=0 && dp[i][j-1]==1))
                    dp[i][j]=1; 
                    else dp[i][j]=0;
                }
                else dp[i][j]=0;
                
                continue;
            }
            if(v[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]%1000000007+dp[i][j-1]%1000000007;
            }
            else dp[i][j]=0;
            
            dp[i][j]%=1000000007;
        }
    }
    // for(int i=0;i<n;i++)
    // {for(int j=0;j<m;j++)
    // cout<<v[i][j]<<" "; cout<<endl;}
    // for(int i=0;i<n;i++)
    // {for(int j=0;j<m;j++)
    // cout<<dp[i][j]<<" "; cout<<endl;}
    cout<<dp[n-1][m-1]%1000000007<<endl;
 	return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
 
typedef long long lint;
 
const int MAX_N = 3e5+2;
 
struct Ant {
	int id;
	lint pos, speed;
 
	Ant(){};
	Ant(int id, lint pos, lint speed) {
		this->id = id;
		this->pos = pos;
		this->speed = speed;
	}
};
 
bool comparePosition(Ant a, Ant b) {
	return (a.pos < b.pos);
}
 
lint mod(lint x, lint m) {
	return ((x % m) + m) % m;
}
 
int ans[MAX_N];
std::vector< Ant > startPosition, endPosition;
 
int main() {
	int n;
	lint cycleLength, time;
 
	std::cin >> n >> cycleLength >> time;
	for(int i = 1; i <= n; i++) {
		int pos, dir;
		std::cin >> pos >> dir;
		pos++;
		startPosition.push_back( Ant(i, pos, (dir == 1) ? 1 : -1) );
	}
 
	std::sort(startPosition.begin(), startPosition.end(), comparePosition);
	for(int i = 0; i < (int)startPosition.size(); i++) endPosition.push_back(startPosition[i]);
 
	lint cyclicShift = 0;
	for(int i = 0; i < n; i++) cyclicShift += startPosition[i].speed;
	cyclicShift = mod(cyclicShift * (time / cycleLength), n);
 
	time %= cycleLength;
	for(int i = 0; i < n; i++) {
		endPosition[i].pos = mod((startPosition[i].pos-1) + time * startPosition[i].speed, cycleLength) + 1;
		if(startPosition[i].speed == 1) {
			if(endPosition[i].pos < startPosition[i].pos) cyclicShift++;
		}
		else {
			if(endPosition[i].pos > startPosition[i].pos) cyclicShift--;
		}
	}
	cyclicShift = mod(cyclicShift, n);
 
	std::sort(endPosition.begin(), endPosition.end(), comparePosition);
	for(int i = 0; i < n; i++) {
		endPosition[i].id = startPosition[mod(i-cyclicShift, n)].id;
		ans[endPosition[i].id] = endPosition[i].pos;
	}
 
	for(int i = 1; i <= n; i++) printf("%d ",ans[i]-1);
	printf("\n");
 
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=(1LL<<60);
const int INF=1<<29;
const int MOD=1e9+7;

template <typename T>
bool chmin(T &a, const T &b){
    if(a > b){
        a=b;
        return true;
    }
    return false;
}

vector<vector<ll>> dp;

int main(){
    int N, M; 
    while(cin >> N >> M){
        if(N == 0 && M == 0) break;
        vi C(M);
        for(auto &y : C) cin >> y;
        vi x(N);
        for(auto &y : x) cin >> y;
        dp.assign(N+1, vector<ll>(256, LINF));
        dp[0][128]=0;
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                for(int k=0; k<256; k++){
                    int val=max(0, k+C[j]);
                    val=min(255, val);
                    chmin(dp[i+1][val], dp[i][k]+(x[i]-val)*(x[i]-val));
                }
            }
        }
        ll res=LINF;
        for(int i=0; i<256; i++) chmin(res, dp[N][i]);
        printf("%lld\n", res);
    }
    return 0;
}


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

using namespace std;

int main(){
    long long n,k;
    string s;
    cin >> n >> k >> s;
    vector<long long> whereis1;
    if(s[0] == '0')
        whereis1.push_back(0);
    bool renzoku = false;
    for(int i=0;i<n;i++){
        if(s[i] == '1'){
            if(renzoku == false){
                whereis1.push_back(i);
                renzoku = true;
                continue;
            }
        } else {
            renzoku = false;
        }
    }
    if(s[n-1] == '0')
        whereis1.push_back(n-1);
    // for(int i=0;i<whereis1.size();i++){
    //     cout << whereis1[i] << endl;
    // }
    int max = 0;
    if(whereis1.size() <= k){
        cout << n << endl;
        return 0;
    }
    for(int i=0;i<whereis1.size()-k;i++){
        int upper = whereis1[i+k];
        while(upper+1 < s.size()){
            if(s[upper+1] == '1'){
                upper++;
            }else{
                break;
            }
        }
        if(upper - whereis1[i] >= max){
            max = upper - whereis1[i];
            // cout << i << " " << upper << endl;
        }
    }
    cout << max + 1<< endl;
    return 0;
}


Measured memory_bytes: 1020
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int k = sc.nextInt();
        sc.close();

        if(k == 0){
            System.out.println(n*n);
            return;
        }

        long ans = (n-k+1)*(n-k)/2;

        for(int i=k+1; i<n; i++){
            long tmp = ((n-i)/i)*(i-k);
            if(n%i >= k){
                tmp += n%i-k+1;
            }
            ans += tmp;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

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

ll arr[100005];
int main() {
  ll n, k;
  cin >> n >> k;

  ll dcg;
  ll max = -10000000;
  for (ll i = 1; i <= n; i++){
    cin >> arr[i];
    if (arr[i] > max){
      max = arr[i];
    }
    if (i == 1){
      dcg = arr[1];
    }
    else if (i > 1){
      dcg = gcd(arr[i],dcg);
    }
  }

  if (max < k){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  if (dcg != 1){
    if (gcd (k,dcg) != dcg){
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }

  cout << "POSSIBLE" << endl;
  return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#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; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ATableTennisTraining {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, a, b; cin >> n >> a >> b;
      if (abs(a-b)%2==0) {
        cout << abs(a-b)/2 << endl;
      } else {
        ll ans = min(b-1, n-a);
        chmin(ans, a+(b-a-1)/2);
        chmin(ans, n-b+1+(b-a-1)/2);
        cout << ans << endl;
      }
    }
};

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

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

int main(){
  int n;
  cin >> n;
  int a[n],cnt = 101;
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n-1;i++){
    if(a[i+1]==a[i]){
      a[i+1] = cnt;
      cnt++;
    }
  }
  cout << cnt - 101 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n,A,B; cin >> n >> A >> B; --A, --B;
    map<int, vi> mpx, mpy;
    map<int, set<ii>> actx, acty;
    vector<ii> po(n);
    for(int i=0,t1,t2,a,b;i<n;i++){
        cin >> t1 >>t2;
        a = t1 - t2;
        b = t1 + t2;
        po[i] = ii(a,b);
        mpx[a].pb(b), actx[a].insert({b,i});
        mpy[b].pb(a), acty[b].insert({a, i});
    }
    for(auto &v:mpx) sort(all(v.y));
    for(auto &v:mpy) sort(all(v.y));
    int ans = 0;
    int s = max(abs(po[A].x - po[B].x), abs(po[A].y - po[B].y));
    queue<int> q;
    vector<bool> check(n,false);
    for(q.push(A), check[A] = true; !q.empty();q.pop()){
        int cur = q.front();
        int l = po[cur].x - s, r = po[cur].x + s;
        int t = po[cur].y + s, b = po[cur].y - s;
        if(mpx.find(r) != mpx.end()){
            ans += upper_bound(all(mpx[r]), t) - lower_bound(all(mpx[r]), b);
            for(auto it = actx[r].lower_bound({b, -1}); it != actx[r].end() && it->first <= t; ){
                if(check[it->second] == false) q.push(it->second);
                check[it->second] = true;
                it = next(it);
                actx[r].erase(prev(it));
            }
        }

        if(mpx.find(l) != mpx.end()){
            ans += upper_bound(all(mpx[l]), t) - lower_bound(all(mpx[l]), b);
            for(auto it = actx[l].lower_bound({b, -1}); it != actx[l].end() && it->first <= t; ){
                if(check[it->second] == false) q.push(it->second);
                check[it->second] = true;
                it = next(it);
                actx[l].erase(prev(it));
            }
        }

        if(mpy.find(t) != mpy.end()){
            ans += upper_bound(all(mpy[t]), r-1) - upper_bound(all(mpy[t]), l);
            for(auto it = acty[t].lower_bound({l, -1}); it != acty[t].end() && it->first <= r; ){
                if(check[it->second] == false) q.push(it->second);
                check[it->second] = true;
                it = next(it);
                acty[t].erase(prev(it));
            }
        }

        if(mpy.find(b) != mpy.end()){
            ans += upper_bound(all(mpy[b]), r-1) - upper_bound(all(mpy[b]), l);
            for(auto it = acty[b].lower_bound({l, -1}); it != acty[b].end() && it->first <= r; ){
                if(check[it->second] == false) q.push(it->second);
                check[it->second] = true;
                it = next(it);
                acty[b].erase(prev(it));
            }
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


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

int64_t mod_pow(int64_t x, int64_t n, const int64_t &p) {
    int64_t ret = 1;
    while(n > 0) {
        if(n & 1)
            (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main() {
    cout << fixed << setprecision(0);

    const int64_t MOD = 1e9 + 7;
    int64_t N;
    cin >> N;

    if(N == 1) {
        cout << 0 << endl;
        return 0;
    }

    // 100 - 81 - 81 + 64

    int64_t ans = mod_pow(10, N, MOD);
    ans -= mod_pow(9, N, MOD);
    if(ans < 0)
        ans += MOD;
    ans -= mod_pow(9, N, MOD);
    if(ans < 0)
        ans += MOD;
    ans = (ans + mod_pow(8, N, MOD)) % MOD;

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

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
	long long  x,y,ans=0;
	cin>>x>>y;
	if(x>0&&y>0)
	{
		if(x<y)
		{
			ans=y-x;//
		}
		if(x==y) 
		{
			ans=0;//
		}
		if(x>y)
		{
			int x1=x*(-1);ans=1+(x-y)+1;//
		}
	}

	if(x>0&&y<0)	
	{
		if(x*(-1)==y) 
		{
			ans=1;//
		}
		int y1=y*(-1);
		if(x<y1) 
		{
			ans=1+(y1-x);//
		}
		if(x>y1) 
		{
			ans=1+(x-y1);//
		}
	}	
	if(x<0&&y<0)
	{
		if(x>y)
		{
			x=x*(-1);int y1=y*(-1);ans=1+(y1-x)+1;//
		}
		if(x<y)
		{
			int y1=y*(-1),x1=x*(-1);ans=x1-y1;//
		}
		if(x==y)
		{
			ans=0;//
		}
	}		
	if(x<0&&y>0)
	{
		int x1=x*(-1);
		if(x1>y)
		{ 
			ans=(x1-y)+1;//
		}
		if(x1<y)
		{
			ans=1+(y-x1);//
		}
		if(x1==y)
		{
			ans=1;//
		}
	}
	if(x==0)
	{
		if(y>0)
		{
			ans=y-x;
		}
		if(y<0)
		{
			int y1=y*(-1);ans=(y1-x)+1;
		}
	}
	if(y==0)
	{
		if(x>0)
		{
			ans=(x-y)+1;
		}
		if(x<0)
		{
			ans=y-x;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC106A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            Console.WriteLine(a * b - (a + b - 1));
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  int tmp = n;
  vi div;
  for (int d = 2; d * d < tmp; d++) {
    if (tmp % d == 0) {
      div.push_back(d);
      while (tmp % d == 0) {
        tmp /= d;
      }
    }
  }
  if (tmp != 1)
    div.push_back(tmp);

  int m = div.size();
  int ans = 0;
  FOR(i, 1, (1 << m)) {
    int cnt = __builtin_popcount(i);
    int mul = 1;
    REP(j, m) {
      if ((i >> j) & 1)
        mul *= div[j];
    }
    if (cnt % 2 == 1) {
      ans += n / mul;
    } else {
      ans -= n / mul;
    }
  }
  cout << n - ans << endl;
  return 0;
}



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

int main(void){
	int n, q, m;
	while(1){
		cin >> n >> q;
		if(!n&&!q) break;
		int v[n][110] = {};
		for(int i = 0; i < n; ++i){
			cin >> m;
			for(int j = 0, tmp; j < m; ++j){
				cin >> tmp;
				v[i][tmp] = 1;
			}
		}
		int ans_data = -1, ans_num = 0, sum = 0;
		for(int j = 0; j < 110; ++j){
			sum = 0;
			for(int i = 0; i < n; ++i){
				if(v[i][j])sum++;
			}
			if(ans_num < sum){
				ans_data = j;
				ans_num = sum;
			}
		}
		cout << (ans_num>=q?ans_data:0) << endl;
	}
	return 0;
}


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

int main()
{
  int N;
  string S, T;
  cin >> N >> S >> T;
  
  string U;
  
  for(int i = 0; i < N; i++)
  {
    U += S.at(i);
    U += T.at(i);
  }
  
  cout << U << endl;
}

Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll arr[4];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    cout<<arr[0]+arr[1]<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3580
using System;

#region Program
namespace Program
{
    #region Solver
    public class Solver
    {

        // ?????? ????´???° ??????
        public static int upper = 100;

        // ????´???°
        int N;

        // ??°???
        int[] A = new int[upper];

        #region Solver
        public Solver()
        {
            N = int.Parse(Console.ReadLine());

            /* ?????????????????¨?????????????????? */
            string[] strAryA = Console.ReadLine().Split(' ');

            /* ????????????????????´??°?????????????????? */
            A = Array.ConvertAll<string, int>(
                    strAryA
                    , delegate (string value)
                    {
                        return int.Parse(value);
                    }
                );
        }
        #endregion

        #region Solve
        public void Solve()
        {
            /* ?????????????????? ???????????? */
            int ans = bubbleSort(A, N);
            /* ?????? ?????? */
            trace(A, N);
            /* ?????? ???????????° */
            Console.WriteLine(ans);
        }
        #endregion

        #region bubbleSort
        /* flag ?????¨???????????????????????? */
        public int bubbleSort(int[] A, int N)
        {
            int sw = 0;
            bool flag = true;
            for (int i = 0; flag; i++)
            {
                flag = false;
                for (int j = N - 1; j >= i + 1; j--)
                {
                    if (A[j] < A[j - 1])
                    {
                        /* ??£??\????´???????????????? */
                        swap(ref A[j], ref A[j - 1]);
                        flag = true;
                        sw++;
                    }
                }
            }
            return sw;
        }
        #endregion

        #region swap
        static void swap<T>(ref T a, ref T b)
        {
            var t = a;
            a = b;
            b = t;
        }
        #endregion

        #region trace
        /* ?????????????´??????????????????? */
        public void trace(int[] A, int N)
        {
            int i;
            for (i = 0; i < N; i++)
            {
                if (i > 0)
                {
                    /* ??£??\??????????´??????????1????????????????????? */
                    Console.Write(" ");
                }
                Console.Write(A[i]);
            }
            /* ????°??????????????????? */
            Console.Write(Environment.NewLine);
        }
        #endregion
    }
    #endregion
}
#endregion

#region Execute
class Execute
{
    public static void Main(string[] args)
    {
        new Program.Solver().Solve();
    }
}
#endregion

Measured memory_bytes: 9172
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(sc.nextInt());
        }
        Collections.sort(A);

        long ans = 0;
        ans += A.get(A.size()-1);
        int j = A.size()-2;
        for (int i = 0; i < N-2; i++) {
            ans += A.get(j-i/2);
            //System.out.println("# "+A.get(j-i/2)+","+(j-i/2));
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 65908
#include <bits/stdc++.h>
using namespace std;
int f(int x, int y, int z) {
	return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
	int n,v;
	cin >> n;
	vector<int> ans(10050);
	for (int i = 1; i < 105; i++) {
		for (int j = 1; j < 105; j++) {
			for (int k = 1; k < 105; k++) {
				v = i * i + j * j + k * k + i * j + j * k + k * i;
				if(v < 10050) ans[v] += 1;
			}
		}
	}
	for (int i = 1; i < n + 1; i++) {
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int[] num = new int[45];

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 0; i <= n; i++) {
			fib(i);
		}
		System.out.println(num[n]);
	}

	private int fib(int n) {
		if (n == 0)
			return num[n] = 1;
		else if (n == 1)
			return num[n] = 1;
		else if(num[n]!=0)
			return num[n];
		else
			return num[n] = fib(n - 2) + fib(n - 1);
	}
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

bool f(P l,P r){
    int a = l.second - l.first;
    int b = r.second - r.first;
    if(a > 0 && b <= 0){
        return true;
    }
    if(a <= 0 && b > 0){
        return false;
    }
    if(a > 0 && b > 0){
        return l.first < r.first;
    }if(a < 0 && b < 0){
        return l.second > r.second;
    }
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    vector<P> lr(n);
    rep(i,n){
        int l = 0;
        int r = 0;
        rep(j,s[i].size()){
            if(s[i][j] == '('){
                ++r;
            }else{
                if(r > 0) --r;
                else ++l;
            }
        }
        lr[i].first = l;
        lr[i].second = r;
    }

    sort(lr.begin(),lr.end(),f);
    if(lr[0].first!=0){
        cout << "No" << endl;
        return 0;
    }
    int l = 0;
    int r = 0;
    rep(i,n){
        if(r < lr[i].first){
            cout << "No" << endl;
            return 0;
        }
        r -= lr[i].first;
        r += lr[i].second;
    }
    cout << (r==0?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 42336
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * n
    ans = []
    for i in range(n-1, -1, -1):
        t = 0
        for j in range(i, n, (i+1)):
            t += ls[j]
        if t % 2 != a[i]:
            ls[i] = 1
            ans.append(i + 1)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 65884
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }

signed main() {

    int n;
    str S;
    cin >> n >> S;

    int ans = 0;
    for (int st = 0; st < n; st++) {
        int left = 0, right = 0;
        vec<int> z(n - st);
        str s = S.substr(st);
        for (int i = 1; i < sz(s); i++) {
            z[i] = max(0LL, min(right - i, z[i - left]));
            if (i >= right || i + z[i] >= right) {
                while (i + z[i] < sz(s) && s[i + z[i]] == s[z[i]]) {
                    z[i]++;
                }
                if (maxi(right, i + z[i])) {
                    left = i;
                }
            }
        }
        for (int i = 0; i < sz(z); i++) {
            maxi(ans, min(z[i], i));
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
const int MAX = 1000001;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll x, y;
  cin >> x >> y;

  ll a, b;

  if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  a = (2 * y - x) / 3;
  b = (2 * x - y) / 3;
  COMinit();
  cout << COM(a + b, a) << endl;
  return 0;
}

Measured memory_bytes: 27088
//nikkei2019_a.cpp
//Sun Jan 27 20:53:58 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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


	cout << min(a,b) << " ";
	if (a+b>=n){
		cout << a+b-n << endl;
	}else {
		cout << 0 << endl;
	}

//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll c[100005];
P p[100005];
bool box[100005];
ll ans;
int main(void){
	ll n,m; cin>>n>>m;
	for(int i=0;i<=n;i++){
		c[i]=1;
	}
	box[1]=true;
	for(int i=0;i<m;i++){
		cin>>p[i].first>>p[i].second;
		c[p[i].first]--;
		c[p[i].second]++;
		if(box[p[i].first]){
			box[p[i].second]=true;
			if(c[p[i].first]==0){
				box[p[i].first]=false;
			}
		}
	}
	for(int i=0;i<=n;i++){
		if(box[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 2688
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  double fa=a,fb=b;
  //cout << (a/b) <<" "<<(a%b)<<" "<<(fa/fb)<<endl;
  printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
  return 0;
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

// <------------- Implement Functions Here ----------> //

  


// <------------- Start of main() -------------------> //

void MAIN() {
	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0] == a[1] && a[0] != a[2]) || (a[2] == a[1] && a[0] != a[2]))	cout<<"Yes\n";
	else cout<<"No\n";
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 13004
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        double[] a = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();

        Console.WriteLine(a[0]*a[1]);
        Console.ReadLine();

    }
}


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

A_tobi=[0]*N
A_max=A[0]
for i in range(len(A)):
    x_sum=A[i]
    if A[i]<A_max:
        x_sum=A_max
        A_max=x_sum
        A_tobi[i]=(x_sum-A[i])
    else :
        A_max=A[i]

print(sum(A_tobi))

    



Measured memory_bytes: 32360
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x=I()
n = 55555
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
#print(len(primes))
#print(primes)
L=[]
for i in range(len(primes)):
    if primes[i]%5==1:
        L.append(primes[i])
for i in range(x):
    print(L[i],end=" ")

    
#エラトステネスの篩っぽいやつ　早いらしい
        
        
    


    

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

int main() {
    int N;
    int A[100];

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

    sort(A, A + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            Alice += A[i];
        } else {
            Bob += A[i];
        }
    }

    cout << Alice - Bob << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;

int main()
{
    int count = 0;
    int n;
    cin >> n;
    if (n % 2 == 0)
    {
        cout << n;
    }
    else
    {
        cout << 2 * n;
    }
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   int ans=a*b-a-b+1;
   cout<<ans<<endl;
}

   


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	//Aは前二桁、Bは後ろ二桁
	string y = "YYMM", m = "MMYY", ym = "AMBIGUOUS", n = "NA";
	int S, A, B;
	cin >> S;
	A = S / 100;
	B = S - A * 100;
	if (A <= 12 && A != 0) {
		if (B <= 12 && B != 0) {
			cout << ym << endl;
			return 0;
		}
		cout << m << endl;
		return 0;
	}
	if (B <= 12 && B != 0) {
		cout << y << endl;
		return 0;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
N-=1
w=input()
f=w[-1]
word={w}
for i in range(N):
    w=input()
    ini=w[0]
    if w in word:
        print("No")
        quit()
    if ini!=f:
        print("No")
        quit()
    word.add(w)
    f=w[-1]
print("Yes")


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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll a, b; cin >> a >> b;

    rep(i, max(a,b)) cout << min(a,b);
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d", &n);

    int min;
    scanf("%d", &min);

    int g = -999999999;

    n--;
    int R, t;

    while (n--) {
        scanf("%d", &R);
        t = R - min;
        if (g < t) g = t;
        if (R < min) min = R;
    }

    printf("%d\n", g);

    return 0;
}

Measured memory_bytes: 596
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int ret=0;
	for(int i=0;i<b;i++)ret+=p[i];printf("%d\n",ret);
}

Measured memory_bytes: 1676
import sys
from pprint import pprint

K, N = map(int, sys.stdin.readline().strip().split())
A = list(map(int, sys.stdin.readline().strip().split()))

d = []
for i in range(1, N):
    d.append(min(A[i] - A[i-1], K - A[i] + A[i-1]))
d.append(min(A[N-1] - A[0], K - A[N-1] + A[0]))

print(K - max(d))

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

typedef long long ll;
string s1,s2;

unordered_set<ll> S;


ll B = 107097077;
ll getHash( const vector<int>& v ){
  ll x = 0;
  for(int i=0;i<26;i++)
    x = x*B+v[i];
  return x;
}

vector<int> v[4444],w[4444];

int main() {
  cin >> s1 >> s2;
  int n = max(s1.size(),s2.size());
  for(int i=0;i<n;i++) v[i] = w[i] = vector<int>(26,0);
  int res = 0;
  for(int k=0;k<n;k++){
    S.clear();
    for(int i=0;i<s1.size();i++){
      int j = i+k;
      if( j >= s1.size() ) continue;
      v[i][ s1[j]-'a' ]++;
      S.insert( getHash(v[i]) );
    }
    for(int i=0;i<s2.size();i++){
      int j = i+k;
      if( j >= s2.size() ) continue;
      w[i][ s2[j]-'a' ]++;
      if( S.count( getHash(w[i] ) ) ) res = k+1;
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];

    ll ans = 0, cur = 0;
    rep(i, 0, n-1) {
        if (h[i] >= h[i+1]) cur++;
        else {
            chmax(ans, cur);
            cur = 0;
        }
    }
    chmax(ans, cur);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#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() {
  int n;

  //入力
  cin >> n;
  vector<int> x(n), y(n), a(n);
  double k = 1;
  rep(i, n) {
    cin >> x.at(i) >> y.at(i);
    a.at(i) = i;
    k *= i+1;
    //cout << x.at(i) << y.at(i) << a.at(i) << k << endl;
  }

  //中身
  double sum = 0; int i, j;
  do{
    rep(l, n-1){
      i = a.at(l+1);
      j = a.at(l);
      sum += sqrt(pow(x.at(i)-x.at(j), 2) + pow(y.at(i)-y.at(j), 2));
    }
  }while(next_permutation(a.begin(), a.end()));

  double avr = sum / k;
  
  
  cout << fixed << setprecision(10) << avr << endl;
  return 0;
}


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

#define INF 1e9

struct WarshallFloyd {
  vector<vector<int>> d;
  int v;

  WarshallFloyd(int n) : v(n), d(n, vector<int>(n, INF)) {
    for(int i = 0; i < v; ++i) d[i][i] = 0;
  }

  void add(int from, int to, int cost) {
    d[from][to] = cost;
    d[to][from] = cost;
  }

  void make() {
    for(int k = 0; k < v; ++k) {
      for(int i = 0; i < v; ++i) {
        for(int j = 0; j < v; ++j) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }

  int dist(int i, int j) {
    return d[i][j];
  }
};

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

  int n, m;
  while(cin >> n >> m, n != 0 && m != 0) {
    WarshallFloyd cost(m), time(m);
    for(int i = 0; i < n; ++i) {
      int a, b, c, t;
      cin >> a >> b >> c >> t;
      a--; b--;
      cost.add(a, b, c);
      time.add(a, b, t);
    }

    cost.make();
    time.make();
    int k;
    cin >> k;
    for(int i = 0; i < k; ++i) {
      int p, q, r;
      cin >> p >> q >> r;
      p--; q--;
      if(r == 0) cout << cost.dist(p, q) << endl;
      else cout << time.dist(p, q) << endl;
    }
  }
}


Measured memory_bytes: 3220
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=1e2+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
int a[MAX_N];
int main()
{
	int n=qi();
	repi(i,1,n) a[i]=qi(); sort(a+1,a+1+n);
	int ans=0;
	repi(i,1,n)repi(j,i+1,n)repi(k,j+1,n)if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3724