akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }
    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int ans = 1000000000;
		for (int i = 0; i <= n-k; i++) {
			int tmp = 1000000000;
			if(a[i+k-1]<0 && i+k-1 == n-1)
			{
				tmp = -a[i];
			}
			else if(a[i]>0 && i == 0)
			{
				tmp = a[i+k-1];
			}
			else if(a[i+k-1]>=0 && a[i]<=0)
			{
				tmp = a[i+k-1]-a[i];
				if(-a[i] > a[i+k-1])
				{
					tmp += a[i+k-1];
				}
				else {
					tmp += -a[i];
				}
			}
			ans = Math.min(ans, tmp);
		}
		
		out.printf("%d", ans);
		out.flush();
	}

    
    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 37716
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=-1e18;
    ans=(ans>a*c)?ans:a*c;
    ans=(ans>b*c)?ans:b*c;
    ans=(ans>b*d)?ans:b*d;
    ans=(ans>a*d)?ans:a*d;  
    cout << ans << endl;  
    

    return 0;   
}

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

const ll mod = 1000000007;

ll modpow(ll a, ll p){
  ll ret = 1;
  while(p){
    if(p & 1) ret = ret * a % mod;
    a = a * a % mod;
    p >>= 1;
  }
  return ret;
}

int main(){
  int n; cin >> n;
  vector<ll> a(n), num(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    num[a[i]]++;
  }
  bool ok = true;
  if(n%2){
    if(num[0] != 1) ok = false;
    for(int i = 2; i < n; i += 2){
      if(num[i] != 2) ok = false;
    }
  }
  else{
    for(int i = 1; i < n; i += 2){
      if(num[i] != 2) ok = false;
    }
  }
  if(ok) cout << modpow(2, n/2) << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 4744
// Author: Amey Bhavsar
// License: CC
// IDE: Geany
// Platform: AtCoder

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

typedef long long ll;
typedef unsigned long long ull;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);


int main() {
	
	float n;
	cin >> n;
	cout << ceil(n/2);
	
	
	return 0;
}


Measured memory_bytes: 256
t=int(input())
if t%2==0 or t%5==0:
  print(-1)
else:
  f=0
  n=7%t
  for i in range(1,10**6+1):
    if n==0:
      f=1
      print(i)
      break
    n=((n*10)+7)%t
  if f==0:
    print(-1)
    

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

path = [0]*N
a = 0

for j in range(N+1):
    count = j
    a = A[a]-1
    if path[a]!= 0:
        b = path[a]
        c = j+1-path[a]
        break
    else:
        path[a] = j+1

mod = (K-b)%c

if count > K:
    print(path.index(K)+1)
else:
    print(path.index(mod+b)+1)

    



Measured memory_bytes: 100068
xx = input()
if xx == 'a':
  print('b')
elif xx == 'b':
  print('c')
elif xx == 'c':
  print('d')
elif xx == 'd':
  print('e')
elif xx == 'e':
  print('f')
elif xx == 'f':
  print('g')
elif xx == 'g':
  print('h')
elif xx == 'h':
  print('i')
elif xx == 'i':
  print('j')
elif xx == 'j':
  print('k')
elif xx == 'k':
  print('l')
elif xx == 'l':
  print('m')
elif xx == 'm':
  print('n')
elif xx == 'n':
  print('o')
elif xx == 'o':
  print('p')
elif xx == 'p':
  print('q')
elif xx == 'q':
  print('r')
elif xx == 'r':
  print('s')
elif xx == 's':
  print('t')
elif xx == 't':
  print('u')
elif xx == 'u':
  print('v')
elif xx == 'v':
  print('w')
elif xx == 'w':
  print('x')
elif xx == 'x':
  print('y')
else:
  print('z')
exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define lambda(i) [](auto &i)
#define compare(i, j) [](auto &i, auto &j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define SZ(a) ll((a).size())
#define REP(i, n) for (decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto &&i : (a))
using namespace std;

const ll INF = 1e18;
const ll mod = 1e9 + 7;

