akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import math



def f(a):
    res = 1
    used = []
    for i in range(len(a)):
        x = 1
        c = 0
        while x != a[i]:
            f = 1
            for j in range(i):
                if a[j] == x:
                    f = 0
                    break
            if f == 1:
                c += 1
            x += 1

        res += c * math.factorial(len(a) - i - 1)
    return res








def solve(N: int, P: "List[int]", Q: "List[int]"):
    print(abs(f(P) - f(Q)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


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

int main() {
    int n, a[1000];

    while (1) {
        cin >> n;
        if (n == 0) break;

        int sum = 0;
        rep(i,n) {
            cin >> a[i];
            sum += a[i];
        }
        double avg = 1.0*sum/n;
        double dist = 0.0;
        rep(i,n) {
            dist += (a[i]-avg)*(a[i]-avg);
        }

        printf("%lf\n", sqrt(dist/n));
    }
}


Measured memory_bytes: 3204
import java.util.Scanner;

//public class A_Multiple_of_2_and_N {
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int answer;
        if (N % 2 == 0) {
            answer = N;
        } else {
            answer = N * 2;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,ans;
	cin >> n;
	int maxt=0;
	for(int i=1;i<=n;i++){
		for(int j=2;j<=n+1;j++){
			ans=pow(i,j)+0.5;
			if(n>=ans){
				maxt=max(maxt,ans);
			}
		}
	}
	cout << maxt << endl;
/////////////////////////////////////////////
}


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

typedef struct _point{
	int x,y,z;
}point;

int max_3(int a, int b, int c)
{
  return max(a, max(b,c));
}
  
int max_happy(vector<point> happy)
{ 
  int n = happy.size();
  vector<point> max_happy(n);
  
  max_happy[0].x = happy[0].x;
  max_happy[0].y = happy[0].y;
  max_happy[0].z = happy[0].z;
  
  for(int i=1; i<n; i++)
  {
  	max_happy[i].x = happy[i].x + max( max_happy[i-1].y, max_happy[i-1].z );
    max_happy[i].y = happy[i].y + max( max_happy[i-1].x, max_happy[i-1].z );
    max_happy[i].z = happy[i].z + max( max_happy[i-1].y, max_happy[i-1].x );
  }
  
  return max_3( max_happy[n-1].x, max_happy[n-1].y, max_happy[n-1].z);
}

int main()
{
  int n;
  cin >> n;
  
  vector<point> happy(n);
  
  for(int i=0; i<n; i++)
  	cin >> happy[i].x >> happy[i].y >> happy[i].z;
  
  cout << max_happy(happy) << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;
constexpr int ESP = 1e-9;
constexpr double PI = acos(-1);

ll frac[200001];

ll modpow(ll x, int n) {
    ll ret = 1;
    while (n) {
        if (n%2)
            ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll modinv(int x) {
    return modpow(x,MOD-2);
}

ll C(int n, int k) {
    return frac[n] * modinv(frac[k]) % MOD * modinv(frac[n-k]) % MOD;
}

int main(void) {
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    ll i;
    frac[0] = 1;
    REP (i,1,200000) frac[i] = frac[i-1] * i % MOD;

    int ans = C(h+w-2,h-1);
    REP (i,b) {
        ans = (ans - C(h-a-1+i,i) * C(w-i+a-2,a-1)) % MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
    return 0;
}


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

int const N = 200001;
int x, y, a, b, c, A[N], B[N], C[N]; 

int main(){
    scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
    for(int i = 0; i<a; ++i){
        scanf("%d", A+i);
    }
    for(int i = 0; i<b; ++i){
        scanf("%d", B+i);
    }
    for(int i = 0; i<c; ++i){
        scanf("%d", C+i);
    }
    sort(A, A+a);
    sort(B, B+b);
    sort(C, C+c);
    vector<int>take;
    for(int i = a-1; i >= a-x; --i)take.push_back(A[i]);
    for(int i = b-1; i >= b-y; --i)take.push_back(B[i]);
    int lst = 0;
    ll an = 0;
    reverse(C, C+c);
    sort(all(take));
    for(auto i: take){
        if(i > C[lst])an += i;
        else{
            if(lst < c)an += C[lst], ++lst;
            else an += i;
        }
    }
    printf("%lld\n", an);
} 

Measured memory_bytes: 2552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double p = h*30 + m*0.5;
		double q = m*6;
		
		double ans = 0;
		double th = Math.abs(p-q);
		double th1 = 360 - Math.abs((p-q));
		if(th<th1) {
			ans = th;
		}else {
			ans = th1;
		}
		double result = Math.cos(Math.toRadians(ans));
		double line = Math.pow(a,2) + Math.pow(b, 2) - 2*a*b*result;
		double x = Math.sqrt(line);
		System.out.println(x);
	}

}


Measured memory_bytes: 35996
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N):
        A.append(int(input_raw[i]))

    pair_count = 0
    already_set = set([])
    for t in range(31, 0, -1):
        x = 2**t
        count_dict = {}
        for i in range(N):
            if i in already_set:
                continue
            if x - A[i] <= 0:
                continue
            if x - A[i] in count_dict and len(count_dict[x - A[i]]) > 0:
                pair_count += 1
                j = count_dict[x - A[i]].pop()
                already_set.add(i)
                already_set.add(j)
            else:
                if A[i] not in count_dict:
                    count_dict[A[i]] = [i]
                else:
                    count_dict[A[i]].append(i)

    print pair_count

if __name__ == '__main__':
    main()


Measured memory_bytes: 135228
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  ll ans = 0;
  REP(i,n) {
    ll l = i+1;
    ans += (1-l) * (n - l + 1);
    ans += n * (n + 1) / 2;
    ans -= l * (l - 1) / 2;
  }
  REP(i,n-1) {
    ll u,v;
    cin>>u>>v;
    if (u > v) swap(u, v);
    ans -= u * (n - v + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 2020;
typedef long long ll;
const int mod = 998244353;
 inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
 }
 inline ll inverse(int x){ return pow(x, mod - 2); }
int h, w;
char ch[maxn][maxn];
int right[maxn][maxn];
int down[maxn][maxn];
int can[maxn][maxn];

inline int calc(int * a) {
	auto min = [&](int x,int y){ return a[x] < a[y] ? x : y; };
	static int st[20][maxn];
	int ret = 0;
	for(int i = 1;i < h;++i) st[0][i] = i;
	for(int i = 1;i < 13;++i) for(int j = 1;j + (1 << i) - 1 < h;++j) {
		st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
	}
	std::function<void(int, int)> solve = [&](int l,int r) {
		if(l > r) return ;
		const int lg = std::__lg(r - l + 1);
		int mn = min(st[lg][l], st[lg][r - (1 << lg) + 1]);
		ret = std::max(ret, (a[mn] + 1) * (r - l + 2));
		solve(l, mn - 1), solve(mn + 1, r);
	};
	solve(1, h - 1);
	return ret;
}
int main() {
	  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> h >> w;
	rep(i, 1, h) cin >> ch[i] + 1;
	for(int i = h - 1;i >= 1;--i) {
		for(int j = w - 1;j >= 1;--j) {
			can[i][j] = !(ch[i][j] + ch[i + 1][j] + ch[i][j + 1] + ch[i + 1][j + 1] & 1);
			right[j][i] = can[i][j] ? right[j + 1][i] + 1 : 0;
		}
	}
	int ans = w;
	rep(i, 1, w - 1) ans = std::max(ans, calc(right[i]));
	cout << ans << '\n';
}


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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}
int main(){
ll n;
cin>>n;
string ans;
while(n){
  n--;
  ans+='a'+n%26;
  n/=26;
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
  return 0;
  
  
}


Measured memory_bytes: 3592
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n;
II a[MAXN];
vector<ll> b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i].FI >> a[i].SE;
    FOR(i,1,n) b.push_back(a[i].FI + a[i].SE);
    FOR(i,1,n) c.push_back(a[i].FI - a[i].SE);
    sort(ALL(b));
    sort(ALL(c));
    cout << max(b[n-1] - b[0], c[n-1] - c[0]);
    return 0;
}


Measured memory_bytes: 9484
"use strict";
function main(input) {
  const inputs = input.split("\n").filter(x => x !== "");

  const N = inputs[0].split(" ").map(Number)[0];
  const X = inputs[1].split(" ").map(Number);

  const sX = X.sort((a,b) => a-b);
  // console.log(sX);
  const diff = [];

  for (let i =0; i<sX.length-1; i++) {
    diff[i] = sX[i+1] -sX[i];
  }

  // console.log(diff)

  const sDiff = diff.sort((a,b) => a-b);

  if (sX.length <= N) {
    console.log(0);
  } else {
    console.log(sDiff.reduce((acc,cur) => cur + acc, 0) - sDiff.slice(sDiff.length - (N -1)).reduce((acc,cur) => cur + acc, 0))
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28440
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquestring;
typedef priority_queue<int> priqueint;
typedef priority_queue<ll> priquell;
typedef priority_queue<char> priquechar;
typedef priority_queue<string,vector<string>,greater<string>> rpriquestring;
typedef priority_queue<int,vector<int>,greater<int>> rpriqueint;
typedef priority_queue<ll,vector<ll>,greater<ll>> rpriquell;
typedef priority_queue<char,vector<char>,greater<char>> rpriquechar;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

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


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    ll n,l;cin >> n >> l;
    vector<ll> a(n);
    ll m=0;ll last;
    rep(i,n){
        cin >> a[i];
        if(i!=0){
            m=max(m,a[i]+a[i-1]);
            if(m==a[i]+a[i-1])last=i-1;
        }
    }
    if(m<l){
        cout << "Impossible" << '\n';return 0;
    }
    cout << "Possible" << '\n';
    rep(i,last){
        cout << i+1 << '\n';
    }
    for(int i=n-2;i>last;i--)cout << i+1 << '\n';
    cout << last+1 << '\n';
}

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

int main() {
  int N;
  cin >> N;
  int c = 0;
  for (int i=0; i<N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      c++;
    }
  }
  if (c > 0) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3632
N=int(input())
A=list(map(int,input().split()))
for i in range(N):
  if(i%2==0):
    print(A[N-1-i],end=" ")
for i in range(N):
  if(N%2):
    if(i%2):
      print(A[i],end=" ")
  else:
    if(i%2==0 and i!=N-2):
      print(A[i],end=" ")
    elif(i==N-2):
      print(A[i])
if(N==1):
  print()

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;


int n;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if (t % 2 == 0)
        {
            if (t % 3 != 0 && t % 5 != 0)
            {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}

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

void Main()
{
  int N, M; cin >> N >> M;
  vector<int> A(M), B(M);
  rep(i,M) {
    cin >> A[i] >> B[i];
  }
  vector<int> shirube(N+1);
  vector<int> dist(N);
  rep(i,N) shirube[i] = 0;
  queue<int> q;
  set<int> visited;
  visited.insert(1);
  rep(i,M) {
    if (A[i] == 1) {shirube[B[i]] = 1; q.push(B[i]); visited.insert(B[i]);}
    if (B[i] == 1) {shirube[A[i]] = 1; q.push(A[i]); visited.insert(A[i]);}
  }
  vector<vector<int>> direction(N+1);
  rep(i,M) {
    direction[A[i]].push_back(B[i]);
    direction[B[i]].push_back(A[i]);
  }
  while (!q.empty()){
  	int cur = q.front(); q.pop();
    rep(i,direction[cur].size()) {
      if (visited.find(direction[cur][i]) == visited.end()){
        if (shirube[direction[cur][i]] == 0){
          q.push(direction[cur][i]); shirube[direction[cur][i]] = cur; visited.insert(direction[cur][i]);
        } else {cout << "No" << endl; return;}
      }
    }
  }
  cout << "Yes" << endl;
  for(int i = 2; i < N+1; i++) cout << shirube[i] << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 16792
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int x, int y, int z) {
    return (x - z) / (y + z);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    int y = reader.nextInt();
    int z = reader.nextInt();
    out.println(solve(x, y, z));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG abc/abc084/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

vector<int> eratosthenes(int n){// n以下の素数を全てvectorに入れて返す
    if(n < 2){
        vector<int> v(0);
        return v;
    }
    int cnt = 0;
    vector<int> v(n + 1, 1);// flag vector 素数なら1
    for(int i = 2; i <= n; i++){
        if(v[i] == 0) continue;// 素数じゃなかったらとばす
        cnt++;
        for(int j = 2; j <= n/i; j++){
            v[i * j] = 0;
        }
    }
    return v;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    vector<int> prime;
    prime = eratosthenes(100000);
    vector<int> sum(100001);
    sum[0] = 0;
    sum[1] = 0;
    sum[2] = 0;
    int cnt = 0;
    for(int i = 3; i <= 100000; i++){
        if(i % 2 == 0){
            sum[i] = sum[i - 1];
            continue;
        }
        if(prime[i] == 1 && prime[(i + 1)/2] == 1){
            sum[i] = sum[i - 1] + 1;
        }else{
            sum[i] = sum[i - 1];
        }
    }

    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << "\n";
    }

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;
} 





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

int main() {
    string s;
    int a, b;
    stack<int> S;
    while(cin >> s){
        if(s.at(0)=='+') {
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(a+b);
        }
        else if(s.at(0)=='-') {
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(b-a);
        }
        else if(s.at(0)=='*') {
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(a*b);
        }
        else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
}


Measured memory_bytes: 3156
#include<cstdio>
using namespace std;
int a[1001][1001],b[1001][1001],c[1001][1001];
int main(){
  int i,j;
  int m,n,k;
  scanf("%d%d%d",&m,&n,&k);
  for(i=0;i<m;++i){
    a[i][0]=b[i][0]=c[i][0]=0;
    char p[1001];
    scanf("%s",p);
    for(j=0;p[j];++j){
      if(false){
      }else if(p[j]=='J'){
	a[i][j+1]=a[i][j]+1;
	b[i][j+1]=b[i][j];
	c[i][j+1]=c[i][j];
      }else if(p[j]=='O'){
	a[i][j+1]=a[i][j];
	b[i][j+1]=b[i][j]+1;
	c[i][j+1]=c[i][j];
      }else if(p[j]=='I'){
	a[i][j+1]=a[i][j];
	b[i][j+1]=b[i][j];
	c[i][j+1]=c[i][j]+1;
      }
    }
  }
  for(i=0;i<k;++i){
    int p,q,r,s;
    scanf("%d%d%d%d",&p,&q,&r,&s);
    --p;
    --q;
    int d=0,e=0,f=0;
    for(j=p;j<r;++j){
      d+=a[j][s]-a[j][q];
      e+=b[j][s]-b[j][q];
      f+=c[j][s]-c[j][q];
    }
    printf("%d %d %d\n",d,e,f);
  }
  return 0;
}

Measured memory_bytes: 12000
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, m = map(int, input().split())
    h = tuple(map(int, input().split()))
    edges = {e:[] for e in range(n)}
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(h[b])
        edges[b].append(h[a])
    r = 0
    for i, he in enumerate(h):
        if not edges[i]:
            r += 1
        else:
            r += he > max(edges[i])

    print(r)
if __name__ == '__main__':
    main()

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) {
    cin >> P.at(i);
  }
  sort(P.begin(), P.end());
  int min = 0;
  rep(i, K) {
    min += P.at(i);
  }

  cout << min << endl;
}


Measured memory_bytes: 3640
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)

Measured memory_bytes: 13968
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {

	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int x = 0, y = 0;
	rep(i, n) {
		if (s[i] == 'a') {
			x++;
			if (x <= a + b) {
				cout << "Yes" << rt;
			}
			else {
				cout << "No" << rt;
			}
		}
		else if (s[i] == 'b') {
			x++;
			y++;
			if (x <= a + b&&y<=b) {
				cout << "Yes" << rt;
			}
			else {
				cout << "No" << rt;
				x--;
			}
		}
		else {
			cout << "No" << rt;
		}
	}

	please AC;
}
//参考：---;

Measured memory_bytes: 896
#include<iostream>
#include<cstring> 
using namespace std;
int main(){
	char a[100010]={},now;
	int cnt=0;
	cin>>a;
	now=a[0];
	for(int i=0;i<strlen(a);i++){
		if(a[i]!=now){
			now=a[i];
			cnt++;
		}
	}
	cout<<cnt<<endl;
return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int ans = 0;
  rep(i,4){
    char s;
    cin >> s;
    if(s=='+') ans++;
    else ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {
    static long MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc =new Scanner(System.in);
        long N = sc.nextLong();
        long ans = 1;
        long A = 1;
        long B = 1;
        long C = 1;

        for (int i = 0; i < N; i++) {
            A = A * 10 % MOD;
        }

        for (int i = 0; i < N; i++) {
            B = B * 9 % MOD;
        }

        for (int i = 0; i < N; i++) {
            C = C * 8 % MOD;
        }

        ans = A - B - B + C;
        ans %= MOD;
        ans = (ans + MOD) % MOD;
        System.out.println(ans);
		sc.close();
    }
}


Measured memory_bytes: 35696
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/graph/adjacency_list.hpp>
#include<boost/graph/dijkstra_shortest_paths.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
using namespace std;
using namespace boost;
using graph_t = adjacency_list<
	vecS, vecS, directedS, no_property, property<edge_weight_t, int>>;

//     ---
//   /  /
//   ---
//横の長さa、縦の長さb、自分がいま右下にいるとして左上にたどり着くまでの距離。
//a <= bを仮定する。
int calc(int a, int b) {
	if (b % a == 0) {
		return ((b - 1) / a) * a * 2 + a;
	}
	return (b / a) * a * 2 + calc(b % a, a);
}

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

	int N, X;
	cin >> N >> X;
	
	int answer = 0;
	if (X * 2 <= N) {
		answer = N + calc(X, N - X);
	}
	else {
		answer = N + calc(N - X, X);
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	int A, B, C;
	cin >> A >> B >> C;

	int t = B / A;
	if (C > t){
		cout << t << endl;

	}
	else if (C < t){

		cout << C << endl;
	}
	else cout << t << endl;





		system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
using namespace std;
int main()
{
    char a[10];
    scanf("%s",a);
    if(a[2]==a[3]&&a[4]==a[5])
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#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 <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int len = s.length();
    int cnt[len] = {};
    for(int i=1;i<len;++i)
    {
        if(s[i-1] == 'A' && s[i] == 'C')
        {
            cnt[i] = cnt[i-1] + 1; 
        }
        else
        {
            cnt[i] = cnt[i-1];
        }
    }

    for(int i=0;i<q;++i)
    {
        int l, r;
        cin >> l >> r;
        cout << cnt[r-1] - cnt[l-1] << endl;
    }
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    string s, t;
    cin>> s;
    t= s;
    reverse(s.begin(), s.end());

    int c= 0;

    for(int i=0; i<s.size(); i++)
    {
        if( s[i]!= t[i])
            c++;
    }

    cout << c/2 ;
    nl;

    return 0;
}




Measured memory_bytes: 3588
#include<bits/stdc++.h>            //  IT'S NEVER TOO LATE...
    	using namespace std;
        #include<math.h>
    	#define ll long long
    	#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
        #define forn(i, n) fore(i, 0, n)
        #define fori(i, l, r) fore(i, l, (r) + 1)
        #define sz(v) int((v).size())
        #define all(v) (v).begin(), (v).end()
        #define pb push_back
        #define mp make_pair
        #define ff first
        #define ss second

        const double PI = atan(1)*4;

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

    	
    	vector<int> ar[1000001];
        vector<pair<int,int>> path;
        int vis[1000001],dis[1000001];

        /*void dfs(int node)
        {
            vis[node]=1;

            for(int child : ar[node])
            {
                if(vis[child]==0)
                {
                    dis[child]=dis[node]+1;
                    dfs(child);
                }
            }
        }*/

    /*    void bfs(int i)
        {
            queue<int> q;
            q.push(i);
            vis[i]=1;
            dis[i]=0;

            while(!q.empty())
            {
                int curr=q.front();
                q.pop();

                for(int child : ar[curr])
                    if(vis[child]==0)
                    {
                        q.push(child);
                        dis[child]=dis[curr]+1;
                        vis[child]=1;
                    }
            }
        }*/

        bool isprime(int n)
        {
            for(int i=2;i*i<=n;i++)
                if(n%i==0)
                    return false;
            return true;
        }

        bool comp(pair<int,int> a, pair<int,int> b)
        {
            return b.ff < a.ff ;
        }

        int modpow(int b,int p,int m)
        {
            if(p==0) return 1%m;
            if(p%2) return (b*modpow(b,p-1,m))%m;
            int u=modpow(b,p/2,m);
            return (u*u)%m;
        }


    	int main()  
    	{

    		int t=1;
    		//cin>>t;
    		
    		while(t--)        // string s contains 'H' for head and 'T' for tail.
    		{
                int n;
                cin>>n;

                cout<<n+pow(n,2)+pow(n,3);
            }
            return 0;
    	}

        //              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 27588
// quote from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#![allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! out {
    ($x:expr) => {
        println!("{}", $x)
    };
}

macro_rules! debug {
    ($x:expr) => {
        println!("{:?}", $x)
    };
}

use std::io::Read;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s);
    let mut iter = s.split_whitespace();
    let n: u32 = iter.next().unwrap().parse().unwrap();

    let mut ans = false;
    for i in (1..10).rev() {
        if n % i == 0 && 1 <= n / i && n / i <= 9 {
            ans = true;
        }
    }
    if ans { out!("Yes") } else { out!("No") }
}


Measured memory_bytes: 4352
//
//  main.cpp
//  173B
//
//  Created by Parsa Alimohammadi on 4/25/1399 AP.
//  Copyright © 1399 Parsa Alimohammadi. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n ,ac,wa,tle,re;
    cin >> n;
    string s;
    ac = wa = tle = re = 0;
    
    for (; n>0; n--)
    {
        cin >> s;
        if (s=="AC")
        {
            ac ++;
        }
        
        else if (s == "WA")
            wa++;
        else if (s=="TLE")
            tle ++;
        else
            re ++;
    }
    
    cout << "AC x " << ac << endl;
    
    cout << "WA x " << wa << endl;
    
    cout << "TLE x " << tle << endl;
    
    cout << "RE x " << re << endl;
    return 0;
    
}


