akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  if(a%2&&b%2) pr("Yes");
  else pr("No");
}

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


Measured memory_bytes: 256
def lcm(a, b)
  [a, b].inject(:lcm)
end

def gcd(a, b)
  [a, b].inject(:gcd)
end

N, M = gets.split.map(&:to_i)
S = gets.chomp
T = gets.chomp


lcm = lcm(N, M)
gcd = gcd(N, M)

n = N/gcd
m = M/gcd

for i in 0..(gcd-1) do
  unless S[n*i] == T[m*i]
    puts -1
    exit
  end
end

puts lcm

Measured memory_bytes: 2044
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<char> ans;
    while (n > 0) {
        char c = char('a' + ((n - 1) % 26));
        ans.push_back(c);
        n = (n - 1) / 26;
    }
    reverse(ans.begin(), ans.end());
    for (char c : ans) cout << c;
    cout << endl;

}


Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long long num[55],meat[55];
long long dfs(int,long long);
int main(void)
{
    int n,i;
    long long x,sum;
    scanf("%d%lld",&n,&x);
    num[0]=1;meat[0]=1;
    for(i=1;i<=n;i++)
    {
        num[i]=2*num[i-1]+3;
        meat[i]=2*meat[i-1]+1;
    }
    sum=dfs(n,x);
    printf("%lld\n",sum);
    return 0;
}
long long dfs(int n,long long x)
{
    long long sum=0;
    if(n==0)sum=1;
    if(x==0){sum=0;
    return 0;}
    if(num[n]<=x)sum=meat[n];
    else if(x<=num[n]/2)sum+=dfs(n-1,x-1);
    else if(x==num[n]/2+1)sum+=meat[n-1]+1;
    else if(x>num[n]/2+1)sum+=meat[n-1]+1+dfs(n-1,x-num[n]/2-1);
    return sum;
}


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

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

import math
from functools import lru_cache

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

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

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

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

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

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

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

N = int(input())

