akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};

const double eps = 0.0000001;


int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

bool isInterSection(vec (&p)[4]){
    switch(ccw(p[0],p[1],p[2])*ccw(p[0],p[1],p[3])){
        case -1:
        case -4:
        case 0:
            break;
        default:
            return false;
    }
    switch(ccw(p[2],p[3],p[0])*ccw(p[2],p[3],p[1])){
        case -1:
        case -4:
        case 0:
            break;
        default:
            return false;
    }
   return true;
}

vec interSection(vec (&p)[4]){
    vec p23=p[3]-p[2],p02=p[2]-p[0],p01=p[1]-p[0];
    double k = p23.cross(p02)/p23.cross(p01);
    return p[0]+p01*k;
}

double dist(vec (&p)[4]){
    if(isInterSection(p)) return 0;
    double dist =1e5;
    vec P;
    P=p[0]+(p[1]-p[0])*((p[1]-p[0]).dot(p[2]-p[0])/(p[1]-p[0]).dot(p[1]-p[0]));
    if(!ccw(p[0],p[1],P)){
        dist = min(dist,(P-p[2]).norm());
    }
    P=p[0]+(p[1]-p[0])*((p[1]-p[0]).dot(p[3]-p[0])/(p[1]-p[0]).dot(p[1]-p[0]));
    if(!ccw(p[0],p[1],P)){
        dist = min(dist,(P-p[3]).norm());
    }
    P=p[2]+(p[3]-p[2])*((p[3]-p[2]).dot(p[0]-p[2])/(p[3]-p[2]).dot(p[3]-p[2]));
    if(!ccw(p[2],p[3],P)){
        dist = min(dist,(P-p[0]).norm());
    }
    P=p[2]+(p[3]-p[2])*((p[3]-p[2]).dot(p[1]-p[2])/(p[3]-p[2]).dot(p[3]-p[2]));
    if(!ccw(p[2],p[3],P)){
        dist = min(dist,(P-p[1]).norm());
    }
    dist = min(dist,(p[2]-p[0]).norm());
    dist = min(dist,(p[2]-p[1]).norm());
    dist = min(dist,(p[3]-p[0]).norm());
    dist = min(dist,(p[3]-p[1]).norm());
    return dist;
}

int main(void){
    vec p[4];
    int q;
    cin >> q;
    cout.precision(10);
    cout << fixed;
    while(q--){
        for(auto& v : p) cin >> v.x >> v.y;
        cout << dist(p) << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;var res = 0L;
        var ar = Input.arL;
        while (ar.Max() > num - 1)
        {
            var sum = ar.Sum(v => v / num); res += sum;
            for(var i=0;i<num;i++)
            {
                var t = ar[i] / num;
                ar[i] %= num;
                ar[i] += sum - t;
            }
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static char[][] gred(int h)
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static string[] Make<T1, T2>(out T1 v1, out T2 v2)
    {
        var r = read.Split(' ');
        v1 = getValue<T1>(r[0]);
        v2 = getValue<T2>(r[1]);
        return r;
    }
    public static string[] Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        var r = Make(out v1, out v2);
        v3 = getValue<T3>(r[2]);
        return r;
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const LL MOD = 1e9+7;

LL qpow(LL a, LL b) {
    LL ret = 1;
    while(b) {
        if(b & 1) (ret *= a) %= MOD;
        (a *= a) %= MOD;
        b >>= 1;
    }
    return ret;
}

void run_case() {
    int n; cin >> n;
    vector<LL> a(n);
    for(auto &x: a) cin >> x;
    sort(a.begin(), a.end(), greater<LL>());
    LL ans = 0;
    for(int i = 0; i < n; ++i)
        (ans += a[i]*(i+2) % MOD) %= MOD;
    (ans *= qpow(4, n-1)) %= MOD;
    cout << (ans + MOD) % MOD;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
long long n,k,s=0,x[55],dp[55][55][2500+5];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>x[i],s+=x[i];
    for(int i=0;i<=n;i++) dp[i][0][0]=1;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            for(int sum=1;sum<=s;sum++)
            {
                dp[i][j][sum]=dp[i-1][j][sum];//khong chon x_i
                if (x[i]<=sum)
                    dp[i][j][sum]+=dp[i-1][j-1][sum-x[i]];//chon x_i
            }
        }
    }
    long long res=0;
    for(int i=1;i<=n;i++) res+=dp[n][i][k*i];//cout<<dp[n][i][k*i]<<' '<<i<<"\n";
    cout<<res;
    return 0;
}


Measured memory_bytes: 28836
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

int find(const string &str, const string& word) {
  int count = 0;
  for (string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos; pos += word.size()) {
    ++count;
  }
  return count;
}

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

  long n;
  cin >> n;

  string s[10001]; 

  rep(i, n) {
    cin >> s[i];
  }

  long cnt = 0;
  long lasta = 0;
  long fstb = 0;
  long futa = 0;
  rep(i, n) {
    cnt+=find(s[i], "AB");
    if (s[i][0] == 'B' && s[i].back() == 'A') futa++;
    else if (s[i][0] == 'B') fstb++;
    else if (s[i].back() == 'A') lasta++;
  }

  // long sd = min(futa, min(fstb, lasta));
  // cnt += 2*sd;
  // futa -= sd;
  // fstb -= sd;
  // lasta -= sd;

  // if (futa == 0) {
  //   cnt += min(fstb, lasta);
  // } else if (fstb == 0 && lasta == 0){
  //   cnt += max(futa-1, 0L);
  // } else {
  //   cnt += futa;
  // }

  if (fstb == 0 && lasta == 0 && futa > 0) {
    cout << cnt + futa + min(fstb, lasta) - 1 << endl;
  } else {
    cout << cnt + futa + min(fstb, lasta) << endl;
  }
}