vi cum(vi V)
{
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve()
{
  ll n;
  ll N = 1e5 + 10;
  bool prime[N];
  REP(i, N) prime[i] = true;
  prime[0] = prime[1] = false;
  REP(i, N){
    if (prime[i]){
      for (int j = i + i; j < N; j += i){
        prime[j] = false;
      }
    }
  }
  cin >> n;
  while(!prime[n]) n++;
  cout << n << endl;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,x,y;
ll c[2005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>x>>y;
    x--;
    y--;
    rep(i,0,n)
    {
    	rep(j,i+1,n)
    	{
    		ll ans=j-i;
    		ans=min(ans,abs(i-x)+1+abs(j-y));
    		c[ans]++;
    	}
    }
    rep(i,1,n)
    	cout<<c[i]<<"\n";
}


Measured memory_bytes: 256
<?php
list($numA, $numB, $numC) = explode(' ', trim(fgets(STDIN)));
$divisorCount = 0;
for ($i = $numA; $i <= $numB; $i++) {
    if (fmod($numC, $i) == 0 ) {
        $divisorCount++;
    }
}
echo $divisorCount, PHP_EOL;

Measured memory_bytes: 15436
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  char str[N];
  cin >> str;
  
  int point=1;
  int i;
  for(i=0;i<N-1;i++){
    if(str[i]!=str[i+1]) point++; 
  }
  printf("%d",point);
  
  
 return 0;
}

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

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

  int n;
  cin >> n;

  vector<int> answer(n + 1);

  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if(tmp > n) break;

        answer[tmp]++;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << answer[i] << '\n';
  }
}


Measured memory_bytes: 3696
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debugg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e7+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,sum;
void solve()
{
    ll n;cin>>n;ll ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }
    cout<<sum-n;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[][] map = new int[n][n];
			for(int i=0;i<n;i++) Arrays.fill(map[i], Integer.MAX_VALUE);
			
			int m = sc.nextInt();
			int p, q;
			for(int i=0;i<m;i++){
				String[] s = sc.next().split(",");
				p = Integer.valueOf(s[0]);
				q = Integer.valueOf(s[1]);
				map[p][q] = Integer.valueOf(s[2])/100 - 1;
				map[q][p] = map[p][q];
			}
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(0);
			int sum = 0;
			int r = 0;
			for(int i=1;i<n;i++){
				q = Integer.MAX_VALUE;
				for(int j=0;j<i;j++){
					p = list.get(j);
					for(int k=0;k<n;k++){
						if(list.contains(k)==false && q>map[p][k]){
							q = map[p][k];
							r = k;
						}
					}
				}
				list.add(r);
				sum += q;
			}
			
			System.out.println(sum);
		}	
	}	
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



int main(){
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define N 100005
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int n,t,a[N],mx[N],delta,ans=0;
int main(){
	n=read(),t=read();
	for(int i=1;i<=n;++i)a[i]=read();
	mx[n]=a[n];
	for(int i=n-1;i;--i)mx[i]=max(mx[i+1],a[i]);
	for(int i=1;i<=n;++i){
		if(delta<mx[i]-a[i])delta=mx[i]-a[i],ans=1;
		else if(delta==mx[i]-a[i])++ans;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
P = list(map(int, input().split()))
min = float('inf')
ans = 0
for i in range(N):
    if P[i] <= min:
        min = P[i]
        ans += 1
    # if P[i] <= min(P[:(i+1)]):
    #     ans += 1
print(ans)

Measured memory_bytes: 24744
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=505;
int n,m,a[N][N],b[N][N];
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		if(i&1){
			for(int j=2;j<m;j++){
				a[i][j]=1;
			}
		}else{
			for(int j=2;j<m;j++){
				b[i][j]=1;
			}
		}
	}
	for(int i=1;i<=n;i++){
		a[i][1]=1;
		b[i][m]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){
				putchar('#');
			}else if(a[i][j]){
				putchar('#');
			}else{
				putchar('.');
			}
		}
		puts("");
	}
	puts("");
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i][j]=='#'){
				putchar('#');
			}else if(b[i][j]){
				putchar('#');
			}else{
				putchar('.');
			}
		}
		puts("");
	}
	return 0;
}

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

