akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vi u(n-1), v(n-1);
    rep(i, n-1) cin >> u[i] >> v[i];
    ll sum = 0;
    rep(i, n) {
        sum += (i+1LL) * (i+2LL) / 2LL;
    }
    rep(i, n-1) {
        ll x = min(u[i], v[i]);
        ll y = max(u[i], v[i]);
        sum -= x * (n-y+1);
        // cout << x << " " << y << " " << sum << '\n';
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 4844
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        long T = sc.nextInt();
        long[] t = new long[N];
        long sum = 0;
        for (int i = 0; i < N; ++i) {
            t[i] = sc.nextInt();

            if (i > 0) {
                sum += Math.min(t[i] - t[i - 1], T);
            }
        }

        _out.println(sum + T);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

bool solve(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    if(B>D)return false;
    if(B>A)return false;

    if(C>=B)return true;

    A%=B;

    int g=gcd(B,D);

    int x=A+(B-1-A)/g*g;
    if(x>C)return false;
    return true;
}

signed main(){
    int T;cin>>T;
    while(T--){
        cout<<(solve()?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long long n,i,j,k,d[20],a;
	char s[20];
  
	scanf("%s",s);
  
	for(i=0;s[i];i++)
		d[i]=s[i]-'0';//printf("%d\n",i);
	for(j=a=0;j<(1<<(i-1));j++)
	{
		n=d[0];
		for(k=0;k<i-1;k++)
		{
			if(j&(1<<k))n=n*10+d[k+1];
			else
			{
				a+=n;//printf("%d\n",n);
				n=d[k+1];
			}
		}
    a+=n;
	}
  printf("%lld\n",a);
  return 0;
}

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




#define mp make_pair
#define pb push_back
#define rep(i,port,sail) for(i=port;i<=sail;i++)
const int N = 1010;
typedef long long ll;

ll dp[N][N];
ll mod = 1e9+7;

ll mx = 0;
string s[N];
int main()
{
	int n,i,j,k,t,u,v,m;
	ll W;
	cin>>n>>m;
	rep(i,1,n){
		cin>>s[i];s[i]="#"+s[i];
	}
	memset(dp,-1,sizeof(dp));
	dp[1][1]=1;
	rep(i,1,n)
	{
		rep(j,1,m)
		{
			if(i==1 &&j==1)continue;
			if(s[i][j]=='#')continue;
			dp[i][j]= 0;
			if(i-1 && dp[i-1][j]+1)dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			if(j-1 && dp[i][j-1]+1)dp[i][j] = (dp[i][j]+ dp[i][j-1])%mod;
		}
	}
	cout<<max(0ll,dp[n][m])<<"\n";

	
	return 0;
}



Measured memory_bytes: 9216
import java.io.*;
import java.util.*;
import java.util.function.IntPredicate;

class Main {
    public static void main(String[] args) {
        new Main().solve();
    }

    public static int upperBound(int lb, int ub, IntPredicate pred) {
        if (! pred.test(lb)) return lb;
        assert !pred.test(ub);
        while (lb + 1 < ub) {
            int mid = (ub - lb) / 2 + lb;
            if (pred.test(mid)) lb = mid;
            else ub = mid;
        }
        return ub;
    }

    final int INF = Integer.MAX_VALUE / 4;
    final int Z = 26;

    void solve() {
        String s = "";
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try { s = reader.readLine(); } catch (IOException e) {}
        final int N = s.length();
        final boolean[] used = new boolean[Z]; Arrays.fill(used, false);
        final int[] len = new int[N + 1]; len[N] = 1;
        int count = Z;
        int length = 0;
        final ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>(Z);
        for (int i = 0; i < Z; i++) a.add(new ArrayList<Integer>());
        for (int i = N - 1; i >= 0; i--) {
            char c = s.charAt(i);
            int c_index = (int)(c - 'a');
            a.get(c_index).add(i);
            len[i] = len[i + 1];
            if (used[c_index]) continue;
            used[c_index] = true;
            count--;
            if (count == 0) {
                Arrays.fill(used, false);
                count = Z;
                length++;
                len[i]++;
            }
        }
        for (ArrayList<Integer> xs : a) Collections.reverse(xs);
        StringBuilder builder = new StringBuilder();
        int cur = -1;
        for (int i = length; i >= 0; i--) {
            for (int j = 0; j < 26; j++) {
                ArrayList<Integer> xs = a.get(j);
                final int _cur = cur;
                int next = upperBound(0, xs.size(), (IntPredicate)(int k) -> { 
                    return k >= xs.size() ? false : xs.get(k) <= _cur; 
                });
                int k = next >= xs.size() ? N : xs.get(next);
                if (k == N) {
                    builder.append((char)(j + 'a'));
                    break;
                } else if (len[k + 1] == i) {
                    cur = k;
                    builder.append((char)(j + 'a'));
                    break;
                }
            }
        }
        System.out.println(builder.toString());
    }
}

Measured memory_bytes: 35224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll H,W;scanf("%lld %lld",&H,&W);
    vvl info(H,vl(W));
    rep(i,H)rep(j,W)scanf("%lld",&info[i][j]);
    vector<pair<pl,pl>> ans;
    rep(i,H)rep(j,W){
        if(i<H-1){
            if(info[i][j]%2){
                ans.push_back({{i+1,j+1},{i+2,j+1}});
                info[i][j]--,info[i+1][j]++;
            }
        }
        else{
            if(j<W-1){
                if(info[i][j]%2){
                    ans.push_back({{i+1,j+1},{i+1,j+2}});
                    info[i][j]--,info[i][j+1]++;
                }
            }
        }
    }
    printf("%lld%s",ans.size(),"\n");
    for(auto p:ans)printf("%lld %lld %lld %lld%s",p.fi.fi,p.fi.se,p.se.fi,p.se.se,"\n");
    return 0;
}


Measured memory_bytes: 8172
from fractions import gcd

N, M = map(int,input().split())
S = input()
T = input()
L = (N*M)//gcd(N,M)
S_a = L // N
T_a = L // M
L_a = (S_a*T_a)//gcd(S_a,T_a)

S_b = L_a // S_a
T_b = L_a // T_a
i = 0
j = 0
while True:
    if S[i] != T[j]:
        print('-1')
        break
    i += S_b
    j += T_b
    if i >= N or j >= M:
        print(L)
        break
    
        

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

int main() {
	std::vector<int>v;
	v.resize(3);
	for (auto&e : v)
		std::cin >> e;

	std::sort(std::begin(v), std::end(v));

	std::cout << std::abs(v[2] - v[1]) + std::abs(v[1] - v[0]) << "\n";
	return 0;
}

Measured memory_bytes: 768
def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass


N, M = map(int, input().split())

K = divisor(M)

ans = 0
for k in K:
    if N * k <= M:
        ans = max(ans, k)


print(ans)



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

int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  
  int t = 60*h + m;
  double angle = 5.5 * t;
  while(angle > 360){angle -= 360;}
  if(angle > 180){angle = 360 - angle;}
  
  double c,pi;
 
  pi = 3.141592653589793238;
  c = cos(angle / 180 * pi);
  
    
    double answer;
  answer = a*a + b*b - 2*a*b*c;
  answer = sqrt(answer);
  
  
  printf("%.12lf\n", answer);
}
  

Measured memory_bytes: 4132
def mx(mtrx):
	maxSum = -1000000
	for colStart in range(n):
		partSum = [0]*n
		for colEnd in range(colStart,n):
			for row in range(n):
				partSum[row] += mtrx[row][colEnd]
			maxSum = max(maxPart(partSum), maxSum)
	return maxSum

def maxPart(array):
	maxSum = -1000000
	calcSum = 0
	for i in range(n):
		calcSum += array[i]
		maxSum = max(calcSum,maxSum)
		if calcSum < 0:
			calcSum = 0
	return maxSum
	
n = int(raw_input())
mtrx = [map(int, raw_input().split()) for i in range(n)]
print mx(mtrx)

Measured memory_bytes: 4568
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new java.util.Scanner(System.in);
        int a = sc.nextInt(); int b = sc.nextInt();
        if (!(a >= 1 && a <= 9 && b >= 1 && b <= 9)) {
            System.out.println("-1");
        } else {
            System.out.println(a * b);
        }
    }

}