Measured memory_bytes: 3628
class node:
    def __init__(self):
        self.parent = None
        self.left = None
        self.right = None
        self.key = None
        
class btree:
    def __init__(self):
        self.root = None
        
    def insert(self, v):
        y = None
        x = self.root
        z = node()
        z.key = v
        
        while x is not None:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z
    

    def print_tree(self):
        def inorder(nd):
            if nd.left is not None:
                inorder(nd.left)
            print(' %i'%nd.key, end='')
            if nd.right is not None:
                inorder(nd.right)
        
        def preorder(nd):
            print(' %i'%nd.key, end='')
            if nd.left is not None:
                preorder(nd.left)
            if nd.right is not None:
                preorder(nd.right)
                
        inorder(self.root)
        print()
        preorder(self.root)
        print()
        
n = int(input())

bt = btree()

for i in range(n):
    inp = input()
    if inp.split()[0]=='insert':
        bt.insert(int(inp.split()[1]))
    else:
        bt.print_tree()
        


Measured memory_bytes: 105180
from collections import deque

n = int(input())
li = list(map(int, input().split()))

li.sort(reverse=True)

d = deque()
ans = 0

for i in range(n):
    if i == 0:
        d.append(li[i])
    elif i == 1:
        d.append(li[i])
        d.append(li[i])
        ans += d.popleft()
    else:
        d.append(li[i])
        d.append(li[i])
        ans += d.popleft()