int main() {
    int N;
    cin>>N;
    int count=0;
    int max=1;
    int count_max=0;
    int a;
    for(int i=1;i<=N;i++){
        int a=i;
        count=0;
        while(a>1){
            if(a%2==0)a=a/2;
            else break;
            count++;
        }
        if(count>count_max){
            count_max=count;
            max=i;
        }

    }
    cout<<max<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<long long>fact;
#define MOD 1000000007LL


long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

long long division(long long a, long long b, long long p) {		// (a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
	long long ans, inv;
	inv = mul_inv(b, p);
	ans = ((a % p) * inv) % p;
	return ans;
}




long long calc(long long n, long long k) {
	long long x = fact[n], y = (fact[n - k] * fact[k]) % MOD, ans;
	ans = division(x, y, MOD);
	return ans;
}

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

	long long n, i, j, k, maxx, minn, ans, x;
	cin >> n >> k;
	vector<long long> a(n), b(n + 1);
	fact.resize(n + 1);
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());

	b[0] = 1;
	for (i = 1; i <= n; i++) b[i] = (b[i - 1] * 2) % MOD;
	fact[0] = 1;
	for (i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % MOD;

	maxx = 0;
	for (i = 1; i <= n; i++) {
		if (i < k) continue;
		x = calc(i - 1, k - 1);
		maxx = (maxx + a[i - 1] * x) % MOD;
	}

	sort(a.rbegin(), a.rend());

	minn = 0;
	for (i = 1; i <= n; i++) {
		if (i < k) continue;
		x = calc(i - 1, k - 1);
		minn = (minn + a[i - 1] * x) % MOD;
	}

	ans = (maxx + MOD - minn) % MOD;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main() {
    int n, *h, *ans;
    cin >> n;
    h = new int [n];
    ans = new int[n];
    int c = 0;

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

    for (int i = 0; i < n-1; i++) {
        if (h[i] >= h[i+1]) {
            ans[c]++;
        }
        else
            c = i+1;
    }

    int a = ans[0];

    for (int i = 1; i < n; i++) {
        a = max(a, ans[i]);
    }

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int h[]=new int[N];
        for(int i=0;i<N;++i) {
            h[i]=sc.nextInt();
        }
        int dp[]=new int[N];
        dp[0]=0;
//        dp[1]=Math.abs(h[1]-h[0]);
        Deque<Integer> dq=new ArrayDeque<>();
        for(int i=1;i<N;++i) {
            dp[i]=Integer.MAX_VALUE;
            for(int j=i-1;j>=0&&j>=i-K;--j) {
                dp[i]=Math.min(dp[j]+Math.abs(h[i]-h[j]),dp[i]);
            }
        }
        System.out.println(dp[N-1]);
    }
}

Measured memory_bytes: 59480
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll ans = 0;
Pli X[int(1e5 + 5)], Y[int(1e5 + 5)];
vector <Pli> Graph[int(1e5 + 5)];
bool visited[int(1e5 + 5)];

int Make_Graph(){
  sort(X, X + N);
  for (int i = 0; i < N - 1; i++){
    ll deg = X[i + 1].fi - X[i].fi;
    Graph[X[i + 1].se].push_back(mp(deg, X[i].se));
    Graph[X[i].se].push_back(mp(deg, X[i + 1].se));
  }
  sort(Y, Y + N);
  for (int i = 0; i < N - 1; i++){
    ll deg = Y[i + 1].fi - Y[i].fi;
    Graph[Y[i + 1].se].push_back(mp(deg, Y[i].se));
    Graph[Y[i].se].push_back(mp(deg, Y[i + 1].se));
  }
  return 0;
}

int Solve(){
  visited[0] = true;
  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  for (int i = 0; i < Graph[0].size(); i++) que.push(Graph[0][i]);

  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (visited[Q.se]) continue;
    visited[Q.se] = true;
    ans += Q.fi;
    for (int i = 0; i < Graph[Q.se].size(); i++){
      Pli next = Graph[Q.se][i];
      if (visited[next.se]) continue;
      que.push(next);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%lld%lld", &X[i].fi, &Y[i].fi);
    X[i].se = i; Y[i].se = i;
  }
  Make_Graph(); Solve();
  return 0;
}


Measured memory_bytes: 17012
#include<bits/stdc++.h>
using namespace std;
#define int long long
int P,Q,A,N;