Measured memory_bytes: 23764
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Q, x[5007], group[5007]; string s[5007], t1, t2; vector<int> g[5007];
int key(string str) {
	return find(s, s + N, str) - s;
}
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> s[i] >> x[i], g[i] = { i }, group[i] = i;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> t1 >> t2;
		int r1 = group[key(t1)], r2 = group[key(t2)];
		if (r1 == r2) continue;
		for (auto &e : g[r2]) {
			group[e] = r1;
			g[r1].push_back(e);
		}
		g[r2].clear();
	}
	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (g[i].empty()) continue;
		int res = 999999999;
		for (auto &e : g[i]) res = min(res, x[e]);
		ret += res * g[i].size();
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3768
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (a, b) = readLongList()
    val gcdAB = gcd(a, b)
    val d = primeFactor(gcdAB).keys.size
    println(d + 1)

}

/** O(log(n)): n = min(a, b) */
fun gcd(a: Long, b: Long): Long {
    var tmpA = a
    var tmpB = b
    while (tmpB != 0L) {
        val tmp = tmpB
        tmpB = tmpA % tmpB
        tmpA = tmp
    }
    return tmpA
}

/**
O(n^(1/2)) // n * n <= Long.MAX_VALUE n <= 10^8 or more
if n == 1, return emptyMap
 */