dic = [[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
  top = int(str(i)[0])
  bottom = int(str(i)[-1])
  dic[top][bottom] += 1

ans = 0
for i in range(10):
  for j in range(10):
    ans += dic[i][j]*dic[j][i]

print(ans)


Measured memory_bytes: 40428
#include <stdio.h>
#include <stdlib.h>

int main(){
  int N;
  int A[100];
  int B[100];
  int i,j,k,l,s,min;
  int count = 0;
  int temp;
  
  scanf("%d",&N);
  
  for(i = 0 ;i < N;i++){
    scanf("%d",&A[i]);
  }

  for(i = 0; i < N-1; i++){
    
    for(k = 0; k < N-1; k++){
      if(A[k] < A[k+1]){
	l = 1;
      }
      else{
	l = 0;
	break;
      }
    }
    
    if(l == 1){
      break;
    }
    
    min = i;
    
    for(j = i; j < N; j++){
      if(A[j] < A[min]){//A[j]がA[min]を下回ればminをjにかえて新たな最小値とする
	min = j;
      }
    }
    for(j = 0; j < N; j++){
      B[j] = A[j];
    }
    
    temp = A[i];
    A[i] = A[min];
    A[min] = temp;
    
    for(j = 0; j < N; j++){
      if(B[j] == A[j]);
      else{
	count++;
	break;
      }
    }
  }
  
  for(i = 0; i < N; i++){
    printf("%d",A[i]);
    if(i == N-1){
      printf("\n");
      break;
    }
    else printf(" ");
  }
  
  printf("%d\n",count);
  
  return 0;
}



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

int main()
{
	set<long long> s;	
	long q;

	cin >> q;

	for (long i = 0; i < q; i++) {
		int t;
		long long x;
		cin >> t >> x;

		if (t == 0) {
			s.insert(x);
			cout << s.size() << endl;
		}
		else if (t == 1) {
			int f = 1;
			if (s.find(x) == s.end())
				f = 0;
			cout << f << endl;
		}
		else if (t == 2)
			s.erase(x);
	}

	return 0;
}


Measured memory_bytes: 12388
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  int a[SIZE];
  int c[] = {0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, INF};
  int count[20] = {};
  
  scanf("%d",&n);

  int spe = 0;
  
  for(int i=0;i<n;i++){
    scanf("%d",a+i);

    if(a[i] >= 3200){
      spe++;
      continue;
    }
    
    for(int j=0;;j++){
      if(c[j] <= a[i] && a[i] < c[j+1]){
        count[j]++;
        break;
      }
    }
  }

  int ans = 0;

  for(int i=0;i<10;i++){
    ans += count[i] > 0;
  }

  cout << max(1,ans) << " " << ans + spe << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(max(a,b)<=min(c,d)||min(a,b)>=max(c,d))
	cout<<"0";
	else if(max(a,b)>=max(c,d))
	{
		if(min(a,b)<=min(c,d))
		cout<<abs(c-d);
		else
		cout<<max(c,d)-min(a,b);
	}
	else if(max(a,b)<=max(c,d))
	{
		if(min(a,b)>=min(c,d))
		cout<<abs(a-b);
		else
		cout<<max(a,b)-min(c,d);
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
ans = -1

for i in range(50000+10):
 x1 = int(i*1.08)
 x2 = i*1.08
 #print(i,x1,x2)
 if(x1 == N): ans = i
 elif(x2 == N): ans = i
  
  
if(ans == -1):
 print(':(')
else:
 print(ans)

Measured memory_bytes: 3060
import std.stdio : write, writeln, writefln, stdin;
import std.array;
import std.range;
import std.algorithm : max;

void main(){
	int[] d = [readln.chomp.to!int];
	while(true){
		auto str = readln.chomp.split(",");
		if(stdin.eof()) break;
		
		int[] r;
		foreach(i; str){
			r ~= i.to!int;
		}
		int[] d_ = repeat(0).take(r.length).array;
		
		if(r.length > d.length){
			for(int i=0; i<d.length; ++i){
				d_[i] = max(d_[i], r[i]+d[i]);
				d_[i+1] = max(d_[i+1], r[i+1]+d[i]);
			}
		}else{
			d_[0] = max(d_[0], r[0]+d[0]);
			for(int i=1; i<d.length-1; ++i){
				d_[i] = max(d_[i], r[i]+d[i]);
				d_[i-1] = max(d_[i-1], r[i-1]+d[i]);
			}
			d_[$-1] = max(d_[$-1], r[$-1]+d[$-1]);
		}
		
		d = d_.clone;
	}
	
	d.front.writeln;
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e7+3e6+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
int s;
void input()
{
	s=read<int>();
}
int dig[N];
const int mo=1e9+7;
int ans;
void add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
int Mod(int x){return x>=mo?x-mo:x;}
int power(int x,int y)
{
	int res=1;
	for(;y;x=1ll*x*x%mo,y>>=1)if(y&1)res=1ll*res*x%mo;
	return res;
}
void work()
{
	int now=0;
	For(i,1,N-5)dig[i]=dig[i/10]+1;
	for(int i=1,j=1;i<1e7;i++)
	{
		while(now<s)now+=dig[j],j++;
		if(now==s)ans++;
		now-=dig[i];
	}
	int num;
	For(i,1,s/8)
	{
		if(s%i==0)
		{
			num=Mod(power(10,s/i)-power(10,s/i-1)+mo);
			add(ans,Mod(num-i+1+mo));	
		}
		else add(ans,1);
	}
	write(ans,'\n');
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 90112
#include <iostream>
#include <algorithm>

using namespace std;
struct UnionFind {
    int* parent;
    int N;
    UnionFind(int N) : N(N) {
        parent = new int[N];
        fill(parent, parent + N, -1);
    }
    ~UnionFind() {
        delete[] parent;
    }
    int root(int x) {
        if (parent[x] == -1) return x;
        return parent[x] = root(parent[x]);
    }
    bool query(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); 
        y = root(y);
        if (x != y) {
            parent[x] = y;
        }
    }
};


int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n + 1);
    for (int i = 0; i < q; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 0) {
            uf.merge(x, y);
        } else {
            cout << uf.query(x, y) << endl;
        }
    }
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    pair<int,pair<int,int>> p[h*w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i%2==0){
                p[w*i+j]={a[i][j],{i+1,j+1}};
            }
            else{
                p[w*i+j]={a[i][w-j-1],{i+1,w-j}};
            }
        }
    }
    vector<pair<pair<int,int>,pair<int,int>>> ans;
    for(int i=0;i<h*w-1;i++){
        if((p[i].first)%2==1){
            ans.push_back({p[i].second,p[i+1].second});
            p[i+1].first++;
        }
    }
    cout<<ans.size()<<endl;
    for(auto g:ans){
        cout<<g.first.first<<" "<<g.first.second<<" ";
        cout<<g.second.first<<" "<<g.second.second<<endl;
    }
}