int dfs(int p,int q,int n,int t){
    if(P*q==p*Q)return 1;
    if(P*q<p*Q)return 0;
    if(N==n)return 0;

    int ret=0;

    for(int i=t;q*i<=A;i++){
        ret+=dfs(p*i+q,q*i,n+1,i);
    }

    return ret;
}

signed main(){
    while(cin>>P>>Q>>A>>N,P||Q||A||N)cout<<dfs(0,1,0,1)<<endl;
    return 0;
}

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

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

    for(int i = 0; i < n.length(); i++){
        if(n[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,a[maxn];
char s[maxn];
int fac[maxn];

int check() {
    int ans=0;
    for(int i=1;i<=n;i++)
        if((a[i]&1)&&fac[n-1]-fac[i-1]-fac[n-i]==0) ans^=1;
    return ans;
}

int main() {
    read(n),scanf("%s",s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'1';
    for(int i=2;i<=n;i++) if(!(i&1)) fac[i]=fac[i>>1]+1;
    for(int i=1;i<=n;i++) fac[i]+=fac[i-1];
    if(check()) {return puts("1"),0;}
    for(int i=1;i<=n;i++) if(a[i]==1) {puts("0");return 0;}
    for(int i=1;i<=n;i++) a[i]/=2;
    if(check()) puts("2");
    else puts("0");
    return 0;
}


Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
char S[105] , T[105];

int main(){
    int N , i;
    scanf( "%d%s%s" , &N , S , T );

    for( i = 0 ; i < N ; ++i )
        printf( "%c%c" , S[i] , T[i] );
    
    puts( "" );
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> h(n);
	for(int i = 0;i < n;i++)cin >> h[i];

	vector<vector<int>> e(n);
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	int cnt = 0;
	for(int i = 0;i < n;i++){
		bool flag = true;
		for(int j = 0;j < e[i].size();j++){
			if(h[i] <= h[e[i][j]])flag = false;
		}
		if(flag){
			cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 8704
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, X, T := ReadInt(), ReadInt(), ReadInt()
	fmt.Println((N + X - 1) / X * T)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String order, str;
        Set<String> s = new HashSet<String>();
        ArrayList<String> ans = new ArrayList<String>();

        for(int i = 0; i < n; i++){
            order = sc.next();
            str = sc.next();

            if(order.equals("insert")) s.add(str);

            if(order.equals("find")){
                if(s.contains(str)) ans.add("yes");
                else ans.add("no");
            }
        }

        for(int i = 0; i < ans.size(); i++){
            System.out.println(ans.get(i));
        }
        sc.close();
    }
}


Measured memory_bytes: 265948
import time
n, m = map(int, input().split())
numbers = list(map(int, input().split()))
costs = [0,2,5,5,4,5,6,3,7,6]
f = [-1]*10010
f[0] = 0
for i in range(1, n+1):
    for x in numbers:
        if i-costs[x] >= 0:
            f[i] = max(f[i], f[i-costs[x]]*10+x)
print(f[n])

Measured memory_bytes: 14448
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/
int dx[4] = {1,-1,0,0}, dy[4] = {0,0,1,-1};
/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H,W; cin >> H >> W;
    vector<string> table(H);
    rep(i,H) cin >> table[i];
    int black = 0;
    rep(i,H){
        rep(j,W){
            if(table[i][j] == '#') black++;
        }
    }

    vector<vector<int>> dist(H,vector<int>(W));
    rep(i,H)rep(j,W) dist[i][j] = -1;

    queue<pair<int,int>> que;
    dist[0][0] = 0;
    que.push({0,0});
    while(!que.empty()){
        pair<int,int> v = que.front(); que.pop();
        rep(i,4){
            int nx = v.second + dx[i];
            int ny = v.first + dy[i];
            if(nx<0 || nx>=W || ny<0 || ny>=H) continue;
            if(dist[ny][nx]!=-1) continue;
            if(table[ny][nx]=='#') continue;

            dist[ny][nx] = dist[v.first][v.second] + 1;
            que.push({ny, nx});
        }
    }

    if(dist[H-1][W-1]==-1){
        cout << -1 << endl;
    }else{
        cout << H*W - (black+dist[H-1][W-1] + 1) << endl;
    }
 
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3612
/*
 * @Author: CucumicsMelon
 * @Date: 2018-11-02 21:31:37
 * @Last Modified by: CucumicsMelon
 * @Last Modified time: 2018-11-02 21:46:28
 */
#include <cstdio>
#include <iostream>
#include <string.h>
#include<bits/stdc++.h>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define rep(i,n,m) for(int i=n;i<=m;++i)
#define per(i,n,m) for(int i=n;i>=m;--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define maxn 100000+50
#define ll long long
void swap(int a,int b)
{
    int t=a;a=b;b=t;
}
using namespace std;
int nex[maxn];
void  getn(int n,char c[])
{
    int i=0,j=-1;
    nex[0]=-1;
    while(i<n)
    {
        if(c[i]==c[j]||j==-1)
        {
            i++;j++;nex[i]=j;
        }
        else j=nex[j];
    }
}
int kmp(char c1[],char c2[])
{
    int i,j=0,l1,l2;
    l1=strlen(c1);l2=strlen(c2);
    getn(l2,c2);
    rep(i,0,l1-1)
    {
        while(j&&c1[i]!=c2[j]) j=nex[j];
        if(c1[i]==c2[j]) j++;
    }
    return j;
}
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b) swap(a,b);
    int ans=a+(b/2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N;
ll A[100];
ll u[100], d[100];

int main(void){
    cin >> N;
    REP(i, N) cin >> A[i];
    for(int i=1;i<N;i++){
        if(A[i] > A[i-1]) u[i-1] = 1;
        if(A[i] < A[i-1]) d[i-1] = 1;
    }

    ll c = 1000;
    ll kabu = 0;
    for(int i=0;i<N;i++){
        if(u[i] == 1){
            kabu += c / A[i];
            c = c % A[i];
        }
        if(d[i] == 1){
            c += A[i] * kabu;
            kabu = 0;
        }
        //cout << kabu << ' ' << c << endl;
    }
    c += A[N-1] * kabu;
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3628
#include<iostream>

using namespace std;
int main() {
    int d;
    while(cin >> d) {
        long long ans = 0;
        int y = d;
        while (y <= 600 - d) {
            ans += (long long)y * y * d;
            y += d;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3100
import collections
import heapq
n, m = map(int, input().split())
c = collections.defaultdict(list)
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    c[m - a].append(b)
h = []
heapq.heapify(h)    
ans = 0
for i in range(m - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) >0:
        ans += -1 * heapq.heappop(h)
print(ans)        

Measured memory_bytes: 27880
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

template <typename T>
T powint(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powint(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;
//using mint = ModInt<998244353>;

template <typename T>
vector<pair<T, int>> prime_factorize(T n) {
    vector<pair<T , int>> ret;
    for (T i = 2; i*i <= n; ++i) {
        if (n % i != 0) continue;
        int cnt = 0;
        while (n % i == 0) {
            ++cnt;
            n /= i;
        }
        ret.emplace_back(i, cnt);
    }
    if (n != 1) ret.emplace_back(n, 1);
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto &e: a) cin >> e;

    map<int, int> lf;
    for (int i = 0; i < n; ++i) {
        auto f = prime_factorize(a[i]);
        for (auto &e: f) {
            lf[e.first] = max(lf[e.first], e.second);
        }
    }

    mint l = 1;
    for (auto &e: lf) {
        l *= powint<mint>(e.first, e.second);
    }

    mint ans = 0;
    for (auto &e: a) {
        ans += l / e;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
//atcoder clange
#include <stdio.h>

int main(void){
    int N;
   int A,B;
   scanf("%d", &N);//数値の取得
   scanf("%d", &A);//数値の取得
   scanf("%d", &B);//数値の取得
  
  if(N*A > B){
	printf("%d",B);
    return 0;
  }else if(N*A <= B){
	printf("%d",N*A);
    return 0;
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())

flg=False
for i in range(100//4 + 1):
    for j in range(100//7 + 1):
        if i==j==0:
            continue
        div = 4*i + 7*j
        if N%div==0:
            flg=True
ans = 'Yes' if flg else 'No'
print(ans)

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

int main(void){
  long long N;
  long long width,height;
  width = 0;
  height = 0;
  
  cin >> N;
  vector<long long> a;

  for (long long i = 0;i < N; i++){
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  for (long long i = N - 1;i >= 0; i--){
    if(i - 3 >= 0){
      if(a[i] == a[i - 1] && a[i - 1] == a[i - 2] && a[i - 2] == a[i - 3]){
        width = width < a[i] ? a[i] : width;
        height = height < a[i] ? a[i] : height;
        i = i - 3;
      }
    }
    if (i - 1 >= 0){
      if(a[i] == a[i - 1] && height >= width){
        width = width < a[i] ? a[i] : width;
        i = i - 1;
      }else if(a[i] == a[i - 1] && width >= height){
        height = height < a[i] ? a[i] : height;
        i = i - 1;
      }
    }
  }
  cout << width * height << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    bool ok=true;
    rep(i,n-1)if(s[i]!=s[i+1]){
        ok=false;
    }
    if (ok){
        cout<<"0\n";
        return 0;
    }
    int ans=101010;
    rep(i,n){
        char c = s[i];
        string t = s;
        bool loop=true;
        int cnt=0;
        while(loop){
            loop=false;
            int m=t.size();
            rep(j,m-1)if(t[j]==c||t[j+1]==c){
                t[j]=c;
            }else{
                loop=true;
            }
            t.pop_back();
            cnt++;
        }
        chmin(ans,cnt);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
   string s;
   cin >> s;
   int n=s.size();
   int root=0;
   bool a=true;
   int cnt=0;
  for(int i=n-1;i>=0;i--){
    if(root==0){
      cnt++;
      if(s.at(i)=='r'){
        
        root=1;
      }
      else if(s.at(i)=='e')root=4;
      else if(s.at(i)=='m')root=5;
      else{
        a=false;
        break;
      }
    }
    else if(root==1){
        cnt++;
        if(cnt==2 && s.at(i)!='e'){
          a=false;
          break;
        }
        else if(cnt==3){
          if(s.at(i)=='s')root=2;
          else if(s.at(i)=='m')root=3;
          else{
            a=false;
            break;
          }
        }
    }
    else if(root==2){
      cnt++;
            if(cnt==4 && s.at(i)=='a');
            else if(cnt==5 && s.at(i)=='r');
            else if(cnt==6 && s.at(i)=='e'){
              root=0;
              cnt=0;
            } 
            else{
            a=false;
            break;
            }
    }
    else if(root==3){
      cnt++;
            if(cnt==4 && s.at(i)=='a');
            else if(cnt==5 && s.at(i)=='e');
            else if(cnt==6 && s.at(i)=='r');
            else if(cnt==7 && s.at(i)=='d'){
              root=0;
              cnt=0;
            }
            else{
              a=false;
              break;
            }
    }
    else if(root==4){
      cnt++;
            if(cnt==2 && s.at(i)=='s');
            else if(cnt==3 && s.at(i)=='a');
            else if(cnt==4 && s.at(i)=='r');
            else if(cnt==5 && s.at(i)=='e'){
              root=0;
              cnt=0;
            }
            else{
              a=false;
              break;
            }
    }
    else if(root==5){
      cnt++;
            if(cnt==2 && s.at(i)=='a');
            else if(cnt==3 && s.at(i)=='e');
            else if(cnt==4 && s.at(i)=='r');
            else if(cnt==5 && s.at(i)=='d'){
              root=0;
              cnt=0;
            }
            else{
              a=false;
              break;
            }
    }
  }
  if(a)cout << "YES" << endl;
  else cout << "NO" << endl;
}



    
   


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c;cin>>a>>b>>c;
  int m=max(max(a,b),c)*3;
  int res=m-a-b-c;

  if(res%2==0)out(res/2)
  else out((res+3)/2)

  return 0;
}


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

int main() {
	int n,k; cin>>n>>k;
	vector<int> heights(n);

	for (int i=0; i<n; i++)
		cin>>heights[i];
	sort(heights.begin(),heights.end());

	int min=heights[k] - heights[0];
	for (int i=0; i<n-k+1; i++) {
		if (heights[i+k-1] - heights[i] < min)
			min = heights[i+k-1] - heights[i];
	}

	cout << min << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest
{
    public class Program
    {
        static long H;
        static long W;
        static long s;

        public static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            if(HW[0]>HW[1])
            {
                H = HW[0];
                W = HW[1];
            }
            else
            {
                H = HW[1];
                W = HW[0];
            }
            s = H * W;

            // ３分割できるとき
            if(H%3== 0 || W%3==0)
            {
                Console.WriteLine(0);
                return;
            }

            // できないとき
            // a1の高さがHのとき（左の四角）
            for (long i = 1; i < W; i++)
            {
                long a1 = H * i;
                long a2 = (long)(H / 2) * (W -i);
                long a3 = H * W - a1 - a2;
                var sw = Math.Abs(a1 - a2);
                if (sw < Math.Abs(a1 - a3)) sw = Math.Abs(a1 - a3);
                if (sw < Math.Abs(a2 - a3)) sw = Math.Abs(a2 - a3);
                if (s > sw) s = sw;
            }
            for (long i = 1; i < W; i++)
            {
                long a1 = H * i;
                long a2 = (long)((W-i) / 2) * H;
                long a3 = H * W - a1 - a2;
                var sw = Math.Abs(a1 - a2);
                if (sw < Math.Abs(a1 - a3)) sw = Math.Abs(a1 - a3);
                if (sw < Math.Abs(a2 - a3)) sw = Math.Abs(a2 - a3);
                if (s > sw) s = sw;
            }
            // a2の幅がWのとき（上の四角）
            for (long i = 1; i < H; i++)
            {
                long a1 = i * W;
                long a2 = (H-i) * (long)(W / 2);
                long a3 = H * W - a1 - a2;
                var sw = Math.Abs(a1 - a2);
                if (sw < Math.Abs(a1 - a3)) sw = Math.Abs(a1 - a3);
                if (sw < Math.Abs(a2 - a3)) sw = Math.Abs(a2 - a3);
                if (s > sw) s = sw;
            }
            for (long i = 1; i < H; i++)
            {
                long a1 = i * W;
                long a2 = (long)((H - i)/2) * W;
                long a3 = H * W - a1 - a2;
                var sw = Math.Abs(a1 - a2);
                if (sw < Math.Abs(a1 - a3)) sw = Math.Abs(a1 - a3);
                if (sw < Math.Abs(a2 - a3)) sw = Math.Abs(a2 - a3);
                if (s > sw) s = sw;
            }
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, T; cin >> N >> T; 
	pair<int, int> A[3010] = {}; 	
	for(int i = 1; i <= N; i++){
		cin >> A[i].first >> A[i].second; 
	}
	sort(A+1, A+N+1); 
	int dp[3010][6010] = {}; // dp[料理iまでを見て][時間jまでに食べきれる] = おいしさmax
	for(int i = 1; i <= N; i++){
		for(int j = T; j < T+3000; j++){
			dp[i][j] = dp[i-1][j]; 
		}
		for(int j = 0; j < T; j++){
			dp[i][j+A[i].first] = max(dp[i][j+A[i].first], dp[i-1][j] + A[i].second); 
			dp[i][j] = max(dp[i][j], dp[i-1][j]); 
		}
	}
	int ans = 0; 
	for(int j = 0; j <= 6000; j++){
		ans = max(ans, dp[N][j]); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    char s[20];
    cin >> n;
    for(int j=0; j<n; j++){
        cin >> s[j];
    }

    cin >> k;

    for(int i=0; i<n; i++){
        if(s[i] == s[k-1]){
            cout << s[i];
        }
        else{
            cout << "*" ;
        }
    }
    cout << endl;
}



Measured memory_bytes: 256
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	V a(n);
	rep(i, 0, n){
		ll t;
		scanf("%ld", &t);
		a[i] = t-i-1;
	}
	std::sort(be(a));
	ll med;
	if(n%2) med = a[n/2];	
	else med = (a[n/2-1]+a[n/2])/2;
	ll ans = 0;
	rep(i, 0, n){
		ans += labs(a[i]-med);
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, M, a;
  std::cin >> N >> M;
  multiset<ll> num;
  for(int i=0;i<N;i++) {
    std::cin >> a;
    num.insert(a);
  }
  for(int i=0;i<M;i++){
    auto itr = num.end();
    itr--;
    ll tmp = *itr;
    num.erase(itr);
    num.insert(tmp/2);
  }
  ll ans = 0;
  auto it = num.begin();
  for(int i=0;i<N;i++){
    ans += *it;
    it++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,d,a;
    cin>>n>>d>>a;
    vl x(n);
    vl h(n);
    vector<pair<LL,LL>> p(n);
    LL ans=0;
    FOR(i,0,n){
        cin>>x[i]>>h[i];
        p[i]=MP(x[i],h[i]);
    }
    sort(p.begin(),p.end());
    p.PB(MP(2LL*mod*mod,0));
    queue<pair<LL,LL>> q;
    LL nw=0;
    FOR(i,0,n){
        while(q.size()){
            auto pr=q.front();
            //cerr<<"pr"<<" "<<pr.ST<<" "<<pr.ND<<endl;
            if(pr.ST<p[i].ST){
                q.pop();
                nw-=pr.ND;
            }else{
                //cerr<<"not pop"<<endl;
                break;
            }
        }
        p[i].ND-=nw;
        if(p[i].ND<=0)continue;
        LL tmp=(p[i].ND+a-1)/a;
        //cerr<<i<<" "<<tmp<<" "<<p[i].ST<<" "<<p[i].ND<<endl;
        ans+=tmp;
        nw+=tmp*a;
        q.push(MP(p[i].ST+2*d,tmp*a));
    }
    cout<<ans;


}


Measured memory_bytes: 11008
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
long long a[1000001];
int cmp(long long x,long long y)
{
	return x>y;
}
long long aa,bb,cc;
int k;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==a[i+1]){
			aa=a[i];
			k=i+2;break;
		}
	}
	for(int i=k;i<=n;i++)
	{
		if(a[i]==a[i+1])
		{
			bb=a[i];
			break;
		}
	}
	cc=aa*bb;
	cout<<cc<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;

    int afrac=(a%10==0?10:a%10);
    int bfrac=(b%10==0?10:b%10);
    int cfrac=(c%10==0?10:c%10);
    int dfrac=(d%10==0?10:d%10);
    int efrac=(e%10==0?10:e%10);

    int frac=min(afrac,min(bfrac,min(cfrac,min(dfrac,efrac))));

    a=ceil((double)a/10)*10;
    b=ceil((double)b/10)*10;
    c=ceil((double)c/10)*10;
    d=ceil((double)d/10)*10;
    e=ceil((double)e/10)*10;

    cout << a+b+c+d+e-(10-frac) << endl;

    return 0;
}


Measured memory_bytes: 3600
N, K = map(int, input().split())
S = input()

p = 0
ans = 0
i = 0
m = 0
while i < N:
    l = 1
    while i + l < N and S[i] == S[i + l]:
        l += 1
    ans += l - 1
    if p >= 2 and m < K:
        ans += 2
        p -= 2
        m += 1
    p += 1
    i += l
if m < K and p >= 2:
    ans += 1
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=30;

int n,tag;
char s[N];
bool vis[N];

int main(){
	int i,j,k;
	scanf("%s",s+1); n=strlen(s+1);
	tag=0;
	if (n==26){
		vis[s[n]-'a']=1;
		for (i=n-1;i>=1;i--){
			for (j=s[i]-'a';j<26;j++)
				if (vis[j]){
					for (k=1;k<i;k++) printf("%c",s[k]);
					printf("%c\n",j+'a');
					return 0;
				}
			vis[s[i]-'a']=1;
		}
		printf("-1\n");
		return 0;
	}
	for (i=1;i<=n;i++) printf("%c",s[i]);
	for (i=1;i<=n;i++) vis[s[i]-'a']=1;
	for (i=0;i<26;i++)
		if (!vis[i]){
			printf("%c\n",i+'a');
			return 0;
		}
	return 0;
}

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

int main() {

  string s;
  cin >> s;
  int t = 0;

  for(int i=0; i<4; i++) {
    s[i] == '+' ? t++ : t--;
  }
  cout << t << endl;
  return 0;
}



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

int main() {
  vector<int> a(3);
  cin >>a.at(0)>>a.at(1)>>a.at(2);
  
  sort(a.begin(),a.end());
  
  cout << a.at(0)<<" "<< a.at(1)<<" "<< a.at(2)<<endl;
}



Measured memory_bytes: 3096