print(ans)

Measured memory_bytes: 32388
#include<iostream>
#include <stdio.h>
#include <string.h>
#include <string>

using namespace std;
int main()
{
	int N, A, B, Ans1, Ans2;

	cin >> N >> A >> B;

	Ans1 = N*A;
	Ans2 = B;

	if (Ans1 > Ans2)
		cout << Ans2;
	else
		cout << Ans1;

	return 0;
	
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException {
        FastReader scan = new FastReader();
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("colorful.out")));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        Task solver = new Task();
        //int t = scan.nextInt();
        int t = 1;
        for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
        out.close();
    }
    static class Task {
        public void solve(int testNumber, FastReader sc, PrintWriter pw){
            int x = sc.nextInt();
            int t = (int)(Math.sqrt(x));
            pw.println(t*t);
        }
    }
    static class tup implements Comparable<tup> {
        String a, b,c,d;
        tup() {
        }
        ;
        tup(String a,String b,String c,String d) {
            this.a=a;
            this.b=b;
            this.c=c;
            this.d=d;
        }
        @Override
        public int compareTo(tup o2) {
            return 0;
        }
    }
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static void shuffle(int[] a,int l, int rb) {
        Random get = new Random();
        for (int i = l; i < rb; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
            public FastReader(String s) throws FileNotFoundException {
                br = new BufferedReader(new FileReader(new File(s)));
            }

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt() {
                return Integer.parseInt(next());
            }

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) { e.printStackTrace();
                }return str;
        }
    }
}