fun primeFactor(n: Long): Map<Long, Long> {
    val factorMap = mutableMapOf<Long, Long>()
    var target = n
    var i = 2L
    while (i * i <= target) {
        while (target % i == 0L) {
            factorMap[i] = factorMap.getOrElse(i) { 0L } + 1L
            target /= i
        }
        i++
    }

    if (target != 1L) { factorMap[target] = 1 }
    return factorMap
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37880
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int x;
    cin >> x;
    x -= 400;

    x /= 200;
    x = 8 - x;

    cout << x << '\n';


    return 0;
}

Measured memory_bytes: 3656
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	int sr, sc;
	cin >> sr >> sc;
	string S, T;
	cin >> S >> T;

	string res = "YES";

	// 左右方向、1から左へ
	int x = sc;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'L') --x;
		if (x <= 0)
			res = "NO";
		if (T[i] == 'R') ++x;
		if (x > W) x = W;
	}
	// 左右方向、Wから右へ
	x = sc;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'R') ++x;
		if (x > W)
			res = "NO";
		if (T[i] == 'L') --x;
		if (x <= 0) x = 1;
	}
	// 上下方法、1から上へ
	int y = sr;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'U') --y;
		if (y <= 0)
			res = "NO";
		if (T[i] == 'D') ++y;
		if (y > H) y = H;
	}
	// 上下方向、Hから下へ
	y = sr;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'D') ++y;
		if (y > H)
			res = "NO";
		if (T[i] == 'U') --y;
		if (y <= 0) y = 1;
	}

	cout << res << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string A, B, C; cin >> A >> B >> C;
	int a = 0, b = 0, c = 0;
	string ans;
	char card = 'a';
	while(1) {
		if(card == 'a') {
			if(a == A.size()) {
				ans = "A";
				break;
			}
			card = A[a];
			a++;
		}
		else if(card == 'b') {
			if(b == B.size()) {
				ans = "B";
				break;
			}
			card = B[b];
			b++;
		}
		else {
			if(c == C.size()) {
				ans = "C";
				break;
			}
			card = C[c];
			c++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,m;
char p[N][N],r[N][N],b[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",p[i]+1);
	for (int i=1;i<=n;i++)r[i][1]='#';
	for (int i=1;i<=n;i++)b[i][m]='#';
	for (int i=1;i<=n;i+=2)
		for (int j=2;j<m;j++)r[i][j]='#';
	for (int i=2;i<=n;i+=2)
		for (int j=2;j<m;j++)b[i][j]='#';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) 
			if ((p[i][j]=='#')||(r[i][j]=='#'))r[i][j]='#';
			else r[i][j]='.';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) 
			if ((p[i][j]=='#')||(b[i][j]=='#'))b[i][j]='#';
			else b[i][j]='.';
	for (int i=1;i<=n;i++)puts(r[i]+1);
	puts("\n");
	for (int i=1;i<=n;i++)puts(b[i]+1);
}

Measured memory_bytes: 1536
h, w, m = map(int, input().split())
bord_x, bord_y = [0]*h, [0]*w
 
