akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int INF=1000010000;
typedef long long ll;
int main() {
  int n;cin >> n;
  vector<int> dp(n+1,INF);
  vector<int> h(n);
  dp[0]=0;
  for(int i=0; i<n; i++) cin >> h[i];
  for(int i=0; i<=n-2; i++){
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    if(i==n-2) continue;
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[n-1] << endl;
}

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

bool is_prime(int64_t x) {
    for(int64_t i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

void Main() {
    int64_t x; cin >> x;
    while (!is_prime(x)) {
        x++;
    }
    cout << x << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;


/**
 * @brief bubble sort
 * @param int &Array 
 * @param int N
 * @return count 
 * @detail print sort data
 */
int bubbleSort(int *Array, int N)
{
  int count = 0;
  for(int i = 0; i < N; i++){
    for(int j = i; j > 0; j--){
      if (Array[j] < Array[j-1]){
        int temp = Array[j];
        Array[j] = Array[j-1]; 
        Array[j-1] = temp;
        count++;
      }
    }
  }

  for(int i = 0; i < N; i++){
    if ( i == N -1 ) cout << Array[i] << endl;
    else cout << Array[i] << " ";
  }

  return count;
}

int main(int argc, char const *argv[])
{
  int n, array[101];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> array[i];
  }

  cout << bubbleSort(array, n) << endl;
  return 0;
}




Measured memory_bytes: 3104
result = 0
datas = $stdin.read.split("\n")
for i in 0..datas[0].to_i do
	for j in 0..datas[1].to_i do
		for k in 0..datas[2].to_i do
			if datas[3].to_i == i * 500 + j * 100 + k * 50 then
				result += 1
			end
		end
	end
end
puts result

Measured memory_bytes: 1788
import java.util.*;

class Main {
	
	int inns, roads, money;
	int[][] charge, enemy;
	
	boolean[][] v;
	
	int dijkstra() {
		v = new boolean[inns + 1][money + 1];
		// {from, distance, enemy}
		Queue<int[]> que = new PriorityQueue<int[]>(1, new Comparator<int[]>() {
			@Override
			public int compare(int[] arg0, int[] arg1) {
				return arg0[2] - arg1[2];
			}
		});
		que.offer(new int[]{1, money, 0});
		while (!que.isEmpty()) {
			int[] p = que.poll();
			int from = p[0], currentMoney = p[1], attacks = p[2];
			
			// ゴールに到達した場合、それが最小の襲われる人数になっている。
			if (from == inns) {
				return attacks;
			}
			
			// PriorityQueueなので最初に見たものが最小の襲われる人数になっている。だから読み飛ばして良い。
			if (v[from][currentMoney]) {
				continue;
			}
			v[from][currentMoney] = true;
			
			for (int to = 1; to <= inns; to++) {
				if (charge[from][to] == 0) continue;
				if (charge[from][to] <= currentMoney) {
					// お金が足りたら襲われなくて済むね。しかもこいつは優先順位が高い。
                    que.offer(new int[]{to, currentMoney - charge[from][to], attacks});
                }
                que.offer(new int[]{to, currentMoney, enemy[from][to] + attacks});	
			}
		}
		return -1;
	}
	
	int solve() {
		return dijkstra();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		String output = "";
		while (sc.hasNext()) {
			inns = sc.nextInt();
			roads = sc.nextInt();
			money = sc.nextInt();
			if (inns == 0 && roads == 0 && money == 0) {
				break;
			} else {
				charge = new int[inns + 1][inns + 1];
				enemy = new int[inns + 1][inns + 1];
				for (int i = 0; i < roads; i++) {
					int a = sc.nextInt(), b = sc.nextInt();
					int d = sc.nextInt(), e = sc.nextInt();
					charge[a][b] = d;
					charge[b][a] = d;
					enemy[a][b] = e;
					enemy[b][a] = e;
				}
				output += solve() + "\n";
			}
		}
		sc.close();
		System.out.print(output);
	}

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

}

Measured memory_bytes: 60772
using System;
using System.Linq;
public class Program {
	public static void Main()
	{
		var list = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
		
		var N = list[0];
		var M = list[1];
		int[] a,b,c;
		a = new int[M];
		b = new int[M];
		c = new int[M];
		
		// 全ての辺を配列にセット
		for(int i = 0; i < M; i++)
		{
			var d = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
			a[i] = d[0] - 1;
			b[i] = d[1] - 1;
			c[i] = d[2];
		}
		
		const int MAX = 1000;
		int[,] dist = new int[N, N];
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < N; j++)
			{
				dist[i, j] = MAX;
			}
			dist[i,i] = 0;
		}		
		for(int i = 0; i < M; i++)
		{
			dist[a[i], b[i]] = c[i];
			dist[b[i], a[i]] = c[i];
		}		

		for(int k = 0; k < N; k++) //中間点
		{
			for(int i = 0; i < N; i++) //始点
			{
				for(int j = 0; j < N; j++)　//終点
				{
					dist[i, j] = Math.Min(dist[i,j], dist[i,k] + dist[k, j]);
					dist[j, i] = Math.Min(dist[i,j], dist[i,k] + dist[k, j]);
				}
			}		
		}
		int ans = 0;
		for (var i = 0; i < M; i++)
		{
			if(dist[a[i], b[i]] < c[i]) 
				ans++;
		}
		Console.WriteLine(ans);
	}
}

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

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

        String s=scan.next();
        String ans="yes";
        for(int i=0;i<s.length();i++){
            for(int j=i+1;j<s.length();j++){
                if(s.charAt(i)==s.charAt(j)){
                    ans="no";
                    break;
                }
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  cin>>n>>t;
  vector<int> c(n);
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>c[i]>>x[i];
  }
  int ans=1001;
  for(int i=0;i<n;i++){
    if(x[i]<=t){
      if(ans>c[i]){
        ans=c[i];
      }
    }
  }
  if(ans==1001){
    cout<<"TLE"<<endl;
  }
  else{
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    int total = 0;
    int p = 0;
    char c;
    while ((c = getchar()) != '\n'){
        if (c == 'p') ++p;
        ++total;
    }
    printf("%d\n", total / 2 - p);
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<vector<int>> idx(2e5 + 1);
  vector<long long> ft(n, -1), next(n);
  for (int i = 0; i < n; ++i) {
    idx[a[i]].push_back(i);
  }
  for (int i = 1; i <= 2e5; ++i) {
    for (int j = 0; j < int(idx[i].size()) - 1; ++j) {
      next[idx[i][j]] = idx[i][j + 1];
    }
    if (!idx[i].empty()) {
      next[idx[i].back()] = idx[i].front() + n;
    }
  }
  //cout << "HERE" << endl;
  int i = 0;
  do {
    int ni = next[i] + 1;
    ft[ni % n] = ft[i] + (ni - i);
    i = ni % n;
  } while (i != 0);
  //for (int i = 0; i < n; ++i) {
  //  cout << i << ": " << next[i] << ' ' << ft[i] << endl;
  //}
  vector<pair<long long, int>> t;
  t.emplace_back(-1, 0);
  for (int i = 0; i < n; ++i) {
    if (ft[i] != -1) {
      t.emplace_back(ft[i], i);
    }
  }
  //cout << "HERE" << endl;
  sort(t.begin() + 1, t.end());
  if (ft[0] == -1) {
    cout << "hello" << endl;
    return 0;
  }
  //cout << "HERE" << endl;
  long long mod = (n * k - 1) % (ft[0] + 1);
  vector<int> ans;
  for (int i = 0; i < int(t.size()) - 1; ++i) {
    //cout << i << ' ' << int(t.size()) - 1 << endl;
    if (mod < t[i + 1].first) {
      //cout << "MOD: " << mod << endl;
      //cout << mod << ' ' << t[i].first << ' ' << t[i].second << endl;
      vector<bool> there(200001);
      for (long long j = t[i].second; j < t[i].second + (mod - t[i].first); ++j) {
        //cout << j << ' ' << t[i].second + (mod - t[i].first) << endl;
        //cout << j % n << ' ' << a.size() << ' ' << a[j % n] << ' ' << there.size() << endl;
        if (there[a[j % n]]) {
          while (!ans.empty() && ans.back() != a[j % n]) {
            there[ans.back()] = false;
            ans.pop_back();
          }
          //cout << "There" << endl;
          if (ans.empty()) {
            //cout << a[j % n] << endl;
            return 0;
          }
          assert(!ans.empty());
          there[ans.back()] = false;
          ans.pop_back();
          there[a[j % n]] = false;
          //if (a[j % n] == 1214) {
          //  cout << "Removed 1214" << endl;
          //}
        } else {
          ans.push_back(a[j % n]);
          there[a[j % n]] = true;
          //if (a[j % n] == 1214) {
          //  cout << "Added 1214" << endl;
          //}
        }
      }
      break;
    }
  }
  //cout << ans.size() << endl;
  for (int i : ans) {
    cout << i << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 22000
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    map<ll, ll> A;
    rep (i, N) {
        ll a;
        cin >> a;
        A[a] += 1;
    }
    rep (i, M) {
        ll b, c;
        cin >> b >> c;
        A[c] += b;
    }
    ll ans = 0;
    ll cnt = 0;
    for (auto it = A.rbegin(); it != A.rend(); ++it) {
        if (cnt + it->snd < N) {
            ans += it->fst * it->snd;
            cnt += it->snd;
        } else {
            ans += it->fst * (N - cnt);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
int arr[10010], brr[10010];
vector<pi> v;
// vector<pair<int, int>> v;
// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }

void solve()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    m /= 5;
    double y = (m / 12), x;
    if (m == 0)
    {
        x = (12 - h) * 5 * 6;
    }
    else if (h >= m)
    {
        x = ((h - m) + y) * 5 * 6;
    }
    else
    {
        x = ((m - h) - y) * 5 * 6;
    }
    cout.precision(22);
    x = cos(x * PI / 180);
    double t = sqrt(a * a + b * b - 2 * a * b * x);
    cout << t << lin;
}

int main()
{
    auto start = clock();
    fast_io;
    //freopen("test.txt", "r", stdin);
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    auto stop = clock();
    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 4308
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
using namespace std;

unsigned long long int res = 0;
string s;

void dfs(vector<bool> vf){
	
	if(s.size() == vf.size() + 1){
		vf.push_back(1);
		unsigned long long int tmp = 0;
		//cout << "---" <<endl;
		for(int i=0;i<s.size();++i){
			tmp *= 10;
			tmp +=  s[i]-'0';
			if(vf[i] == true){
				res += tmp;
				//cout << tmp << endl;
				tmp = 0;
			}
		}
		//cout << "---" <<endl;
		//cout << "---" <<endl;
		
		return;
	}
	
	
	vector<bool> a = vf;
	a.push_back(true);
	vf.push_back(false);
	
	dfs(vf);
	dfs(a);
	
	
	
}


int main() {
	
	cin >> s;
	
	
	dfs(vector<bool>());
	
	cout << res  <<endl;
	
    return 0;
}


Measured memory_bytes: 256
N, _ = list(map(int, input().split()))
d = set(list(input().replace(" ", "")))

for i in range(N,10*N+1):
  n = str(i)
  ns = set(list(n))
  flg = False
  for t in ns:
    if t in d:
      flg = True
      break
  if flg == False:
    print(n)
    exit()
print(0)

Measured memory_bytes: 41324
#include <iostream>

int main()
{
  int n, m;
  std::cin >> n;
  std::cin >> m;
  int conds[n+1];
  int si, ci;
  for (int i = 0; i < n+1; i++) {
    conds[i] = -1;
  }
  bool has_conflict = false;
  for (int i = 0; i < m; i++) {
    std::cin >> si;
    std::cin >> ci;
    if (conds[si] == -1) {
      conds[si] = ci;
    } else if (conds[si] != ci) {
      has_conflict = true;
    }
  }
  if (has_conflict) {
    std::cout << -1 << std::endl;
    return 0;
  }
  if (m == 0 && n == 1) {
    std::cout << 0 << std::endl;
    return 0;
  }
  for (int i = 1; i < n+1; i++) {
    if (n > 1 && i == 1 && conds[i] == 0) {
      std::cout << -1 << std::endl;
      return 0;
    }
    if (n > 1 && i > 1 && conds[i] == -1) {
      conds[i] = 0;
    }
  }
  if (conds[1] == -1) {
    conds[1] = 1;
  }
  for (int i = 1; i < n+1; i++) {
    std::cout << conds[i];
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n 
#define pl(n) cout<<n<<" "
const int Nx=1e6+2;
const int mod=1e9+7;
const int inf=(int)(1e19+10LL);
void solve(){
 int n,k;
 sl(n);sl(k);
 Vl arr(n);
 for(auto &it:arr)sl(it);
 int cntx=0,cnty=0;
 for(int i=0;i<n;i++){
 	for(int j=i+1;j<n;j++){
 		if(arr[i]>arr[j])cntx++;
 	}
 	
 	
 }
 int ans=(k*cntx)%mod;
 for(int i=0;i<n;i++){
 	int cnty=0;
 	for(int j=0;j<n;j++){
 		if(arr[i]>arr[j])cnty++;
 	}
 	int val=(k*(k-1))/2;
 	val=val%mod;
 	val=(cnty%mod*val)%mod;
 	ans+=val;
 	ans=ans%mod;
 }
 cout<<ans<<endl;
 
}

signed main(){
  int test=1;
  //sl(test);
 while(test--){
 	solve();
 }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> m;
    ll sum = 0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    int q;
    cin>>q;
    vector<int> b(q),c(q);
    for(int i=0; i<q; i++) cin>>b[i]>>c[i];
    for(int i=0; i<q; i++){
        ll minus = (ll)b[i] * m[b[i]];
        ll plus = (ll)c[i] * m[b[i]];
        m[c[i]] += m[b[i]];
        m[b[i]] = 0;
        sum -= minus;
        sum += plus;
        cout << sum << endl;
    }
}

Measured memory_bytes: 8772
z[2002],*a=z,*b=z+1001,m,i,j,t,u;main(n){for(;m=scanf("%d",&n)-++n;printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)t=b[j]=n+~i&&getchar()>45?1+fmin(u=a[j],t<u?t:u):0;}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
    int kyaru;
    int point = 0;
    scanf("%d", &kyaru);
    
    if(kyaru/500>0){
        point = kyaru / 500 * 1000;
        kyaru = kyaru % 500;
    }
    if(kyaru/5>0){
        point = point + kyaru / 5 * 5;
    }
    printf("%d", point);
}


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

int main()
{
    int n,k;cin>>n>>k;
    int arr[n];
    
    for(int i=0;i<n;i++)
    cin>>arr[i];
    
    long long int dp[n];
   for(int i=0;i<n-1;i++)
   dp[i]=100000000000;
    
    dp[n-1]=0;
    
    for(int i=n-2;i>=n-k;i--)
    {
       for(int j=i+1;j<n;j++)
       {
           dp[i]=min(dp[i], dp[j]+abs(arr[i]-arr[j]) );
       }
    }
    
     for(int i=n-k-1;i>=0;i--)
    {
       for(int j=i+1;j<=i+k;j++)
       {
           dp[i]=min(dp[i], dp[j]+abs(arr[i]-arr[j]) );
       }
    }
    
    
    
    
    
   
    
    cout<<dp[0]<<endl;
    
   // for(int i=0;i<n;i++)
    //cout<<dp[i]<<" ";

    return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
   int n,d,x;
   cin>>n>>d>>x;
   int a[110];
   for(int i=0;i<n;i++)cin>>a[i];
   int ans=x;
   for(int i=0;i<n;i++){
      if(d%a[i]==0)ans+=d/a[i];
      else ans+=d/a[i]+1;
   }
   cout<<ans<<endl;
}

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

using namespace std;

int main () {
    string s, t;
    cin >> s >> t;
    using pr = pair<int, pair<int, int>>;
    vector<vector<pr>>dp(s.size()+1, vector<pr>(t.size()+1, {0, {0, 0}}));

    for(int i = 1; i <= s.size(); ++i) {
        for(int j = 1; j <= t.size(); ++j) {
            if(s[i-1] == t[j-1]) {
                dp[i][j] = {dp[i-1][j-1].first + 1, {i-1, j-1}};
            } else {
                if(dp[i-1][j].first > dp[i][j-1].first) 
                    dp[i][j] = {dp[i-1][j].first, {i-1, j}};
                else
                    dp[i][j] = {dp[i][j-1].first, {i, j-1}};
            }
        }
    }

    pr ans = dp[s.size()][t.size()];

    int steps = ans.first, i = s.size(), j = t.size();

    string lcs = "";

    while(i > 0 or j > 0) {
        ans = dp[i][j];
        if(ans.second.first+1 == i and ans.second.second+1 == j) 
            lcs.push_back(s[i-1]);
        i = ans.second.first; j = ans.second.second;
        steps = ans.first;
    }

    reverse(begin(lcs), end(lcs));
    cout << lcs << endl;
    return 0;
}

Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,W;
	cin>>n>>W;
	vector<int> w(n),v(n);
	for(int i =0;i<n;i++)
		cin>>w[i]>>v[i];
	long long sum = 0;
	for(int x:v)
		sum+=x;
	const long long INF = 1e18 + 5;
	vector<long long> dp(sum+1,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j = sum-v[i];j>=0;j--)
		{
			dp[j +v[i]] = min(dp[j+v[i]],dp[j]+w[i]);
		}
	}
	long long ans = -1;
	for(int i =0;i<=sum;i++)
		if(dp[i]<=W)
			ans = i;
	cout<<ans<<'\n';
}


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

int main()
{
	int i, j;
	char c[3][3];
	for (i = 0;i < 3;i++) {
		for (j = 0;j < 3;j++) {
			cin >> c[i][j];
		}
	}
	cout << c[0][0] << c[1][1] << c[2][2] << endl;

}

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

int main()
{
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count = 0;

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

Measured memory_bytes: 256
import itertools
N, M, Q = map(int,input().split())
s = [tuple(map(int, input().split())) for i  in range(Q)]
l = list(range(1,M+1))
ans = [0]
for v in itertools.combinations_with_replacement(l, N):
    count = 0
    for i in range(Q):
        a, b, c, d = s[i]
        if v[b-1] - v[a-1] == c:
            count += d
    ans.append(count)
print(max(0, max(ans)))


Measured memory_bytes: 12692
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n" 
#define pb push_back
#define mp make_pair
typedef long long int ll;
 
int main()
{
    fast;
    ll k; 
    cin >> k;
    ll gcd = 0;
    for(ll i = 1; i <= k; i++){
        for(ll j = 1; j <= k; j++){
            for(ll x = 1; x <= k; x++){
                gcd += __gcd(i, __gcd(j, x));
            }
        }
    }
    cout << gcd << endl;


    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNextInt())
		{
			int n = sc.nextInt();
			int a = 1;
			for (int i = 0; i < n; i++)
			{
				a += 1 + i;
			}
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int A[1<<17],B[1<<17];
long ans[1<<17];
main()
{
	int N,M;
	cin>>N>>M;
	long now=(long)N*(N-1)/2;
	for(int i=0;i<M;i++)cin>>A[i]>>B[i];
	UF uf(N+1);
	for(int i=M;i--;)
	{
		ans[i]=now;
		if(!uf.same(A[i],B[i]))
		{
			now-=(long)uf.size(A[i])*uf.size(B[i]);
			uf.unite(A[i],B[i]);
		}
	}
	for(int i=0;i<M;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    repe(i,a,b+1){
        if (c%i == 0) ans++;
    }
    cout << ans << endl;
}


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

int     main() {
        int a, b, c, d;
        cin >>a >>b >>c >>d;
        if (d >= abs(c-a)) {
                cout <<"Yes" <<endl;
                return 0;
        } else if ((d >= abs(c-b))&&(d>=abs(b-a))) {
                cout <<"Yes" <<endl;
                return 0;
        }
        cout <<"No" <<endl;
        return 0;
};

Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N;
	cin >> N;
	ll A[N],B[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
	for (ll i = 0; i < N; ++i) cin >> B[i];
 
	// 解法
	ll diff[N];
	REP(i,N) diff[i] = A[i] - B[i];
	sort(diff, diff + N);
	ll n_minus = 0;
	ll total_minus = 0;
	REP(i,N){
		if (diff[i]<0){
			n_minus++;
			total_minus -= diff[i];
		} 
		else break;
	}
	ll acc[N-n_minus];
	REP(i,N-n_minus){
		if (i==0) acc[i] = diff[N-i-1];
		else acc[i] = acc[i-1] + diff[N-i-1];
	}
	// printf("n minus %lld\n", n_minus);
	// printf("total minus %lld\n", total_minus);
	// REP(i,N-n_minus){
	// 	printf("%lld ", acc[i]);
	// }
	printf("\n");
	ll ans = -1;
	REP(i,N-n_minus){
		if (total_minus <=acc[i]){
			ans = i+1 + n_minus;
			break;
		}
	}
	if (total_minus==0) ans = 0;
	
	//出力
	cout << ans << endl;
}

Measured memory_bytes: 3200
<?php
while($input = trim(fgets(STDIN))){
    $array =explode(" ", $input);
    
    $H = $array[0];
    $W = $array[1];

    if($H == 0 && $W == 0)
        break;
    
    for($i = 0; $i < $H; $i++){
        for($j = 0; $j < $W; $j++){
            echo "#";
        }
        echo "\n";
    }
    echo "\n";
        
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e3+5;
int a[maxn];
int main()
{
    int n,x;
    while(cin>>n>>x)
    {
        int ans = 1;
        a[0] = 0;
        for(int i = 1; i <= n; ++i)
        {
            cin>>a[i];
            a[i] += a[i-1];
            if(a[i] <= x)ans++;
        }
        cout<<ans<<endl;
    }
}




















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

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

    int ans = 0;
    for (int i = 0; i <= (S.length() - 1) / 2; i++)
    {
        if (S[i] != S[S.length() - 1 - i])
        {
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n; cin >> n;
    vector<ll> v;
    for(ll i=1; i*i<=n; ++i){
        if(n%i==0){
            v.push_back(i);
            if(n/i!=i){v.push_back(n/i);}
        }
    }
    sort(v.begin(), v.end());
  	//for(int i=0; i<v.size(); ++i){cout << v[i] << ",";} cout << endl;
    ll res; 
    if(v.size()%2==1){
        ll d = (v.size())/2; 
        res = 2*v[d] - 2;
      	if(v[d]==1){res += 1;}
    }
    else{ll d = (v.size())/2 - 1; //cout << d << endl;
        res = v[d] + v[d+1] -2; //cout << v[d] << "," << v[d+1] << endl;
        if(v[d]==1){res = v[d+1]-1;}
    }
  	
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
 
typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;
 
bool TEST=false;
ll MOD = 1000000007;
 
void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
 
ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll gcd(ll x,ll y){
    while (y>0){
        x=x%y;
        swap(x,y);
    }
    return x;
}

v_bool primes(ll n){
    v_bool x(n+1,true);
    x[0]=false;x[1]=false;
    for (ll i=2;i<=n;i++){
        if (x[i]){
            for(ll j=i*2;j<=n;j+=i){
                x[j]=false;
            }
        }
    }
    return x;
}

ll N,M;
vv_ll D; 
int main(){
    cin >> N >> M;
    ll inf=100000000000;
    D.assign(M+1,v_ll((ll)1<<N,inf));
    D[0][0]=0;
    for(ll i=1;i<=M;i++){
        ll a,b;
        cin >> a >> b;
        ll key=0;
        ll cost=a;
        for(ll j=0;j<b;j++){
            ll c;
            cin >>c;
            key+=(ll)1<<(c-1);
        }
        for(ll j=0;j<(ll)1<<N;j++){
            D[i][j]=D[i-1][j];
        }
        for(ll j=0;j<(ll)1<<N;j++){
            if (D[i-1][j&(~key)]+cost<D[i][j]) D[i][j]=D[i-1][j&(~key)]+cost;
        }
    }
    if (D[M][((ll)1<<N)-1]==inf){
        cout << "-1" << endl;
        return 0;
    }
    cout << D[M][((ll)1<<N)-1] <<endl;
}

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define endl                    "\n"
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pi      	            (2 * acos(0.0))
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    fastRead;
    double r;
    cin >> r;
    cout << fixed << setprecision(15) << 2 * pi * r << endl;
    return 0;
}




Measured memory_bytes: 3776
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
                int a;
		int b = 0;
		int c = 0;
		int s = 0;
		Scanner scan = new Scanner(System.in);
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		if(a>b){
			s = a;
			a = b;
			b = s;
		}
		if(b>c){
			s = b;
			b = c;
			c = s;
		}
		if(a>b){
			s = a;
			a = b;
			b = s;
		}
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 26124
#include <iostream>
#include <cmath>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll X;
  std::cin >> X;

  ll ans = 1;
  for (ll a = 1; a <= X; a++) {
    for (ll b = 2; b <= X; b++) {
      ll calc_val = (ll)std::pow(a, b);
      if (calc_val <= X) {
	ans = std::max(ans, calc_val);
      }
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long a,b;
int main()
{
	long long x,y,z;
	cin>>a>>b;
	x=a+b;
	y=a-b;
	z=a*b;
	cout<<max(max(x,y),z)<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void multiple(int p,int* a,int n){
	for(int i=2*p;i<=n;i+=p){
		a[i]=1;
	}
}
int main() {
	int n;
	while(cin>>n){
		int a[n+1]={0};
		int count=0;
		for(int i=2;i<=n;i++){
        	if(a[i]==0){
        		count++;
        		multiple(i,a,n);	
        	}  		
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 6988
package main

import (
	"fmt"
	"math"
)

func divmod(a, b int) (int, int) {
	q := math.Floor(float64(a / b))
	r := a % b
	return int(q), r
}

func main() {

	var n, a, b int
	fmt.Scan(&n, &a, &b)

	var res int = 0
	for i := 1; i <= n; i++ {
		var q int = i
		var r int = 0
		var tot int = 0
		for q != 0 {
			q, r = divmod(q, 10)
			tot += r

		}
		if a <= tot && tot <= b {
			res += i
		}
	}
	fmt.Println(res)

}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int n,m,x,y,a,b;
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a>x)x=a;
	}
	for(int i=0;i<m;i++){
		cin>>b;
		if(b<y)y=b;
	}
	cout<<(x<y?"No ":"")<<"War"<<endl;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,m;
    cin >> n >> m;
    int l = n-1,r = 0;
    vector<P> ans;
    vector<bool> a(n+1,false);
    for (int i = 0;i < n/2;++i) {
        ans.push_back(make_pair(l,r));
        a[l-r] = a[n-(l-r)] = true;
        l--;r++;
        if (a[l-r] || a[n-(l-r)] || l-r == n-l+r) {
            l--;
            while (l > r) {
                ans.push_back(make_pair(l,r));
                l--;r++;
            }
            break;
        }
    }
    for (int i = 0;i < m;++i) cout << ans[i].first+1 << " " << ans[i].second+1 << newl;
}

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

int main() {
    
    ll n,m,X;
    cin>>n>>m>>X;

    vector<vector<int>> arr(n, vector<int>(m+1,0));
    vector<ll> res(m);
    ll cost= 0;
    ll minCost = INT_MAX;
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m+1;j++)
            cin>>arr[i][j];
    }
    bool flag = true;
    bool found = false;
    for(int val = 0; val< (pow(2,n)); val++)
    {
        for(int i = 0; i<m ;i++)
            res[i] = 0;
        cost = 0;
        flag = true;
        for(int i = 0; i< n ;i++)
        {
            if((val >> i) &0x1)
            {
                cost += arr[i][0];
                for(int j=0;j<m;j++)
                {
                    res[j] += arr[i][j+1];
                }
            }
        }

        for(int i= 0;i<m;i++)
        {
            if(res[i] < X)
            {
                flag = false;
                break;
            }
        }

        if(flag)
        {
            found = true;
            minCost = min(minCost,cost);
        }
    }

    if(found)
        cout<< minCost<<endl;
    else
        cout<<"-1"<<endl;

    return 0;                          
}


Measured memory_bytes: 4116
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
res=0
for i in range(len(A)):
    res += B[A[i]-1]
    if i > 0 and (A[i] - A[i-1]) == 1:
        res += C[A[i-1]-1]
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a) for(ll i=a;i>=0;i--)
ll mod=1e9+7;
/*ll power(ll x,ll n)
{
    ll ans=1;
    while(n)
    {
       if(n&1)
       ans=(ans*x)%mod;
       n>>=1;
       x=(x*x)%mod;
    }
   // ans%=mod;
    return ans;
}
/*
struct comp {
    bool operator()(const pair& x, const pair& y) const {
        if (x.second != y.second)
            return x.second < y.second;

        return x.first < y.first;
    }
};
void dfs(int source,vector<int> graph[],vector<int> &path,bool status[])
{
 path.push_back(source);
 status[source]=0;
 //int j=graph[source].size();
 for(int i=0;i<graph[source].size();i++)
 {
     if(status[graph[source][i]]==1)
     dfs(graph[source][i],graph,path,status);
 }
 return;
}*
bool solve(int i,int j,string s)
{
    while(i<j)
    {
      if(s[i]<s[j])
      return 0;
      if(s[i]>s[j])
      return 1;
      i++;
      j--;
    }
    return 1;
}
bool isprime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
        return 0;
    }
    return 1;
    
}
ll lg(ll x,ll n)
{
    ll ans=0;
    while(x/n!=0)
    {
        ans++;
        x/=n;
    }
    return ans;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,q,t,y,x,k1,i1,j1,z,x1,y1,m,z1;
    cin>>n>>x>>t;
    j=n/x;
    if(n%x!=0)
    j++;
    cout<<j*t;
}



Measured memory_bytes: 3636
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
int a[101];
int tm[101];
int n;
int nkvd(int tmie);
int kgb(int tmie);
int mingap(int m,int tmie)
{
	int mn=BIG;
	for(int i=0;i<m;i++)
	{
		mn=min(mn,kgb(nkvd(tm[i]-tmie)));
	}
	return mn;
}
int nkvd(int tmie)
{
	return (tmie+24)%24;
}
int kgb(int tmie)
{
	return min(24-tmie,tmie);
}
bool cmp(const int &a,const int &b)
{
	return a>b;
}
int mx=BIG;
int ypa()
{
	for(int i=1;i<=n;i++)
	{
		if(mingap(i,nkvd(a[i]))>mingap(i,nkvd(-a[i])))
		{
			tm[i]=nkvd(a[i]);
			mx=min(mx,mingap(i,nkvd(a[i])));
		}
		else
		{
			tm[i]=nkvd(-a[i]);
			mx=min(mx,mingap(i,nkvd(-a[i])));
		}
	}
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	sort(a+1,a+1+n);
	int mn=BIG;
	ypa();
	//for(int i=0;i<=n;i++)cout<<tm[i]<<endl;
	cout<<mx;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int  r, c;
    scanf("%d %d", &r, &c);

    int  table[r + 1][c + 1];

    int i, j;

    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            scanf("%d", &table[i][j]);
        }
    }

    for (i = 0; i <= r ; i++)
        table[i][c] = 0;
    for (j = 0; j <= c ; j++)
        table[r][j] = 0;

    for (i = 0; i <= r; i++) {
        for (j = 0; j < c; j++) {
            table[i][c] = table[i][c] + table[i][j];
        }
    }
    for (j = 0; j <= c; j++) {
        for (i = 0; i < r; i++) {
            table[r][j] = table[r][j] + table[i][j];
        }
    }

    for (i = 0; i <= r; i++) {
        for (j = 0; j <= c; j++) {
            printf("%d", table[i][j]);
            if (j == c) {
                printf("\n");
            } else {
                printf(" ");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 2048
void main()
{
    long n, a, b;
    rdVals(n, a, b);

    long c = a + b;
    long d = n / c, r = n % c;

    writeln(a * d + min(a, r));
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const long long INF = 1LL << 60;

struct Edge {
    long long from;
    long long to;
    long long cost;
    Edge(int s, int d) : to(s),cost(d) {}
};

using Graph = vector<vector<Edge>>;
using Edges = vector<Edge>;
 
/* dijkstra(G,s,dis)
    入力：グラフ G, 開始点 s, 距離を格納する dis
    計算量：O(|E|log|V|)
    副作用：dis が書き換えられる
*/
void dijkstra(const Graph &G, int s, vector<long long> &dis) {
    int N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;  // 「仮の最短距離, 頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {  // 最短距離で無ければ無視
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {  // 最短距離候補なら priority_queue に追加
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}    
 
/* bellman_ford(Es,s,t,dis)
    入力: 全ての辺Es, 頂点数V, 開始点 s, 最短経路を記録するdis
    出力: 負の閉路が存在するなら ture
    計算量：O(|E||V|)
    副作用：dis が書き換えられる
*/
bool bellman_ford(const Edges &Es, int V, int s, vector<long long> &dis) {
    dis.resize(V, INF);
    dis[s] = 0;
    int cnt = 0;
    while (cnt < V) {
        bool end = true;
        for (auto e : Es) {
            if (dis[e.from] != INF && dis[e.from] + e.cost < dis[e.to]) {
                dis[e.to] = dis[e.from] + e.cost;
                end = false;
            }
        }
        if (end) break;
        cnt++;
    }
    return (cnt == V);
}

int main() {
    char s;
    cin >> s;
    if(isupper(s)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}

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

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

    vector<int> lower(N, INT32_MAX);
    vector<bool> confirm(N, false);

    for (int i = 0; i < N; i++) {
        if (i == 0 || A[i] > A[i-1]) {
            confirm[i] = true;
        }
        lower[i] = A[i];
    }

    for (int i = N-1; i >= 0; i--) {
        if (i == N-1 || B[i] > B[i+1]) {
            if (confirm[i]) {
                if (lower[i] != B[i]) {
                    cout << 0 << endl;
                    return 0;
                }
            } else {
                if (B[i] > lower[i]) {
                    cout << 0 << endl;
                    return 0;
                }
                confirm[i] = true;
                lower[i] = B[i];
            }
        } else {
            lower[i] = min(lower[i], B[i]);
        }
    }

    long long MOD = 1e9 + 7;
    long long ret= 1;
    for (int i= 0; i < N; i++) {
        if (confirm[i]) continue;
        (ret *= lower[i]) %= MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 4528
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

//A[i] := SとSのi文字目以降の最長共通接頭辞の長さ
//としたものを返す
//参考:http://snuke.hatenablog.com/entry/2014/12/03/214243
vector<ll> Z_algorithm(const string& S) {
    vector<ll> A(S.size());
    A[0] = S.size();
    ll i = 1, j = 0;
    while (i < S.size()) {
        while (i + j < S.size() && S[j] == S[i + j]) {
            j++;
        }
        A[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        ll k = 1;
        while (i + k < S.size() && k + A[k] < j) {
            A[i + k] = A[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return A;
}

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

    string concat = s;

    while (concat.size() < t.size()) {
        concat += s;
    }
    concat = t + "$" + concat + concat;

    vector<ll> Z = Z_algorithm(concat);

    vector<bool> match(s.size(), false);
    for (uint64_t i = 0; i < s.size(); i++) {
        match[i] = (Z[i + t.size() + 1] == t.size());
    }

    //i番目のノードから続くパス長
    vector<int64_t> num(s.size(), -1);

    for (uint64_t i = 0; i < s.size(); i++) {
        if (!match[i]) {
            num[i] = 0;
            continue;
        }

        if (num[i] != -1) {
            continue;
        }

        stack<int64_t> st;
        st.push(i);
        int64_t curr = (i + t.size()) % s.size();

        while (true) {
            if (curr == i) { //ループした
                cout << -1 << endl;
                return 0;
            }

            if (num[curr] != -1) { //すでに調べたノードに到達した
                break;
            }

            if (!match[curr]) { //次がない
                num[curr] = 0;
                break;
            }

            st.push(curr);
            curr = (curr + t.size()) % s.size();
        }

        while (!st.empty()) {
            int64_t top = st.top();
            st.pop();
            num[top] = num[(top + t.size()) % s.size()] + 1;
        }
    }

    cout << *max_element(num.begin(), num.end()) << endl;
}

Measured memory_bytes: 31244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	vvi dp(n+1,vi(3000));
	dp[0][0]=1;
	rep(k,n)for(int i=n-1;i>=0;i--)rep(j,3000)if(dp[i][j]){
		dp[i+1][j+in[k]]+=dp[i][j];
	}
	ll out=0;
	rep(i,n)out+=dp[i+1][m*(i+1)];
	cout<<out<<endl;
}
 
 







Measured memory_bytes: 1408
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  [ss, ps] <- transpose . map words <$> replicateM n getLine
  let rs = zip3 ss (map (negate . read :: String -> Int) ps) [1..]
  mapM_ (\(_, _, a) -> print a) $ sort rs



Measured memory_bytes: 1020