Measured memory_bytes: 22996
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
    

// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int t1,t2;
    cin>>t1>>t2;
    int a1,a2,b1,b2;
    cin>>a1>>a2>>b1>>b2;
    int x=a1*t1+a2*t2;
    int y=b1*t1+b2*t2;
    if(x==y)
    {
        cout<<"infinity";
        return 0;
    }

    if(x<y)
    {
        if(a1<b1)
        {
            cout<<0;
            return 0;
        }
        else
        {
            int z=(a1-b1)*t1;
            int dis=y-x;
            int ans=z/dis;
            ans*=2;
            if(z%dis==0)
            {
                ans--;
            }
            
            cout<<ans+1;
        }
    }
    else
    {
        if(b1<a1)
        {
            cout<<0;
            return 0;
        }
        else
        {
            int z=(b1-a1)*t1;
            int dis=x-y;
            int ans=z/dis;
            ans*=2;
            if(z%dis==0)
            {
                ans--;
            }
            cout<<ans+1;
        }
    }
    

// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	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 n=3;
	int arr[]=new int[n];
	readArray(arr,sc);
	Arrays.sort(arr);
	if(arr[n-1]!=arr[n-2]) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
		

	}
	
	static void readArray(int[] arr,Scanner sc) { 
		for(int i=0;i<arr.length;i++) {
			arr[i]=sc.nextInt();
		}
	}
	
	
	

}


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