Measured memory_bytes: 8176
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

bool dfs(int N, int M, vector< vector<bool> >& adj, vector<int>& a, vector<int>& b, int i, vector<bool>& vis) {
	vis[i] = true;
	for (int j = 0; j < M; j++) {
		if (!adj[i][j] || a[i] == j) continue;
		if (b[j] == -1) {
			b[j] = i;
			a[i] = j;
			return true;
		}
		int _i = b[j];
		if (!vis[_i] && dfs(N, M, adj, a, b, _i, vis)) {
			b[j] = i;
			a[i] = j;
			return true;
		}
	}
	return false;
}

int match(int N, int M, vector< vector<bool> >& adj) {
	vector<int> a(N, -1), b(M, -1);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != -1) continue;
		vector<bool> vis(N);
		if (dfs(N, M, adj, a, b, i, vis))
			cnt++;
	}
	return cnt;
}

int main() {
	for (;;) {
		int N, M; cin >> N >> M;
		if (N == 0) break;
		vector<int> x(N), y(N), v(N);
		for (int i = 0; i < N; i++)
			cin >> x[i] >> y[i] >> v[i];
		vector<int> X(M), Y(M);
		for (int j = 0; j < M; j++)
			cin >> X[j] >> Y[j];
		double lb = 0, ub = 20000;
		for (int t = 0; t < 100; t++) {
			double mid = (lb + ub) / 2;
			vector< vector<bool> > adj(N, vector<bool>(M));
			for (int i = 0; i < N; i++)
				for (int j = 0; j < M; j++) {
					double dx = X[j] - x[i], dy = Y[j] - y[i];
					adj[i][j] = (sqrt(dx * dx + dy * dy) <= mid * v[i]);
				}
			if (match(N, M, adj) == M) ub = mid;
			else lb = mid;
		}
		printf("%.10f\n", lb);
	}
}

Measured memory_bytes: 1260
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
using namespace std;
using P = pair<int, int>;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

set<int> segmerge(const set<int> a, const set<int> b){
    set<int> c = a;
    for(auto it = b.begin(); it != b.end(); ++it){
        c.insert(*it);
    }
    return c;
}

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> c(n+1);
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    vector<pair<P, int>> query(q);
    for(int i = 0; i < q; i++){
        cin >> query[i].first.second >> query[i].first.first;
        query[i].second = i;
    }
    sort(query.begin(), query.end());
    BinaryIndexedTree<int> BIT(n+1);
    vector<int> col(n+1, -1);
    vector<int> ans(q);
    int nowq = 0;
    for(int i = 1; i <= n; i++){
        if (col[c[i]] == -1){
            col[c[i]] = i;
            BIT.add(i, 1);
        }
        else{
            BIT.add(col[c[i]], -1);
            col[c[i]] = i;
            BIT.add(i, 1);
        }
        while(nowq < q && i == query[nowq].first.first){
            int l = query[nowq].first.second;
            int r = query[nowq].first.first;
            int num = query[nowq].second;
            ans[num] = BIT.sum(r) - BIT.sum(l-1);
            nowq++;
        }
    }
    for(auto a: ans)cout << a << endl;
    return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
