akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	
	public double dist(Point a, Point b){
		return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
	}
	public double dist(Point a, Circle b){
		return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
	}
	public boolean judge(Circle wall, Point a, Point b){
		if( (Math.hypot(a.x-wall.x, a.y-wall.y)-wall.r)*(Math.hypot(b.x-wall.x, b.y-wall.y)-wall.r) < 0 ){
			return true;
		} else if( Math.hypot(a.x-wall.x, a.y-wall.y)-wall.r < 0 ){
			return false;
		}
		double t = (double)-1*((a.x-wall.x)*(b.x-a.x)+(a.y-wall.y)*(b.y-a.y)) / dist(a, b);
		double p = a.x - wall.x + t*(b.x-a.x);
		double q = a.y - wall.y + t*(b.y-a.y);
		if( p*p + q*q <= wall.r*wall.r ){
			double key = Math.max(dist(a, wall)-wall.r*wall.r, dist(b, wall)-wall.r*wall.r);
			if( dist(a, b) - key >= 0 ){
				return true;
			}
		}
		return false;
	}		
	public void solve() throws IOException{
		int n;
		while( (n = nextInt()) != 0 ){
			Circle[] wall = new Circle[n];
			for(int i = 0; i < n; i++){
				int x = nextInt(), y = nextInt(), r = nextInt();
				wall[i] = new Circle(x, y, r);
			}
			int m = nextInt();
		
		out:for(int i = 0; i < m; i++){
				int x = nextInt(), y = nextInt(), w = nextInt(), z = nextInt();
				Point hide = new Point(x, y);
				Point seek = new Point(w, z);
				for(int j = 0; j < n; j++){
					if( judge(wall[j], hide, seek) ){
						writer.println("Safe");
						continue out;
					}
				}
				writer.println("Danger");
			}			
		}
		writer.flush();
	}		
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

class Circle {
	int x;
	int y;
	int r;
	Circle(int x, int y, int r){
		this.x = x;
		this.y = y;
		this.r = r;
	}
	public String toString(){
		return x + " " + y + " " + r;
	}
}

class Point {
	int x;
	int y;
	Point(int x, int y){
		this.x = x;
		this.y = y;
	}
	public String toString(){
		return x + " " + y;
	}
}

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

int main() {
int N, X, Y;
  cin  >> N >> X >> Y;
  int count = 0;
  int kyori;
	vector<int> ans(N);
  	for(int i = 1; i <= N-1; i++){
    	for(int j = i+1; j <= N; j++){
        	int A = abs(X-i);
          	int B = abs(j-Y);
          	kyori = min(j-i, A+B+1);
          	ans[kyori-1]++;
        }
    }
      for(int i = 0; i < N-1; i++){
   		   cout << ans[i] << endl;
      }  
}

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

