akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=3e3+10, maxm=5e3+10, lg=18, mod=1e9+7, inf=1e18;

ll pwm(ll a,ll b){ll ret=1;for(;b;b/=2,a=a*a%mod)if(b%2)ret=ret*a%mod;return ret;}
ll n,q,a[maxn],dp[maxn][maxn],mos[maxn][maxn],i2=pwm(2,mod-2);

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		for(int j=1;j<i;j++) dp[j][i]=(a[j]>a[i]), mos[i][j]=mos[j][i]=(a[i]==a[j]);
	}
	for(int i=0;i<q;i++){
		ll x,y; cin>>x>>y;
		if(x>y) swap(x,y);
		dp[x][y]=(1-mos[x][y]+mod)*i2%mod;
		for(int j=x+1;j<y;j++){
			ll A=dp[x][j],B=dp[j][y];
			dp[x][j]=(1-(1-A+mod)*i2%mod-(B+mos[j][y])*i2%mod+2*mod)%mod;
			dp[j][y]=(1-(1-B+mod)*i2%mod-(A+mos[x][j])*i2%mod+2*mod)%mod;
		}
		for(int j=1;j<x;j++) dp[j][x]=dp[j][y]=(dp[j][x]+dp[j][y])*i2%mod;
		for(int j=y+1;j<=n;j++) dp[x][j]=dp[y][j]=(dp[x][j]+dp[y][j])*i2%mod;
		for(int j=1;j<=n;j++)if(j!=x&&j!=y) mos[x][j]=mos[j][x]=mos[j][y]=mos[y][j]=(mos[x][j]+mos[j][y])*i2%mod;
	}
	ll sum=0; for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++) sum+=dp[i][j], sum%=mod;
	cout<<sum*pwm(2,q)%mod;
	
	return 0;
}






Measured memory_bytes: 120244
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;

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

  int max = 0;
  int ct = 0;
  for (int i = 0; i < n; i++){
    if (h[i] >= max){
      ct++;
    }

    if (h[i] > max){
      max = h[i];
    }
  }

  cout << ct << endl;
}


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

int main()
{
    ll a, b, v, w, t;
    cin >> a >>v >> b >> w >> t;
    if(a > b) 
    {
        a = -a;
        b = -b;
    } 
    while (t > 0)
    {
        a += v;
        b += w;
        if(a >= b)
        {
            cout << "YES" << endl;
            return 0;
        }
        --t;
    }

    cout << "NO" << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(1) == s.at(2) ){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}




Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int need,value;
};

struct Data{
	int happiness,cost;
};

struct LOC{
	LOC(int arg_num,int arg_HP){
		num = arg_num;
		HP = arg_HP;
	}
	int num,HP;
};

int dp[101][10001],next_dp[101][10001];
int max_hp[101],next_max_hp[101];
int dp_2[10001];
int dp_3[10001];
int dp_4[101][101];

