akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,k,m,p[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <LL> vec;
set <int> s;
map <int,int> M;


int main()
{
    scl(n);scl(k);
    for(int i=0;i<n;i++)scl(p[i]);
    sort(p,p+n);
    reverse(p,p+n);
    LL sum=0;
    for(int i=k;i<n;i++)sum+=p[i];
    cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 1792
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
readStr().ToCharArray()
|> Array.exists ((=) '7')
|> function
  | true -> "Yes"
  | false -> "No"
|> printfn "%s"

Measured memory_bytes: 29608
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		
		// 計算
		long result = 0;
		long c = abs(x)/d;
		if(k <= c){
		    result = abs(x) - d*k;
		    //System.out.println("a");
		}else{
		    if((k-c)%2 == 0){
		        result = abs(x) - d*c;
		    }else{
		        result = abs(abs(x) - d*c - d);
		    }
		    //System.out.println("b");
		}
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 25396
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;

int main(){
	cin>>n>>k;
	double res=0;
	for(int i=1;i<=n;i++){
		int t=i;
		double tmp=1.0/n;
		while(t<k){
			t*=2;
			tmp/=2;
		}
		res+=tmp;
	}
	cout<<syosu(11)<<res<<endl;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(string[] ss) {
    bool[string] d = [ss[0]: true];
    for (int i = 1; i < ss.length; i++) {
        if (ss[i] in d) return false;
        if (ss[i-1][$-1] != ss[i][0]) return false;

        d[ss[i]] = true;
    }
    return true;
}

void main() {
    int n = readint;
    string[] ss;
    for (int i = 0; i < n; i++) {
        ss ~= read!string;
    }

    writeln(calc(ss) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    double a[16];
    while (scanf("%lf", a) != EOF) {
        rep (i, 10) a[i+1] = i%2 ? a[i]/3 : a[i]*2;
        double ans = 0;
        rep (i, 10) ans += a[i];
        printf("%.8f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e5 + 7;
const ll inf = 1e9 + 5;




ll n, k;



int main()
{
    MohamedMotaz;
    cin >> n;
    vector<ll> v(n + 5, 0);
    f(i,0,n) cin >> v[i];
    ll dp[N][2] = {};

    dp[0][0] = 0;
    dp[0][1] = v[0];
    dp[1][0] = dp[1][1] = max(v[0], v[1]);
    f(i,2,n) {
        if (i % 2){
            dp[i][0] = dp[i][1] = max(dp[i - 2][0] + v[i], dp[i-1][1]);
        }else{
            dp[i][1] = dp[i - 2][1] + v[i];
            dp[i][0] = max(dp[i - 1][0], dp[i - 2][0] + v[i]);
        }
    }
    cout << dp[n -1 ][0] << endl;

}





Measured memory_bytes: 7652
#include <stdio.h>
#include <string.h>
int main(){
	char data[10000];
	int joi,ioi,i,moji;
	while(scanf("%s",data)!=EOF){
		joi=0;
		ioi=0;
		moji=strlen(data);
		for(i=0;i<moji-2;i++){
			if(data[i+1]=='O'&&data[i+2]=='I'){
				if(data[i]=='J'){
					joi++;
				}
				else if(data[i]=='I'){
					ioi++;
				}
			}
		}
		printf("%d\n%d\n",joi,ioi);
	}
	return 0;
}

Measured memory_bytes: 556
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

P = prime_factorize(n)

import collections
C = collections.Counter(P)


L = [0]
for i in range(1, 1000):
    L.append(L[-1] + i)

import bisect


ans = 0

for k, v in C.items():
    i = bisect.bisect(L, v) - 1
    ans += i
print(ans)


Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int N, R;
    cin >> N >> R;
    if (N  >= 10) cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int r, D, x;
  cin >> r >> D >> x;

  for (int i = 0; i < 10; i++)
  {
    x = r * x - D;
    cout << x << endl;
  }
  
}


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

int n;
string str;

int p[10], f;

int main()
{
	while (cin >> n, n){
	cin >> str;
	
	memset(p, 0, sizeof(p));
	f = 0;
	for (int i = 0; i < 100; i++){
		int cur = i % n;
		if (str[i] == 'M') p[cur]++;
		else if (str[i] == 'S'){
			f += p[cur] + 1;
			p[cur] = 0;
		}
		else {
			p[cur] += f + 1;
			f = 0;
		}
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) printf("%d ", p[i]);
	printf("%d\n", f);
	
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<s.size()/2;i++)
  {
    if(s[i]!=s[s.size()-1-i])
      c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		List<Integer> H = new ArrayList<>();
		
		for (int i=0; i<N; i++) {
			H.add(sc.nextInt());
		}
		
		Collections.sort(H);
		long ans = 0;
		for (int i=0; i<N - K; i++) {
			ans += H.get(i);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 94240
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
vector<int> a[100001];
bool c[100001];
void go(int x) {
	for (int i = 0; i < (int)a[x].size(); i++) {
		int y = a[x][i];
		if (!c[y]) {
			c[y] = true;
			go(y);
		}
	}
}
int main() { // E,F , virtual
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m; cin >> n >> m;
	rep(i, m) {
		int x, y, z; cin >> x >> y >> z;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!c[i]) {
			c[i] = true;
			go(i);
			ans += 1;
		}
	}
	cout << ans << '\n';



}


Measured memory_bytes: 10496
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int L[] = new int[N];
        for (int i=0; i<N; i++) {
            L[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(L);

        int cnt = 0;
        for(int i=0; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                for (int k=j+1; k<N; k++) {
                    int a = L[i];
                    int b = L[j];
                    int c = L[k];
                    if ((c<a+b) && (a<b+c) && (b<c+a)) {
                        cnt++;
                    } else {
                        break;
                    }
                }
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(cnt);
        out.flush();
    }
}

Measured memory_bytes: 25748
n = int(input())
S = [0] * n
for i in range(n):
    S[i] = list(input())

count = [[0] * 27 for _ in range(n)]

alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)


for i in range(n):
    for j in range(len(S[i])):
        tmp = alpha2num(S[i][j].upper())
        count[i][tmp] += 1

#print(count)


count_min = [0] * 27
for i in range(27):
    tmp = 100
    for j in range(n):
        tmp = min(tmp, count[j][i])
    count_min[i] = tmp

#print(count_min)

ans = ''
for i in range(1,27):
    ans += num2alpha(i).lower() * count_min[i]

print(ans)

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

using namespace std;

int main() {
    int n, a[200000];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int ans[200000];
    for(int i = n; i > 0; i--) {
        ans[i - 1] = a[i - 1];
        for(int j = 1; j <= sqrt(1.0 * i); j++) {
            if(i % j == 0) {
                a[j - 1] = (a[j - 1] + 2 - ans[i - 1]) % 2;
                if(j * j != i) a[i / j - 1] = (a[i / j - 1] + 2 - ans[i - 1]) % 2;
            }
        }
    }

    bool flag = true;
    for(int i = 0; i < n; i++) {
        if(a[i] != 0) {
            flag = false;
            break;
        }
    }

    if(flag) {
        vector<int> v;
        for(int i = 0; i < n; i++) {
            if(ans[i] == 1) v.push_back(i + 1);
        }
        cout << v.size() << endl;
        for(int i = 0; i < v.size(); i++) {
            if(i != 0) cout << ' ';
            cout << v[i];
        }
        cout << endl;
    }else {
        cout << -1 << endl;
    }

    return 0;
}


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

int main(){
    int N,A,B;
    int sum = 0;
    std::cin >> N >> A >> B;
    for (int n = 1; n < N + 1; ++n)
    {
        int tmp_sum = 0;
        string n_str;
        n_str = std::to_string(n);
        // std::cout << n_str << "\n";
        for (int i = 0; i < (int)(n_str.length()); ++i)
        {
            tmp_sum = tmp_sum + n_str[i] - 48;
            // std::cout << "tmpsum" <<tmp_sum << "\n";
        }
        if ((tmp_sum >= A)&&(tmp_sum <= B))
        {
            sum = sum + n;
            // std::cout << "sum" << sum << "\n";
        }
    }
    std::cout << sum << "\n";
}

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

       // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

int main()
{
   string s,t,n,m,min,max;
   int a=0,b=0,i=0,j=0;
   
   cin >> s >> t;
   // for (int i = 0; i < N; ++i) cin >> A[i];
   
   a = s.size();
   b = t.size();
   
   for (i = 0; i < a; ++i) {           
         min[0] = s[i];
           //cout << s[i] << endl;
         for (j = i; j < a; ++j) {
           //cout << s[j] << endl;
            if (s[j] <= min[0]) {
               min[0] = s[j];
               s[j] = s[i];
               s[i] = min[0];
            }  
          } 
   }

   for (i = 0; i < b; ++i) {           
         max[0] = t[i];
           //cout << t[i] << endl;
         for (j = i; j < b; ++j) {
           //cout << t[j] << endl;
            if (max[0] <= t[j] ) {
               max[0] = t[j];
               t[j] = t[i];
               t[i] = max[0];
            }  
          } 
   }

   // cout << s << endl;
   // cout << t << endl;
   if(s < t) cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;

}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int total[40];

int main() {
    //cout.precision(10);
    int N, M;
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        int K;
        cin >> K;
        while(K--){
            int a;
            cin >> a;
            total[a]++;
        }
    }
    int ans = 0;
    for(int i = 1; i <= M; i++) {
        if(total[i] == N) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a_abs = list(map(abs, a))

if 0 in a:
    print(sum(a_abs))
else:
    cnt = 0
    for i in a:
        if i < 0:
            cnt += 1
    if cnt%2 == 0:
        print(sum(a_abs))
    else:
        print(sum(a_abs)-min(a_abs)*2)

Measured memory_bytes: 14252
a, b, x = map(int, input().split())
m1 = a % x
m2 = b % x
if a == b:
  if a % x == 0:
    print(1)
  else:
    print(0)
  exit()
if m1 != 0:
  a = (a//x)*x + x
if m2 != 0:
  b = (b//x)*x

print((b//x-a//x)+1)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n; cin >> n;
  	int ans;
  	if(n==1) ans=1;
  	else if(n<4) ans=2;
  	else if(n<8) ans=4;
    else if(n<16) ans=8;
    else if(n<32) ans=16;
  	else if(n<64) ans=32;
  	else ans=64;
  	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
struct place {
    int wi,he;
    place(int wi,int he):wi(wi),he(he){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
const int MAXH = 3001;
const int MAXW = 3001;
int C_h,C_w;
int D_h,D_w;
char S[MAXH][MAXW];
int H,W;
int maze[MAXH][MAXW]; //到達できる場所

void show_maze(){
    rep(i,H){
        rep(j,W){
            cout << maze[i][j];
        }
        cout << endl;
    }
    cout << endl;
}

int main(){
    cin >> H >> W;
    cin >> C_h >> C_w;
    cin >> D_h >> D_w;

    rep(i,H)rep(j,W){
        cin >> S[i][j];
    }

    rep(i,MAXH)rep(j,MAXW){
        maze[i][j] = -1;
    }

    queue<pair<int,int> > Q;

    Q.push(make_pair(C_h-1,C_w-1));
    maze[C_h-1][C_w-1] = 0;


    int x_dir[4]={1,-1,0,0};
    int y_dir[4]={0,0,1,-1};
    int counter = 0;
    deque<pair<int,int>> T;
    int tmo=1;
    T.push_front(make_pair(C_h-1,C_w-1));
    while(!Q.empty()){
        int tm = 0;
        while(!Q.empty()){
            pair<int,int> current = Q.front();
            Q.pop();
            rep(i,4){
                int y = current.first + y_dir[i];
                int x = current.second + x_dir[i];
                if(maze[y][x]==-1 && y>=0 && y<H && x>=0 && x<W && S[y][x]=='.'){
                    maze[y][x] = counter;
                    Q.push(make_pair(y,x));
                    T.push_front(make_pair(y,x));
                    tm++;
                }
            }
        }
        tm += tmo;
        tmo = 0;
        counter++;
        for(int m=0;m<tm;m++){
            pair<int,int> current = T.front();
            T.pop_front();
            int i = current.first;
            int j = current.second;
            if(maze[i][j]==(counter-1)){
                for(int k=-2;k<=2;k++){
                    for(int l=-2;l<=2;l++){
                        if(!((k==1 && l==0 )|| (k==-1 && l==0 )|| (k==0 && l==1) || (k==0 && l==-1) || (k==0 && l==0))){ 
                            int x = j+l;
                            int y = i+k;
                            if(y>=0 && y<H && x>=0 && x<W && maze[y][x]==-1 && S[y][x]=='.'){
                                maze[y][x] = counter;
                                Q.push(make_pair(y,x));
                                T.push_back(make_pair(y,x));
                                tmo++;
                            }
                        }
                    }
                }
            }
        }
        // show_maze();
    }
    


    cout << maze[D_h-1][D_w-1] << endl;

    // show_maze();


    return 0;
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 5e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

int obr[N], tek[N];

int step (int x, int st) {
    if (st == 0) return 1;
    int k = step(x, st / 2);
    k *= k;
    k %= MOD;
    if (st % 2) k *= x;
    k %= MOD;
    return k;
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, a, b, tek = 1;
    cin >> n >> a >> b;
    for (int i = 1; i <= max(a, b); i++) {
        tek *= i;
        tek %= MOD;
        obr[i] = step(tek, MOD - 2);
    }
    int ans = (step(2, n) - 1 + MOD) % MOD;
    tek = 1;
    for (int i = n - a + 1; i <= n; i++) tek *= i, tek %= MOD;
    tek *= obr[a]; tek %= MOD;
    ans = (ans + MOD - tek) % MOD; tek = 1;
    for (int i = n - b + 1; i <= n; i++) tek *= i, tek %= MOD;
    tek *= obr[b]; tek %= MOD;
    ans = (ans + MOD - tek) % MOD;
    cout << ans;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

struct edge {
	int to, cost;
};

int N, M, K, P[100000], C[100000], J[100000], p, q, r;
ll res[100000], dist[100000], dist2[100000];
vector<edge>v[100000];


int main() {
	cin >> N >> M >> K;
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
		--C[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> J[i];
	}
	for (int i = 0; i < M; ++i) {
		cin >> p >> q >> r;
		--p;
		--q;
		v[p].push_back({ q,r });
		v[q].push_back({ p,r });
	}
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>q;
	for (int i = 0; i < N; ++i) {
		dist[i] = -1;
		dist2[i] = -0xE869120E869120;
	}
	q.push(mkp(0, 0));
	while (!q.empty()) {
		int x = q.top().second;
		ll d = q.top().first;
		q.pop();
		if (dist[x] != -1)continue;
		dist[x] = d;
		for (edge e : v[x]) {
			if (dist[e.to] == -1) {
				q.push(mkp(d + e.cost, e.to));
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		q.push(mkp(dist[i] - P[i], i));
	}
	while (!q.empty()) {
		int x = q.top().second;
		ll d = q.top().first;
		q.pop();
		if (dist2[x] != -0xE869120E869120)continue;
		dist2[x] = d;
		for (edge e : v[x]) {
			if (dist2[e.to] == -0xE869120E869120) {
				q.push(mkp(d + e.cost, e.to));
			}
		}
	}
	for (int i = 0; i < K; ++i) {
		res[i] = -0xE869120E869120;
	}
	for (int i = 0; i < N; ++i) {
		res[C[i]] = max(res[C[i]], J[i] - (dist[i] + dist2[i]));
	}
	for (int i = 0; i < K; ++i) {
		cout << res[i] << endl;
	}
}



Measured memory_bytes: 18116
def splitString(target, start, end):
    first = target[:start]
    middle = target[start:end + 1]
    last = target[end + 1:]
    return (first, middle, last)

def doReplace(target, args):
    start = int(args[0])
    end = int(args[1])
    replace_str = args[2]

    first, _, last = splitString(target, start, end)

    return first + replace_str + last


def doReverse(target, args):
    start = int(args[0])
    end = int(args[1])

    first, middle, last = splitString(target, start, end)

    return first + middle[::-1] + last


def makeMessage(target, args):
    start = int(args[0])
    end = int(args[1])

    _, middle, _ = splitString(target, start, end)

    return middle


def transform():
    messages = []  # プリント用文字を格納するリスト
    target = input()
    q = int(input())

    for _ in range(q):
        line = input()
        cmd = line.split(' ')[0]
        args = line.split(' ')[1:]

        # 各命令を実行
        if cmd == 'print':
            messages.append(makeMessage(target, args))
        elif cmd == 'replace':
            target = doReplace(target, args)
        elif cmd == 'reverse':
            target = doReverse(target, args)
    # 各メッセージの表示
    [print(message) for message in messages]


def kantanna_test(expected, actual):
    if expected == actual:
        print('OK')
    else:
        print('NG')


if __name__ == '__main__':

    transform()


Measured memory_bytes: 5624
#include<stdio.h>
#include<string.h>

int check(int x){
  if(x==4 || x==6 || x==9 || x==11){
    return 2;
  }else if(x==2){
    return 3;
  }else{
    return 1;
  }
}

int main(void){
  int x,y;
  int gx,gy;

  scanf("%d%d",&x,&y);

  gx = check(x);
  gy = check(y);

  if(gx==gy){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

}


Measured memory_bytes: 128
x,y=map(int,input().split())
if abs(x)==abs(y):
  print((x*y<0)+0)
elif x*y==0:
  print(abs(abs(x)-abs(y))+(x>0 or y<0)*1)
elif x*y<0:
  print(abs(abs(x)-abs(y))+1)
else:
  print(abs(abs(x)-abs(y))+(x>=y)*2)


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i + 1;
    }
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    int cnt1 = 0, cnt2 = 0;
    int cnt = 0;
    do
    {
        cnt++;
        int flag = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != p[i])
            {
                flag = 1;
                break;
            }
        }
        if (!flag)
            cnt1 = cnt;
        int flag1 = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != q[i])
            {
                flag1 = 1;
                break;
            }
        }
        if (!flag1)
            cnt2 = cnt;
    } while (next_permutation(a.begin(), a.end()));
    cout << abs(cnt1 - cnt2) << "\n";
    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

n = int(input())
s = input()


def solve(s):
    d = defaultdict(int)
    for i in range(2**n):
        blue = red = ""
        for k in range(n):
            if 1 << k & i:
                blue += s[k]
            else:
                red += s[k]
        d[(blue, red)] += 1
    return d


left = solve(s[:n])
right = solve(s[::-1][:n])


ans = 0
for (b, r), v in left.items():
    ans += v * right[(r, b)]

print(ans)

Measured memory_bytes: 166440
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n, m, c, sum;
		n = scan.nextInt();
		m = scan.nextInt();
		c = 0;// list2??§?????¨
		sum = 0;// ?¨???????????¨??????§?????????
		List<Integer> list1 = new ArrayList<Integer>();
		List<Integer> list2 = new ArrayList<Integer>();

		// list1???(n*m)????????°????????\??????
		for (int count = 0; count < (n * m); count++) {
			list1.add(scan.nextInt());
		}
		// list2???m????????°????????\??????
		for (int count2 = 0; count2 < m; count2++) {
			list2.add(scan.nextInt());
		}

		// m??????????¨????
		for (int count3 = 0; count3 < (n * m); count3++) {
			sum = sum + list1.get(count3) * list2.get(c);
			
			if (c == (m-1)) {// ???????????????????????°??§StringBuilder???sum???????????\??????
				sb.append(sum);
				sb.append("\n");
				sum = 0;// sum??????????????????
				c = 0;// list2??§?????¨??????c??????????????????
			}else{
				c++;
			}
		}
		System.out.print(new String(sb));

	}
}

Measured memory_bytes: 41080
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, As):
    ans = 0
    for i in range(1, N):
        if As[i - 1] > As[i]:
            ans += As[i - 1] - As[i]
            As[i] = As[i - 1]
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)


Measured memory_bytes: 32192
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int r, D, x;
  cin >> r >> D >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

ans = [[None] * W for i in range(H)]
AA = []
for i, a in enumerate(A):
    AA.append((a,i))
AA.sort(reverse=True)
now_num = 0
now_row = 0
now_col = 0
for i, a in enumerate(AA):
    num = a[0]
    while num > 0:
        flg = False
        for j in range(now_col, W):
            # print(i,j,num,a[0],a[1],now_row)
            if num != 0:
                num -= 1
                ans[now_row][j] = str(a[1]+1)
            else:
                flg = True
                break
        if flg:
            now_col = j
            break
        else:
            now_col = 0
            now_row += 1

for i in range(1,H,2):
    ans[i] = ans[i][::-1]

for i in range(H):
    print(' '.join(ans[i]))


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

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

    for (int i = 0; i < s.length()-1; i++) {
        if (s[i]=='A' && s[i+1]=='C') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define pb push_back
#define maxn 200005
int n,m,a,b,c,x,y,z,i,j,k;

void solve(){
    cin >> n >> k ;
    cout << setprecision(9);
    double ans ;
    double p = 1.0/(double)n ;
    for(int i=1;i<=n;i++){
        int r = k-i ;
        int x = 0 ;
        for(int j=i;j<k;j*=2)
            x++ ;
        //cout << x << endl ;
        ans += p*(1.0/(double)pow(2,x));
    }
    cout << ans ;
}
signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> egde[100005];
int A[100005];
int n,k;
 
int getroot(int nd, int fr){
	
	for (int i=0;i<egde[nd].size();i++){
		if (egde[nd][i]!=fr){
			return getroot(egde[nd][i],nd);
			
		}
	}
	return nd;
}
 
long long getans(int nd, int fr, int ko){
	if (ko<=0) return 0;
	long long ans = ko;
	int count = 1;
	if (nd!=fr) count=2;
	for (int i=0;i<egde[nd].size();i++){
		if (egde[nd][i]!=fr){
			ans = (ans * getans(egde[nd][i],nd,k-count))%1000000007;
			count++;
		}
	}
	
	return ans;
}
 
int main(){
	cin >> n >> k;
	for (int i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		egde[a].push_back(b);
		egde[b].push_back(a);
	}
	
	//int r = getroot(1,1);
	
	
	long long ans = getans(1,1,k);
	cout << ans;
	return 0;
}

Measured memory_bytes: 11520
import sys

N, W = list(map(int, input().split()))

ans = 0
DP = [0] * (W + 1)
for i in range(N):
    dp = []
    w, v = map(int, sys.stdin.readline().split())
    for j, element in enumerate(DP):
        if j >= w:
            dp.append(DP[j - w] + v if element < DP[j - w] + v else element)
        else:
            dp.append(element)
    DP = dp

print(max(DP))


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

using namespace std;
#define ll long long 
#define db long double
#define f(i,l,u) for(ll i=l;i<u;i++)
int main() {
ll n;
cin>>n;
ll a[n];
map<ll,ll> mp;
ll sum=0;
f(i,0,n)
{
    cin>>a[i];
    mp[a[i]]++;
    sum+=a[i];
}
//cout<<"sum= "<<sum<<endl;
ll q;
cin>>q;
f(i,0,q)
{
    ll aa,b;
    cin>>aa>>b;
    ll val=sum-((mp[aa])*(aa));
    ll te=mp[aa];
    val+=te*(b);
    mp[aa]=0;
    mp[b]+=te;
    sum=val;
    
    cout<<val<<endl;
    
    
    
    
}





   return 0;
}

Measured memory_bytes: 10148
import heapq
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB,key=lambda x:x[0])
dp = [0 for _ in range(M)]
p = 0
q = []
for a,b in AB:
    n = a-1
    if n > M-1:
        break
    if n != p:
        while q and p < n:
            dp[p] = heapq.heappop(q)
            p += 1
        p = n
    heapq.heappush(q,b*(-1))
while q and p < M:
    dp[p] = heapq.heappop(q)
    p += 1
print(sum(dp)*(-1))

Measured memory_bytes: 83032
#include<bits/stdc++.h>
using namespace std;
long long n,freq[200005],a,arr[200005],diff,pl,ans;
int main(){
    cin>>n;
    for(int i =1;i<=n;i++){
        cin>>arr[i];
        freq[arr[i]]++;
    }
    for(int i =0;i<=n;i++){
        ans += (freq[i]*(freq[i]-1))/2;
    }
    // cout<<ans<<endl;
    for(int i =1;i<=n;i++){
        diff=(freq[arr[i]]*(freq[arr[i]]-1))/2;
        pl = ((freq[arr[i]]-1)*(freq[arr[i]]-2))/2;
        cout<<ans-diff+pl<<endl;
    }
    // cout<<endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a;
  cin>>n>>m;
  if(m==2)
    cout<<n-1;
  else
  {
    a=n/(m-1);
    if(a*(m-1)+1<n)
      a++;
    cout<<a;
  }
  return 0;
}
    

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>

#define fi first
#define se second
#define eb emplace_back
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string w;
	cin >> w;
	FOR (i, 0, w.length()) {
	  if ((i & 1) == 1) {
	    if (w[i] == 'R') {
	      cout << "No" << '\n';
	      return 0;
      }
    } else {
      if (w[i] == 'L') {
	      cout << "No" << '\n';
	      return 0;
      }
    }
  }
  cout << "Yes" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long A, long long B, long long C, long long K){
    if (K % 2 == 0) {
        std::cout << A - B << std::endl;
    } else {
        std::cout << B - A << std::endl;
    }
    return;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long C;
    long long B;
    long long A;
    long long K;
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&C);
    scanf("%lld",&K);
    solve(A, B, C, K);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, a, b): (usize, usize, usize) = parse_line().unwrap();
    let ans;

    if (a.max(b) - a.min(b)) % 2 == 0 {
        ans = (a.max(b) - a.min(b)) / 2;
    } else {
        let edge = ((a - 1).min(b - 1)).min((n - a).min(n - b));
        ans = edge + 1 + ((a.max(b) - a.min(b)) - 1) / 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
import java.util.*;

public class Main {
	public void run() {
		Scanner scan = new Scanner(System.in);
		Record[][] recordArray = new Record[3][8];
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 8; j++) {
				recordArray[i][j] = new Record (scan.nextInt() , scan.nextDouble());
			}
		}
		
		for (int i = 0; i < 3; i++) {
			Arrays.sort(recordArray[i]);
		}
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 2; j++) {
				System.out.println(recordArray[i][j].number + " " + recordArray[i][j].time);
			}
		}
		
		Record[] record = new Record[6];
		for (int i = 0; i < 3; i++) {
			for (int j = 2; j < 4; j++) {
				record[i * 2 + (j - 2)] = recordArray[i][j];
			}
		}
		
		Arrays.sort(record);
		
		System.out.println(record[0].number + " " + record[0].time);
		System.out.println(record[1].number + " " + record[1].time);
		
		
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
	public class Record implements Comparable<Record>{
		int number;
		double time;
		
		public Record(int number, double time) {
			this.number = number;
			this.time = time;
		}
		
		@Override
		public int compareTo(Record o) {
			if (time < o.time) {
				return -1;
			}else if (time > o.time) {
				return 1;
			}else {
				return 0;
			}
		}
	}

}

Measured memory_bytes: 19988
fn main() {
    let (a, b): (i32, i32) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let c: i32 = (b as f64 / 0.1) as i32;
    for n in c..c+10 {
        if (n as f64 * 0.08) as i32 == a {
            println!("{}", n);
            return;
        }
    }
    println!("-1");
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
#define max(a,b) a > b ? a : b
int main(){
    int h,w,n;
    cin >> h >> w >> n;

    int ans = max(h,w);
    if(n % ans == 0) cout << n/ans <<endl;
    else cout << n/ans +1 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int main(){

	long long n,k;
	cin>>n>>k;

	long long cnt[100001]={};
	for(int i=0;i<n;i++){
		long long a,b;
		cin>>a>>b;
		cnt[a-1]+=b;
	}

	long long sum=0;
	for(int i=0;i<100000;i++){
		sum+=cnt[i];
		if(sum>=k){
			cout<<i+1<<endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int used[8]={0};
int connect[8][8]={0};
int n, m;

int dfs(int now, int depth)
{
  int ans, i;
 
  if(used[now]) return 0;

  if(depth == n) return 1;

  used[now] = 1;

  ans = 0;

  for(i = 0; i < n; i++){
    if(connect[now][i]) ans += dfs(i, depth+1);
  }
  used[now] = 0;

  return ans;
}

int main(void)
{
  int a, b;
  int i;

  scanf("%d %d", &n, &m);
  for(i = 0; i < m; i++){
    scanf("%d %d", &a, &b);
    a--; b--;           
    connect[a][b] = 1;  
    connect[b][a] = 1;
  }
  printf("%d\n", dfs(0, 1));

  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 100000 + 10;
typedef long long LL;
LL a[N],b[N];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",&a[i]);
	sort(a,a+n);
	b[0]=a[0];
	for(int i=1;i<n;i++) b[i]=b[i-1]+a[i];
	int num=0;
	for(int i=n-1;i>0;i--) 
		if(a[i]<=b[i-1]*2) num++;
		else break;
	printf("%d\n",num+1);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
main(){
  int d,m,s=0,i;

  while( scanf("%d",&d)!=EOF){
 
 s=0,m=0;
    
 for(i=0; d*i<= (600-d);i++){
      s=s+(i*d*i*d*d);
      
}

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

}

  return 0;
}

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

void Main() {
  ll n;
  R n;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  priority_queue<PP,vector<PP>,greater<PP> > q[2];
  priority_queue<PP> q2;
  ll ans=0;
  {
    rep(i,n) {
      q[0].push(PP(a[i].S,P(a[i].F,i)));
      q[1].push(PP(-a[i].F,P(-a[i].S,i)));
    }
    set<ll> s;
    ll sum=0,x=0;
    rep(i,n) {
      PP p=q[i%2].top();q[i%2].pop();
      while(s.count(p.S.S)) {
        p=q[i%2].top();q[i%2].pop();
      }
      if(i%2) p.F*=-1,p.S.F*=-1;
      {
        int l=p.F,r=p.S.F;
        if(l>r) swap(l,r);
        if(l<=x&&x<=r) goto next;
      }
      sum+=abs(x-p.F);
      x=p.F;
    next:;
      s.in(p.S.S);
    }
    sum+=abs(x);
    ans=max(ans,sum);
  }
  {
    rep(i,n) {
      q[0].push(PP(a[i].S,P(a[i].F,i)));
      q[1].push(PP(-a[i].F,P(-a[i].S,i)));
    }
    set<ll> s;
    ll sum=0,x=0;
    REP(i,1,n+1) {
      PP p=q[i%2].top();q[i%2].pop();
      while(s.count(p.S.S)) {
        p=q[i%2].top();q[i%2].pop();
      }
      if(i%2) p.F*=-1,p.S.F*=-1;
      {
        int l=p.F,r=p.S.F;
        if(l>r) swap(l,r);
        if(l<=x&&x<=r) goto next2;
      }
      sum+=abs(x-p.F);
      x=p.F;
    next2:;
      s.in(p.S.S);
    }
    sum+=abs(x);
    ans=max(ans,sum);
  }
  pr(ans);
}

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


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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(n) for(int i = 0; i < n; i++)
#define run(i, a, b) for(int i = a; i < b; i++)
#define cinarr(arr, n) repi(n) cin >> arr[i]
#define coutarr(arr, n) repi(n) cout << arr[i] << " "; cout << endl
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define cinset(st, n) {int _t; repi(n) {cin >> _t; st.insert(_t);}}


typedef long long int ll;
typedef unsigned long long int ull;

ll mod = 1000000007;

ll power(ll a, ll b){
	if(b == 1) return a;
	ll p = power(a, b / 2);
	if(b & 1){
		return (((p * p) % mod) * a) % mod;
	}
	return (p*p) % mod;
}

int main(){
    FAST_IO
    
    ll n;
    cin >> n;
    
    ll a1 = power(10, n);
    ll a2 = power(9, n);
    ll a3 = power(8, n);
    
    ll ans = ((a1 + a3)%mod - ((2*a2) % mod) + mod) % mod;
    
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
  int hands[5], i, numRock, numScis, numPaper;
  while(cin >> hands[0], hands[0]){
    for(i=1; i<5; i++){
      cin >> hands[i];
    }
    numRock=0, numScis=0, numPaper=0;
    for(i=0; i<5; i++){
      if(hands[i]==1)numRock++;
      if(hands[i]==2)numScis++;
      if(hands[i]==3)numPaper++;
    }
    if(numRock==0 && numScis>0 && numPaper>0){
      for(i=0; i<5; i++){
        if(hands[i]==2){
          cout << 1 << endl;
        }else{
          cout << 2 << endl;
	}
      }
    }else if(numScis==0 && numRock>0 && numPaper>0){
      for(i=0; i<5; i++){
	if(hands[i]==3){
          cout << 1 << endl;
	}else{
          cout << 2 << endl;
        }
      }
    }else if(numPaper==0 && numRock>0 && numScis>0){
      for(i=0; i<5; i++){
        if(hands[i]==1){
          cout << 1 << endl;
        }else{
          cout << 2 << endl;
        }
      }
    }else{
      for(i=0; i<5; i++){
	cout << 3 << endl;
      }
    }
  }
}

Measured memory_bytes: 3088
//強連結成分分解
//O(V + E)
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
#define MAX_V 100010

int V, E;                                       //頂点数　辺数
vector<int> G[MAX_V];                           //グラフの隣接リスト表現(0-indexed)
vector<int> rG[MAX_V];                          //辺の向きを逆向きにしたグラフ
vector<int> vs;                                 //帰りがけ順での頂点の並び
bool used[MAX_V];                               //dsfのために、すでに訪れたかどうかを管理する
int cmp[MAX_V];                                 //属する強連結成分のトポロジカル順序

void dfs(int v){

    used[v] = true;
    for(int i = 0; i < (int)G[v].size(); i++){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }

    //帰りがけ順に格納
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    for(int i = 0; i < (int)rG[v].size(); i++){
        if(!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc(){
    memset(used, false, sizeof(used));
    vs.clear();
    for(int v = 0; v < V; v++){
        if(!used[v]) dfs(v);

    }
    memset(used, false, sizeof(used));
    int k = 0;
    for(int i = V - 1; i >= 0; i--){
        if(!used[vs[i]]){
            rdfs(vs[i], k);
            k++;
        }
    }    
    return k;
}

int main(){

    //入力
    cin >> V >> E;                              //頂点数　辺数
    
    for(int i = 0; i < E; i++){
        int from, to; cin >> from >> to;        //from -> toへの有向辺
        G[from].push_back(to); 
        rG[to].push_back(from);
    }

    memset(used, false, sizeof(used));
    scc();
    
    int Q; cin >> Q;
    for(int i = 0; i < Q; i++){
        int u, v; cin >> u >> v;
        cout << (cmp[u] == cmp[v]) << endl;
    }
    return 0;
}


Measured memory_bytes: 9136
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    public static void solve(Scanner sc) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        sc.nextLine();
        String[] Ds = sc.nextLine().split(" ");
        Set<String> DSet = new HashSet<>(Arrays.asList(Ds));
        boolean contains = true;
        while (contains) {
            contains = false;
            String ns = String.valueOf(N);
            for (int i = 0; i < ns.length(); i++) {
                if (DSet.contains(String.valueOf(ns.charAt(i)))) {
                    N++;
                    contains = true;
                    break;
                }
            }
        }

        System.out.println(N);
    }
}

Measured memory_bytes: 25936