int main(){
    int  n;
    bool ok = true;

    cin >>n;

    vector<long long> A(n);

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

    for(int i = 0;i < n;i++){
        if(A[i] %2 == 0){
            if(!(A[i]%3 == 0 || A[i]%5==0)){
                ok = false;
            }
        }

    }

    if(ok){
    cout << "APPROVED"<<endl;

    }else{
    cout << "DENIED"<<endl;

    }

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;

int n, m;

LL a[6];

int main(){
	a[1] = 2LL;
	for(int i = 2; i <= 5; i++) a[i] = a[i - 1] * 2LL;
	while(~scanf("%d %d", &n, &m)){
		int t = 1 << m;
		int ans = t * (1900 * m + (n - m) * 100);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string t;
    cin >> t;
    int n = 0,w = 0,s = 0,e = 0;
    rep(i,t.size()){
        if(t[i] == 'N') n = 1;
        if(t[i] == 'W') w = 1;
        if(t[i] == 'S') s = 1;
        if(t[i] == 'E') e = 1;
    }
    Yes((n == s) && (w == e));
}


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

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

	int ans = 0;
	for( int maskh = 0; maskh < 1 << H; maskh++ ) {
		for( int maskw = 0; maskw < 1 << W; maskw++ ) {
			vector<string> s = c;
			for( int i = 0; i < H; i++ ) {
				if( maskh >> i & 1 ) s[i] = string( W, '0' );
			}
			for( int i = 0; i < W; i++ ) {
				if( maskw >> i & 1 ) {
					for( int j = 0; j < H; j++ ) {
						s[j][i] = '0';
					}
				}
			}
			int num = 0;
			for( int i = 0; i < H; i++ ) {
				for( int j = 0; j < W; j++ ) {
					if( s[i][j] == '#' ) num++;
				}
			}
			if( num == K ) ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  int q;
  while (scanf("%d", &q) == 1 && q != -1) {
    double x = q/2.0;
    for (;;) {
      x = x - (x*x*x - q)/(3*x*x);
      if (fabs(x*x*x - q) < 1e-5*q) {
        break;
      }
    }
    printf("%.6f\n", x);
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    vector<double> p(n);
    for(int i=0; i<n; i++) cin>>p[i];

    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    // dp[i][j] := i 枚目のコインまでで j 回表が出たときの確率
    dp[0][0] = 1;

    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            if(dp[i][j] == 0) continue;
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    double ans = 0;
    for(int i=n/2+1; i<=n; i++){
        ans += dp[n][i];
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 70784
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1];
}

Measured memory_bytes: 256
import math
import collections
def main():
    n = int(input())
    s = []
    dd = collections.defaultdict(int)
    for i in range(n):
        a  = int(input())
        dd[a]+=1
        s.append(a)
    k = max(dd.keys())
    lis = sorted(list(dd.keys()),reverse = True)

    for i in range(n):
        if(s[i]==k and dd[s[i]]==1):
            print(lis[1])
        else:
            print(k)






if __name__ == '__main__':
    main()


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

int main(){
  string S;
  cin >> S;
  int N = S.size();

  int64_t ans = 0;
  
  for (int tmp = 0; tmp < (1 << N-1); tmp++) {
    bitset<10> s(tmp);
    int64_t sum = S.at(0) - '0';
    for (int i = 0; i < N-1; i++){
      if(s.test(i)){
        ans += sum;
        sum = S.at(i+1) - '0';
      } else {
        sum *= 10;
        sum += S.at(i+1) - '0';
      }
    }
    ans += sum;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(10)]
for k in range(10):
	for i in range(10):
		for j in range(10):
			d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = 0
for _ in range(h):
	for x in map(int,input().split()):
		ans += (x!=-1) * d[x][1]
print(ans)

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

 int compare(const void *a, const void *b)
 {
     return *(int *)b - *(int *)a;
 }
int main()
{
    int na= 0;
    int i;
    int a[200010];
    int b= 0;
    
    printf("\n");
    scanf("%d", &na);
  
    for(i=0; i<na; i++)
    {
        scanf("%d", &a[i]);
    }
            
    qsort(a, na, sizeof(int), compare);
        
    for(i=0; i<na; i++){
        if(a[i]==a[i+1])
        {
            b++;
        }
    }
        
    if(b==0)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    
    return 0;
}


Measured memory_bytes: 1788
n,k=map(int,input().split())
#0-indexed
p=[i-1 for i in list(map(int,input().split()))]
c=list(map(int,input().split()))
#1回以上K回以下
ansF=-1000000000000000000
for i in range(n):
    #すでに辿ったもの
    check=[False]*n
    #辿った順番
    turns=[]
    #今
    now=i
    while check[now]==False:
        check[now]=True
        turns.append(now)
        now=p[now]
    #答え(今の)
    ans=0
    #kのうち何回分
    #更新を毎回行う
    spare=turns.index(now)
    if spare>=k:
        for j in range(k):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        continue
    for j in range(spare):
        ans+=c[turns[j]]
        ansF=max(ans,ansF)
    turns=turns[spare:]
    spare=k-spare
    #サイクルの長さ
    l=len(turns)
    #サイクルの和(あまりも)
    #サイクルどこで止めるか
    x=0
    for j in range(l):
        x+=c[turns[j]]
    #そもそもサイクル回らない場合
    if spare<=l:
        for j in range(spare):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        continue
    #サイクル回した方が良い場合もある
    #最後のサイクルは回さない方が良いパターンも
    if x>=0:
        ans+=(x*(spare//l-1))
        ansF=max(ans,ansF)
        for j in range(l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
        for j in range(spare%l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
    #サイクル回さない方がいい場合
    else:
        for j in range(l):
            ans+=c[turns[j]]
            ansF=max(ans,ansF)
print(ansF)


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

long long int a, b, c, d;
long long int ans;

int main() {
    cin >> a >> b >> c >> d;

    ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import math
b=int(input())+1
sum=0
for x in range(1,b):
    for y in range(1,b):
        for z in range(1,b):
            if x==1 or y==1 or z==1:
                sum+=1
            elif x==y and x==z:
                sum+=x
            elif x==y or z==y:
                sum+=math.gcd(x, z)
            elif x==z:
                sum+=math.gcd(y, z)
            else:
                sum+=math.gcd(x, math.gcd(y, z))
print(sum)

Measured memory_bytes: 73564
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


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;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {

	int n;
	cin >> n;
	int sum = 0;
	rep(i, n) {
		int x;
		cin >> x;
		sum += x;
	}
	sum -= n;
	cout << sum  << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;




int main(void){

    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 6; i++){
        if (s[i] == '1'){
            ans++;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

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

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

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

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

// --------------------------------------
int n;
int a[100005];
int b[100005];
int c[100005];

int adp[100005];
int bdp[100005];
int cdp[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  REP(i, n) {
    cin >> a[i] >> b[i] >> c[i];
  }

  REP(i, n) {
    REP(j, 3) {
      if(j == 0) {
        adp[i + 1] = max(bdp[i] + a[i], cdp[i] + a[i]);
      } else if(j == 1) {
        bdp[i + 1] = max(adp[i] + b[i], cdp[i] + b[i]);
      } else {
        cdp[i + 1] = max(adp[i] + c[i], bdp[i] + c[i]);
      }
    }
  }

  cout << max({adp[n], bdp[n], cdp[n]}) << endl;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (r, g, b, n) = readIntList()

    var gg = 0
    var ans = 0
    while (g * gg <= n) {
        var bb = 0
        while (b * bb <= n - g * gg) {
            if ((n - g * gg - b * bb) % r == 0) ans++
            bb++
        }
        gg++
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 36368
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
//        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int[] suuji = new int[a];
        for(int i=0;i<a;i++){
            suuji[i] = int.Parse(ReadLine());
        }
        Array.Sort(suuji);
        long maxsd = 0;
        long maxds = 0;
        int[] sort = new int[a];
        for(int i=0;i<a;i++){
            if(i%2==0){
                sort[i] = suuji[i/2];
            }else{
                sort[i] = suuji[a-1-(i/2)];
            }
        }
/*        for(int i=0;i<a;i++){
            Write(sort[i]);
            Write(" ");
        }*/
        for(int i=0;i<a-2;i++){
            maxsd += Abs(sort[i] - sort[i+1]);
        }
        maxsd += Max(Abs(sort[a-1]-sort[a-2]),Abs(sort[a-1]-sort[0]));
        
        for(int i=0;i<a;i++){
            if(i%2==1){
                sort[i] = suuji[i/2];
            }else{
                sort[i] = suuji[a-1-(i/2)];
            }
        }
/*        for(int i=0;i<a;i++){
            Write(sort[i]);
            Write(" ");
        }*/
        for(int i=0;i<a-2;i++){
            maxds += Abs(sort[i] - sort[i+1]);
        }
        maxds += Max(Abs(sort[a-1]-sort[a-2]),Abs(sort[a-1]-sort[0]));
//        WriteLine(maxsd);
//        WriteLine(maxds);
        WriteLine(Max(maxds,maxsd));
    }
}

Measured memory_bytes: 17884
import itertools


# N！通りのパターンを全て作る
# それを辞書順にソートして一個ずつ確かめる
# 一致した順番が値

N = int(input())
P = tuple(map(lambda x: int(x), input().split()))
Q = tuple(map(lambda x: int(x), input().split()))

candidates = list(itertools.permutations(range(1,N+1)))
a = candidates.index(P)
b = candidates.index(Q)

print(abs(a - b))


Measured memory_bytes: 8052
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    now = str(input())
    if now == "AC":
        AC += 1
    elif now == "WA":
        WA += 1
    elif now == "TLE":
        TLE += 1
    elif now == "RE":
        RE += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


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

int main() {
  int A, B; cin >> A >> B;
  int divide = 16;
  int min_n = min(A, B);
  divide -= min_n * 2; A -= min_n; B -= min_n;
  if (divide / 2 >= max(A, B)) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll l, r, d;
	cin >> l >> r >> d;
	ll count = 0;
	for (ll i = l; i <= r; i++)
	{
		if (i % d == 0)
			count++;
	}
	cout << count << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// using Graph = vector<vector<int>>;

int n;
vector<int> fb(45);

int main(void)
{
	cin >> n;
	fb[0] = 1;
	fb[1] = 1;

	for (int i = 2; i <= n; i++)
	{
		fb[i] = fb[i - 2] + fb[i - 1];
	}

	cout << fb[n] << endl;
}


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

num_negative = sum(1 for x in A if x < 0)
positives = [abs(x) for x in A]
if num_negative % 2 == 0:
    print(sum(positives))
else:
    print(sum(positives) - min(positives) * 2)

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

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

  vector<int> r(n);
  rep(i,n) {
    cin >> r[i];
  }


  int max1 = -10000000000; 
  int min1 = r[0];

  for(int i=1;i<n;i++){
    min1 = min(min1,r[i-1]);
    max1 = max(max1,r[i]-min1);
  }

  cout << max1 << endl;
  return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

bool cmp(pair<ll,ll>a,pair<ll,ll>b){
  return a.second < b.second;
}

ll n;
vector<pair<ll,ll>>v;

int main(){
  cin >> n;
  v.resize(n);
  for(int i=0;i<n;i++) cin >> v[i].first >> v[i].second;
  sort(All(v),cmp);

  bool ok = true;
  ll sum = 0;
  for(int i=0;i<n;i++){
    sum += v[i].first;
    if(sum > v[i].second) ok = false;
  }
  if(ok) cout<< "Yes" <<endl;
  else cout<< "No" <<endl;

}


Measured memory_bytes: 3328
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		List[] list = new ArrayList[n+1]; //0は使わない
		for(int i = 0 ; i < n ; i++) {
			list[i+1] = new ArrayList();
		}
		
		boolean[] follow = new boolean[n+1];
		follow[1] = true;
		int[] guid = new int[n+1];
		
		for(int i = 0 ; i < m ; i++) {
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			list[a].add(new root(a,b));
			list[b].add(new root(b,a));
		}
		
        Deque<List> queue = new ArrayDeque<>();
        queue.add(list[1]);
        
        int pos = 1;
        while(!queue.isEmpty()){
        	List<root> tmplist = queue.poll();
        	for(root tmp : tmplist) {
        		if(!follow[tmp.next]) {
        			follow[tmp.next] = true;
        			guid[tmp.next] = tmp.pos;
        			queue.add(list[tmp.next]);
        		}
        	}
        }
		
        System.out.println("Yes");
        for(int i = 2 ; i < n+1 ; i++) {
    		System.out.println(guid[i]);
        }
		
	}
}


class root{
	public int pos;
	public int next;
	
	public root(int pos , int next) {
		this.pos = pos;
		this.next = next;
	}
	
	
}


Measured memory_bytes: 71136
var MAX_VALUE = 1000;

var inputRaw = require('fs').readFileSync('/dev/stdin', 'utf8');
var rows = inputRaw.trim().split('\n');
var row1 = rows[0].split(' ').map(Number);
var N = row1[0];
var W = row1[1];
var list = rows.slice(1).map(r => r.split(' ').map(Number));
var dp = Array.from({ length: N + 1 }, _ => Array( N * MAX_VALUE + 1).fill(Infinity));
dp[0][0] = 0;

function solve() {

  for (var i = 0; i < N; i++) {
    for (var j = 0; j <= N * MAX_VALUE; j++) {
      if (list[i][1] <= j) {
        var a = dp[i][j - list[i][1]] + list[i][0];
        var b = dp[i][j];
        dp[i + 1][j] = Math.min(a, b);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  var result = 0;
  for (var i = 0; i <= N * MAX_VALUE; i++) if (dp[N][i] <= W) result = i;
  return result;
}

console.log(solve());


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

int main () {
  int N;
  cin >> N;
  vector<long> a(N), b(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  long count = 0;
  for (int i = N-1; i >= 0; i--) {
    long x = a.at(i)+count;
    if (x%b.at(i) != 0) {
     count += (b.at(i)-x%b.at(i));
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int time=0;
		int sets=0;
		int mae=0,ato=0;
		int sum=0;
		while(sc.hasNext()) {
			time=sc.nextInt();
			if(time==0) {
				System.exit(0);
			}
			sets=sc.nextInt();
			sum=0;
			for(int i=0; i<sets; i++) {
				mae=sc.nextInt();
				ato=sc.nextInt();
				sum=sum+(ato-mae);
			}

			if(sum>=time) {
				System.out.println("OK");
			}
			else {
				System.out.println(time-sum);
			}
		}
	}
}


Measured memory_bytes: 31404
#include <iostream>
#include <vector>
#include <algorithm>
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  size_t N, W, weight, value, V = 100 * 1000 + 1;
  std::cin >> N >> W;
 
  std::vector<std::vector<size_t>> dp(2);
  dp[0] = std::vector<size_t>(V, W+1);
  dp[1] = std::vector<size_t>(V, W+1);
  dp[0][0] = 0;
 
  unsigned ans = 0;
 
  for (unsigned i = 0; i < N; ++i)
  {
    std::cin >> weight >> value;
    for (unsigned j = 0; j < V; ++j)
    { 
      if (j >= value)
      { 
        dp[1][j] = std::min(dp[0][j], dp[0][j-value] + weight);
      }
      else
      { 
        dp[1][j] = dp[0][j];
      }
      if (dp[1][j] <= W)
      { 
        ans = std::max(ans, j);
      }
    }
    dp[0].swap(dp[1]);
  }
  std::cout << ans;
 
  return 0;
}

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

int main()
{
    int n,m,x;
    long long int sum=0;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>n)
        cout<<-1<<endl;
    else cout<<n-sum<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#ifdef XENON
#include <debug.h>
#endif

#define F first
#define S second
#define endl "\n"
#define eb emplace_back
#define fastio() ios_base:: \
  sync_with_stdio(false); \
  cin.tie(NULL)

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pii = pair<int,int>;

const int N = 2e5+5;
const ll INF = 1e18+1;
const int MOD = 1e9+7;

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

  if (n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
    cout << "hon" << endl;
  else if (n%10 == 3)
    cout << "bon" << endl;
  else cout << "pon" << endl;
  return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
using namespace std;
int main(){
   string s;
   cin >> s;
   int a = 700;
   if (s[0] =='o') a=a+100;
   if (s[1] =='o') a=a+100;
   if (s[2] =='o') a=a+100;
   cout << a << endl;
   return 0 ;
}

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

int main() {
    string s;   cin >> s;
    int min_num = 1e9;
    for (int i = 0; i < s.length()-2; i++) {
        int seq = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
        min_num = min(min_num, abs(seq - 753));
    }
    cout << min_num << endl;
}

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

int main() {
  char c; cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

int main(){
    int i,ans=0,max=0;
    string s;

    cin >> s;
    for(i=0;i<s.length();++i){
        if(s[i]=='A' ||s[i]=='G'||s[i]=='C'||s[i]=='T')ans++;
        else ans=0;

        if(ans>max)max=ans;
    }

    cout << max <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)
#define f first
#define sec second

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

    cout << t+s << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1000000007;

const int MAX_N = 112345;
vector<int> g[MAX_N];

ll ans;
ll K;
void dfs(int cur, int prev, ll kk) {
  (ans *= kk) %= MOD;
  int ci = 0;
  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur, K - 1 - ci - (prev != -1 ? 1 : 0));
    ci++;
  }
}


int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextLong();
  K = nextLong();
  REP(i, N-1) {
    int a = nextLong()-1;
    int b = nextLong()-1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ans = 1;
  dfs(0, -1, K);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 9472
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];

    ll tigai = 0;
    REP(i, n) {
        if (p[i] != i+1) tigai++;
    }
    cout << YES(tigai == 0 || tigai == 2) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 81;
const int INF = 0x3f3f3f3f;
int a[N][N], b[N][N];
bitset<N * N * 4> dp[N][N];

int main()
{
    // freopen("in.txt", "r", stdin);
    int h, w;
    while (cin >> h >> w)
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cin >> a[i][j];
            }
        }
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                cin >> b[i][j];
            }
        }
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                dp[i][j].reset();
            }
        }
        dp[0][0][a[0][0] - b[0][0] + N * N * 2] = 1;
        dp[0][0][b[0][0] - a[0][0] + N * N * 2] = 1;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                int tmp = abs(a[i][j] - b[i][j]);
                if (j)
                {
                    dp[i][j] |= dp[i][j - 1] << tmp;
                    dp[i][j] |= dp[i][j - 1] >> tmp;
                }
                if (i)
                {
                    dp[i][j] |= dp[i - 1][j] << tmp;
                    dp[i][j] |= dp[i - 1][j] >> tmp;
                }
            }
        }
        int res = INF;
        for (int i = 0; i < N * N * 4; i++)
        {
            if (dp[h - 1][w - 1][i]) res = min(res, abs(i - N * N * 2));
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 21120
import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    var taro:Int = 0
    var hanako:Int = 0
    
    for(i in 1..n){
	    val str1 = cin.next()
	    val str2 = cin.next()
        when{
	        str1 > str2 -> {taro += 3}
	        str1 < str2 -> {hanako += 3}
	        else -> {
		        taro++
		        hanako++
	        }
	    }
    }
    println("${taro} ${hanako}")
}



Measured memory_bytes: 30984
# C
n = int(input())
A = list(map(int, input().split()))
res_1 = 0
res_2 = 0

# first < 0
som_1 = 0
for i in range(n):
    if i % 2 == 1:
        som_1 += A[i]
        if som_1 >= 0:
            res_1 += (som_1 + 1)
            som_1 = -1
    else:
        som_1 += A[i]
        if som_1 <= 0:
            res_1 += (-som_1 + 1)
            som_1 = 1
# first > 0
som_2 = 0
for i in range(n):
    if i % 2 == 0:
        som_2 += A[i]
        if som_2 >= 0:
            res_2 += (som_2 + 1)
            som_2 = -1
    else:
        som_2 += A[i]
        if som_2 <= 0:
            res_2 += (-som_2 + 1)
            som_2 = 1
print(min([res_1, res_2]))

Measured memory_bytes: 14468
def F(N):
  # N未満のxor sum
  if not N&1:
    # 偶数未満
    # 上位bitは2回ずつセット
    # 1の位だけ見ればよい
    x = N>>1
    return x&1
  # Nが奇数の場合
  return (N-1)^F(N-1)

A,B = map(int,input().split())
answer = F(B+1)^F(A)
print(answer)

Measured memory_bytes: 2940
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

ll l, r;

void solve()
{
    ll ans = 2019;
    l %= 2019;
    r %= 2019;
    if(l > r) cout << 0 << endl;
    else{
        FOR(i, l, r){
            FOR(j, i+1, r+1){
                ans = min(ans, (i*j)%2019);
            }
        }
        cout << ans << endl;
    }
}

void solve2()
{
    r=min(r,l+2019);

	  ll mi=2019;
	  for(ll a=l;a<=r;a++) for(ll b=a+1;b<=r;b++) mi=min(mi,a*b%2019);
	  cout<<mi<<endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> l >> r;
    solve2();
    return 0;
}

// vim:set foldmethod=marker:


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'
int main()
{
    vector<int> ans(5);
    int answer = 567890;
    rep(i, 5)
    {
        cin >> ans[i];
    }
    sort(ans.begin(), ans.end());

    do
    {
        int t = 0;
        rep(i, 4)
        {
            int temp = ans[i];
            if (t % 10 != 0)
            {
                t = t + 10 - (t % 10);
            }
            t += temp;
        }
        if (t % 10 != 0)
        {
            t = t + 10 - (t % 10);
        }
        t = t + ans[4];
        answer = min(answer, t);

    } while (next_permutation(ans.begin(), ans.end()));
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int n, m;
  deque<int> costs;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    costs.push_back(tmp);
  }

  int cost_sum = 0;
  for (int i = 0; i < m; i++) {
    cost_sum += costs[i];
  }

  if (cost_sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - cost_sum << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {

  long n,x;
  scanf("%ld %ld", &n, &x);
  long p[n+1],b[n+1],all[n+1];
  p[0] = 1;
  b[0] = 0;
  all[0] = 1;
  for (int i = 1; i <= n; i++) {
    p[i] = p[i-1]*2+1;
    b[i] = b[i-1]*2+2;
    all[i] = p[i]+b[i];
  }
  long eat = 0;
  for (int i = n; i >= 0; i--) {
    if (x < all[i]) {
      if (x > 0) {
        x--;
      } else {
        break;
      }
    } else {
      eat += p[i];
      x -= all[i];
      if (x > 0) {
        eat++;
        x--;
      }
      if (x >= all[i]) {
        eat += p[i];
        x -= all[i];
      }
      if (x > 0) {
        x--;
      }
      if (x == 0) {
        break;
      }
    }
  }
  printf("%ld\n", eat);

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

int n=0;
int i, count;
int h[20];
int k =0;
int j =0;

    scanf("%d\n", &n);
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }
    for(i=0;i<n;i++){
        while(h[j]<=h[i]){
            if(j==i){
                count++;
            }
            j++;
        }
        j=0;
    }
    printf("%d\n", count);
    
    return 0;
}








Measured memory_bytes: 128
i=0
l = [int(input()) for _ in range(5)]
while i<5:
    if(l[i]==0):
        break
    else:    
        a=1000-l[i]
        b=a//500  
        c=(a%500)//100   
        d=((a%500)%100)//50  
        e=(((a%500)%100)%50)//10
        f=((((a%500)%100)%50)%10)//5
        g=(((((a%500)%100)%50)%10)%5)//1
        print(b+c+d+e+f+g)
        i=i+1



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> a >> b >> c;
    if(a % c == 0)
        cout << b/c - a/c + 1;
    else
    cout << b/c - a/c;


    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+10;
int n,ans,a[N],num[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(a[i])num[a[i]-1]++;
		num[a[i]]++;
		num[a[i]+1]++;
	}
	for(int i=0;i<=(int)1e5;i++)
		ans=max(ans,num[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char a[4][5] = {"abcc", "abdd", "eefg", "hhfg"};
char b[5][6] = {"abbcc", "add.e", "f..ge", "f..gh", "iijjh"};
char c[6][7] = {"aabbcc", "d.e.f.", "d.e.f.", ".g.h.i", ".g.h.i", "jjkkll"};
char d[7][8] = {"a..bbcc", "adde...", "f..e..g", "f...hhg", ".hhi..j", "k..i..j", "kll.mm."};
char s[1005][1005];

void Push(int x, int y, int op) {
  if (op == 0) {
    for (RI i = 0; i < 4; ++i)
      for (RI j = 0; j < 4; ++j)
        s[i + x][j + y] = a[i][j];
  }
  if (op == 1) {
    for (RI i = 0; i < 5; ++i)
      for (RI j = 0; j < 5; ++j)
        s[i + x][j + y] = b[i][j];
  }
  if (op == 2) {
    for (RI i = 0; i < 6; ++i)
      for (RI j = 0; j < 6; ++j)
        s[i + x][j + y] = c[i][j];
  }
  if (op == 3) {
    for (RI i = 0; i < 7; ++i)
      for (RI j = 0; j < 7; ++j)
        s[i + x][j + y] = d[i][j];
  }
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; cin >> n;
  int tttttt = n;
  if (n <= 2) return puts("-1"), 0;
  if (n == 3) {
    puts("a..");
    puts("a..");
    puts(".bb");
    return 0;
  }
  for (RI i = 0; i < n; ++i)
    for (RI j = 0; j < n; ++j)
      s[i][j] = '.';
  Push(0, 0, n % 4);
  int cnt = 4 + n % 4;
  n -= 4 + n % 4;
  while (n) Push(cnt, cnt, 0), cnt += 4, n -= 4;
  for (RI i = 0; i < tttttt; ++i)
    puts(s[i]);
  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 2176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func parseInt(s string) (n int) {
	n, _ = strconv.Atoi(s)
	return
}

var count int

func dfs(s string, n int) {
	if parseInt(s) > n {

	} else {
		if strings.Contains(s, "7") && strings.Contains(s, "5") && strings.Contains(s, "3") {
			count++
		}
		dfs(s+"3", n)
		dfs(s+"5", n)
		dfs(s+"7", n)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()

	dfs("3", n)
	dfs("5", n)
	dfs("7", n)

	fmt.Println(count)
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,m;
  while(cin>>m>>n,n){
    bool flag[7370000]={};
    int cnt=0;
    for(int i=m;i<7370000;i++){
      if(flag[i]==false){
	if(cnt==n){
	  cout<<i<<endl;
	  break;
	}
	for(int j=i;j<7370000;j+=i)
	  flag[j]=true;
	cnt++;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 10276
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <stdio.h>
#define INF 100000000
typedef long long int ll;
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = x * r - d;
        cout << x << '\n';
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            double[] ar = new double[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextDouble();
            }
            Arrays.sort(ar);
            double res = ar[0];
            for (int i = 1; i < n; i++) {
                res = (ar[i] + res) / 2;
            }
            out.println(res);
        }

    }
}



Measured memory_bytes: 23252
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)*max(b)
    ng=-1
    
    def check(a,b,mid,k):
        if sum(a[i]-mid//b[i]for i in range(n) if a[i]*b[i]>mid)<=k:
            return 1
        else:
            return 0
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if check(a,b,mid,k):
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()

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

int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll Min =0x3f3f3f3f3f3f3f;
        for(ll i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                Min =min(n/i+i-2,Min);
            }
        }
        printf("%lld\n",Min);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 998244353 ;
const int maxn = 55 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
int n , m , q ;
int a[maxn] , b[maxn] , c[maxn] , d[maxn] ;
int e[maxn] ;
int ans = 0 ;
void cal()
{
	int sum = 0 ;
	rep(i , 1 , q)
	{
		if(e[b[i]] - e[a[i]] == c[i])  sum += d[i] ;
	}
	ans = max(ans , sum) ;
}
void dfs(int now , int last)
{
	if(now == n + 1)
	{
		cal() ;
		return ;
	}
	rep(i , last , m)
	{
		e[now] = i ;
		dfs(now + 1 , i) ;
	}
}
int main()
{
	rr(n , m) , r(q) ;
	rep(i , 1 , q)  rr(a[i] , b[i]) , rr(c[i] , d[i]) ;
	dfs(1 , 1) ;
	w(ans) , en() ;
	return 0 ;
} 

Measured memory_bytes: 3824