int main(){

	int S,T,U,N,O,D;
	scanf("%d %d %d %d %d %d",&S,&T,&U,&N,&O,&D);

	Info info[T];
	for(int i = 0; i < T; i++){
		scanf("%d %d",&info[i].need,&info[i].value);
	}

	Data data[N];
	for(int i = 0; i < N; i++){
		scanf("%d %d",&data[i].happiness,&data[i].cost);
	}

	for(int i = 0; i <= U; i++){
		for(int k = 0; k <= 10000; k++){
			dp[i][k] = -1;
			next_dp[i][k] = -1;
		}
	}

	for(int i = 0; i <= U; i++){
		max_hp[i] = 0;
		next_max_hp[i] = 0;
	}

	dp[0][0] = 0;
	next_dp[0][0] = 0;

	vector<LOC> Updated;
	int max_num = 0,next_max_num = 0;

	for(int i = 0; i < T; i++){
		for(int k = 0; k <= min(U-1,max_num); k++){
			for(int hp = 0; hp <= min(10000-info[i].need,max_hp[k]); hp++){
				if(dp[k][hp] == -1)continue;

				if(next_dp[k+1][hp+info[i].need] < dp[k][hp]+info[i].value){
					next_dp[k+1][hp+info[i].need] = dp[k][hp]+info[i].value;
					next_max_hp[k+1] = max(next_max_hp[k+1],hp+info[i].need);
					Updated.push_back(LOC(k+1,hp+info[i].need));
					next_max_num = max(next_max_num,k+1);
				}
			}
		}
		for(int k = 0; k < Updated.size(); k++){
			dp[Updated[k].num][Updated[k].HP] = next_dp[Updated[k].num][Updated[k].HP];
		}
		Updated.clear();
		for(int k = 0; k <= U; k++){
			max_hp[k] = next_max_hp[k];
		}
		max_num = next_max_num;
	}

	for(int i = 0; i <= 10000; i++){
		dp_2[i] = -1;
	}

	dp_2[0] = 0;
	for(int i = 0; i < N; i++){
		for(int k = 0; k <= 10000-data[i].cost; k++){
			if(dp_2[k] == -1)continue;
			dp_2[k+data[i].cost] = max(dp_2[k+data[i].cost],dp_2[k]+data[i].happiness);
		}
	}

	for(int i = 1; i <= 10000; i++){
		if(dp_2[i-1] > dp_2[i])dp_2[i] = dp_2[i-1];
	}

	for(int i = 0; i <= 10000; i++)dp_3[i] = 0;

	for(int i = 0; i <= 10000; i++){
		if(dp[U][i] != -1){
			dp_3[i] = max(dp_3[i],dp_2[dp[U][i]]);
		}
	}

	for(int day = 0; day <= D; day++){
		for(int hp = 0; hp <= S; hp++)dp[day][hp] = -1;
	}

	dp[0][S] = 0 ;
	int next_HP;

	for(int day = 0; day < D; day++){
		for(int hp = 1; hp <= S; hp++){
			if(dp[day][hp] == -1)continue;

			for(int use = 0; use <= hp; use++){
				if(dp_3[use] > 0){
					next_HP = min(S,hp-use+O);
					dp[day+1][next_HP] = max(dp[day+1][next_HP],dp[day][hp]+dp_3[use]);
				}
			}
		}
	}

	int maximum = -1;
	for(int hp = 0; hp <= S; hp++){
		maximum = max(maximum,dp[D][hp]);
	}

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

	return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second
typedef long long ll;
using namespace std;
const int N = 2e5;

int a[N+1];


int main() {
  ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  int n,m = -1;
  cin >> n;
  
  int arr[n];
  for (int i=0; i<n; i++){
    cin >> arr[i];
    a[arr[i]]++;
    m=max(m,arr[i]);
  }
  
  for (int i=0; i<n; i++){
    for (int j=m; j>=0; j--){
      if (a[j]>1||(arr[i]!=j&&a[j])){
        cout << j;
        break;
      }
    }
    cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
const int iadd[] = {0, 1, 0, -1}, jadd[] = {1, 0, -1, 0};
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
char str[maxn];
int vis[28];

int main(){
	memset(vis, 0, sizeof(vis));
	scanf("%s", str);
	for(int i = 0; str[i]; i++){
		vis[str[i] - 'a']++;
	}
	for(int i = 0; i < 26; i++) {
		if(vis[i] == 0) {
			printf("%c\n", i + 'a');
			return 0;
		}
	}
	puts("None");
}






Measured memory_bytes: 384
X, K, D = map(int, input().split())

if abs(X) > D:
    d = abs(X) // D
    y = abs(X) % D
    if d > K:
        a1 = abs(X) - (D * K)
        print(abs(a1))
        exit()

    a1 = abs(X) - (D * d)
    a2 = abs(X) - (D * (d+1))
    if abs(a1) < abs(a2):
        ans = a1
        yobi = a2
        K = K - d
    else:
        ans = a2
        yobi = a1
        K = K - (d+1)
    if K % 2 == 0:
        print(abs(ans))
    else:
        print(abs(yobi))
     
else:
    a1 = abs(X)
    a2 = abs(abs(X) - D)
    if a1 < a2:
        ans = a1
        yobi = a2
    else:
        ans = a2
        yobi = a1
        K = K - 1
    if K % 2 == 0:
        print(abs(ans))
    else:
        print(abs(yobi))



Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int sum[300000], w[300000];
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, fmax = -1, at;
	cin>>n>>k;
	rep(i, 0, n) cin>>w[i];
	rep(i, 0, k) sum[0] += w[i];
	hrp(i, 1, n-k) sum[i] = sum[i-1]-w[i-1]+w[i+k-1];
	hrp(i, 0, n-k) if (sum[i] > fmax) fmax = sum[i], at = i;
	double ans = 0.0;
	rep(i, at, at+k) hrp(j, 1, w[i]) ans += 1.0*j/w[i];
	printf("%.9lf\n", ans);
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

const int INF = 1 << 29;

int main(int argc, char **argv)
{
  int K;
  cin >> K;

  priority_queue< pair<int, int>,
                  vector< pair<int, int> >,
                  greater< pair<int, int>>> pque;
  vector<int> dp(K, INF);

  for (int i = 1; i <= 9; ++i) {
    pque.push(make_pair(i, i % K));
    // if i > K continue;
    // dp[i] = i;
    if (dp[i%K] > i) dp[i%K] = i;
  }

  while (!pque.empty()) {
    int zantei = pque.top().first;
    int jouyo = pque.top().second;
    // cout << jouyo << ',' <<  zantei << endl;
    pque.pop();
    if (dp[jouyo] < zantei) continue;
    for (int i = 0; i <= 9; ++i) {
      // if i > K continue;
      int new_jouyo = (10 * jouyo + i) % K;
      // cout << new_jouyo << endl;
      if (dp[jouyo] + i < dp[new_jouyo]) {
        dp[new_jouyo] = dp[jouyo] + i;
        pque.push(make_pair(dp[new_jouyo], new_jouyo));
      }
    }
  }

  cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int N;
	cin>>N;
	double sum = 0;
	for (int i = 0; i < N; i++) {
		double tmp;
		string S;
		cin>>tmp>>S;
		if(S=="JPY"){
			sum += tmp;
		}else{
			sum += tmp * 380000;
		}
	}

	cout << sum << endl;

	return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;

  vector<int> a(q);
  vector<int> bucket(n, (k - q));
  for (int i = 0; i < q; i++) {
    cin >> a[i];
    bucket[a[i] - 1]++;
  }

  for (int i = 0; i < n; i++) {
    if (bucket[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    while(h != 0 && w != 0)
    {
        for(int i=0; i<h; ++i)
        {
            for(int j=0; j<w; ++j)
            {
                if((i+j)%2 == 0) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	ll n;
	cin>>n;
	vector<char> ans;
	while(n!=0){
      	n--;
		int a=n%26;
		ans.pb(a+'a');
		n/=26;
	}
	for(int i=ans.size()-1;i>=0;i--){
		cout<<ans[i];
	}
	cout<<endl;
}


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

using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  vector<int> c[10];
  for (int i = 0; i < 10; i++)
  {
    c[i].resize(10);
    for (int j = 0; j < 10; j++)
      cin >> c[i][j];
  }
  vector<int> cost(10, 1e9);
  priority_queue<pair<int, int>> pq;
  cost[1] = 0;
  pq.push({0, 1});
  while (pq.size())
  {
    pair<int, int> p = pq.top();
    pq.pop();
    int s = p.first, n = p.second;
    for (int i = 0; i < 10; i++)
      if (cost[n] + c[i][n] < cost[i])
      {
        cost[i] = cost[n] + c[i][n];
        pq.push({cost[i], i});
      }
  }
  int ans = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
    {
      int a;
      cin >> a;
      if (a != -1)
        ans += cost[a];
    }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main
 
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
 
//=====I/O=====
 
var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)
 
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}
 
func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}
 
func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}
 
func scanText() string {
	sc.Scan()
	return sc.Text()
}
 
func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}
 
//=====main=====
 
func main() {
	sc.Split(bufio.ScanWords)
 
	n,m := scanInt(), scanInt()
	a := scanInts(n)
 
	val := a[0]/2
	for i := 1; i < n; i++ {
		e := euclidean(val,a[i]/2)
		val = val*(a[i]/2)/e
	}
 
	val2 := a[0]
	for i := 1; i < n; i++ {
		e := euclidean(val2,a[i])
		val2 = val2*a[i]/e
	}
 
	for i := 0; i < n; i++ {
		if val%a[i]==0 {
			fmt.Println(0)
			return
		}
	}
 
	fmt.Println(m/val-m/val2)
}
 
func euclidean(a,b int) int {
	r, x := a%b, b
	for r != 0 {
		x, r = r, x%r
	}
	return x
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(){	
	char str[25];
	scanf("%s", str);
	
	for(int i=0; str[i]!='\0'; i++){
		if(str[i]==','){
			printf(" ");
		} else {
		printf("%c", str[i]);
		}
	}
	
	puts(" ");
	return 0;
}

Measured memory_bytes: 1636
S = input()[::-1]
ans = 0
mods = [0] * 2019
mods[0] = 1
current = 0
x = 1
for s in S:
  current = (current + x * int(s)) % 2019
  ans += mods[current % 2019]
  mods[current % 2019] += 1
  x = x * 10 % 2019
print(ans)

Measured memory_bytes: 9124
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    long ans = 0;
    for (int i = K+1; i <= N; i++) {
      ans += (long)(i-K)*(N/i);
      if (N%i != 0 && N%i >= K) {
        ans += K == 0 ? N%i : N%i-K+1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,sum;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        int temp;cin>>temp;
        sum+=temp;
    }
    sum-=n;
    cout<<sum<<newl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
mt19937 rng(steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

ll n, m;

void solve(int tc) {
  cin >> n >> m;
  cout << (n + m - 1) / m << '\n';
}
 
int main() {
  send help
 
  // usaco("file");

  
 
  int tc;
  tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

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

struct disjoint_set{
  size_t n;
  vector<int> par;
  disjoint_set(){}
  disjoint_set(size_t _n):n(_n){
    par.resize(n,-1);
  }
  void reset(size_t _n){
    n = _n;
    par.clear();
    par.resize(n,-1);
  }
  int root(int k){
    if(par[k]<0){
      return k;
    }
    return par[k] = root(par[k]);
  }
  int size(int k){
    k = root(k);
    return -par[k];
  }
  auto operator[](int k){
    return size(k);
  }
  bool connect(int a,int b){
    a = root(a);
    b = root(b);
    if(a==b)return false;
    if(size(a)<size(b))swap(a,b);
    par[a] += par[b];
    par[b] = a;
    return true;
  }
  auto operator()(int a,int b){
    return connect(a,b);
  }
  bool same(int a,int b){
    return root(a) == root(b);
  }
};

signed main(){

  int n,m,k;
  cin>>n>>m>>k;
  disjoint_set st(n);
  vector<int> deg(n);
  for(int _{0};_<m;++_){
    int a,b;
    cin>>a>>b;
    a--;b--;
    st(a,b);
    deg[a]++;
    deg[b]++;
  }
  for(int _{0};_<k;++_){
    int c,d;
    cin>>c>>d;
    c--;d--;
    if(st.same(c,d)){
      deg[c]++;
      deg[d]++;
    }
  }
  for(int v{0};v<n;++v){
    cout<<(st[v]-deg[v]-1)<<" ";
  }
  cout<<endl;

}

Measured memory_bytes: 1664
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int minv = INF;
	rep(i,n){
		int a;
		cin >> a;
		int tmp = __builtin_ctz(a);
		minv = min(minv,tmp);
	}
	cout << minv << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,c;
	cin>>n>>c;
	int ans = 0;
	multiset<ar<int,2>> m;
  	vector<ar<ll,3> > v;
  for(int i = 0; i<n; i++)
  {
	int j,k,l;
    cin>>j>>k>>l;
    v.pb({j,k,l});
  }
  sort(v.begin(),v.end());
	for(int i = 0; i<n; i++)
	{
		int j,k,l;
		j = v[i][0];
      	k = v[i][1];
      	l = v[i][2];
		auto y = m.lower_bound({0,0});
		int flag = 1;
		for(;y!=m.end();y++)
		{
			ar<int,2> t = *y;
          if(t[0]<j)
			{
				m.erase(y);
				m.insert({k,l});
				flag = 0;
				break;
			}
			else if(t[0]==j && t[1]==l)
			{
				m.erase(y);
				m.insert({k,l});
				flag = 0; 
				break;
			}
			else if(t[0]>j)
				break;
		}
		if(flag)
			m.insert({k,l});
	}
	cout<<m.size()<<endl;
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int n, a;
	int64_t ans = 2 * pow(10, 9);

	cin >> n;
	vector<int64_t> a_sum(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (i == 0)
			a_sum[i] = a;
		else
			a_sum[i] = a_sum[i - 1] + a;
	}
	for (int i = 0; i < n - 1; i++)
		ans = min(ans, abs(2 * a_sum[i] - a_sum[n - 1]));
	cout << ans << endl;
}


Measured memory_bytes: 4856
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	bool f = true;
	while (n--) {
		int a; cin >> a;
		if (a % 2 == 0 && (a % 3 && a % 5)) f = false;
	}
	cout << (f ? "APPROVED" : "DENIED") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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

double n,t,a,h[1010]={},temp,ans = 1000,dis;

cin >> n >> t >> a;
rep(i,n){
    cin >> h[i];
}

rep(i,n){
    temp = t-h[i]*0.006;
    dis = abs(temp-a);
    ans = min(ans,dis);
}

rep(i,n){
    temp = t-h[i]*0.006;
    if (ans == abs(temp-a))
    {
        cout << i+1 << endl;
        break;
    }
    
}






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<ll,ll> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

struct S{
	set<pi> s;
	void insert(pi x){
		while(1){
			auto i = s.lower_bound(x);
			rep(it, 2){
				if(i != s.end() && !(i->second < x.first || x.second < i->first)){
					x = pi(min(i->first, x.first), max(i->second, x.second));
					s.erase(i); goto NEXT;
				}
				if(i == s.begin()) break;
				else --i;
			}
			break; NEXT:;
		}
		s.insert(x);
	}
	ll cnt(ll d){
		ll res = 0;
		for(pi i : s) res += (i.second - i.first) / d;
		return res;
	}
};

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	ll n, x, d; cin >> n >> x >> d;
	if(d == 0){
		if(x == 0) cout << 1 << endl;
		else cout << n + 1 << endl;
		return 0;
	}
	if(d < 0){
		x += (n - 1) * d;
		d *= -1;
	}
	map<ll, S> is;
	
	ll lo = 0, hi = 0;
	rep(i, n + 1){
		ll m = (lo % d + d) % d;
		is[m].insert(pi(lo, hi + d));
		//dbg(lo, hi, m, is[m].s);
		lo += x + i * d;
		hi += x + (n - 1 - i) * d;
	}
	ll ans = 0;
	for(auto &i : is) ans += i.second.cnt(d);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31488
N = gets.to_i
As = gets.split.map(&:to_i)

x = As.inject(:^)
a = As.map{|a| a & ~x}
r = 0
59.downto(0).each do |i|
  if j = (r ... N).find{|k| (a[k] >> i).odd?}
    a[r], a[j] = a[j], a[r]
    N.times do |j|
      next if j == r
      a[j] ^= a[r] if (a[j] >> i).odd?
    end
    r += 1
  end
end
puts 2*a[0, r].inject(0, :^) + x

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int pos[Sz];

int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();    
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    pos[x] = i;
  }               
  int len = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (pos[i] > pos[i - 1])
      len++;
    else
      len = 1;
    ans = max (ans, len);
  }
  cout << n - ans;



  return 0;
}






// Coded by Z..



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> m;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  int maxi = 0;
  int index = 0;
  for(int i = 0; i < n; i++) {
    if(maxi < m[i]){
      maxi = m[i];
      index = i;
    }
  }
  int maxi2 = 0;
  for(int i = 0; i <= n; i++) {
    if(m[i] != maxi){
      //maxi2 = max(maxi2, m[i]);
    }
  }
  map<ll, ll> m2, m3;
  ll sum = 0;
  for(int i = 0; i <= n; i++) {
    m2[i] = m[i] * (m[i] - 1) / 2;
    if(m[i] >= 0){
      m3[i] = (m[i] - 1) * (m[i] - 2) / 2;
    }else{
      m3[i] = 0;
    }
    sum += m2[i];
    //cout << m3[i] << " ";
  }
  //cout << '\n';
  // cout << maxi << " " << maxi2 << '\n';
  for(int i = 0; i < n; i++){
    cout << sum - m2[a[i]]  + m3[a[i]] << '\n';
  }

  return 0;
}

Measured memory_bytes: 41728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
				out.println("Possible");
			} else {
				out.println("Impossible");
			}
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
ll n,c,k;
vi A;
bool check(ll mid){
  ll mi = llINF;
  ll cnt = 0;
  ll ho = 0;
  for(int i=0;i<n;i++){
    if(mi == llINF){
      mi = A[i];
      cnt++;
    }else{
      if(mi+k < A[i]){
	cnt = 1;
	mi = A[i];
	ho++;
      }else{
	cnt++;
      }
    }
    if(cnt == c){
      mi = llINF;
      ho++;
      cnt = 0;
    }
  }
  if(cnt)ho++;
  return ho <= mid;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>c>>k;
  A.resize(n);
  for(auto &a:A)cin>>a;
  ll le = 0,ri=111111;
  sort(ALL(A));
  while(ri-le > 1){
    ll mid = (ri+le)/2;
    if(check(mid)){
      ri = mid;
    }else{
      le = mid;
    }
  }
  cout<<ri<<endl;
  return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    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];
        }
    }
    int n = 0;
    int ans[h*w][4];
    for(int i = 0; i < h; i++){
        if(i%2 == 0){
            for(int j = 0; j < w; j++){
                if(a[i][j]%2 == 0) continue;
                int y, x;
                if(j != w-1){
                    y = i;
                    x = j+1;
                }
                else{
                    y = i+1;
                    x = j;
                }
                if(y < 0 || h <= y || x < 0 || w <= x) continue;
                a[y][x]++;
                a[i][j]--;
                ans[n][0] = i+1;
                ans[n][1] = j+1;
                ans[n][2] = y+1;
                ans[n][3] = x+1;
                n++;
            }
        }
        else{
            for(int j = w-1; j >= 0; j--){
                if(a[i][j]%2 == 0) continue;
                for(int k = 0; k < 4; k++){
                    if(a[i][j]%2 == 0) continue;
                    int y, x;
                    if(j != 0){
                        y = i;
                        x = j-1;
                    }
                    else{
                        y = i+1;
                        x = j;
                    }
                    if(y < 0 || h <= y || x < 0 || w <= x) continue;
                    a[y][x]++;
                    a[i][j]--;
                    ans[n][0] = i+1;
                    ans[n][1] = j+1;
                    ans[n][2] = y+1;
                    ans[n][3] = x+1;
                    n++;
                }
            }
        }
    }
    cout << n << endl;
    for(int i = 0; i < n; i++){
        cout << ans[i][0] << " " << ans[i][1] << " ";
        cout << ans[i][2] << " " << ans[i][3] << endl;
    }
    return 0;
}