Measured memory_bytes: 1016
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String[] c = new String[2];
		c[0] = in.next();
		c[1] = in.next();
		if(c[0].charAt(0)==c[1].charAt(2)&&c[0].charAt(1)==c[1].charAt(1)&&c[0].charAt(2)==c[1].charAt(0))System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#define NUM 200
using namespace std;
int score[NUM][3];
int n;
int ans;
bool flag;
int check(int i){
	int sum=0;
	for(int j=0;j<3;j++){
		flag=true;
		for(int k=0;k<n;k++){
			if(i==k)continue;
			if(score[i][j]==score[k][j])flag=false;
		}
		if(flag)sum+=score[i][j];
	}
	return sum;
}

int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> score[i][j];
		}
	}

	for(int i=0;i<n;i++){
		ans=check(i);
		cout <<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3076
'use strict'

const main = (input) => {
    input = input.split('\n').map(v => v.split(' ').map(v => parseInt(v)))
    const w = input[0][0]
    const h = input[0][1]
    const n = input[0][2]
    const arr = input.slice(1, n + 1)

    let first = {
        x: 0,
        y: 0,
    }

    let last = {
        x: w,
        y: h,
    }

    arr.forEach(v => {
        if(v[2] === 1){
            if(first.x < v[0]){
                first.x = v[0]
            }
        }
        if(v[2] === 2){
            if(last.x > v[0]){
                last.x = v[0]
            }
        }
        if(v[2] === 3){
            if(first.y < v[1]){
                first.y = v[1]
            }
        }
        if(v[2] === 4){
            if(last.y > v[1]){
                last.y = v[1]
            }
        }
    })
    if(first.x < last.x && first.y < last.y){
        console.log((last.x - first.x) * (last.y - first.y))
    }else{
        console.log(0)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 23092
import sys
import numpy as np 

n, *a = map(int, sys.stdin.read().split())
a = np.array([0] + a + [0])

def main():
    res1 = np.absolute(a[2:] - a[1:-1]) + np.absolute(a[1:-1] - a[:-2])
    res2 = np.absolute(a[2:] - a[:-2])
    default = np.absolute(a[1:] - a[:-1]).sum()
    
    ans = default - (res1 - res2)
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

dist=[None]*N
for i in range(N):
    if i==N-1:
        dist[i]=A[0]+K-A[i]
    else:
        dist[i]=A[i+1]-A[i]
#print(dist)
print(sum(dist)-max(dist))

Measured memory_bytes: 77644
#include "bits/stdc++.h"
using namespace std;

void call(double x, double y, int &res, double d){
    x = abs(x), y = abs(y);
    double dist = (double)sqrt((x*x + y*y));
    if(dist <= d)
        res++;
}
int main(){
    double x, y, n , d;
    cin>>n>>d;
    int res = 0;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        call(x, y, res, d);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    int l1 = 1, r1 = m+1, l2 = m+2, r2 = 2*m+1;
    auto put = [](int &a, int &b) {
        cout << a << " " << b << endl;
        a++; b--;
    };
    rep(i, m) {
        if (l1 < r1) put(l1, r1);
        else put(l2, r2);
    } 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;


int main() {
  int n;cin >> n;
  int ds[n];
  rep(i,n)cin >> ds[i];
  int ans=0;
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      ans += ds[i]*ds[j];
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int, input().split()))


class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow


graph = Dinic(n + 2)
for i in range(n):
    if a[i] >= 0:
        graph.add_edge(i, n, a[i])
        continue
    graph.add_edge(n + 1, i, -a[i])
for i in range(1, n + 1):
    for j in range(2 * i, n + 1, i):
        graph.add_edge(i-1, j-1, 10**11)
print(sum([max(0, i) for i in a])-graph.flow(n+1, n))


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    int count=0;
    
    
    
    
    cin >> S;
    
    if(S[0]=='o')   count++;
    if(S[1]=='o')   count++;
    if(S[2]=='o')   count++;
    
    cout << 700+(100*count);
    
    
    
   
}


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

using namespace std;

map<int, int> memo;

bool dfs(int n, int x) {
    if (memo[n] == -1) return false;
    if (n == x) return true;
    if (n > x) return false;

    if (dfs(n + 100, x)) return true;
    if (dfs(n + 101, x)) return true;
    if (dfs(n + 102, x)) return true;
    if (dfs(n + 103, x)) return true;
    if (dfs(n + 104, x)) return true;
    if (dfs(n + 105, x)) return true;

    memo[n] = -1;

    return false;
}

int main() {
    int X; cin>>X;

    cout << dfs(0, X) << endl;

    return 0;
}

Measured memory_bytes: 384
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t X,K,D;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> X>>K>>D;

    if (X < 0) {
        X = -X;
    }

    if (K <= X/D) {
        out << X - K * D << endl;
        return 0;
    }

    K -= X / D;
    X %= D;

    if (K % 2 == 1) {
        out << -(X - D) << endl;
        return 0;
    }

    out << X << endl;


    return 0;
}
#endif


Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define PI 3.14159265
#define seive_len 1

typedef long long int lli;

int *array;
int seive[seive_len];

long long int min(long long int a, long long int b) {
    return a<b?a:b;
}

long long int max(long long int a, long long int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

long double abs1(long double n) {
    if(n < 0)
        return n*(-1.0);
    return n*1.0;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

int binSearch(int a[], int x, int l, int r) {
    if(r >= l) {
        int mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

void makeSeive() {
    int i;
	seive[1] = 1;
    for(i=2;i<seive_len;i++) {
        if(seive[i] == 0) {
            long long int temp=(long long int)i*i;
            while(temp <= seive_len-1) {
                seive[temp] = 1;
                temp += i;
            }
        }
    }
}

int isPrime(int n) {
    int i;
    for(i=2;i*i<=n;i++)  {
        if(n%i == 0)
            return 0;
    }
    return 1;
}

void getInput(lli a[], lli n) {
    for(lli i=0;i<n;i++)
        scanf("%d", &a[i]);
}

void testCase() {
    lli n, i, k;
    // scanf("%lld%lld", &n, &k);
    // lli a[n];
    // getInput(a, n);
    char a;
    scanf("%c", &a);
    if(a >= 'A' && a <= 'Z') {
        printf("A");
        return;
    }
    printf("a");
}

int main() {
    int t=1;
    scanf("%d", &t);
    // makeSeive();
    while(t--) {
        testCase();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1660
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b) = (v[0], v[1]);
    let mut cur = 1;
    for i in 0.. {
        if cur >= b {
            println!("{}", i);
            return;
        }
        cur += a - 1;
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
bool prime(int x){
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return 0;
    }
    return 1;
}
int main(){
    int x[100001];
    x[0]=0;
    x[1]=0;
    for(int i=2;i<=100000;i++){
        if(i%2==0)x[i]=x[i-1];
        else{
            if(prime(i) && prime((i+1)/2))x[i]=x[i-1]+1;
            else x[i]=x[i-1];
        }
    }
    int q;
    cin>>q;
    int l[q],r[q];
    for(int i=0;i<q;i++)cin>>l[i]>>r[i];
    for(int i=0;i<q;i++)cout<<x[r[i]]-x[l[i]-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int dx[4] = {0,0,-1,1}, dy[4] = {1,-1,0,0};
int main() {
    int height,width; cin >> height >> width;
    vector<string> v(height);
    rep(i,height){
        cin >> v[i];
    }
    bool flag = true;
    rep(i,height){
        rep(j,width){
            if(v[i][j]=='#'){
                bool flag2 = false;
                rep(k,4){
                    int nx = j + dx[k], ny = i + dy[k];
                    if(nx>=0 && nx<width && ny>=0 && ny<height){
                        if(v[ny][nx]=='#'){
                            flag2 = true;
                        }
                    }
                }
                if(!flag2){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int d = stdIn.nextInt();
        int x[][] = new int[n][d];
        int count = 0;
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < d; j++){
                x[i][j] = stdIn.nextInt();
            }
        }
        
        for(int i = 0; i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                double sum = 0;
                for(int k = 0; k < d; k++){
                    sum += Math.pow(x[i][k] - x[j][k], 2);
                }  
                
                sum = Math.sqrt(sum);
                
                if(sum == (int)sum){
                    count++;
                }
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 22996
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second

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

char fld[200][200];
int N;
void init(){
    fill(*fld,*fld+40000,' ');
    REP(i,N+4)fld[0][i]=fld[N+3][i]=fld[i][0]=fld[i][N+3]='#';
}

void solve(){
    int x=2,y=N+1,d=1;
    while(true){
        fld[y][x]='#';
        bool f2=false;
        REP(i,4){
            int nd=(d+i)%4;
            int ny=y+dy[nd];
            int nx=x+dx[nd];
            bool flag=true;
            REP(j,4){
                if(j==(nd+2)%4)continue;
                if(fld[ny+dy[j]][nx+dx[j]]=='#')flag=false;
            }
            if(flag){
                x=nx;
                y=ny;
                d=nd;
                f2=true;
                break;
            }

        }
        if(f2==false)return;
    }
}


int main(){
    int n;cin>>n;
    bool flag=false;
    while(n--){
        cin>>N;
        if(flag)cout<<endl;
        else flag=true;
        init();
        solve();
        if(N==2){
            cout<<"##"<<endl;
            cout<<"# "<<endl;
            continue;
        }
        FOR(i,2,N+2){
            FOR(j,2,N+2)cout<<fld[i][j];
            cout<<endl;
        }
    }

    return 0;
}

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

int main() {
    int N;
    cin>>N;
    vector<int> h(N);
    map<int,int> m;
    for (int i = 0; i < N; i++){
        cin>>h[i];
        m[i-h[i]]++;
    }
    long long count=0;
    for (int i = 0; i < N; i++){
        count+=m[i+h[i]];
    }
    cout<<count<<endl;
}


Measured memory_bytes: 21140
import collections
import sys

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(sys.stdin.readline()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while S2 and (S2[-1] > left_edge):
                if S2[-1] > left_edge:
                    S2.pop()
                    new_puddle += S3.pop()
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), *S3)

Measured memory_bytes: 8416
S = input()
T = input()

# Tが当てはまる？
s = 0 # Tが当てはまる最初のインデックス
for i in range(len(S)-len(T)+1)[::-1]:
    flag = 1
    for j in range(len(T)):
        if S[i+j] != "?" and S[i+j] != T[j]:
            flag = 0
            break
    if flag:
        s = i
        break

if len(S) < len(T) or not flag:
    print("UNRESTORABLE")
else: # Tが当てはまった場合
    S = S[:s] + T + S[s+len(T):]
    # "?"を"a"で埋める
    S = S.replace("?", "a")
    print(S)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
using ll = long long;
int main(){
  ll n,k;
  cin >> n >> k;
  n = n%k;

  if(k-n<=n)  cout << k-n;
  else  cout << n;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#define rt return
#define ct continue
#define br break
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mmod 1000000007
#define pmod 998244353
using namespace std;
int gcd(int a,int b){
    while (b) b^=a^=b^=a%=b;
    return a;
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int bigmod(int b,int p,int m){
    int ans=1;
    b%=m;
    if (!b) return 0;
    while (p){
        if (p&1) ans=(ans*b)%m;
        p>>=1;
        b=(b*b)%m;
    }
    return ans;
}
int ncr(int n,int r){
	if (n<r) return 0ll;
	int ans=1,k=min(n-r,r);
	for (int i=1; i<=k; i++) ans=ans*(n-i+1)/i;
	return ans;
}
double eu(int x1,int y1,int x2,int y2){
	int dx=abs(x1-x2),dy=abs(y1-y2);
	return sqrt(dx*dx+dy*dy);
}
int ham(string s,string t){
	int ans=0;
	for (int i=0; i<s.size(); i++) ans+=(s[i]!=t[i]);
	return ans;
}
int ce(int a,int b){
	if (a%b==0) return a/b;
	else return a/b+1;
}
bool cmp(){
	return 1;
}
void solve(){
	int n;
	cin>>n;
	for (int i=0; i<n; i++) cout<<"ACL";
	
	
	
}
signed main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--) solve();
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int k = scanner.nextInt();
		String ans = "No";

		for(int i=0 ; i<k ; i++) {
			if(b > c) {
				c *= 2;
			}else if(a >= b) {
				b *= 2;
			}else {
				c *= 2;
			}
		}

		if(b > a && c > b) {
			ans = "Yes";
		}

		System.out.println(ans);

		scanner.close();

	}

}


Measured memory_bytes: 35684
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int tc,n,m,a[N],d,x,k,ans;

char s[N];

vector<int> g[N];

map<int,int> cnt;

int main(){
    //IO();
    ll ans = 0;
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++){
        scanf("%d",&a[i]);
        ans += cnt[i - a[i]];
        cnt[a[i] + i]++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 45112
#include<iostream>
using namespace std;
int main(){
    int n, k, d, i, j, a, b[100] = {0}, count = 0;
    cin >> n >> k;
    for (i = 0; i < k; i++){
        cin >> d;
        for (j = 0; j < d; j++){
            cin >> a; b[a-1]++;
        }
        
    }
    for (i = 0; i < n; i++){
        if (b[i] == 0){
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>

using namespace std;

void out(int n, char c)
{
  for (int i = 0; i < n; ++i) cout << c;
}

int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;
  out(dy, 'U');
  out(dx, 'R');
  out(dy, 'D');
  out(dx, 'L');
  out(1, 'L');
  out(dy + 1, 'U');
  out(dx + 1, 'R');
  out(1, 'D');
  out(1, 'R');
  out(dy + 1, 'D');
  out(dx + 1, 'L');
  out(1, 'U');
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a==1){
      if(b==2){
        System.out.println(3);
      }else{
        System.out.println(2);
      }
    }else if(a==2){
      if(b==1){
        System.out.println(3);
      }else{
        System.out.println(1);
      }
    }else{
      if(b==1){
        System.out.println(2);
      }else{
        System.out.println(1);
      }  
    }

 }
}

Measured memory_bytes: 20692
/*
 © 2020-07-05 06:57:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n; cin >> n;
  map<string, lli> mp;
  fore(i, 0, n){
    string s; cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << ENDL;
  cout << "WA x " << mp["WA"] << ENDL;
  cout << "TLE x " << mp["TLE"] << ENDL;
  cout << "RE x " << mp["RE"] << ENDL;
  return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
int main()
{
	char S[1][101];
	int i=0;
	gets(S[0]);
	for(i=0;S[0][i]!='\0';i++)
	{
		if((i+1)%2==0&&S[0][i]=='R')
		{
			printf("No");
			return 0;
		}
		if((i+1)%2!=0&&S[0][i]=='L')
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}


Measured memory_bytes: 128
n,k,q = list(map(int, input().split()))
lst = []
dct = {}
for _ in range(q):
  num = int(input())
  if num in dct:
    dct[num] += 1
  else:
    dct[num] = 1
for i in range(n):
  person = i + 1
  if person in dct:
    a = dct[person]
  else:
    a = 0
  if k - q + a > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9060
#!/usr/bin/ruby

def solve(a, b)
  if b % a == 0
    a + b
  else
    b - a
  end
end

def each_case(sin)
  while ln = sin.gets
    a, b = ln.chomp.split(" ").map(&:to_i)
    yield a, b
  end
end

each_case(STDIN) do |a, b|
  puts solve(a, b).to_s
end




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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vi dp(n+1,1);
    int f;
    rep(i,n){
        if(s[i]=='o'){f=i;break;}
    }
    for(int i=f+1;i<n;++i){
        if(s[i]=='o'&&i>=c+1){
            dp[i]=dp[i-c-1]+1;
        }
        else dp[i]=dp[i-1];
    }
    if(dp[n-1]>k){
        return 0;
    }
    map<int,int>a;
    int key,l;
    for(int i=n-1;i>=0;--i){
        if(s[i]=='o'){
            l=i;
            key=dp[i];
            a[key]++;
            break;
        }
    }
    vi ans;
    int w=l;
    for(int i=w-1;i>=f;--i){
        if(s[i]=='o'){
            if(key==dp[i])a[dp[i]]++;
            else{
                if(a[key]==1)ans.PB(key);
                key=dp[i];
                while(i+c>=l||s[i]!='o'){
                    i--;
                }
                a[key]++;
                l=i;
            }
        }
    }
    if(a[key]==1)ans.PB(key);
    reverse(all(ans));
    int cnt=0;
    for(int i=0;i<n;++i){
        if(ans[cnt]==dp[i]){
            cout<<i+1<<endl;
            cnt++;
            if(cnt==ans.size())break;
        }
    }
}

Measured memory_bytes: 14388
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;

template<typename T>
void print_vec_vec(vector <vector <T> >v){
  for(int i=0;i<v.size();i++){
	for(int j=0;j<v[i].size();j++){
	  cout << v[i][j] << " ";
	}
	cout << endl;
  }
}


int main(){
  int H,W,N;
  cin >> H >> W;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
	cin >> a[i];	
  }

  vector <int> t_c;
  for(int i=0;i<N;i++){
	for(int j=0;j<a[i];j++){
	  t_c.push_back(i+1);
	}
  }

  vector <vector <int> > c(H,vector<int>(W));
  for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
	  if(i%2==0){
		c[i][j]=t_c[i*W+j];
	  }else{
		c[i][W-j-1]=t_c[i*W+j];
	  }
	}
  }
  
  print_vec_vec(c);


  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int add(int a, int b){ a+=b;return a>=mod?a-mod:a;}
void ckadd(int &a, int b){ a=add(a,b);}
int sub(int a, int b){ a-=b;return a<0?a+mod:a;}
void cksub(int &a, int b){ a=sub(a,b);}
int mul(int a, int b){ return (ll)a*b%mod;}
void ckmul(int &a, int b){ a=mul(a,b);}
int powmod(int x, int k){ int ans=1;for(;k;k>>=1,ckmul(x,x)) if(k&1) ckmul(ans,x);return ans;}
int inv(int x){ return powmod(x,mod-2);}

const int N=105;
const int X=505;
int dp[2][N][X],l[N],sum[X],sum_dp[X],sum_nunc[X];
int main()
{
	int n,x;
	scanf("%i %i",&n,&x);
	for(int i=1;i<=n;i++) scanf("%i",&l[i]);

	//srand(time(0));
	//n=100;
	//x=500;
	//for(int i=1;i<=n;i++) l[i]=rand()%x+1;

	sort(l+1,l+1+n);
	reverse(l+1,l+1+n);
	int now=1,las=0;
	dp[las][1][x-l[1]]=1;
	for(int i=2;i<=n;i++)
	{
		for(int groups=1;groups<=i;groups++)
		{
			sum[0]=0;
			for(int unc=1;unc<=x;unc++) sum[unc]=add(sum[unc-1],mul(dp[las][groups][unc],groups*2));

			sum_dp[0]=dp[las][groups+1][0];
			for(int unc=1;unc<=x;unc++) sum_dp[unc]=add(sum_dp[unc-1],dp[las][groups+1][unc]);

			sum_nunc[0]=0;
			for(int nunc=1;nunc<=x;nunc++) sum_nunc[nunc]=add(sum_nunc[nunc-1],mul(nunc,dp[las][groups+1][nunc]));

			for(int unc=0;unc<=x;unc++)
			{
				dp[now][groups][unc]=0;
				dp[now][groups][unc]=mul(dp[las][groups][unc],x-unc-(l[i]-1)*groups);
				//printf("(%i %i %i): %i\n",i,groups,unc,dp[now][groups][unc]);

				int tmp=0;
				ckadd(tmp,mul(l[i]-1+unc,sub(sum_dp[min(x,unc+l[i]-2)],unc==0?0:sum_dp[unc-1])));
				cksub(tmp,sub(sum_nunc[min(x,unc+l[i]-2)],unc==0?0:sum_nunc[unc-1]));
				ckadd(dp[now][groups][unc],mul(groups,tmp));
				//for(int gap=0;gap<=l[i]-2;gap++)
				//	if(unc+gap<=x) ckadd(dp[now][groups][unc],mul(dp[las][groups+1][unc+gap],mul(groups,l[i]-gap-1)));
				//printf("(%i %i %i): %i\n",i,groups,unc,dp[now][groups][unc]);
				if(unc+l[i]<=x) ckadd(dp[now][groups][unc],mul(dp[las][groups-1][unc+l[i]],groups));
				//printf("(%i %i %i): %i\n",i,groups,unc,dp[now][groups][unc]);

				ckadd(dp[now][groups][unc],sub(sum[min(x,unc+l[i]-1)],sum[unc]));
				//for(int gap=1;gap<=l[i]-1;gap++)
				//	if(unc+gap<=x) ckadd(dp[now][groups][unc],mul(dp[las][groups][unc+gap],2*groups));
				//printf("(%i %i %i): %i\n",i,groups,unc,dp[now][groups][unc]);
			}
		}
		swap(now,las);
	}
	int ans=0;
	for(int i=1;i<=n;i++) ckadd(ans,dp[las][i][0]);
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 640
D = int(input())
c = list(map(int, input().split()))
S = []
for i in range(D):
    S.append(list(map(int, input().split())))

for i in range(D):
    s = S[i]
    max_s = max(s)
    max_s_index = s.index(max_s)
    print(max_s_index + 1)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  if (n == 1)
  {
    cout << "Hello World";
    return;
  }
  int a, b;
  cin >> a >> b;
  cout << a + b;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    string s; cin >> s;
    REP (x, 1<<3) {
        string ans = s.substr(0, 1);
        ll acc = s[0] - '0';
        FOR (i, 1, 4) {
            int num = s[i] - '0';
            if (x&(1<<i-1)) {
                acc += num;
                ans += "+";
            } else {
                acc -= num;
                ans += "-";
            }
            ans += s[i];
        }
        // cout << ans << '\n';
        if (acc == 7) {
            ans += "=7";
            cout << ans << '\n';
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
n = int(input())
ans = ''
i = 0
while not n == 0:
    i += 1
    if n % 2 == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n += (-1) ** i
    n //= 2
if i == 0:
    ans += '0'
print(ans)

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    int fn = 0;
    int n_tmp = n;

    for (int i = 0; i < 8; i++) {
        fn += n_tmp % 10;
        n_tmp /= 10;
    }

    if (n % fn == 0) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

int n,m,k,a,b,c;
string s,t;

int main() {
  cin >> a >> b >> c >> k;
  if(k<=a)
  cout << k << endl;
  else if(k<=b)
  cout << a << endl;
  else 
  cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3572
h,n = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]

dp = [float("inf") for i in range(10**5)]
dp[0] = 0

for a,b in ab:
    for k in range(a+1):
        dp[k] = min(dp[k], b)
    for k in range(a+1,h+1):
        dp[k] = min(dp[k], dp[k-a] + b)
print(dp[h])

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

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

using namespace std;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  
  if(a.back()==b.at(0) && b.at(b.size()-1)==c.at(0)){
    cout<<"YES";
  }else{
    cout<<"NO";
  }
  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]].append(i)
    else:
        d[a[i]] = [i]


def simulate(k):
    if k == 0:
        return 0, []
    lap = 1
    res = [0]
    while True:
        s = res.pop()
        nxt = d[a[s]][bisect_right(d[a[s]], s) % len(d[a[s]])] + 1
        if nxt == n:
            if lap == k and s == n-1:
                res.append(s)
            if s == n-1:
                lap += 1
            return lap, res
        elif nxt <= s+1:
            if lap == k:
                res.append(s)
                if s == n-1:
                    return lap, res
                res.append(s+1)
                if s+1 == n-1:
                    return lap, res
            else:
                res.append(nxt)
                lap += 1
        else:  # s+1 < nxt
            s = nxt
            res.append(s)
    return 0


period, ans = simulate(k)

if period != k:
    lap, ans = simulate(k % period)

print(*[a[x] for x in ans])


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, k;
    cin >> n >> m;
    ll ret = 0;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            if(m/i>=n)ret = max(ret,i);
            if(i>=n)ret = max(ret,m/i);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fill(x,t) memset(x,t,sizeof(x))
#define fi first
#define se second

typedef std:: pair <int,int> pair;
const int INF=0x3f3f3f3f;
const double pi=acos(-1);
const int N=400005;

int f[N],s[N];
pair p[N],u[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	pair st,ed;
	st.fi=read(),st.se=read();
	ed.fi=read(),ed.se=read();
	int n=read(),tot=0;
	rep(i,1,n) p[i].fi=read(),p[i].se=read();
	if (st.fi>ed.fi) {st.fi*=-1,ed.fi*=-1; rep(i,1,n) p[i].fi*=-1;}
	if (st.se>ed.se) {st.se*=-1,ed.se*=-1; rep(i,1,n) p[i].se*=-1;}
	rep(i,1,n) if (p[i].fi>=st.fi&&p[i].fi<=ed.fi&&p[i].se>=st.se&&p[i].se<=ed.se) {
		u[++tot]=p[i];
	}
	std:: sort(u+1,u+tot+1);
	int mx=0;
	rep(i,1,tot) {
		f[i]=std:: lower_bound(s+1,s+mx+1,u[i].se)-s;
		if (f[i]>mx) s[mx=f[i]]=u[i].se;
		else s[f[i]]=std:: min(s[f[i]],u[i].se);
	}
	double ans=100.0*(ed.fi-st.fi+ed.se-st.se)-(20-5*pi)*mx;
	if (mx-1==std:: min(ed.fi-st.fi,ed.se-st.se)) ans+=5*pi;
	printf("%.12lf", ans);
	return 0;
}

Measured memory_bytes: 8320
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    a,b,c=pin()
    t=(c-(a-b))
    if t<0:t=0
    print(t)
#%%submit!
resolve()

Measured memory_bytes: 38460
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
# print(f'{T=}, {C=}, {K=}')

time = T[0] + K
bus = 1
people = 1
# print(f't={T[0]}, {time=}, {bus=}, {people=}')
for t in T[1:]:
    if t <= time and people < C:
        people += 1
    else:
        time = t + K
        bus += 1
        people = 1
    # print(f'{t=}, {time=}, {bus=}, {people=}')
print(bus)


Measured memory_bytes: 14088
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
int main() {
	int n, k;
	cin >> n >> k;
	if (n == 1) {
		cout << k << endl;
		return 0;
	}
	ll ans = k;
	int i = 1;
	while (i != n ) {
		i++;
		ans *= (k - 1);
		
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, X[200];
    cin>>N;
    rep(i, N){
        cin>>X[i];
    }
    ll Minim=1000000;
    rep(i, 101){
        ll cost=0;
        rep(j, N){
            cost+=(X[j]-i)*(X[j]-i);
        }
        Minim=min(Minim, cost);
    }
    cout<<Minim<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<long long> CS(N+1);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        CS[i+1] = CS[i]+--a;
        CS[i+1] %= K;
    }
    map<int, int> M;
    int i = 0;
    for (; i < min(K, N+1); ++i) {
        ++M[CS[i]];
    }
    for (auto m : M) {
        ans += (long long)m.second*(m.second-1)/2;
    }
    for (; i < N+1; ++i) {
        --M[CS[i-K]];
        ans += M[CS[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12032
import math
N = 10 ** 5 + 5
lst = [0] * (N)

for i in range(10, N-3):
    count = 0
    for j in range(1, int(math.sqrt(i))+1):
        if i%j == 0:
            count += 1
        if count >= 3:
            lst[i] = lst[i-1] + 1
    if lst[i] == 0:
        lst[i] = lst[i-1]

Q = int(input())
for _ in range(Q):
    print (lst[int(input())])



Measured memory_bytes: 8412