hw = []
for _i in range(m):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    bord_x[s] += 1
    bord_y[t] += 1
    hw.append([s, t])
 
x_max, y_max = max(bord_x), max(bord_y)
 
cnt = 0
for i, j in hw:
    if bord_x[i] == x_max and bord_y[j] == y_max:
        cnt += 1
 
if cnt == bord_x.count(x_max)*bord_y.count(y_max):
    x_max -= 1
 
print(x_max+y_max)

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

int main(){
  int a, b;
  cin >> a >> b;
  int c = min(a, b) + '0';
  int d = max(a, b);
  char S[10];
  rep(i, 10) S[i] = 0;
  rep(i, d) S[i] = c;
  cout << S << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<vector<int>> C(N + 1, vector<int>(0));
    rep(i, 0, M){
        cin >> A.at(i) >> B.at(i);
        C.at(A.at(i)).push_back(B.at(i));
        C.at(B.at(i)).push_back(A.at(i));
    }
    vector<int> D(N + 1, INF);
    queue<int> q;
    q.push(1);
    D.at(1) = 0;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        rep(i, 0, C.at(x).size()){
            int y = C.at(x).at(i);
            if(D.at(y) == INF){
                q.push(C.at(x).at(i));
                D.at(y) = x;
            }
        }
    }
    rep(i, 2, N + 1){
        if (D.at(i) == INF){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i, 2, N + 1){
        cout << D.at(i) << endl;
    }
}

Measured memory_bytes: 11688
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
A,B,K= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
wari=min(A,B)
while True:
    if A%wari==0 and B%wari==0:
        count+=1
    if count==K:
        print(wari)
        exit()
    wari-=1

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	auto H=vecin(N);
	vll dp(N,1ll<<60);
	dp[0] = 0;

	REP(i,N-1){
		chmin(dp[i+1],dp[i]+abs(H[i]-H[i+1]));
		if(i+2<N) chmin(dp[i+2],dp[i]+abs(H[i]-H[i+2]));
	}
	out(dp[N-1]);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  for (int i = 0; i < s.size() - 2; ++i) {
    if (s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      for(int i = 0;i<n;i++){
         a[i] = sc.nextInt();
         if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
               System.out.println("DENIED");
               return;
            }
         }
      }
      System.out.println("APPROVED");     
   }
}

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