Measured memory_bytes: 6912
from scipy.sparse.csgraph import floyd_warshall
import itertools
n,m,r = map(int,input().split())
L = list(map(int,input().split()))
d = [[float("inf")]*n for i in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(m):
    a,b,l = map(int,input().split())
    d[a-1][b-1] = l
    d[b-1][a-1] = l
d = floyd_warshall(d)
ans = float('inf')
seq = []
for i in range(r):
  seq.append(i)
K = list(itertools.permutations(seq))
for i in range(len(K)):
  cur = 0
  for j in range(1,r):
    p = L[K[i][j-1]]-1
    q = L[K[i][j]]-1
    cur += d[p][q]
  if cur != float('inf'):
    if cur <= ans:
      ans = cur
print(int(ans))

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

const int INF = 1001001001;

int main(){

    int n;
    cin >>n;
    int ans = (1000-n%1000)%1000;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, 0, N) cin >> H[i];
    sort(all(H));
    reverse(all(H));
    ll ans = 0;
    rep(i, K, N) {
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
pii a[maxn];
int dp[maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,t;
    cin>>n>>t;
    for(int i=1;i<=n;i++){
        cin>>a[i].F>>a[i].S;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        for(int j=t-1;j>=0;j--){
            dp[min(j+a[i].F,t)]=max(dp[j]+a[i].S,dp[min(j+a[i].F,t)]);
        }
    }
    int ans=0;
    for(int i=1;i<=t;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
	exit(0);
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    
    // 入力
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Double as[] = new Double[n];
    int y = 0;
    while(sc.hasNext()){
      as[y] = sc.nextDouble();
      y++;
    }
    
    // 結果用
    Set<Double> aSet = new HashSet<Double>();
    // 削除用
    Set<Double> dSet = new HashSet<Double>();
    
    // ソート
    Arrays.sort(as);
    
    // 重複する要素の検索
    for(Double a:as){
      if(aSet.contains(a)){
        dSet.add(a);
      }else{
        aSet.add(a);
      }
    }
    
    // 検索
    for(int i=0;i<n;i++){
      Double ai = as[i];
      
      if(ai*2 > as[n-1]){
        // 終了条件
        break;
      }
        int j = 2;
        while(ai <= as[n-1]){
          // 倍数
          ai = as[i] * j;
          if(aSet.contains(ai)){
            // セットにある場合、倍数を削除
            aSet.remove(ai);
          }
          j++;
        }
    }
    // 同じ数字が複数存在する場合は削除
    aSet.removeAll(dSet);
    // 出力
    System.out.println(aSet.size());
  }
}


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

using namespace std;

int main(){
    //入力
    string s,t="";
    string text[4] ={"dream", "dreamer", "erase", "eraser"};
    cin >> s;

    //処理
    string result = "NO";
    while(t.length() < s.length()){
        int tmp = s.length();
        for(int i=0; i<4; i++){
            if(text[i].length() <= s.length()){
                if(s.compare(s.length()-text[i].length(), s.length(), text[i])==0){
                    s = s.substr(0, s.length()-text[i].length());
                    break;
                }
            }
        }
        //長さが変わらなかったら（一致するものがなかったら）
        if(tmp == s.length()){
            break;
        }
        //すべて分割できたら
        if(s.length() == 0){
            result = "YES";
            break;
        }
    }
    //出力
    cout << result << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int A=0,B=0;
  for(int i=0; i<n;) {
  	A += s[i];
    B += s[i+1];
    i += 2;
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define MOD 998244353
#define SIZE 200005

using namespace std;
typedef long long int ll;
template<class T> T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; }
template<class T> T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; }
ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

template<int mod, int primitive_root>
class NTT {
public:
	int get_mod() const { return mod; }
	void _ntt(vector<ll>& a, int sign) {
		const int n = sz(a);
		//assert((n ^ (n&-n)) == 0); //n = 2^k
		const int g = 3; //g is primitive root of mod
		int h = (int)mod_pow(g, (mod - 1) / n, mod); // h^n = 1
		if (sign == -1) h = (int)mod_inv(h, mod); //h = h^-1 % mod
		//bit reverse
		int i = 0;
		for (int j = 1; j < n - 1; ++j) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (j < i) swap(a[i], a[j]);
		}
		for (int m = 1; m < n; m *= 2) {
			const int m2 = 2 * m;
			const ll base = mod_pow(h, n / m2, mod);
			ll w = 1;
			FOR(x, m) {
				for (int s = x; s < n; s += m2) {
					ll u = a[s];
					ll d = a[s + m] * w % mod;
					a[s] = u + d;
					if (a[s] >= mod) a[s] -= mod;
					a[s + m] = u - d;
					if (a[s + m] < 0) a[s + m] += mod;
				}
				w = w * base % mod;
			}
		}
		for (int i=0;i<a.size();i++) if (a[i] < 0) a[i] += mod;
	}
	void ntt(vector<ll>& input) {
		_ntt(input, 1);
	}
	void intt(vector<ll>& input) {
		_ntt(input, -1);
		const int n_inv = mod_inv(sz(input), mod);
		for (int i=0;i<input.size();i++) input[i] = input[i] * n_inv % mod;
	}
	vector<ll> convolution(const vector<ll>& a, const vector<ll>& b){
		int ntt_size = 1;
		while (ntt_size < sz(a) + sz(b)) ntt_size *= 2;
		vector<ll> _a = a, _b = b;
		_a.resize(ntt_size); _b.resize(ntt_size);
		ntt(_a);
		ntt(_b);
		FOR(i, ntt_size){
			(_a[i] *= _b[i]) %= mod;
		}
		intt(_a);
		return _a;
	}
};
NTT <MOD,3> solve;
ll fac[SIZE],finv[SIZE],inv[SIZE];
ll dp[SIZE];

void make()
{
	inv[1]=1;
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(ll) (MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	dp[0]=1;
	for(int i=0;i<m;i++)
	{
		//n -> n+k の時に、(n+k+2)! / (k+2)! / n! * dp[n] 
		vector <ll> A,B;
		for(int j=0;j<=n;j++) A.push_back(dp[j]*finv[j]%MOD);
		for(int k=0;k<=n;k++) B.push_back(finv[k+2]);
		vector <ll> gt=solve.convolution(A,B);
		for(int j=0;j<=n;j++) dp[j]=(gt[j]*fac[j+2]%MOD-dp[j]*(ll) j%MOD+MOD)%MOD;
		//for(int j=0;j<=n;j++) printf("%lld ",dp[j]);puts("");
	}
	ll ret=0;
	for(int i=0;i<=n;i++) ret=(ret+dp[i]*C(n,i)%MOD)%MOD;
	printf("%lld\n",ret);
	return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string tostr(int n){
  stringstream ss;
  ss<<n;
  return ss.str();
}
int toint(string s){
  return atoi(s.c_str());
}

int main(){
  vector<int> kaibun;
  for(int i = 0; i < 100000; i++){
    string s = tostr(i);
    string t = s;
    reverse(t.begin(), t.end());
    if(s == t) kaibun.push_back(i);
  }
  int N;
  while(cin>>N){
    int ans = -INF;
    REP(i, kaibun.size()){
      if(abs(ans - N) > abs(kaibun[i] - N)) ans = kaibun[i];
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  string str;
  str = "abcdefghijklmnopqrstuvwxyz";
  
  	char C;
  	cin >> C;
  
  	for(int i=0; i < 26; i++){
      if(C == str.at(i)){
        cout << str.at(i+1) << endl;
      }
    }
  
	return 0;
}


Measured memory_bytes: 256