using namespace std;

int main() {
    int n;
    vector<int> flag(101);
    cin >> n;
    for(int i = 0; i < n; i++) {
        int d;
        cin >> d;
        flag[d] = 1;
    }

    int ans = 0;
    for(int i = 0; i < 101; i++) {
        ans += flag[i];
    }

    cout << ans << endl;

    return 0;
}

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

int n, x, p;
set<int> s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        cin >> p;
        s.insert(p);
    }

    int ans = 1e9;
    for (int i = -1000; i <= 1000; i++) {
        if (s.count(i)) {
            continue;
        }

        if (abs(i - x) < abs(ans - x)) {
            ans = i; 
        }
    }

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

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

int main(void) {
  long long int x;
  long long int a,b;
  scanf("%lld", &x);
  //scanf("%d", &b):
  int m;
  int tmp;
  int flag=0;

  for(int i = 0;i<1200;i++){
    a = i;
    tmp = a;
    a = a*a*a*a*a;
    b = a-x;
    if(b > 0){

      for(int j = 1;j<500;j++){
        int c = 0;
        c = b-(j*j*j*j*j);
        if(c == 0){
          m = j;
          flag =1;
          break;
        }
        }
        if(flag == 1){
          break;
      }
    }
    else{
    for(int k = -1;k > -500;k--){
      int d = 0;
      d = b-(k*k*k*k*k);
      if(d == 0){
        m = k;
        flag =1;
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }

  }
  printf("%d %d\n",tmp,m);



  return 0;
}


Measured memory_bytes: 1696