akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define pll pair<ll,ll>
#define vll vector<ll>
#define forn(i,n) for(ll i=0; i<n; ++i)
#define pb push_back
#define MOD 1000000007
#define range(c) c.begin() , c.end()
#define Print(a) for(auto it : a)cout << (it) <<" ";cout << endl;
#define test ll t;cin >> (t);while(t--)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : ";cout << arg1 <<" ";}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : ";
cout << arg1 <<" ";cout << " | ";__f(comma + 1, args...);}
char local ='O';
#define db(...) if(local=='L') {__f(#__VA_ARGS__, __VA_ARGS__); cout<<endl;}
//////////////////////////////////////////////////////////////
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
	local = 'L';
#endif

	ll n,x,t;
	cin >> n >> x >> t;
	ll nx = ceil(n*1.0/x);
	cout << nx * t ;
}

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

int main(void) {
	long long N;
	long long ans = 1e12;
	scanf("%lld", &N);
	for (long long i = 1; i <= N/2; i++) {
		long long j = N / i;
		if (i > j) {
			break;
		}
		if (N % i != 0) {
			continue;
		}
		ans = min(ans, (i - 1) + (j - 1));
	}
	printf("%lld", ans);

	return 0;
}


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

//create arrays outside of main()

int a[5];

int main(){

    bool can = false;

    for(int j=0; j<5; j++){
        cin >> a[j];
    }

    int k;
    cin >> k;

    int length;
    for(int i=0; i<4; i++){
        length = a[i+1] - a[0];
        if(length>k){
            can = false;
        } else {
            can = true;
        }
    }

    if(can == true){
        cout << "Yay!";
    } else {
        cout << ":(";
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class PG{
    static void Main(string[] args){
        int[] n=new int[2];
        int i=1;
        while(true){
            n=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(n[0]==0&&n[1]==0){
                break;
            }else if(n[0]>n[1]){
                Console.WriteLine("{0} {1}",n[1],n[0]);
            }else{
                Console.WriteLine("{0} {1}",n[0],n[1]);
            }
        }
    }
}


Measured memory_bytes: 16328
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 負数の剰余演算を避けるため一時的に0以上の整数にしています
print(-sum(a))

Measured memory_bytes: 20464
#include <iostream>
using namespace std;
int main(void){
    int array[200010];
    int n;
    int i, j;
    long long max, min;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> array[i];
    }
    max = -10000000000;
    min = array[0];

    for(i = 1; i < n; i++){
        //max?????´??°
        if(array[i] - min > max){
            max = array[i] - min;
        }

        //min?????´??°
        if(array[i] < min){
            min = array[i];
        }
    }
    cout << max << endl;
    return 0;
}

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

int num[101][101];
int dist[101][101];
#define INF 100000000

class state{
public:
	int now,money,cost;
	state(int now,int money,int cost):now(now),cost(cost),money(money){}
	bool operator < (const state &a){
		return cost>a.cost;
	}
};

bool operator < (state a,state b){
	return a.cost>b.cost;
}

int main()
{
	int n,m,l;
	while(cin>>n>>m>>l && n!=0){

		int C[101][101];
		for(int i=0;i<101;i++)
			for(int j=0;j<101;j++)
				num[i][j]=dist[i][j]=C[i][j]=INF;

		for(int i=0;i<m;i++){
			int in,out,d,e;cin>>in>>out>>d>>e;
			num[in][out]=num[out][in]=e;
			dist[in][out]=dist[out][in]=d;
		}

		priority_queue<state> Q;
		Q.push(state(1,l,0));
		while(!Q.empty()){
			state t=Q.top(); Q.pop();
			if(C[t.now][t.money]<=t.cost) continue;
			C[t.now][t.money]=t.cost;
			if(t.now==n){cout<<t.cost<<endl; break;}
			for(int i=1;i<=n;i++){
				if(dist[t.now][i]<INF){
					if(t.money-dist[t.now][i]>=0)
						Q.push(state(i,t.money-dist[t.now][i],t.cost));
					Q.push(state(i,t.money,t.cost+num[t.now][i]));
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
N, A, B, C = map(int, input().split())
MOD = 10**9+7
fact_list = [1]
for i in range(1, 2*N):
    fact_list.append(fact_list[-1]*i % MOD)
def div_mod(x, MOD=MOD):
    return pow(x, MOD-2, MOD)
def comb(n, r, MOD=MOD):
    ret = fact_list[n]*div_mod(fact_list[n-r])*div_mod(fact_list[r])
    return ret % MOD
ans = 0
for M in range(N, 2*N):
    temp = (((pow(A, N, MOD)*pow(B, M-N, MOD))% MOD) 
            + ((pow(A, M-N, MOD)*pow(B, N, MOD)) % MOD)) % MOD
    bunshi = (comb(M-1, N-1)*temp*M*100) % MOD
    ans += (bunshi*div_mod(pow(100-C, M+1, MOD))) % MOD
    ans = ans %MOD
print(ans)

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

const int T[] = {-1, 6000, 4000, 3000, 2000};

int main()
{
	for (int i = 0; i < 4; i++){
		int t, n;
		cin >> t >> n;
		cout << T[t] * n << endl;
	}
	
	return 0;
}

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



int main() {
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> v;
	for (int i = 0;i < n;i++) {
		int x;
		cin >> x;
		v.push_back(x);

	}
	vector<int> dp(v.size(), 1e9);
	dp[0] = 0;
	for (int i = 0;i < v.size();i++) {
		for (int j = i + 1;j <=i+k;j++)
		{
			if (j < v.size()) {
				dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
			}
		}

	}
	cout<< dp[v.size() - 1];

}

Measured memory_bytes: 1144
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s, t;
    cin >> s >> t;

    sort(all(s));
    sort(rall(t));

    if(s < t) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 636
'use strict';

function Main(INPUT) {
    const input = INPUT.split("\n").map(n => Number(n));
    if (input[0] == 1) {
        console.log("Hello World");
    } else {
        console.log(input[1] + input[2]);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll N,T[1000],M,P[1000],X[1000],sum=0;
	cin>>N;
	reg(i,1,N){
		cin>>T[i];
		sum+=T[i];
	}
	cin>>M;
	rep(i,M)cin>>P[i]>>X[i];
	rep(i,M)cout<<sum+X[i]-T[P[i]]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    a.push_back(a[N-1]+100);
    vector<int> nums;
    nums.push_back(0);
    nums.push_back(0);
    nums.push_back(0);
    int ans=0,cnt=0;
    for(int i=a[0]; i<=a[N-1]; i++){
        int tmp=0;
        while(a[cnt+tmp]==i)tmp++;
        cnt+=tmp;
        nums.push_back(tmp);
        ans=max(nums[3+i-a[0]]+nums[2+i-a[0]]+nums[1+i-a[0]], ans);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1528
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }

int main(){
	for(int n;scanf("%d",&n),n;){
		static ll b[32000];
		int m=n*(n+1)/2;
		rep(i,m) scanf("%lld",b+i);

		int n_ev=0,n_od=0;
		static ll b_ev[250],b_od[32000];
		rep(i,m){
			if(b[i]%2==0) b_ev[n_ev++]=b[i];
			else          b_od[n_od++]=b[i];
		}

		sort(b_ev,b_ev+n_ev);
		sort(b_od,b_od+n_od);

		vector<ll> a0_cand;
		rep(j,n_ev) rep(i,j) {
			ll x=b_ev[i],y=b_ev[j],z=b_od[0],g;
			g=gcd(x,z); x/=g; z/=g;
			g=gcd(y,z); y/=g; z/=g;
			if(z==1){
				ll a0=(ll)(sqrt(x)*sqrt(y)+0.5);
				for(ll t=max(a0-7,2LL);t<=a0+7;t++){
					if(t%2==0 && t*t==x*y) a0_cand.push_back(t);
				}
			}
		}

		ll a0;
		static ll a_od[250];
		rep(i,a0_cand.size()){
			a0=a0_cand[i];

			rep(j,n) a_od[j]=b_ev[j]/a0;

			int n_od2=0;
			static ll b_od2[32000];
			rep(k,n_ev) rep(j,k) b_od2[n_od2++]=a_od[j]*a_od[k];
			sort(b_od2,b_od2+n_od2);

			bool ok=true;
			rep(j,n_od) if(b_od[j]!=b_od2[j]) { ok=false; break; }
			if(ok) break;
		}

		printf("%lld\n",a0);
		rep(i,n_ev) printf("%lld%c",a_od[i],i<n_ev-1?' ':'\n');
	}

	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int l, r;
    int a,b,c,d;
    cin >> a >> b >> c >> d;


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

}

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

#define ll long long
#define endl "\n"

int main(){
	ll n, w; cin>>n>>w;
	vector<pair<ll, ll>> v(n);
	for(auto &i : v){
		cin>>i.first>>i.second;
	}
	vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
	for(int i = 1; i<=n; i++){
		for(int j = 1; j <= w; j++){
			if(j - v[i-1].first >= 0){
				dp[i][j] = max(dp[i-1][j], v[i-1].second + dp[i-1][j-v[i-1].first]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int A,B,C,D,k;

inline bool check(int mid)
{
	int a=A-mid/(k+1)*k-mid%(k+1);
	int b=B-mid/(k+1);
	return b<=1LL*a*k;
}

int main()
{
	int T=read();
	while (T--)
	{
		A=read(),B=read(),C=read(),D=read();
		k=max(ceil(1.0*A/(B+1)),ceil(1.0*B/(A+1)));
		int left=0,right=A+B+1;
		while (left<right)
		{
			int mid=(left+right)>>1;
			if (check(mid))
				left=mid+1;
			else
				right=mid;
		}
		int a=A-left/(k+1)*k-left%(k+1);
		int b=B-left/(k+1);
		right=left+b-a*k+1;
		for (int i=C;i<=min(D,left);i++)
		{
			if (i%(k+1))
				cout << 'A';
			else
				cout << 'B';
		}
		for (int i=max(C,left+1);i<=D;i++)
		{
			if ((i-right)%(k+1))
				cout << 'B';
			else
				cout << 'A';
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;



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

const int mod = 1e+9 + 7;

typedef long long ll;

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

  string str;
  cin >> str;
  cout << str.substr(0,str.size()-8) << endl;
 
  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
m_list = [int(input()) for i in range(N)]

donatu = 0

# とりあえずm_listの合計をXから引く
sum_m_list = sum(m_list)
X_nokori = X - sum_m_list
donatu += N

# その後m_listの最小値と残ったXで割り算
donatu = donatu + X_nokori // min(m_list)

print(donatu)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortbysec_2(const pair<string,int> &a, 
              const pair<string,int> &b) 
{ 
    return (a.second < b.second); 
} 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
double distance(int x1, int y1, int x2, int y2) 
{ 
    return sqrt(pow(x2 - x1, 2) +  
                pow(y2 - y1, 2) * 1.0); 
} 
#define ll long long int
#define ld long double
#define f first
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll64 int64_t
#define pb push_back
#define pll pair<long long int,long long int>
#define pi pair<int,int>
#define mi map<int,int>
#define mll map<long long int,long long int>
#define umi unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long int,long long int>>
#define mod 1000000007
#define fp(i,x,n) for(int i=x;i<n;i++)
#define fn(i,x,n) for(int i=x;i>n;i--)
#define fpm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define asort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysec)
#define asort_vp_first(vect) sort(vect.begin(), vect.end())
#define dsort_vp_first(vect) sort(vect.begin(), vect.end(), sortinrev) 
#define dsort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysecdesc)
#define vi vector<int>
#define vld vector<long double>
#define asort(v) sort(v.begin(),v.end())
#define dsort(v) sort(v.begin(),v.end(),greater<int>())
#define dsort_ll(v) sort(v.begin(),v.end(),greater<long long int>())
#define dsort_ld(v) sort(v.begin(),v.end(),greater<long double>())
#define vll vector<long long int>
#define mp(a,b) make_pair(a,b)

int main() {
    FIO;
   string s;
   cin>>s;
   int n = s.size();
   
   int suf=0;
   int power =1;
   vector<int> v(2019);
   v[suf]++;
   long long ans=0;
   for(int i=n-1;i>=0;i--)
   {
       int digit = s[i] -'0';
       suf = (suf + digit*power)%2019;
       power = power*10 %2019;
       ans+=v[suf];
       v[suf]++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3712
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> a;
    a.resize(n);
    rep(i,n)cin>>a[i];
    int ans=x;
    d--;
    rep(i,n){
        ans+=1+(d/a[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
signed main(){
  int a,b,e=0,f=0,g=0;
  cin>>a>>b;
  vector<int> c(a+1,0),d(b+2,10000000000000);
  fo(i,b)
  cin>>d[i];
  c[0]=1;
  for(int i=0;i<a;i++){
    int t=c[i];
   // cout<<t<<' ';
    if(i==d[g]){
      g++;
      continue;
    }
   // cout<<t<<' ';
    if(i+1==d[g])
      e=1;
    if(i+2==d[g])
      f=1;
    if(i+2==d[g+1])
      f=2;
   // cout<<t<<' ';
    if(e==1&&f==2){
      c[a]=0;
      break;
    }
  //  cout<<t<<' ';
    if(e==0&&i+1<a+1){
      c[i+1]+=t;
      c[i+1]=c[i+1]%1000000007;
    }
    if(f!=1&&i+2<a+1){
      c[i+2]+=t;
      c[i+2]=c[i+2]%1000000007;
    }
    e=0;
    f=0;
  //  cout<<c[i]<<' ';
   }
   cout<<c[a]<<endl;
 }


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;
int n;
int h;
int f[100005] = { 0 };
priority_queue<int>V;
int main()
{
	cin >> n >> h;
	int M = 0;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		f[i] = a;
		if (M < a)M = a;
		V.push(b);
	}
	int ans = 0;
	while (V.top()>M&&h>0) {
		ans++;
		h -= V.top();
		V.pop();
		if (V.empty())break;
	}
	if (h > 0) {
		ans += (h / M);
		h -= M * (h / M);
	}
	if (h > 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 1148
N = int(input())
A = [int(x) for x in input().split()]
S = [0] * (N+1)      #累積和用のリスト
s = 0
CONST = 10**9+7

#前準備として累積和を計算
for i in range(N):
    S[i+1] = S[i] + A[i]

#積の総和を計算
for i in range(N-1):
    s += A[i] * ((S[N] - S[i+1]) % CONST)
    s %= CONST

print(s)

Measured memory_bytes: 31432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str_List = Console.ReadLine().Split(' ');
            var list = new List<int>();
            foreach (string str in str_List)
            {
                list.Add(int.Parse(str));
            }
            list.Sort();


            Console.Write(list[0]);
            Console.Write(" ");
            Console.Write(list[1]);
            Console.Write(" ");
            Console.WriteLine(list[2]);


            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
#define N 100001
#define MAX 1500000000

int ans[N] ;

int main() {
    int n, k;

    cin >> n >> k;

    int a[n];

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

    ans[0] = 0;

    ans[1] = abs(a[0] - a[1]);

    for (int i = 2;i < n;i++) {

        for (int j = 1;j <= min(i, k);j++) {
            ans[i] = min((ans[i - j] + abs(a[i] - a[i - j])), ans[i]);
        }

    }

    cout << ans[n - 1];

}

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

int main(){
  int h,w;
  cin >> h >> w;
  string s;
  rep(i,h){
    cin >> s;
    cout << s << endl;
    cout << s << endl;
    s = "";
  }
  return 0;
}


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

int main(){
  long long N,a,b,c,d,e;
  cin>>N>>a>>b>>c>>d>>e;
  cout<<max({(N-1)/a,(N-1)/b,(N-1)/c,(N-1)/d,(N-1)/e})+5<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);


    int num1 = (l-1) / d;
    int num2 = r / d;

    printf("%d", num2 - num1);

    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int A[3];
int idx[3] = {0, 1, 2};

signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  REP(i,3) cin >> A[i];

  int ans = INF;
  do {
    ans = min(ans, abs(A[idx[1]] - A[idx[0]]) + abs(A[idx[2]] - A[idx[1]]));
  } while (next_permutation(idx, idx + 3));

  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$result['P'] = 0;
$result['W'] = 0;
$result['G'] = 0;
$result['Y'] = 0;
$arare_arr = explode(' ', trim(fgets(STDIN)));
foreach($arare_arr as $val) {
    $result[$val] = 1;
}
//var_dump($result);
echo (array_sum($result) == 3) ? 'Three' : 'Four';

Measured memory_bytes: 4856
#include <stdio.h>

int main(){

  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  int num = 0;
  for(int i=a;i<b+1;i++){
    if(c%i == 0) num++;
  }

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

  return 0;
}


Measured memory_bytes: 2760
A,B,C,X,Y = list(map(int, input().split()))
max_C = max(X,Y)*2
min_amount = 99999999999
#print("max_C : {}".format(max_C))
for num_C in range(max_C + 1):
  #print(num_C)
  if num_C % 2 == 0:
    num_A = max(0, X - 0.5*num_C)
    num_B = max(0, Y - 0.5*num_C)
    #print("A:{0}, B:{1}, C:{2}".format(num_A,num_B,num_C))
    
    total = A*num_A + B*num_B + C*num_C
    #print("total : {0}".format(total))
    if total < min_amount:
      min_amount = total

print(int(min_amount))

Measured memory_bytes: 3064
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        char C;
        C = sc.nextChar();
        solve(C);
    }

    static void solve(char C){
        System.out.println((char)((int)C+1));
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    for(int i=0;i<s.size();i++){
        int tmp=(s[i]-'A')+N;
        if(tmp>'Z'-'A') tmp-=26;
        s[i]='A'+tmp;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
N=int(input())
A=input()
allcards=A.split()
for i in range (len(allcards)):
    allcards[i]=int(allcards[i])
allcards.sort()
alice=[]
bob=[]
alicet=True
bobt=False

for a in allcards:
    if alicet == True :
        alice.append(a)
        alicet=False
        bobt=True
    elif bobt == True:
        bob.append(a)
        bobt=False
        alicet=True

alicesum=sum(alice)
bobsum=sum(bob)

if alicesum - bobsum > 0 :
    print(alicesum - bobsum)
else :
    print(bobsum - alicesum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  if(N%10==7){
      cout<<"Yes"<<endl;
  }else if((N%100-N%10)==70){
      cout<<"Yes"<<endl;
  }else if((N%1000-N%100)==700){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
 
}




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

#define ntest 0

using namespace std;
int n;
int d[105][2];
void solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> d[i][0] >> d[i][1];
    for (int i = 1; i <= n - 2; ++i)
    {
        int ok = 1;
        for (int j = i; j <= i + 2; ++j)
        {
            if (d[j][0] != d[j][1]) ok = 0;
        }
        if (ok)
        {
            cout << "Yes\n";
            return;
        }
    }

    cout << "No\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    if(ntest)
    {
        int t;
        cin >> t;
        while(t--) solve();
    }
    else
    {
        solve();
    }

}




Measured memory_bytes: 3648
//written by NewbieChd
#include <cstdio>
#include <cctype>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003;
int f[maxN];
inline int find(int x) {
    int r = x, y;
    while (f[r] != r)
        r = f[r];
    while (x != r)
        y = f[x], f[x] = r, x = y;
    return r;
}

bool vis[maxN];

int main() {
    int n = read(), m = read(), i, x, y, z, ans = 0;
    for (i = 1; i <= n; ++i)
        f[i] = i;
    for (i = 1; i <= m; ++i) {
        x = find(read()), y = find(read()), z = read();
        if (x != y)
            f[x] = y;
    }
    for (i = 1; i <= n; ++i) {
        x = find(i);
        if (!vis[x])
            vis[x] = 1, ++ans;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  string ans = "No";
  if (A % 2 == 1 && B % 2 == 1)
    ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int x, y;
	cin >> x >> y;
	ll ans;
	if(x>=0)
	{
		if(x<=y) ans=y-x;
		else if(x+y>=0)
		{
			if(y<=0) ans=1+x+y;
			else ans=2+x-y;
		}
		else ans=1-x-y;
	}
	else
	{
		if(y>0)
		{
			if(x+y>=0) ans=1+x+y;
			else ans=1-x-y;
		}
		else
		{
			if(x<=y) ans=y-x;
			else ans=x-y+2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef unsigned long long uint64;
typedef vector<uint64> VI;
typedef vector<VI> Matrix;

void readMatrix(Matrix &mat, const int &row, const int &column)
{
    for(int r = 0; r < row; r++)
    {
        for(int c = 0; c < column; c++)
        {
            cin >> mat[r][c];
        }
    }
}

void multipleMatrix(const Matrix &matA, const Matrix &matB, Matrix &matC)
{
    size_t l = matA.size();
    size_t m = matB.size();
    size_t n = matB[0].size();

    for(size_t r = 0; r < l; r++)
    {
        for(size_t c = 0; c < n; c++)
        {
            uint64 tmp = 0;
            for(size_t i = 0; i < m; i++)
            {
                tmp += matA[r][i] * matB[i][c];
            }
            matC[r][c] = tmp;
        }
    }
}

void outputMatrix(const Matrix &mat)
{
    size_t r = mat.size();
    size_t c = mat[0].size();

    for(size_t i = 0; i < r; i++)
    {
        for(size_t j = 0; j < c; j++)
        {
            cout << mat[i][j];
            if(j != c - 1){ cout << " "; }
        }
        cout << "\n";
    }

}

int main()
{
    int l = 0, m = 0, n =0;
    cin >> n >> m >> l;

    Matrix matA(n, VI(m, 0));
    Matrix matB(m, VI(l, 0));
    Matrix matC(n, VI(l, 0));

    //Read matA, matB
    readMatrix(matA, n, m);
    readMatrix(matB, m, l);

    multipleMatrix(matA, matB, matC);

    outputMatrix(matC);

    return 0;
}

Measured memory_bytes: 3200
package main

import (
	"fmt"
)

func main()  {
	var R int
	_,_ = fmt.Scan(&R)
	if R < 1200 {
		fmt.Println("ABC")
	} else if R < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		for (int i=0;i<=A;i++) {
			if ((N-i)%500==0) {
				System.out.println("Yes");
				return ;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23892
# E - Knapsack 2
def knapsack_heavy(weight_limit: int, weights: list, values: list) -> int:
    max_value = sum(values)
    dp = [0] + [1 << 30] * max_value  # dp[i] := minimum weight at value i
    for w, v in zip(weights, values):
        for cur_v in range(max_value, v - 1, -1):
            if dp[cur_v - v] + w < dp[cur_v]:
                dp[cur_v] = dp[cur_v - v] + w
    return max(v for v, w in enumerate(dp) if w <= weight_limit)


def main():
    N, W, *WV = map(int, open(0).read().split())
    print(knapsack_heavy(W, WV[::2], WV[1::2]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 40176
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
// const ll mod = 1000000007;

// --------------------------------------
#include <cassert>
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 998244353;
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

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

  cin >> n;
  vector<int> a(n + 5, -1);
  int l, r;
  REP(i, n + 1) {
    int t;
    cin >> t;
    if(a[t] != -1) l = a[t], r = i + 1;
    else a[t] = i + 1;
  }

  FOR(i, 1, n + 2) {
    cout << c(n + 1, i) - c(l + n - r, i - 1) << endl;
  }
}


Measured memory_bytes: 4736
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

ll a[100000];
ll b[100000];
int main(){
  ll N;
  cin >> N;
  rep(i, N){
    cin >> a[i] >> b[i];
  }
  reverse(a, a + N);
  reverse(b, b + N);

  ll sum = 0;
  ll ans = 0;
  rep(i, N){
    ll A = a[i] + sum;
    ll B = b[i];
    if(A % B){
      ll C = B - A % B;
      sum += C;
      ans += C;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

  vector<string> l(3);
  rep(i, 3) cin >> l[i];

  int next = 0;
  while (true) {
    string s = l[next];
    if (s.size() == 0) {
      printf("%c", 'A'+next);
      return 0;
    }
    l[next] = s.substr(1, s.size()-1);
    next = s[0]-'a';
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RANGE(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RANGE3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) {if((a)<(b))(a)=(b);}
#define MINI(a,b) {if((a)>(b))(a)=(b);}

int main(){
	int n, m, *a, *b;
	std::bitset<220000> once, twice;
	scanf("%d%d", &n, &m);
	a = (int *)malloc(sizeof(int) * m);
	b = (int *)malloc(sizeof(int) * m);
	REP(i, m) scanf("%d%d", a + i, b + i);
	REP(i, m) if(a[i] == 1) once[b[i] - 1]  = 1;
	REP(i, m) if(once[a[i] - 1]) twice[b[i] - 1] = 1;
	if(twice[n - 1]) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n), bs(n);
    bool same = true;
    ll ans = 0, mini = M, acc = 0;
    for(int i = 0; i < n; i++){
        cin >> as[i] >> bs[i];
        acc += as[i];
        same &= as[i] == bs[i];
        if(as[i] < bs[i]){
            ans += bs[i];
        }else if(as[i] > bs[i]){
            mini = min(mini, bs[i]);
        }
    }
    if(same){
        cout << 0 << '\n';
        return 0;
    }
    ans = max(ans, acc - mini);
    cout << ans << '\n';
}


Measured memory_bytes: 640
import math
A, B, H, M = map(int,input().split())

h_degree = 30 * (H % 12 + M / 60)
m_degree = M * 6


dif_degree = abs(h_degree - m_degree)
if dif_degree >= 180:
    degree = 360 - dif_degree
else:
    degree = dif_degree

ans = math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(degree)))
print(ans)

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

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP(a,b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
const int mod =1e9+7;
int h[100005];
int n,k;
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>k;
    for(int i=0;i<n;++i) cin>>h[i];
    vector<int> dp(n,1000000005);
    dp[0]=0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<=i+k;++j)
        {
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
b=[0]*26
for aa in a:
  for ai in aa:
    b[ord(ai)-97]+=1

x=(h//2)*(w//2)
y=(h%2)*(w//2)+(h//2)*(w%2)
z=(h%2)*(w%2)

for bb in b:
  t=bb
  while x and t>3:
    x-=1
    t-=4
  while y and t>1:
    y-=1
    t-=2
  z-=t
if not(x==y==z==0):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<deque>
using namespace std;

int main()
{

	string S;
	cin >> S;

	int front = 0, back = S.size() - 1;
	int count = 0;

	while (front < back - front)
	{
		if (S[front] != S[back - front]) {
			count++;
		}

		front++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int count=0,x,y,z;
	
	scanf("%d %d %d",&x,&y,&z);
	for(int i=x;i<=y;i++){
		if((z%i)==0){
			count++;
		}
	}
	printf("%d\n",count);
return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	map<int, int> m;
	forn(i, n) {
		int x;
		cin >> x;
		m[x] = i;
	}
	for(auto i : m) {
		cout << i.se+1 << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 8280
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
  int i,x,n;
  cin>>x>>n;
  vector<int>vec;
  for(i=0; i<n; i++)
  {
    int v;
    cin>>v;
    vec.push_back(v);
  }
  sort(vec.begin(),vec.end());
  int ans=-1,min1=100000000;
  for(i=x-101; i<=101+x; i++)
  {
    int pos1=lower_bound(vec.begin(),vec.end(),i)-vec.begin();
    int pos2=upper_bound(vec.begin(),vec.end(),i)-vec.begin();
    if(pos2-pos1!=1)
    {
      if(abs(i-x)<min1)
      {
        min1=abs(i-x);
        ans=i;
      }
    }
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	using LL = long long; 
	struct node
	{
		LL d;
		int l, r;
		node(LL d):d(d) { l = r = -1; }
	};

	int N;
	LL L;
	cin >> N >> L;
	vector<node>v;
	v.push_back(node(0));
	for( int n = 0; n < N; n++ )
	{
		int now = 0;
		string s;
		cin >> s;

		for( int i = 0; i < s.length(); i++ )
		{
			if( s[i] == '0' )
			{
				if( v[now].l != -1 )
				{
					now = v[now].l;
				}
				else
				{
					v[now].l = v.size();
					v.push_back(node(v[now].d + 1));
					now = v[now].l;
				}
			}
			else
			{
				if( v[now].r != -1 )
				{
					now = v[now].r;
				}
				else
				{
					v[now].r = v.size();
					v.push_back(node(v[now].d + 1));
					now = v[now].r;
				}
			}
		}
	}

	LL ans = 0;
	for( auto i : v )
	{
		if( i.l == -1 && i.r == -1 ) 
			continue;

		if( i.l == -1 || i.r == -1 ) 
			ans ^= (L - i.d)&(i.d - L);
	}

	if( ans ) 
		cout << "Alice" << endl;
	else
		cout << "Bob" << endl;
}

Measured memory_bytes: 2548
import math

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    ar =  30 * a[2] + (a[3] /2)
    br = 6 *a[3]

    ax = a[0]* math.sin(math.radians(ar))
    ay = a[0]* math.cos(math.radians(ar))
    bx = a[1]* math.sin(math.radians(br))
    by = a[1]* math.cos(math.radians(br))

    length = abs(ax-bx)*abs(ax-bx)+abs(ay-by)*abs(ay-by)

    print(math.sqrt(length))


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

void solve(){
  int n, p; cin >> n >> p;
  long long int ans = 0;
  if(p == 2 || p == 5){
    vector<int> v(n);
    for(int i = 0; i < n; i++){
      char c; cin >> c;
      int x = c - 48;
      v[i] = x;
    }
    for(int i = v.size() - 1; i >= 0; i--){
      if(v[i] % p == 0) ans += i + 1;
    }
  }
  else{
    vector<int> v(n);
    vector<int> v2(n + 1, 0);
    int ten = 1;
    string s; cin >> s;
    for(int i = n - 1; i >= 0; --i){
      int x = s[i] - '0';
      v[i] = x;
      v2[i] = x * ten % p;
      ten *= 10;
      ten %= p;
    }
    //for(int i = 0; i < v2.size(); i++) cout << v2[i] % p; cout << endl;
    for(int i = v2.size() - 2; i >= 0; --i){
      v2[i] += v2[i + 1] % p;
    }
    //for(int i = 0; i < v2.size(); i++) cout << v2[i] % p; cout << endl;
    vector<long long int> a(p, 0);
    for(int i = 0; i < v2.size(); i++){
      a[v2[i] % p]++;
    }
    for(int i = 0; i < a.size(); i++){
      ans += a[i] * (a[i] - 1) / 2;
    }
  }
  cout << ans << endl;

  return;
}

void solve2(){
  int n, p; cin >> n >> p;
  string s; cin >> s;
  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  for(int i = 0; i < d.size(); i++) cout << d[i]; cout << endl;
  vector<int> cnt(p);
  long long int ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  //solve2();
  return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n,d,x,a[105];
    scanf("%d",&n);
    scanf("%d%d",&d,&x);
    int sum=0;
    for (int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        int k=0;
        while ((1+k*a[i])<=d) { sum++; k++; }
    }
    printf("%d\n",sum+x);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const ll mod = 10000000000007;
ll m, k;
string s;
vector<int> road[2010], vec;
bool flag[2010], res;
map<P, int> mp;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

ll gcd(ll x, ll y)
{
	if (y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}

int main(void)
{
	cin >> m >> k;
	if (m == 0)
	{
		if (k == 0)
		{
			cout << "0 0" << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	else if (m == 1)
	{
		if (k == 0)
		{
			cout << "0 0 1 1" << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	else
	{
		if (pow(2, m) > k)
		{
			for (int i = 0; i < pow(2, m); i++)
			{
				if (i == k) continue;
				cout << i << ' ';
			}
			cout << k << ' ';
			for (int i = pow(2, m) - 1; i >= 0; i--)
			{
				if (i == k) continue;
				cout << i << ' ';
			}
			cout << k << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	int www;
	cin >> www;
}


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



int main(){
     double w, h, x, y;
     cin >> w >> h >> x >> y;
     cout << w*h / 2 << " ";
     if(x == w / 2 && y == h / 2) cout << 1 << endl;
     else cout << 0 << endl;

}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<long long int> p;
    vector<long long int> m;
    p.push_back(0);
    m.push_back(0);
    for(int n=0; n<N; n++) {
        long long int x;
        cin >> x;
        if(x<0) {
            m.push_back(abs(x));
        } else {
            p.push_back(x);
        }
    }
    
    sort(m.begin(), m.end());
    
    long long int ans=1e9*1e9;
    for(int i=0; i<p.size(); i++) {
        if(K-i<m.size()) {
            ans = min(ans, p[i]+m[K-i]*2);
            ans = min(ans, p[i]*2+m[K-i]);
        }
    }
    
    cout << ans << endl;

    return 0;
    
}

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

int main(){
  
  string toping;
  
  cin >> toping;
  
  int count = 0;
  
  if(toping.at(0) == 'o')	count++;
  if(toping.at(1) == 'o')	count++;
  if(toping.at(2) == 'o')	count++;
  
  cout << 700 + count * 100 << endl;
  
}

Measured memory_bytes: 256