int main() {
  int N;
  cin >> N;
  int sum;
  
  for(int i = 0;i < N;i++){
    int r,s;
    cin >> r >> s;
    sum += s - r + 1;
  }
  cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

int main(){
  ll N, x; cin >> N >> x;
  vector<ll> a(N);
  vector<vector<ll>> b(N, vector<ll>(N));
  REP(i, N) {
    cin >> a[i];
    b[i][0] = a[i];
  }
  ll ans = 1e18;
  //魔法の回数kで全探索
  REP(k,N){
    ll cost = k*x;
    REP(i,N){
      if(k!=0) b[i][k] = min(b[i][k-1], a[(i-k+N)%N]);
      cost += b[i][k];
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
}



Measured memory_bytes: 31744
#include <iostream>
using namespace std;
int digit(int a){
    int p = 0;
    while(a>0){
        a/=10;
        p++;
    }
    return p;
}
int main(){
    int cnt = 0;
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++){
        if(digit(i)%2==1) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
	int n;
  	cin >> n;
  	
  	cout << pow(n, 3);
    
    return 0;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n, m;
    cin >> n >> m;
    vector<string> s(n), t(m);
    rep(i,n) cin >> s[i];
    rep(i,m) cin >> t[i];
    
    rep(y,n-m+1)rep(x,n-m+1){
        bool ok = true;
        rep(i,m)rep(j,m){
            if(t[i][j] != s[y+i][x+j]) ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 1e5+5;

ll n,k,a[MAXN],b[MAXN]{0},q;

int main() {
	isc;
	cin >> n >> k >> q;
	rep(i,0,q){
		cin >> a[i];
		b[a[i]]++;
	}
	rep(i,1,n+1){
		if(k-(q-b[i])<=0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	return 0;
}



Measured memory_bytes: 2176
class EndLoop(Exception):
    pass
 
 
def solve():
    N = int(input())
 
    try:
        for h in range(1, 3500):
            for n in range(1, 3500):
                if 4 * h * n - n * N - h * N == 0:
                    pass
                elif (h * n * N) % (4 * h * n - n * N - h * N) == 0 and\
                            (4 * h * n - n * N - h * N) > 0:
                    w = (h * n * N) / (4 * h * n - n * N - h * N)
                    print(h, n, int(w))
                    raise EndLoop
    except(EndLoop):
        pass
 
 
solve()

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

int main(){
    int n;
    cin>>n;
    char s;
    int ans=0,x=0;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=='I')x++;
        else if(s=='D')x--;
        if(x>ans)ans=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3576
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    len_s = len(s)

    ok = True
    for i in range(len_s//2):
        if s[i] != s[len_s-1-i]:
            ok = False
    
    for i in range((len_s//2)//2):
        if s[i] != s[(len_s//2)-1-i]:
            ok = False
    
    if ok:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define INF               1e18
#define ff                first
#define ss                second
#define vi                vector<int>
#define pii               pair<int,int>
#define mii               map<int,int>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define debug(x)          cout<<#x<<" is "<<(x)<<endl
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(long long i=a;i<b;i++)
#define sp(ans,p)         fixed <<setprecision(p)<<ans;
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int n, m, k, q, l, r, x, y, z;
int a[1000005];
int b[1000005];
int c[1000005];
string s, t;
int ans = 0;



void solve()
{
    cin >> n >> k;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) --a[i];
    rep(i, 0, n) cin >> b[i];
    // ai(b, n);

    ans = -2e18;
    rep(i, 0, n)
    {
        int csize = 0, cval = 0;
        int pt = i;
        do {
            pt = a[pt];
            ++csize;
            cval += b[pt];
        } while (pt != i);

        int rem = k, cur = 0;
        if (cval > 0)
        {
            cur += (k / csize) * cval;
            rem %= csize;
        }

        int cbest = -2e18;
        if (rem == 0) cbest = 0;
        cval = 0;

        pt = i;
        do {
            if (rem <= 0) break;
            pt = a[pt];
            cval += b[pt];
            cbest = max(cbest, cval);
            --rem;
        } while (pt != i);

        ans = max(ans, cbest + cur);
    }

    rep(i, 0, n)
    {
        int csize = 0, cval = 0;
        int pt = i;
        do {
            pt = a[pt];
            ++csize;
            cval += b[pt];
        } while (pt != i);

        if (k >= csize)
        {
            int rem = k, cur = 0;
            if (cval > 0)
            {
                cur += (k / csize - 1) * cval;
                rem %= csize;
                rem += k;
            }

            int cbest = -2e18;
            if (rem == 0) cbest = 0;
            cval = 0;

            pt = i;
            do {
                if (rem <= 0) break;
                pt = a[pt];
                cval += b[pt];
                cbest = max(cbest, cval);
                --rem;
            } while (pt != i);

            ans = max(ans, cbest + cur);
        }
    }

    cout << ans << '\n';
}

signed main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    int t = 1;
    // cin >> t;
    while (t--)   solve();
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
bool tate[110],yoko[110];
int main() {
  ll h,w;
  cin>>h>>w;
  char c[110][110];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];
  for(int i=0;i<h;i++){
    bool f=1;
    for(int j=0;j<w;j++){
      if(c[i][j]=='#')f=0;
    }
    if(f)yoko[i]=1;
  }
  for(int i=0;i<w;i++){
    bool f=1;
    for(int j=0;j<h;j++){
      if(c[j][i]=='#')f=0;
    }
    if(f)tate[i]=1;
  }
  for(int i=0;i<h;i++){
    if(yoko[i])continue;
    for(int j=0;j<w;j++){
    if(tate[j])continue;
    cout<<c[i][j];
    }
    cout<<endl;
  }
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> m(n);
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        m[i] = x;
    }
    int max = m[0];
    int count = 1;
    for(int i = 1; i < n; i++)
    {
        if (m[i] >= max) {
            count++;
            max = m[i];
        }
    }
    cout << count << "\n";
}

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

int main() {

  int A, B, I, J, H, S, M, X;
  cin >> A >> B;
  X = 0;
  for(int i = A; i <= B; i++){
  M = i / 10000;
  S = (i % 10000) / 1000;
  J = (i % 100) / 10;
  I = (i % 10);
  if(M == I && S == J){
   X++;
  }
  }
cout << X << endl;
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    while (H!=0 || W!=0)
    {
        for (int i = 0; i < H; i++)
        {
            for(int j = 0; j < W; j++)
            {
                cout << "#";
            }
            cout <<endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3112
a = list(map(int,input().split()))
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
x = a[0]
y = a[1]
if(x != 1) and (x != 0):
    c = (combinations_count(x, 2))
else:
    c = 0
if(y != 1) and (y != 0):
    d = (combinations_count(y, 2))
else:
    d = 0
print(c + d)

Measured memory_bytes: 3572
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in range(m):
  s,t=map(int,input().split())
  if x[s-1]<x[t-1]:
    y.append(s)
  elif x[s-1]>x[t-1]:
    y.append(t)
  else:
    y.append(s)
    y.append(t)
z=set(y)
print(n-len(z))

Measured memory_bytes: 20116
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, a; cin >> n >> a;
    ll ans = 0;
    ans += n / a;
    if(n % a != 0)ans++;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

bool is_intersect(P a1, P a2, P b1, P b2){ //線分の交差判定
    return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) && 
        (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS);
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

#define printP(P) cout << "(" << P.real() << ", " << P.imag() << ")" << endl;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q;
    cin >> q;
    while(q--){
        double x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        P p0(x0,y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
        if(is_para(p0,p1,p2,p3)){
            print("2");
        }else if(is_orth(p0,p1,p2,p3)){
            print("1");
        }else{
            print("0");
        }

    }
}


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

int main(void){
  string s;
  int k;
  vector< int >num;
  cin >> s;
  cin >> k;
  for(int i = 0;i < (int)s.size();++i){
    int a = (26 - (s[i] - 'a')) % 26;
    num.push_back(a);
  }
  for(int i = 0;i < (int)s.size();++i){
    if(num[i] <= k){
      k -= num[i];
      s[i] = 'a';
      num[i] = 0;
    }
  }
  k %= 26;
  int itr = (int)s.size();
  for(int i = (int)s.size()-1;i >= 0;--i){
    if(num[i] != 0){
      s[i] += k;
      k = 0;
      break;
    }
  }
  if(k > 0)s[(int)s.size()-1] += k;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1020
N, x = list(map(int, input().split()))
candies = list(map(int, input().split()))


def put_sum_candies(candies):
    base = 0
    for i, _ in enumerate(candies):
        if i == 0:
            continue
        if candies[i-1] + candies[i] <= x:
            continue
        if candies[i-1] > x:
            base += candies[i-1] - x
            candies[i-1] -= candies[i-1] - x
            base += candies[i] + candies[i-1] - x
            candies[i] -= candies[i] + candies[i-1] - x
        elif candies[i-1] <= x:
            base += candies[i] + candies[i-1] - x
            candies[i] -= candies[i] + candies[i-1] - x
    return base


base = put_sum_candies(candies)
print(base)


Measured memory_bytes: 14544
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define BUFF_SIZE 1024
char buffer[1024 * 32];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    int i;
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }

    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 392
#include <bits/stdc++.h>
#define L long long
 
using namespace std;
 
struct S{
	L s,e;
};
 
bool operator<(S a,S b){
	if(a.s!=b.s) return a.s<b.s;
	return a.e<b.e;
}
 
set<S>st;
 
char str[100010];
L b[100010];
L n,len;
 
L tr[400040];
 
void update(L now,L S,L E,L s,L e,L val){
	while(e)
	{
		tr[e]+=val;
		e^=e&-e;
	}
	s--;
	while(s)
	{
		tr[s]-=val;
		s^=s&-s;
	}
}
 
L get(L now,L S,L E,L loc){
	L ret=0;
	while(loc<=len)
	{
		ret+=tr[loc];
		loc+=loc&-loc;
	}
	return ret;
}
 
void E(L x){
	//printf("%lld\n",x);
	puts("NO");
	exit(0);
}
 
int main()
{
	scanf("%s %lld",str,&n);
	L i,j;
	for(i=0;str[i];i++);
	len=i;
	//printf("%lld\n",len);
	for(i=1;i<=n;i++)
	{
		L s,e;
		scanf("%lld %lld",&s,&e);
		if(s<=len/2)
		{
			if(e>len/2)
			{
				e=len-e;
				if(e<s)
				{
					s--;
					e++;
					swap(s,e);
					if(s>e) continue;
				}
			}
			if(len%2&&e==(len+1)/2) e--;
			if(s>e) continue;
		}
		else
		{
			s=len-s+1;
			e=len-e+1;
			swap(s,e);
		}
		st.insert((S){s,e});
	}
	for(i=1;i<=len;i++)
	{
		b[i]=str[i-1]-'a';
	}
	for(i=1;i<=len/2;i++)
	{
		b[i]-=b[len-i+1];
		if(b[i]<0) b[i]+=26;
		//printf("%lld ",b[i]);
	}
	//puts("");
	len/=2;
	for(i=1;i<=len;i++)
	{
		update(1,1,len,i,i,b[i]);
	}
	//for(set<S>::iterator it=st.begin();it!=st.end();it++)
	//	printf("%lld %lld\n",it->s,it->e);
	//printf("sz %lld\n",st.size());
	for(i=1;i<=len;i++)
	{
		L temp=get(1,1,len,i)%26;
		if(temp)
		{
			if(st.empty()||st.begin()->s!=i) E(1);
			S range=*(st.begin());
			//printf("%lld %lld %lld\n",range.s,range.e,temp);
			update(1,1,len,range.s,range.e,26-temp);
			
			st.erase(st.begin());
			set<S>sttemp;
			L prelast=range.e;
			for(set<S>::iterator it=st.begin();it!=st.end()&&it->s==range.s;it++)
			{
				sttemp.insert((S){prelast+1,it->e});
				prelast=it->e;
			}
			while(1)
			{
				set<S>::iterator it=st.begin();
				if(it==st.end()||it->s!=range.s) break;
				st.erase(it);
			}
			for(set<S>::iterator it=sttemp.begin();it!=sttemp.end();it++)
			{
				st.insert(*it);
			}
		}
		else
		{
			if(!st.empty()&&st.begin()->s==i)
			{
				S range=*(st.begin());
				st.erase(st.begin());
				set<S>sttemp;
				L prelast=range.e;
				for(set<S>::iterator it=st.begin();it!=st.end()&&it->s==range.s;it++)
				{
					sttemp.insert((S){prelast+1,it->e});
					prelast=it->e;
				}
				while(1)
				{
					set<S>::iterator it=st.begin();
					if(it==st.end()||it->s!=range.s) break;
					st.erase(it);
				}
				for(set<S>::iterator it=sttemp.begin();it!=sttemp.end();it++)
				{
					st.insert(*it);
				}
			}
		}
		/*for(j=1;j<=len;j++)
		{
			printf("%lld ",get(1,1,len,j));
		}
		puts("");*/
	}
	puts("YES");
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                    ll n,d;
                    cin>>n>>d;
                    ll count=0;
                    ll x,y;
                    for(int i=0;i<n;++i)
                    {
                         cin>>x>>y;
                         if(x*x+y*y<=d*d)
                              count++;
                    }
                    cout<<count;
          }
          return 0;
}


Measured memory_bytes: 3692
k = input()
s = raw_input()

if k==0:
    print s
    exit(0)
if len(s) % (k+1) == 0:
    p = len(s) / (k+1)
    print max(int(s[i:i+p]) for i in xrange(0,len(s),p))
    exit(0)

l = len(s) / (k+1)
r = (len(s)+k) / (k+1)
left = 10**(l-1)
right = 10**r
while 1:
    mid = (left + right) / 2
    cnt = 0
    now = ""
    mid_c = str(mid)
    cp = idx = 0
    for c in s:
        now += c
        if not cp and idx < len(mid_c) and c != mid_c[idx]:
            cp = 1 if c > mid_c[idx] else -1
        idx += 1
        if (idx == len(mid_c) and cp == 1) or idx > len(mid_c):
            cnt += 1
            idx = 1; cp = 0
            if int(c) > mid:
                cnt = 100003
                break
            now = c
            if c != mid_c[0]:
                cp = 1 if c > mid_c[0] else -1
    if cnt > k:
        if left == mid:
            break
        left = mid
    else:
        if right == mid:
            break
        right = mid
print left+1


Measured memory_bytes: 24732
module Main where

import Data.Functor

main :: IO ()
main = do
  { [x, y] <- getInts
  ; if x == 0 && y == 0 then done
    else do
      { case compare x y of
          LT -> putInts [x,y]
          GT -> putInts [y,x]
          EQ -> putInts [x,y]
      ; main
      }
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 4080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    return 0;
}

Measured memory_bytes: 256
def main():
  A, B, C, D = map(int, input().split())

  for i in range(100):
    C -= B
    if C <= 0:
      print('Yes')
      exit()
    else:
      pass
    A -= D
    if A <= 0:
      print('No')
      exit()
    else:
      pass 

if __name__ == "__main__":
  main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

void chmax(int &a, int b){a = max(a, b);}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int m;
    cin >> s >> m;
    int n = s.length();
    s = "#" + s;
    vector<vector<vector<int> > > dp(n+1, vector<vector<int> > (n+2, vector<int> (m+1, 0)));
    int ans = 0;
    for(int i=1;i<=n;i++){
    	for(int j=n;j>=i;j--){
    		for(int k=0;k<=m;k++){
    			chmax(dp[i][j][k], dp[i][j+1][k]);
    			chmax(dp[i][j][k], dp[i-1][j][k]);
    		}
    		if(s[i] == s[j]){
    			for(int k=0;k<=m;k++){
    				if(i == j) chmax(dp[i][j][k], dp[i-1][j+1][k] + 1);
    				else chmax(dp[i][j][k], dp[i-1][j+1][k] + 2);
    				chmax(ans, dp[i][j][k]);
    			}
    		}else{
    			for(int k=0;k<m;k++){
    				if(i == j) chmax(dp[i][j][k+1], dp[i-1][j+1][k] + 1);
    				else chmax(dp[i][j][k+1], dp[i-1][j+1][k] + 2);
    				chmax(ans, dp[i][j][k+1]);
    			}
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 110720
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<31;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	REP(i, N + 1) scanf("%d", &A[i]);
	
	bool ng = false;
	
	vector<ll> mx(N + 1, longINF);
	{
		ll cur = 0;
		mx[0] = 1 - A[0];
		if (mx[0] < 0) ng = true;
		REP(i, N + 1) {
			if (mx[i] < 0) ng = true;
			if (i < N) chmin(mx[i + 1], mx[i] * 2 - A[i + 1]); // 子を持って良い頂点の最大数
		}
	}
	
	ll ans = 0, cur = 0;
	for (int i = N; i >= 0; --i) {
		if (cur > mx[i]) {
			ll resmx = cur / 2;
			ll diff = cur - mx[i];
			if (diff > resmx) { ng = true; break; }
			cur = mx[i];
		}
		cur += A[i];
		ans += cur;
	}
	
	if (ng) ans = -1;
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n, l;
	cin >> n >> l;
	int ans = (l + l + n - 1) * n / 2;
	if(l > 0) ans -= l;
	else if(l + n - 1 < 0) ans -= l + n - 1;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){	
	set<int>Q;
	int a,b,c;
	cin>>a>>b>>c;
	Q.insert(a);
	Q.insert(b);
	Q.insert(c);
	cout<<Q.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	long long h;
	cin >> h;

	long long attackNum = 0;
	int n = 0;
	while (h > 0) {


		attackNum += pow(2, n);
		n++;
		h = (long long)(h / 2);
	}

	cout << attackNum;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132
{
    class Program
    {


        static void Main(string[] args)
        {
            string Str = Console.ReadLine().Trim();
            int n = int.Parse(Str);

            Str = Console.ReadLine().Trim();
            string[] StrArr = Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
            int[] d = StrArr.Select(int.Parse).ToArray();
            int k = 0;
            int tmp = n / 2;
            //d.OrderByDescending(value =>value);
            Array.Sort(d);
            if (d[tmp-1]==d[tmp])
            {
                k = 0;
            }
            else
            {
                k = d[tmp] - d[tmp-1];
            }
            Console.WriteLine(k);

        }

    }
}


Measured memory_bytes: 18016