using ll = long;
main(){
  int n;cin>>n;
  vector<ll> a(n);
  for(auto&q:a)cin>>q;
  auto b=a;
  sort(b.begin(),b.end());
  for(int i=0;i<n;++i){
    ll key=a[i],mid=(n-2)/2;
    ll idx=lower_bound(b.begin(),b.end(),key)-b.begin();
    if(idx<=mid) mid++;
    cout<<b[mid]<<endl;
  }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,k; cin >> n >> k;
    vec<int> x(n); rep(i,n) cin >> x[i];

    int ans = inf;
    for(int i = 0; i+k-1 < n; ++i) {
        if((x[i]<0 && x[i+k-1]>=0) || (x[i]<=0 && x[i+k-1]>0)) {
            int p = abs(x[i]) + abs(x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1]));
            // debug(p);
            chmin(ans, p);
        }
        else {
            int p = max(abs(x[i]), abs(x[i+k-1]));
            chmin(ans, p);
            // debug(p);
        }
        // debug(ans);
    }
    cout << ans << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

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

int main(){
	long long int N, Num;
	cin >> N;
	Num = 1000000007;
	
	long long int i, pow=1;
	for(i=1; i<=N; i++){
		pow *= i;
		if(pow>=Num){
			do{
				pow -= Num;
			}while(pow>Num);
		}
	}
	
	cout << pow << endl;
	
	return 0;
}


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

using namespace std;
const int maxn = 110;
const int maxv = 100000;

int n, k;
int w[maxn], v[maxn];
long long dp[maxv + 10];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) 
		scanf("%d%d", w+i, v+i);
		
	for (int i = 1; i <= maxv; i++)
		dp[i] = (1LL << 50);
	
	for (int i = 0; i < n; i++) 
		for (int j = maxv; j >= v[i]; j--) 
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			
	int maxi = 0;
	for (int i = 0; i <= maxv; i++)
		if (dp[i] <= (long long)k) maxi = i;
	printf("%d", maxi);
	return 0;
}


Measured memory_bytes: 1024
def main():
    n,l = [int(x) for x in input().split()]
    array = [int(x) for x in range(l,l+n)]

    array_abs = [abs(x) for x in array]
    minimum_val = min(array_abs)
    min_index = array_abs.index(minimum_val)

    array[min_index] = 0
    ans = sum(array)
    print(ans)

if __name__ == '__main__':
    main()


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

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

  if ( a+b == c+d ) cout << "Balanced" << endl;
  else if( a+b > c+d ) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int num = n*(n-1)/2;
        int[] x = new int[n];
		int[] y = new int[n]; 
		double[] sa = new double[num];
		int count = 0;        
        for(int i = 1;i <= n;i++){
            x[i-1] = sc.nextInt();
            y[i-1] = sc.nextInt();
		}
		for(int i = 0;i < n -1;i++){
			for(int j = i+1;j < n;j++){				
				sa[count] = Math.sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
				count++;			
			}
		}
		int hayami = 1;
		for(int i = 1;i <= n;i++){
            hayami *= i;
		}
		int b = (hayami * (n-1))/num;
		double[] ans = new double[num];
		for(int i = 0;i < sa.length;i++){
			ans[i] = sa[i] * b;
		}
		double sum = 0;
		for( int i=0; i < ans.length; i++ ) {
				sum += ans[i];
		}
		double ave = sum / hayami;
		System.out.println(ave);		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
 
ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3604
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  import std.typecons;
  alias Point=Tuple!(int, "x", int, "y");
  auto u=new Point[](n), v=new Point[](n);
  foreach(i; 0..n) rd(u[i].x, u[i].y);
  foreach(i; 0..n) rd(v[i].x, v[i].y);

  auto mf=new maxFlow(n*n+2), s=n*n, t=s+1;
  foreach(i; 0..n) mf.addEdge(s, i, 1), mf.addEdge(n+i, t, 1);
  foreach(i; 0..n)foreach(j; 0..n){
    if(u[i].x<v[j].x && u[i].y<v[j].y){
      // writeln(i, " ", j);
      mf.addEdge(i, n+j, 1);
    }
  }

  writeln(mf.ford(s, t));
}

