akhauriyash/Code-Regression huggingface dataset:
<?php

for($i=0;$i<5;$i++){
    $array[$i] = trim(fgets(STDIN));
}

$time = 0;
$min = 10;
$num = 0;
$x = 0;

for($i=0;$i<5;$i++){
    $x = $array[$i] % 10;
    if($x < $min && $x != 0){
        $min = $x;
        $num = $i;
    }
}

$tmp = $array[4];
$array[4] = $array[$num];
$array[$num] = $tmp;


for($i=0;$i<4;$i++){
    $time += $array[$i];
    while($time % 10 != 0){
        $time++;
    }
}

$time += $array[4];


echo $time;

?>

Measured memory_bytes: 4856
#include<iostream>
#include<string>
using namespace std;
int main(){
  string S;
  int counter=0;
  int max = 0;
  cin >> S;
  for(int i = 0; i < int(S.size()); i++){
    if((S[i] == 'A')||(S[i] == 'C')||(S[i] == 'G')||(S[i] == 'T')){
      counter++;
    }else{
        if(counter > max){
          max = counter;
        }
        counter = 0;
    }
  }
  if(counter > max){
    max = counter;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
N , M = map(int , input().split())

switch_list = [list(map(int , input().split())) for _ in [0]*M]

p=list(map(int , input().split()))
ans = 0

for i in range(1<<N):
    switch_info = list(str(bin(i)[2:]).rjust(N , '0'))
    ramp_data =[]
    for j in range(M):
        count = 0
        for k in switch_list[j][1:]:
            if switch_info[k-1] == '1':
                count +=1
        ramp_data.append(count%2)
    if ramp_data == p:
        ans +=1


print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int h,w,n;cin >> w >> h >> n;
    vector<vector<int>> a(h);
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        a[y].pb(x);
    }
    for (int i = 0; i < h; i++) {
        a[i].pb(w);
        sort(ALL(a[i]));
    }
    int ans = w;
    int x = 0;
    int t = 0;
    int p = 0;
    for (int i = 0; i < h; i++) {
        if(x>=w) break;
        ans = min(ans,a[i][t]);
        p = a[i][t];
        if(i+1<h){
            t = 0;
            x++;
            while(a[i+1][t]<x){
                t++;
            }
            while(a[i+1][t]==x){
                t++;
                x++;
            }
            if(x >= p) break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11392
from sys import exit

H, W = map(int, input().split())
goal = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if goal[i][j] == "#":
            if i + 1 < H and goal[i+1][j] == "#":
                continue
            if i - 1 >= 0 and goal[i-1][j] == "#":
                continue
            if j + 1 < W and goal[i][j+1] == "#":
                continue
            if j - 1 >= 0 and goal[i][j-1] == "#":
                continue
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 39024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const ll INF = 1e11;
const int MOD = 1e9+7;

ll mi, ma;

ll f = 1;

void dfs(int v, vector<ll> &g, vector<vector<pii> > &path) {
  FOR(e, path[v]) {
    int right = (*e).first, d = (*e).second;
    if(g[right] == INF) {
      g[right] = g[v] + d;
      mi = min(mi, g[right]);
      ma = max(ma, g[right]);
      dfs(right, g, path);
    } else {
      if (g[right] - g[v] != d) f = 0;
    }
  }
}

int main(void){
  int n, m;
  cin >> n >> m;

  vector<ll> g(n+1, INF);
  vector<vector<pii> > path(n);

  REP(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    path[r].push_back(pii(l, -d));
    path[l].push_back(pii(r, d));
  }

  REP(i, n) {
    mi = 0LL, ma = 0LL;
    if(g[i] == INF) g[i] = 0L;
    dfs(i, g, path);
    if(ma - mi > 1e9) f = 0;
  }

  cout << (f ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
bool b[110];
int main()
{
	int x,n,a;
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		b[a]=1;
	}
	int curr=0,ans1,ans2;
	bool f1=0,f2=0;
	while(1)
	{
		ans1=x+curr,ans2=x-curr;
		if(b[ans1]==0)
			f1=1;	
		if(b[ans2]==0)
			f2=1;
		if(f1&&f2)
		{
			cout<<min(ans1,ans2);
			return 0;
		}
		if(f1)
		{
			cout<<ans1<<endl;
			return 0;
		}
		if(f2)
		{
			cout<<ans2<<endl;
			return 0;
		}
		curr++;
		f1=0,f2=0;
	}
	return 0;
}


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

int main()
{
    int c[3][3],a,a2[3],a3[3],b[3];
    int ans=0;
    
    for(int i=0;i<3;++i){
        for(int j=0;j<3;++j){
            cin>>c[i][j];
        }
    }
    
        for(int i=0;i<101;++i){
        a=i;
        for(int j=0;j<3;++j){
            b[j] =c[0][j]-a;
            a2[j]=c[1][j]-b[j];
            a3[j]=c[2][j]-b[j];
        }
        if(a2[0]==a2[1] && a2[0]==a2[2] && a3[0]==a3[1] && a3[0]==a3[2]){
            ans=1;
            break;
        }
        }
        if(ans==1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;

//  for(int i=0;i<3;++i){
//    cout<<b[i]<<" "<<a2[i]<<" "<<a3[i]<<endl;
//  }
  
//    cout<<ans<<endl;
}

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

class Point {
  public:
  int idx, x, y;
  double rad;
  Point(int _idx = 0, int _x = 0, int _y = 0) {
    idx = _idx; x = _x; y = _y;
    rad = atan2(x, y);
  }
};

int main() {
  int n; cin >> n;
  vector<int> xs(n), ys(n);
  vector<Point> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i] >> ys[i];
    ps[i] = Point(i, xs[i], ys[i]);
  }

  sort(ps.begin(), ps.end(),
  [](Point const &a, Point const &b) -> bool { return a.rad < b.rad; });

  double ans = 0.0;
  for (int s = 0; s < ps.size(); s++) {
    double px = ps[s].x, py = ps[s].y;
    double tmp = sqrt(px * px + py * py);
    for (int c = 1; c < ps.size(); c++) {
      int e = (s + c) % ps.size();
      px += ps[e].x; py += ps[e].y;
      double next = sqrt(px * px + py * py);
      if (next < tmp) {
        break;
      }
      tmp = next;
    }
    if (ans < tmp) {
      ans = tmp;
    }
  }
  printf("%.10lf\n", ans);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  int n,m;
  cin >> n >> m;
  priority_queue<int> a;
  REP(i,n) {
    int x;
    cin >> x;
    a.push(x);
  }
  REP(i,m) {
    a.push(a.top()/2);
    a.pop();
  }
  LL answer = 0ll;
  REP(i,n) {
    answer += a.top();
    a.pop();
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 892
n, m = list(map(int, input().split()))
if min(n, m) == 1:
    if max(n, m) == 2:
        ans = 2
    elif max(n, m) == 1:
        ans = 1
    else:
        ans = max(n, m) - 2
elif min(n, m) == 2:
    ans = 0
else:
    ans = (n - 2) * (m - 2)
print(ans)


Measured memory_bytes: 3064
from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1; cw-=1; dh-=1; dw-=1
area = [list(input()) for _ in range(h)]
inf = 10**100
dist = [[inf]*w for i in range(h)]

dwalk = [(0, 1), (0, -1), (1, 0), (-1, 0)]

def Dijkstra(ch, cw):
    import heapq
    edgelist = [(0, ch, cw)]
    heapq.heapify(edgelist)
    dist[ch][cw] = 0
    while len(edgelist):
        cost, y, x = heapq.heappop(edgelist)
        if y==dh and x==dw:
            return dist
        if dist[y][x] < cost: continue
        for next_y, next_x in dwalk:
            if 0<=y+next_y<h and 0<=x+next_x<w:
                if area[y+next_y][x+next_x]=='#': continue
                if dist[y+next_y][x+next_x]>cost:
                    dist[y+next_y][x+next_x] = cost
                    heapq.heappush(edgelist, (cost, y+next_y, x+next_x))
        for next_y in range(-2, 3):
            for next_x in range(-2, 3):
                    if 0<=y+next_y<h and 0<=x+next_x<w:
                        if area[y+next_y][x+next_x]=='#': continue
                        if dist[y+next_y][x+next_x]>cost+1:
                            dist[y+next_y][x+next_x] = cost+1
                            heapq.heappush(edgelist, (cost+1, y+next_y, x+next_x))
    return dist

dist = Dijkstra(ch, cw)
if dist[dh][dw] == inf:
    print(-1)
else:
    print(dist[dh][dw])

Measured memory_bytes: 164780
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
  	string s;
  	cin >> s;

  	if(s == "Y"){
  		cout << "Four" << endl;
  		return 0;
  		}
	}
	cout << "Three" << endl;
  
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s; cin >> s;
	vvi cnt(9, vi(9, 0));
	REP(i, n - 1) {
		cnt[s[i] - '0' - 1][s[i + 1] - '0' - 1]++;
	}
	vi p(9);
	REP(i, 9)p[i] = i;
	int ans = INF;
	vi ansp = p;
	do {
		vi x(9), y(9);
		REP(i, 9) {
			x[i] = i / 3;
			y[i] = i % 3;
		}
		int sum = 0;
		REP(i, 9)REP(j, 9) {
			sum += cnt[p[i]][p[j]] * (abs(x[i] - x[j]) + abs(y[i] - y[j]));
		}
		if (chmin(ans, sum))ansp = p;
	} while (next_permutation(ALL(p)));
	REP(i, 3) {
		REP(j, 3) {
			cout << ansp[i * 3 + j]+1;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3284
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var result = 0L;
            for (int a = 1; a <= K; a++)
            {
                for (int b = 1; b <= K; b++)
                {
                    for (int c = 1; c <= K; c++)
                    {
                        var ab = GCD(a, b);
                        var abc = GCD(ab, c);
                        result += abc;
                    }
                }
            }
            Console.WriteLine(result);
        }
        static long GCD(long A, long B)
        {
            if (B > A) return GCD(B, A);
            if (A % B == 0)
            {
                return B;
            }
            else
            {
                return GCD(B, A % B);
            }
        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

const int N = 200005; 
char s[N]; 
int n; 
long long occur[26]; 

int main() {
    #define file "in"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    cin >> s + 1; 
    n = strlen(s + 1); 
    for (int i = 1; i <= n; i++) {
    	occur[s[i] - 'a']++; 
    }
    long long res = 1; 
    for (int c = 0; c < 26; c++) {
    	for (int c2 = c + 1; c2 < 26; c2++) {
    		res += occur[c] * occur[c2]; 
    	}
    }
    cout << res; 
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cntW = 0;
	int cntR = 0;
	for(char x : s){
		if(x=='W') cntW++;
		else if(x=='R') cntR++;
	}
	if(cntW==0 || cntR==0){
		cout<<"0\n";
		return 0;
	}
	vector <int> r,w;
	for(int i=0;i<n;i++){
		if(s[i]=='W') w.push_back(i);
		else if(s[i]=='R') r.push_back(i);
	}
	int ans = 0;
	int i=r.size()-1,j=0;
	while(i>=0 && j<w.size()){
		if(r[i]>w[j]){
			ans++;
			s[r[i]] = 'W';
			s[w[j]] = 'R';
			i--;
			j++;
		}else break;
	}
	if(j<w.size()){
		j = w[j];
		for(int l=j;l<n;l++){
			if(s[l]=='R'){
				ans++;
				s[l] = 'W';
			}
		}
	}
	//cout<<s<<"\n";
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4748
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum , a , b ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>a>>b;
		cout<<(a-2*b>0 ? a-2*b : 0);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            long X = in.nextInt();
            long sum = 0;
            int i = 1;
            for (; sum < X; i++) {
                sum += i;
            }
            System.out.println(i - 1);
        }
    }
}


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

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

    for (char c : s) {
        c += n;
        if (c > 'Z') {
            c -= 26;
        }
        cout << c;
    }

    cout << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int A,B; cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
    return 0;
}

Measured memory_bytes: 3632
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int A,B;
	scanf("%d%d",&A,&B);
	int ans=0;
	for(int i=100;i<=999;i++)
	{
		int n=i*100+i/10%10*10+i/100;
		if(A<=n && n<=B) ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int t;cin>>t;while(t--)
#define clean(x) memset(x,0,sizeof(x))
const lli mod = 1000000007;
const lli maxn = 1e18;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
void solve()
{
    int n,x,t;cin>>n>>x>>t;
    int ans=(n/x)*t + (n%x!=0)*t;
    cout<<ans<<endl;
}
int main()
{
    solve();
}


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

int main() {
    ll h,w;
    cin >> h >> w;
    ll kisuu = (h+1)/2;
    ll guusuu = h/2;
    ll ans = 0;
    REP(i,w){
        if(i%2==1) ans+=kisuu;
        else ans += guusuu;
    }
    if(h==1||w==1) cout << "1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	forn(i, s.size()) {
		if (s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt;
 	return 0;
}

Measured memory_bytes: 3764
def main():
    global visited, adj, sets
    print = out.append
    ''' Cook your dish here! '''
    q = get_int()
    st = sys.stdin.readline().strip()
    if st[:q//2]==st[q//2:]:
        print("Yes")
    else:
        print("No")



''' Coded with love at India by Satyam Kumar '''
import sys, threading
from collections import defaultdict
#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
# [main() for _ in range(int(input()))]
print(*out, sep='\n')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

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

	// ll t;	cin>>t;
	// while(t--)
	// {
		
	// }
	ll n;	cin>>n;
	ll mx = INT_MIN;
	ll ans = 0;
	for(ll i=0; i<n; i++)
	{
		ll x;	cin>>x;
		if(x <= mx)
			ans += (mx-x);
		else
			mx = x;
	}
	cout<<ans;

	return 0;
}

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

#pragma warning(disable:4996)
using namespace std;
using ld=long double;
ld eps=1e-9;

struct Edge {
	int from;
	int to;
	long long int val;
};

struct Status {
	int now;
	int hot;
	int rest;
	long long int cost;
};
bool operator<(const Status&l, const Status&r) {
	return l.cost>r.cost;
}

void add_edge(vector<vector<Edge>>&graph,int a, int b, int c) {
	graph[a].push_back(Edge{ a,b,c });
	graph[b].push_back(Edge{ b,a,c });
}

long long int value(const long long int sa, const long long int S, const long long int T) {
	if (sa > 0) {
		return - sa*S;
	}
	else {
		return - sa*T;
	}
}

int main() {
	long long int N;
	int M,K;cin>>N>>M>>K;K-=M;
	long long int A,B,C;cin>>A>>B>>C;
	long long int T;cin>>T;
	vector<long long int>Ss(M);
	for (int i = 0; i < M; ++i) {
		cin>>Ss[i];Ss[i]--;
	}

	long long int ans=0;
	vector<long long int>v;
	for (int i = 0; i < M; ++i) {
		long long int exp_time=B*Ss[i];
		if (exp_time > T) {

		}
		else {
			if(i!=0)ans++;
			if(i==M-1)continue;
			long long int rest_normal = Ss[i + 1] - Ss[i] - 1;
			long long int rest_time=T-exp_time;

			long long int normal_num=min(rest_normal,rest_time/A);

			ans+=normal_num;

			rest_normal-=normal_num;

			long long int semi_point=Ss[i]+normal_num+1;
			int x=K;
			while (rest_normal) {
				x--;
				if(x<0)break;
				long long int semi_time=exp_time+C*(semi_point-Ss[i]);
				if (semi_time > T) {
					break;
				}
				else {
					long long int nans=0;
					long long int rest_time=T-semi_time;
					long long int anormal_num=min(rest_normal,1+rest_time/A);

					nans=anormal_num;
					v.push_back(nans);

					rest_normal-=anormal_num;
					semi_point+=nans;
				}
			}
		}
	}
	sort(v.begin(),v.end(),greater<long long int>());
	long long int plus=0;
	if(v.size()<K)plus=accumulate(v.begin(),v.end(),0ll);
	else plus=accumulate(v.begin(),v.begin()+K,0ll);
	cout<<ans+plus<<endl;
	return 0;
} 


Measured memory_bytes: 7068
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

// ====== pbds begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== pbds ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ld l;
    cin >> l;
    ld a = l/3;
    ld b = (l - a)/2;
    ld c = (l - a - b);
    cout << fixed << setprecision(10);
    cout << a * b * c << nl;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
	int a, b, c, d, e, f;
	cin >> a;
	cin >> b >> c;
	d = c - b;
	e = b % a;
	f = c % a;
	if (d >= a) {
		cout << "OK";
	}
	else {
		if ((e == 0) || (f == 0)) {
			cout << "OK";
		}
		else {
			if (e <= f) {
				cout << "NG";
			}
			else {
				cout << "OK";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, m;

    cin >> n >> m;
    pair<ll, ll> st[n], g[m];

    for(int i=0; i<n; i++) cin >> st[i].first >> st[i].second;
    for(int i=0; i<m; i++) cin >> g[i].first >> g[i].second;

    ll cal, ans[n];
    for(int i=0; i<n; i++){
      pair<ll, ll> tmp = make_pair(1e+17, 0);
      for(int j=0; j<m; j++){
        cal = abs(st[i].first-g[j].first)+abs(st[i].second-g[j].second);
        if(cal < tmp.first)  tmp = make_pair(cal, j+1);

      }
      ans[i] = tmp.second;
    }
    for(int i=0; i<n; i++)
      cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int x=in(),a=in(),b=in(),A=abs(x-a),B=abs(x-b);
	if(A<B)puts("A");
	else puts("B");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef vector< vector<int> > VVI;

const int INF = (1e9);

void wFloyd ( VVI &v )
{
	int len = v.size();

	for (int k = 0; k < len; ++k)
	{
		for (int i = 0; i < len; ++i)
		{
			for (int j = 0; j < len; ++j)
			{
				v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
			}
		}
	}
}

int main ( void )
{
	int n, k;

	while (cin >> n >> k, (n | k))
	{
		VVI v(n, vector<int>(n, INF));

		for (int i = 0; i < k; ++i)
		{
			int x;

			cin >> x;

			if (x)
			{
				int c, d, e;

				cin >> c >> d >> e;

				--c; --d;

				if ((v[c][d] > e) || (v[d][c] > e))
				{
					v[c][d] = v[d][c] = e;
					wFloyd(v);
				}
			}
			else
			{
				int a, b;

				cin >> a >> b;

				--a; --b;

				if (v[a][b] == INF)
				{
					cout << -1 << endl;
				}
				else
				{
					cout << v[a][b] << endl;
				}
			}
		}
	}

	return 0;
}

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

int main()
{

    int a,b,c;
   cin>>a>>b>>c;
    int x,y,z,q,w,e,sum1,sum2,sum3;
    if((a>=b)&&(a>=c))
    {
        x=a-b;
        y=a-c;
        if(x>=y)
            sum1=y+(x-y)/2+((x-y)%2)*2;
        else
            sum1=x+(y-x)/2+((y-x)%2)*2;
        cout<<sum1<<endl;
    }
    else  if((b>=a)&&(b>=c))
    {
        z=b-a;
        q=b-c;
        if(z>=q)
            sum2=q+(z-q)/2+((z-q)%2)*2;
        else
            sum2=z+(q-z)/2+((q-z)%2)*2;
             cout<<sum2<<endl;
    }
    else if((c>=a)&&(c>=b))
    {
        w=c-a;
        e=c-b;
        if(w>=e)
            sum3=e+(w-e)/2+((w-e)%2)*2;
        else
            sum3=w+(e-w)/2+((e-w)%2)*2;
             cout<<sum3<<endl;
    }


    return 0;
}


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

#define MOD 1000000007;

int main(){
	long long a, b, x;
	cin >> a >> b >> x;
	if(a%x)
		a = (a+x)/x*x;
	if(b%x)
		b = b/x*x;
	long long num=0;
	if(b>=a)
		num = (b-a)/x+1;
	cout << num << endl;
	return 0;
}

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

int main(){
    int64_t i, j, k;
    int N;
    vector<vector<int64_t>> weight;
    cin >> N;
    for(i=0; i<N; i++){
        int64_t a, b;
        scanf("%lld %lld", &a, &b);
        weight.push_back({a, 0LL, i});
        weight.push_back({b, 1LL, i});
    }
    sort(weight.begin(), weight.end());
    bool use_side[2] = {false, false};
    bool dub = false;
    bool use_num[100000];
    for(i=0; i<N; i++) use_num[i] = false;

    int64_t ans = 0;
    for(i=0; i<N; i++){
        auto v = weight[i];
        ans += v[0];
        use_side[v[1]] = true;
        if(use_num[v[2]]) dub = true;
        use_num[v[2]] = true;
    }

    if(use_side[0] && use_side[1] && !dub){
        int64_t loss;
        if(weight[N-1][2] == weight[N][2]){
            loss = min(weight[N+1][0] - weight[N-1][0], weight[N][0] - weight[N-2][0]);
        }else{
            loss = weight[N][0] - weight[N-1][0];
        }
        ans += loss;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12716
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

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};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	Vec< int > a(N+1);
	for_(i,0,N) cin >> a[i+1];
	
	Vec< int > ans, cnt(N+1, 0);
	for (int i=N; i>0; --i) {
		bool add = false;
		if (a[i] == 0) add = ((cnt[i] % 2) == 1);
		else add = ((cnt[i] % 2) == 0);
		
		if (add) {
			ans.push_back(i);
			int REP = sqrt(i)+1;
			for_(j,1,REP) {
				if (i % j == 0) {
					++cnt[j];
					if (j != i/j) ++cnt[i / j];
				}
			}
		}
	}
	
	int M = ans.size();
	cout << M << endl;
	for_(i,0,M) cout << ans[i] << (i<M-1 ? " " : "\n");
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

int a[200002];
map<LL,LL> mp;

/*
LL solve()
{
    LL count=0;
    LL number=1000000;
    LL stp=sqrt(number);

    for(LL i=2;i<=stp;i++)
    {
        if(mp[i])
        for(LL j=i*i;j<=number;j+=(i+i))
        {
            if(mp[j])
            if(j%i  && i!=j)
            {
                count+=mp[i];

            }

        }

    }

    return count;
}
*/

int main()
{
    int n;
    si(n);

    Rep(i,0,n-1)
    {
        si(a[i]);
        mp[a[i]]++;
    }

    sort(a,a+n);


    for(int i=0;i<n;i++)
    {
        int nm=a[i];

        while(nm<=a[n-1])
        {
            if(mp[nm]>1)
                {
                    mp[nm]=0;
                }

            nm+=a[i];

            if(mp[nm]==1)
                mp[nm]--;

        }
    }

    int res=0;


    for(int i=0;i<n;i++)
    {
        if(mp[a[i]]>0)
        {
            res++;
        }
    }

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


    return 0;
}


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

  int h, w;
  rd(h, w);
  int a, b;
  rd(a, b);

  auto p = h / a, q = w / b;
  writeln((h - p * a) * w + h * (w - q * b) - ((h - p * a) * (w - q * b)));
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}



Measured memory_bytes: 2448
import itertools
while True:
    n, s = map(int, input().split())
    if n == s == 0:
        break
    l = list(itertools.combinations(range(1,n+1),3))
    result = 0
    for _ in l:
        if sum(list(_)) == s:
            result += 1
    print(result)



Measured memory_bytes: 31420
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))


def lcm(a, b):
    y = a * b // gcd(a, b)
    return y


c = 0
for i, a in enumerate(A):
    if i == 0:
        c = a
    else:
        c = lcm(c, a)

result = 0
for a in A:
    result += c // a

print(result % (10 ** 9 + 7))

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
typedef long long ll;

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

int main()
{
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    int ans = 1e9;

    vector<tuple<int, int, int>> t1(N / 2), t2(N - N / 2); //前半と後半
    for (size_t i = 0; i < N; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (i < N / 2)
            t1[i] = {a, b, c};
        else
        {
            t2[i - N / 2] = {a, b, c};
        }
    }
    vector<pair<int, int>> T2; //探す値を持っておく配列 後半の配列をbit全探索して入れていく
    for (int bit = 0; bit < (1 << t2.size()); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < t2.size(); i++)
        {
            auto [A, B, C] = t2[i];
            if (bit & (1 << i))
            {
                a += A;
                b += B;
                c += C;
            }
        }
        
        T2.push_back({b * Ma - a * Mb, c});
        int d=b*Ma-a*Mb;
        if(d==0 && c>0){
            chmin(ans,c);
        }
    }
    sort(all(T2)); //普通のpair<int,int>の順序で昇順ソート
    for (int bit = 0; bit < (1LL << t1.size()); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (size_t i = 0; i < t1.size(); i++)
        {
            auto [A, B, C] = t1[i];
            if (bit & (1LL << i))
            {
                a += A;
                b += B;
                c += C;
            }
        }
        
        int d = a * Mb - b * Ma; //このdの値がT2に入ってるか二分探索で調べる
        ll ok = T2.size() - 1, ng = -1;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (T2[mid].first >= d)
                ok = mid;
            else
                ng = mid;
        }
        //この時点でokは 「T2[i].second >= dを満たすようなiの集合」 の最小値になっているはず(あるいはその集合は空)
        if (T2[ok].first == d and c + T2[ok].second > 0) 
        {
                chmin(ans, c + T2[ok].second);
        }
        if(d==0 && c>0){
            chmin(ans,c);
        }
    }
    if (ans != 1e9)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 11612
N = int(input())
S = [int(i) for i in input()]
ans = 0
for i in range(10):
    fp = -1
    for tf in range(N - 2):
        if S[tf] == i:
            fp = tf
            break
    if fp == -1:
        continue

    for j in range(10):
        sp = -1
        for ts in range(fp + 1, N - 1):
            if S[ts] == j:
                sp = ts
                break
        if sp == -1:
            continue

        for k in range(10):
            for tt in range(sp + 1, N):
                if S[tt] == k:

                    ans += 1
                    break

print(ans)







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

using namespace std;

int main()
{
	string S;
	string tmp = "";

	cin >> S;

	while (S.empty() == false)
	{
		tmp = S.substr(S.size() - 5, S.size());
		if (tmp == "dream" || tmp == "erase")
		{
			S.erase(S.end()-5, S.end());
			continue;
		}
		tmp = S.substr(S.size() - 6, S.size());
		if (tmp == "eraser")
		{
			S.erase(S.end() - 6, S.end());
			continue;
		}
		tmp = S.substr(S.size() - 7, S.size());
		if (tmp == "dreamer")
		{
			S.erase(S.end() - 7, S.end());
			continue;
		}

		cout << "NO" << endl;
		break;
	}

	if (S.empty() == true)
		cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 512
a,b = map(int,input().split())
s = input()
c = 0

def is_int(s):
	try:
		int(s)
		return True
	except ValueError:
		return False

for i in range(a):
	if is_int(s[i]) == True:
		c += 1
for i in range(a+1,a+b):
	if is_int(s[i]) == True:
		c += 1
if s[a] == '-' and c == len(s) - 2:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  
  vector<int> s(n);
  
  for (int i = 0; i < n-1;i++){
    s.at(i) = a.at(i+1) -a.at(i);
  }
  s.at(n-1) = k - a.at(n-1) + a.at(0);
  
  int l = 0;
  
  for (int i = 0; i < n;i++){
    l = max(l, s.at(i));
  }
  
  cout << k - l << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << max({a - b, a + b, a * b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include<queue>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

#define MOD 1000000007
int main(){
    ll h, w, d;
    cin >> h >> w >> d;
    vector<pair<ll,ll>> a(100000);
    a[0].first =  0;
    a[0].second = 0;
    for(int i  = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            ll x;
            cin >> x;
            a[x].first  = i;
            a[x].second = j;
        }
    }
    ll q;
    cin >> q;
    ll l[q], r[q];
    rep(i, q)cin >> l[i] >> r[i];

    ll score[100000];
    for(int i = 1; i <= d; ++i)score[i] = 0;
    for(int i = d+1; i <= h*w; ++i){
        score[i] += score[i-d] + abs(a[i].first - a[i-d].first) + abs(a[i].second - a[i-d].second);
    }
    rep(i, q)cout << score[r[i]] - score[l[i]] << endl; 
    
}

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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}


int main(){
  int H,W,ans=0;
  cin >> H >> W;
  vector<string> S(H);
  rep(i,H) cin >> S.at(i);
  rep(i,H){
    rep(j,W){
      if(S.at(i).at(j)=='#'){
        continue;
      }
      vector<vector<int>> dp(H, vector<int>(W,1000));
      dp.at(i).at(j)=0;
      queue<P> Q;
      Q.push(P(i,j));
      while(!Q.empty()){
        P q=Q.front();
        Q.pop();
        if(q.first!=0){
          if(S.at(q.first-1).at(q.second)!='#'&&dp.at(q.first-1).at(q.second)==1000){
            dp.at(q.first-1).at(q.second)=dp.at(q.first).at(q.second)+1;
            ans=max(ans,dp.at(q.first-1).at(q.second));
            Q.push(P(q.first-1,q.second));
          }
        }
       if(q.first!=H-1){
          if(S.at(q.first+1).at(q.second)!='#'&&dp.at(q.first+1).at(q.second)==1000){
            dp.at(q.first+1).at(q.second)=dp.at(q.first).at(q.second)+1;
            ans=max(ans,dp.at(q.first+1).at(q.second));
            Q.push(P(q.first+1,q.second));
          }
        }
        if(q.second!=0){
          if(S.at(q.first).at(q.second-1)!='#'&&dp.at(q.first).at(q.second-1)==1000){
            dp.at(q.first).at(q.second-1)=dp.at(q.first).at(q.second)+1;
            ans=max(ans,dp.at(q.first).at(q.second-1));
            Q.push(P(q.first,q.second-1));
          }
        }
        if(q.second!=W-1){
          if(S.at(q.first).at(q.second+1)!='#'&&dp.at(q.first).at(q.second+1)==1000){
            dp.at(q.first).at(q.second+1)=dp.at(q.first).at(q.second)+1;
            ans=max(ans,dp.at(q.first).at(q.second+1));
            Q.push(P(q.first,q.second+1));
          }
        }
      }
    }
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappush, heappop
n, m = map(int, input().split())
baito_dict = defaultdict(list)
for _ in range(n):
    day, weight = map(int, input().split())
    baito_dict[day].append(weight)


max = 0

available_works = []

for day in range(1, m+1):
    for weight in baito_dict[day]:
        heappush(available_works, -weight)
    if available_works:
        max += heappop(available_works)

print(-max)


Measured memory_bytes: 27880
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    // 整数の入力
    long x = sc.nextLong();

    int year = 0;
    BigDecimal money = new BigDecimal(100);
    BigDecimal X = new BigDecimal(x);
    while (X.compareTo(money) > 0) {
      money = money.multiply(new BigDecimal("1.01")).setScale(0, RoundingMode.DOWN);
      year++;
    }

    // 出力
    System.out.println(year);
  }
}


Measured memory_bytes: 38532
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    ll ans = 0;
    rep(i, n){
        ll h;cin >> h;
        if(h >= k)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int H,N;
    cin>>H>>N;
    vector<pair<int,int>> magic(N);
    REP(i,N) cin>>magic[i].first>>magic[i].second;
    using P = pair<int,int>;
    int ans=1e9;
    vector<vector<int>> dp(N+1,vector<int>(H+1,1e9));
    dp[0][0]=0;
    REP(i,N) REP(j,H+1){
        dp[i+1][j]=min(dp[i][j],dp[i+1][max(j-magic[i].first,0)]+magic[i].second);
    }
    cout<<dp[N][H]<<endl;
}


Measured memory_bytes: 39424
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAXN = 100100;

int N;
int arr[MAXN];
int aval[MAXN];

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

    aval[0] = 1;
    int codd = 1;
    for (int i = 1; i < N; i++)
    {
        if (arr[i-1] >= codd)
        {
            aval[i] = aval[i-1];
            codd += 2;
        }
        else
        {
            aval[i] = aval[i-1] + 1;
        }
    }

    ll ans = 1;
    int cloc = 0;
    for (int i = 1; i <= N; i++)
    {
        while (cloc < N && aval[cloc] == i)
            cloc++;
        ans = (ans * (cloc - i + 1)) % MOD;
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n, x[55], y[55];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        x[i] *= 2;  y[i] *= 2;
    }
    
    vector<pair<pair<int, int>, pair<int, int>>> center;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            center.emplace_back(make_pair((x[i] + x[j]) / 2, (y[i] + y[j]) / 2), make_pair(i, j));
        }
    }
    sort(center.begin(), center.end());
    
    //for (int idx = 0; idx < center.size(); idx++) cout << center[idx].first.first << " " << center[idx].first.second << " "<<center[idx].second.first << " " << center[idx].second.second << endl;
    
    int idx = 0;
    while (idx != center.size()) {
        bool ok[55] = {};
        int cx = center[idx].first.first, cy = center[idx].first.second, sub = 0;
        while (cx == center[idx + sub].first.first && cy == center[idx + sub].first.second) {
            ok[center[idx + sub].second.first] = true;
            ok[center[idx + sub].second.second] = true;
            sub++;
        }
        idx += sub;
        bool ans = true;
        //for (int i = 0; i < n; i++) cout << ok[i] << " ";
        //cout << endl;
        for (int i = 0; i < n; i++) {
            if (!ok[i]) ans = false;
        }
        if (ans){
            cout << setprecision(10) << float(cx) / 2.0 << " " << float(cy) / 2.0 << endl;
            return 0;
        }
    }
    cout << "NA" << endl;
    
}



Measured memory_bytes: 3288
import java.util.*;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        int max = 0;

        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            max = Math.max(max, a[i]);
        }
        int max2 = 0;
        int b = 0;
        int ans = 0;
        for(int i=0; i<n; i++){
            if(a[i]<=max/2){
                b = a[i];
            }
            else{
                b = max - a[i];
            }
            max2 = Math.max(max2, b);
            if(max2==b){
                ans = a[i];
            }
        }
        System.out.println(max + " " + ans);
    }
}

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

using namespace std;
using ll = long long;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256