class maxFlow{
  import std.typecons, std.conv, std.algorithm; // , std.stdio;
  alias T=int;
  alias Edge=Tuple!(int, "to", int, "rev", T, "cap");
  Edge[][] g;
  bool[] vis;
  auto inf=(1_000_000_000).to!(T);
 
  this(int sz){
    g.length=sz;
    vis.length=sz;
  }
 
  void addEdge(int from, int to, T cap){
    g[from]~=Edge(to, (g[to].length).to!(int), cap);
    g[to]~=Edge(from, (g[from].length-1).to!(int), (0).to!(T));
  }
 
  T flow(int i, T curf, int sink){
    if(i==sink) return curf;
    vis[i]=true;
    foreach(ref e; g[i]){
      if(vis[e.to] || e.cap==0) continue;
      auto tmpf=flow(e.to, min(curf, e.cap), sink);
      if(tmpf>0){
        e.cap-=tmpf;
        g[e.to][e.rev].cap+=tmpf;
        return tmpf;
      }
    }
    return 0;
  }
 
  T ford(int source, int sink){
    auto maxf=(0).to!(T);
    while(true){
      fill(vis, false);
      auto f=flow(source, inf, sink);
      if(f>0) maxf+=f;
      else return maxf;
    }
  }
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 2556
from sys import stdin
import bisect

N = int(input())
L = list(map(int,stdin.readline().strip().split()))

L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        idx = bisect.bisect_left(L,L[i]+L[j],j)
        ans += (idx-j-1)

print(ans)    


Measured memory_bytes: 43356
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        string s, t;
        cin >> s >> t;
        if (s.size() > t.size())
            cout << "GREATER" << endl;
        else if (s.size() < t.size())
            cout << "LESS"<<endl;
        else {
            if (s>t)
                        cout << "GREATER" << endl;
            else if (s<t)
                        cout << "LESS" << endl;
            else
                cout << "EQUAL" << endl;
            }
            
            


return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100500][2], dp[100500][2];
void solve() {
	int n;
	cin >> n;
	vector<pair<int, int>> tmp(n);
	for (int i = 1; i <= n; i++) {
		cin >> tmp[i - 1].first >> tmp[i - 1].second;
	}
	sort(begin(tmp), end(tmp));
	for (int i = 1; i <= n; i++) {
		a[i][0] = tmp[i - 1].first;
		a[i][1] = tmp[i - 1].second;
	}
	dp[0][1] = INT_MIN;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0];
		if (a[i][0] - a[i][1] >= dp[i - 1][1]) {
			dp[i][1] = a[i][0] + a[i][1];
			dp[i][0] += 1;
		}
		else {
			if (dp[i - 1][1] > a[i][0] + a[i][1]) {
				dp[i][1] = a[i][0] + a[i][1];
			}
			else {
				dp[i][1] = dp[i - 1][1];
			}
		}
	}
	cout << dp[n][0];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 5560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
const int N=505;
long long n;
struct qwe
{
	long long c,s,f;
}a[N];
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<n;i++)
		scanf("%lld%lld%lld",&a[i].c,&a[i].s,&a[i].f);
	for(long long i=1;i<n;i++)
	{
		long long t=0;
		for(long long j=i;j<n;j++)
		{
			if(t<=a[j].s)
				t=a[j].s;
			else if(t%a[j].f!=0)
				t=t+a[j].f-t%a[j].f;
			t+=a[j].c;
		}
		printf("%lld\n",t);
	}
	puts("0");
	return 0;
}

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

int main() {
	long long N, ANS = 0;
	vector<vector<pair<long long, long long> > > V;
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) {
		long long A;
		cin >> A;
		for (int j = 0; j < A; j++) {
			long long X, Y;
			cin >> X >> Y;
			X--;
			V[i].push_back({ X, Y });
		}
	}
	for (int i = 0; i < (1 << N); i++) {
		long long X[15] = {}, I = i, COUNT = 0;
		bool check = true;
		for (int j = 0; j < N; j++) X[j] = I % 2, I /= 2;
		for (int j = 0; j < N; j++) {
			if (X[j] == 1) {
				COUNT++;
				for (int k = 0; k < V[j].size(); k++) {
					if (V[j][k].second != X[V[j][k].first]) check = false;
				}
			}
		}
		if (check) ANS = max(ANS, COUNT);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
N=int(input())
ans=[]

def calc(N):
    if N==0: return
    elif N>0:
        n=N
        power=-2
        while n>0:
            power+=2
            n-=2**power
    else:
        n=-N
        power=-1
        while n>0:
            power+=2
            n-=2**power
            
    ans.append(power)
   # print(power)
    calc(N-(-2)**power)

if N==0:print('0')
else:
    calc(N)
    answer=''
    for a in range(ans[0],-1,-1):
        if a in ans: answer=answer+'1'
        else: answer=answer+'0'
    print(answer)

Measured memory_bytes: 3064
/**
 *    author:  FromDihPout
 *    created: 2020-09-13
**/

#include <bits/stdc++.h>
using namespace std;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define REP(i,m,n) for(int i = (int) (m); i < (int) (n); i++)
#define rep(i,n) REP(i,0,n)
#define f first
#define s second
#define all(x) (x).begin(), (x).end()


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	bool ans = n == 0;
	cout << ans << endl;
	return 0;	
}


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

using namespace std;

int main(void)
{
  int n, m;
  int a[1010];

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

  for (int i = 1; i <= m; i++){
    for (int j = 0; j < n - 1; j++){
      if (a[j] % i > a[j + 1] % i){
        swap(a[j], a[j + 1]);
      }
    }
  }

  for (int i = 0; i < n; i++) cout << a[i] << endl;

  return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll ar[n];
    set<ll> s;
    ll ans=0;
    for(ll i=0;i<n;++i)
    {
        cin>>ar[i];
        s.insert(ar[i]);
        ll x=*s.begin();
        if(ar[i]<=x){++ans;}
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 11264
H, N = map(int, input().split())

inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = map(int, input().split())
    for j in range(H):
        t1 = j + A
        if t1 > H:
            t1 = H
        t2 = dp[j] + B
        if t2 < dp[t1]:
            dp[t1] = t2
print(dp[H])


Measured memory_bytes: 46940
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");

const inputs = input.split(" ");
const A = Number(inputs[0]);
const B = Number(inputs[1]);
const C = Number(inputs[2]);

const main = (A, B, C) => {
  let space = A - B;
  if (space >= C) {
    return 0;
  } else {
    return C - space;
  }
};

console.log(main(A, B, C));

Measured memory_bytes: 7372
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#define LL long long


using namespace std;

int main() {
    int w, a, b;
    cin >> w >> a >> b;
    if (a + w < b)
    {
        cout << b - (a + w) << endl;
    }
    else if (b <= a + w && a + w <= b + w || b <= a && a <= b + w)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << a - (b + w) << endl;
    }
    return 0;
}   


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A = new int[10];
		for(int i = 0; i < 10; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();

		Arrays.sort(A);
		for(int i = 9; i >= 7; i--) {
			System.out.println(A[i]);
		}

	}

}



Measured memory_bytes: 26312
from sys import *
from bisect import *

n = int(input())
a = list(map(int, stdin.readlines()))

dp = [1]
for j in a:
    j *= -1
    i = bisect(dp, j)
    if i < len(dp):
        dp[i] = j
    else:
        dp.append(j)
print(len(dp))

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        System.out.println( solve(sx, sy, tx, ty) );
    }

    private static String solve(int sx, int sy, int tx, int ty) {
        int dx = tx - sx;
        int dy = ty - sy;

        StringBuilder b = new StringBuilder();
        // sx < tx, sy < ty なので 特定の形式で行ける
        // first
        b.append( renzoku('R', dx) );
        b.append( renzoku('U', dy) );

        // second
        b.append( renzoku('L', dx) );
        b.append( renzoku('D', dy) );

        // third
        b.append( renzoku('D', 1) );
        b.append( renzoku('R', dx + 1) );
        b.append( renzoku('U', dy + 1) );
        b.append( renzoku('L', 1) );

        // forth
        b.append( renzoku('U', 1) );
        b.append( renzoku('L', dx + 1) );
        b.append( renzoku('D', dy + 1) );
        b.append( renzoku('R', 1) );

        return b.toString();
    }

    private static String renzoku(char c, int n) {
        char[] chars = new char[n];
        Arrays.fill(chars, c);
        return new String(chars);
    }
}


Measured memory_bytes: 21844
// CGL_2_A
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;

struct vec{
	int x;
	int y;
};

struct point{
	int x;
	int y;
};

double inner_p(struct vec a, struct vec b){
	return (a.x*b.x + a.y*b.y);
}

double cross_p(struct vec a, struct vec b){
	return (a.x*b.y - a.y*b.x);
}

int main(){
	point p[4];
	vec v[2];
	int q;

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>p[0].x>>p[0].y>>p[1].x>>p[1].y>>p[2].x>>p[2].y>>p[3].x>>p[3].y;

		for(int j=0;j<2;j++){
			v[j].x = p[2*j+1].x - p[2*j].x;
			v[j].y = p[2*j+1].y - p[2*j].y;
		}

		if(cross_p(v[0], v[1]) == 0)
			cout<<"2"<<endl;
		else if(inner_p(v[0], v[1]) == 0)
			cout<<"1"<<endl;
		else
			cout<<"0"<<endl;
	}

	return 0;
}

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

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

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll m = n / i;
        ans += i * m * (m + 1) / 2;
    }
    cout << ans << endl;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,T;
	cin>>N>>T;
    typedef pair<ll,ll> P;
    vector<P> AB(N);
    ll max_b = 0;
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        AB[i] = P(a,b);
    }
    sort(AB.begin(),AB.end(),[](P p1,P p2){return p1.first < p2.first;});

    vector<vector<ll>> dp(N,vector<ll>(T));
    ll ans = AB[0].second;
    rep(i,N){
        ll a = AB[i].first;
        ll b = AB[i].second;
        if(i!=0) ans = max(ans,dp[i-1][T-1]+b);
        rep(j,T){
            if(j-a<0){
                if(i==0) continue;
                dp[i][j] = dp[i-1][j];
            }else{
                if(i==0){
                    dp[i][j]= b;
                    continue;
                }
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-a]+b);
            }

        }
    }
    cout<<ans<<"\n";


	return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
    stack<int> S;
    int a, b, x;
    string s;

    while(cin >> s){
        if( s[0] == '+' ){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }else if( s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        }else if( s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3212
l=readlines
r=Array.new(l.shift.split(' ').last.to_i, 0)
l.map{|a|a.split(' ').map(&:to_i)}.each do |a|
  puts (a+[a.inject(&:+)])*' '
  a.each_with_index{|v,i| r[i]+=v}
end
puts (r+[r.inject(&:+)])*' '

Measured memory_bytes: 9020
#include<stdio.h>
#include<stdlib.h>
 
int insertionSort(int*, int, int);
void shellSort(int*, int);
 
int insertionSort(int *A, int n, int g){
  int i, j, v;
  int cnt = 0;
 
  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
 
  return cnt;
}
 
void shellSort(int *A, int n){
  int i, j;
  int cnt = 0;
  int m = 0;
  int *G;
 
  i = n;
  if(n == 1)  m = 1;
  while(i > 1){
    m++;
    i /= 2;
  }
 
  G = (int *)malloc(sizeof(int) * m);
 
  G[0] = n/2;
  for(i=1;i<m;i++){
    G[i] = G[i-1]/2;
  }
 
  for(i=0;i<m;i++){
    cnt += insertionSort(A, n, G[i]);
  }
 
  // print
  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",G[i]);
    if(i != m-1) printf(" ");
    else printf("\n");
  }
  printf("%d\n",cnt);
  for(i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
}
 
int main(){
  int i,n;
  int *A;
 
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  shellSort(A, n);
 
  return 0;
}



Measured memory_bytes: 5600
#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n,a,b=map(int,input().split())
def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10

sum=0

for i in range(n+1):
        if a<=int(s(i))<=b:
                sum+=i

print(sum)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

double dp[301][301][301];
int c1,c2,c3,n;
double fill(int n3,int n2,int n1){
    if(n3==0&&n2==0&&n1==0) return dp[0][0][0]=0;
    if(!(dp[n3][n2][n1]<0)) return dp[n3][n2][n1];
    double r3=(n3?fill(n3-1,n2+1,n1):0),
           r2=(n2?fill(n3,n2-1,n1+1):0),
           r1=(n1?fill(n3,n2,n1-1):0);
    double ret=(r3*(n3+0.0)+r2*(n2+0.0)+r1*(n1+0.0)+n)/(0.0+n3+n2+n1);
    return dp[n3][n2][n1]=ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    rep(i,301)rep(j,301)rep(k,301) dp[i][j][k]=-10;


    cout<<setprecision(12);
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==1) c1++;
        if(a[i]==2) c2++;
        if(a[i]==3) c3++;
    }
    cout<<(fill(c3,c2,c1))<<endl;
    return 0;
}


Measured memory_bytes: 213504
#include <iostream>

bool isBad[100001];
long long res;

int main()
{
    long long n, m;
    std::cin >> n >> m;
    long long h[n + 1], a, b;
    for (long long i = 1; i <= n; i++)
    {
        std::cin >> h[i];
    }
    for (long long i = 0; i < m; i++)
    {
        std::cin >> a >> b;
        if (h[a] > h[b])
        {
            isBad[b] = true;
        }
        else if (h[b] > h[a])
        {
            isBad[a] = true;
        }
        else
        {
            isBad[a] = true;
            isBad[b] = true;
        }
    }
    for (long long i = 1; i <= n; i++)
    {
        if (!isBad[i])
        {
            res++;
        }
    }
    std::cout << res;
}

Measured memory_bytes: 4504
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {

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

    int n,m;
    cin>>n>>m;
    int a,b;
    p p[m];
    rep(i,m){
        cin>>a>>b;
        a--;
        b--;
        p[i]=make_pair(b,a);
    }
    sort(p,p+m);
    int ans=1;
    int small=p[0].first;
    rep(i,m){
        if(small<=p[i].second){
            ans++;
            small=p[i].first;
        }
    }
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        String numsArray[] = br.readLine().split(" ");
        long sum = 0;
        int max=-1000000;
        int min=1000000;
        int tmp=0;
        for(int i=0; i<num; i++){
            tmp = Integer.parseInt(numsArray[i]);
            if(tmp>max){
                max = tmp;
            }
            if(tmp<min){
                min = tmp;
            }
            sum = sum+tmp;
        }
        System.out.println(min+" "+max+" "+sum);
    }
}
 

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

using namespace std;

int N, M;
vector<int> TargetInfo;
int TotalScore[101];

int main() {
	int num, target, cnt;

	memset(TotalScore, 0, sizeof(TotalScore));
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> num;
		TargetInfo.push_back(num);
	}
	for (int i = 0; i < M; ++i) {
		target = TargetInfo[i];
		cnt = 0;
		for (int j = 1; j <= N; ++j) {
			cin >> num;
			if (num == target) {
				++TotalScore[j];
				continue;
			}
			++cnt;
		}
		TotalScore[target] += cnt;
	}
	for (int i = 1; i <= N; ++i) {
		cout << TotalScore[i] << endl;
	}

	return 0;
}


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

int main()
{
    int N, x;
    cin >> N;
    int A[N + 1];

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

    for (int i = 1; i < N + 1; i++)
    {
        cout << A[i] + 1 << " ";
    }

    return 0;
}

Measured memory_bytes: 1152
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 1e5 + 10;
int n , c , k , t[MAXN] , cap , mn , ans;
int32_t main()
{
        cin >> n >> c >> k;
        for(int i = 0 ; i < n ; i ++)
                cin >> t[i];
        sort(t , t + n) , ans = 1 , cap = 0 , mn = t[0];
        for(int i = 0 ; i < n ; i ++)
        {
                if(t[i] < mn || cap == c || t[i] > mn + k)
                        mn = t[i] , ans ++ , cap = 0;
                cap ++;
        }
        return cout << ans << endl , 0;
}
                                                                                                                                                                                                      


Measured memory_bytes: 1024