akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int a , b, k;
	cin >> a >> b >> k;
	int temp = max(a,b);
	
	vector <int> r;
	
	for (int i = 1; i<=temp; i++)
	{
		if (a%i == 0 && b%i == 0) 
		{
			r.push_back(i);
			
		}
	}
	
	sort(r.rbegin(), r.rend());
	
	
	cout << r[k-1] <<endl;
	
	
	
	
	
	
	return 0;
}



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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
vector < vector<int> > g (100005);
stack <int> ts;
int vis[100004];


void dfs (int u) {
    vis[u] = 1;
    for (int v : g[u]) {
        if (vis[v] == 0)
            dfs (v);
    }
    ts.push (u);
}

void testCase() {
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    //topological sort the edges
    for (int i=1; i<=n; i++) {
        if (vis[i] == 0)
            dfs (i);
    }
    int ans[100005] = {0};
    while (!ts.empty()) {
        int u = ts.top();
        ts.pop();
        for (int v : g[u])
            ans[v] = max (ans[v], ans[u]+1);
    }
    int val = 0;
    for (int i=1; i<=n; i++)
        val = max (val, ans[i]);
    cout << val << endl;
}

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

Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll min(ll x, ll y){
    if(x<y)return x;
    return y;
}
int a[8];
int b[8];
int p[8][8];

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int count = 0;
    for(int i = 0;i < 8;i++){
        for(int j = 0;j < 8;j++){
            p[0][0] = 0;
        }
    }
    for(int i = 0;i < m;i++){
        int c, d;
        scanf("%d %d", &c, &d);
        c--;
        d--;
        p[c][d] = 1;
        p[d][c] = 1;
    }
    for(int i = 0;i < 8;i++){
        a[i] = i;
    }
    do {
        int flag = 1;
        for(int i = 0;i < n-1;i++){
            if(!p[a[i]][a[i+1]]){
                flag = 0;
                break;
            }
        }
        if(flag)count++;
    }while(next_permutation(a + 1, a + n));
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sum=a*100+b*10+c;
		if((a>=1&&a<=9)||(b>=1&&b<=9)||(c>=1&&c<=9))
		{if(sum%4==0)
		 System.out.println("YES");
		 else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
# 整数の入力
N, K = map(int, input().split())
# スペース区切りの整数の入力
h = [int(e) for e in input().split()]
a = 0
for i in range(N):
  a += h[i] >= K
print('{}'.format(a))


Measured memory_bytes: 11912
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n, m;
    cin >> n >> m;

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

    vector<int> c(m), d(m);
    rep(i, m){
        cin >> c[i] >> d[i];
    }

    rep(i, n){
        int mini = IINF;
        int ans = -1;
        rep(j, m){
            if(chmin(mini, abs(a[i] - c[j]) + abs(b[i] - d[j]))){
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-10;  // floating point precision

class rational {
    public:
    lli p, q;
    rational(string& s) {
        q = 1;
        p = 0;
        bool flag = false;
        for(int i = 0; i < s.length(); i++) {
            if(flag) {
                q *= 10;
            }
            if(s[i] == '.') {
                flag = true;
            }
            else {
                p = p * 10 + (lli)(s[i] - '0');
            }
        }   
        lli gcd = __gcd(p, q);
        p /= gcd;
        q /= gcd;
    }   
};

lli ct[51][16][51][16];

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin >> n;
    vector<string> v(n);
    memset(ct, 0, sizeof ct);
    lli ans = 0ll;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        rational r(v[i]);
        lli u2 = 0, u5 = 0;
        lli d2 = 0, d5 = 0;
        lli p = r.p;
        lli q = r.q;
        while(p % 2 == 0) {
            p /= 2;
            u2++;
        }
        while(p % 5 == 0) {
            p /= 5;
            u5++;
        }
        while(q % 2 == 0) {
            q /= 2;
            d2++;   
        }
        while(q % 5 == 0) {
            q /= 5;
            d5++;
        }
        lli num2 = max(0ll, u2 - d2), num5 = max(0ll, u5 - d5);
        lli dem2 = max(0ll, d2 - u2), dem5 = max(0ll, d5 - u5);
        lli res = 0ll;
        for(auto ii = dem2; ii < 51; ii++) {
            for(auto jj = dem5; jj < 16; jj++) {
                for(auto kk = num2; kk >= 0; kk--) {
                    for(auto ll = num5; ll >= 0; ll--) {
                        res += ct[ii][jj][kk][ll];
                    }
                }
            }
        }
        ans += res;
        ct[num2][num5][dem2][dem5]++;
    }
    cout << ans << endl;
    return 0;
    
}


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

int main(){
  char S[3];
  scanf("%s",S);
  int len=strlen(S);
  if(len==2){
    printf("%s",S);
  }else{
    printf("%c",S[2]);
    printf("%c",S[1]);
    printf("%c",S[0]);
  }
  return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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;
}

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

  int X, A, B; cin >> X >> A >> B;
  X-=A;
  cout<<X%B<<endl;

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc172/tasks/abc172_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << N + N * N + N * N * N << endl;

    return 0;
}


Measured memory_bytes: 3612
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_cols<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn visit(
    maze: &Vec<Vec<bool>>,
    state: &mut Vec<Vec<usize>>,
    queue: &mut VecDeque<(usize, usize)>,
    i: i32,
    j: i32,
    distance: usize,
) {
    if i < 0 || i >= maze.len() as i32 {
        return;
    }

    if j < 0 || j >= maze[0].len() as i32 {
        return;
    }

    let i = i as usize;
    let j = j as usize;

    if !maze[i][j] {
        return;
    }

    if state[i][j] > distance {
        state[i][j] = distance;
        queue.push_back((i, j));
    }
}

fn bfs(maze: &Vec<Vec<bool>>) -> i32 {
    let mut queue = VecDeque::new();

    let h = maze.len();
    let w = maze[0].len();

    let mut state = Vec::new();
    {
        let mut inner = Vec::new();
        inner.resize(w, usize::max_value());
        state.resize(h, inner);
    }

    state[0][0] = 0;
    queue.push_back((0, 0));
    while let Some((i, j)) = queue.pop_front() {
        let current = state[i][j];
        if i == h - 1 && j == w - 1 {
            // goal
            return current as i32;
        }
        let next = current + 1;
        let i = i as i32;
        let j = j as i32;
        visit(maze, &mut state, &mut queue, i - 1, j, next);
        visit(maze, &mut state, &mut queue, i, j + 1, next);
        visit(maze, &mut state, &mut queue, i + 1, j, next);
        visit(maze, &mut state, &mut queue, i, j - 1, next);
    }

    -1
}

fn count_white(maze: Vec<Vec<bool>>) -> usize {
    let mut count = 0;
    for col in maze {
        for b in col {
            if b {
                count += 1;
            }
        }
    }

    count
}

fn main() {
    let headers = read_cols::<u32>();
    let h = headers[0];
    let _w = headers[1];

    let mut maze = Vec::new();
    for _ in 0..h {
        let col = read::<String>();
        let mut col_maze = Vec::new();
        for c in col.chars() {
            if c == '.' {
                col_maze.push(true);
            } else {
                col_maze.push(false);
            }
        }
        maze.push(col_maze);
    }

    let distance = bfs(&maze);

    if distance < 0 {
        println!("-1");
        return;
    }

    println!("{}", count_white(maze) - (distance as usize + 1));
}


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

int main()
{
    int n,a[200],flag = 1,ans = -1;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    while(flag){
        for(int i = 0; i < n; i++){
            if(a[i] % 2 != 0) flag = 0;
            else{
                a[i] /= 2;
                if(a[i] == 0) flag = 0;
            }
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string s;
    cin >> s;
    int sum = 0;
    for(int i = 0;i < 3;i++)if(s[i] == '1')sum++;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl X(N);
  rep(i, N) cin >> X[i];

  ll ans = (ll)pow(10, 18);

  rep2(P, 1, 101){
    ll sum = 0;
    rep(j, N) sum += (X[j] - P) * (X[j] - P);

    ans = min(sum, ans);
  }

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


Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BOrdinaryNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int count = 0;
            for (int i = 1; i < n - 1; i++) {
                if ((a[i] > a[i - 1] && a[i] < a[i + 1]) || (a[i] < a[i - 1] && a[i] > a[i + 1]))
                    count++;
            }
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

struct vst
{
	int a;
	int b;
	int c;
	int d;
};

long search(vector<int> A, int Aindex, int start, int end, vector<vst> condition)
{
	if (Aindex < A.size())
	{ //探索を進める
		long maxscore = 0;
		for (int i = start; i <= end; i++)
		{
			A[Aindex] = i;
			long tmpscore = search(A, Aindex + 1, i, end, condition);
			if (tmpscore > maxscore)
				maxscore = tmpscore;
		}
		return maxscore;
	}
	else
	{ //スコアを求める
		long score = 0;
		for (int i = 0; i < condition.size(); i++)
		{
			if (A[condition[i].b - 1] - A[condition[i].a - 1] == (long)condition[i].c)
				score += condition[i].d;
		}
		return score;
	}
}

int main()
{
	int N; //配列Aの長さ
	int M; //配列Aのとりうる最大値
	int Q; //整数の組の数
	cin >> N >> M >> Q;

	//vst* vsts = new vst[Q]; //整数の組
	vector<vst> condition;
	for (int i = 0; i < Q; i++)
	{
		//cin >> vsts[i].a >> vsts[i].b >> vsts[i].c >> vsts[i].d;
		vst tmp;
		cin >> tmp.a >> tmp.b >> tmp.c >> tmp.d;
		condition.emplace_back(tmp);
	}


	//int* A = new int[N];
	vector<int> A(N);
	long maxscore = 0;
	//cout << search(A, 0, 1, M, vsts) << endl;
	cout << search(A, 0, 1, M, condition) << endl;



	return 0;
}



Measured memory_bytes: 3600
N, K = map(int, input().split())
A = list(map(int, input().split()))
B=[0]*K
A+=B
dp=[10**100]*110000
dp[0]=0


for i in range(N):
    for j in range(1,K+1):
        dp[i+j]=min(dp[i+j],dp[i]+abs(A[i]-A[i+j]))
        #print(dp)

print(dp[N-1])


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    vector<bool> light(N,false);
    int count=0;
    bool ok = false;
    int st=0;
    while(!ok) {
        if(!light[a[st]-1]) {
            light[a[st]-1] = true;
            count++;
            if(light[1]) {
                ok = true;
                break;
            }
            st = a[st]-1;
        }
        else ok = true;
    }

    if(light[1]) cout << count << endl;
    else cout << "-1" << endl;

    return 0;
}

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

#define ASORT(arr, n)          sort(arr,arr+n)
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;

const double eps = 1e-9;


int main()
{
  fastIO();

	char a;
	cin>>a;
	if(isupper(a))
	{
		cout<<"A"<<'\n';
	}
	else 
	{
		cout<<"a"<<'\n';
	}


 return 0;
 }


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

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.size();
	int m=s2.size();
	ll lcs[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
       for(int j=0;j<=m;j++)
       {
       	if(i==0 || j==0)
       	lcs[i][j]=0;
       	else if(s1[i-1]==s2[j-1])
       	{
       		lcs[i][j]=lcs[i-1][j-1]+1;
		   }
		   else
		   lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
	   }
		
	}
	/*cout<<lcs[n][m];

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			cout<<lcs[i][j]<<" ";

		}			cout<<endl;
	}*/
		string ans;
	int i=n,j=m;
   while(i>0 && j>0)
   {
   	if(s1[i-1]==s2[j-1])
   	{
   	ans+=s1[i-1];
   	i--;
   	j--;
   }
   else if(lcs[i-1][j]>lcs[i][j-1])
   i--;
   else
   j--;
}
reverse(ans.begin(),ans.end());
cout<<ans;
   	
   }

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)

int main()
{
    string a;
    string b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();
    if (n > m)
    {
        cout << "GREATER" << endl;
    }
    else if (n < m)
    {
        cout << "LESS" << endl;
    }
    else
    {
            if (a > b)
            {
                cout << "GREATER" << endl;
                return 0;
            }
            else if (a < b)
            {
                cout << "LESS" << endl;
                return 0;
            }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
import numpy as np

a = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
b = [int(input()) for _ in range(n)]

for i in b:
    a[a == i] = -1

if any(np.all(a == -1, axis=0)) or any(np.all(a == -1, axis=1)):
    print('Yes')
elif a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0] == -1:
    print('Yes')
else:
    print('No')


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, m;
    while (cin >> n >> m, n) {
        vi s(n);
        rep(i, n) cin >> s[i];
        vi d(m + 1);
        rep2(i, 1, m + 1) cin >> d[i];
        sort(all(d));

        vi c(1 << n); // c[X] = sum{s[k] | k \in X}
        rep(X, 1 << n) {
            rep(k, n) {
                if (X >> k & 1) {
                    c[X] += s[k];
                }
            }
        }

        vvi dp(m + 1, vi(1 << n, inf));
        dp[0][0] = 0;
        rep2(j, 1, m + 1) {
            rep(X, 1 << n) {
                rep(k, n) {
                    chmin(dp[j - 1][X | 1 << k], dp[j - 1][X]);
                }
            }
            rep(X, 1 << n) {
                dp[j][X] = dp[j - 1][X] + abs(d[j] - c[X]);
            }
        }

        cout << *min_element(all(dp.back())) << endl;
    }

}

Measured memory_bytes: 29832
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {x:i64}
  if x >= 30 {
    println!("Yes")
  } else {
    println!("No")
  }
}


Measured memory_bytes: 2124
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    val days = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
    for (Array(y1, m1, d1, y2, m2, d2) <- in if y1 != -1) {
        val tmp = (y1 to y2).flatMap(y =>
            if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) days.updated(1, 29)
            else days
        )
        println(tmp.drop(m1-1).dropRight(13-m2).sum - d1 + d2)
    }
}

Measured memory_bytes: 50704
import sys
n,m,x=map(int,input().split())

minsum=0
booklist=[]
for i in range(n):
    booklist.append(list(map(int,input().split())))
    minsum+=booklist[i][0]
minsum+=1
org=minsum
for i in range(2**n):
    masterlist=[0 for _ in range(m+1)]
    for j in range(n):
        if ((i>>j) & 1):
            for k in range(m+1):
                masterlist[k]=masterlist[k]+booklist[j][k]
    flag = True
    for l in range(1,m+1):
        if masterlist[l] < x:
            flag = False

    if flag:
        if masterlist[0] < minsum:
            minsum=masterlist[0]

if minsum == org:
    print(-1)
else:
    print(minsum)


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

using namespace std;
#define REP(i, n) for(int i=0; i < (int)(n); ++i)
#define REPR(i, n) for(int i=n; i>= 0; --i)
#define FOR(i, m, n) for(int i=m; i<(n); ++i)

using ll = long long;

int main(){
    ll N;
    cin >> N;
    ll ans = (N-1)*(N)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n, yen;
    cin >> n >> yen;
    for (int i = 0; i < 2001; i++) {
        for (int j = 0; j < 2001; j++) {
            int x = i * 10000;
            int y = j * 5000;
            int baki = yen - x - y;
            if (baki < 0) {
                continue;
            }
            if (baki == 0 && i + j == n) {
                cout << i << " " << j << " " << 0 << '\n';
                return 0;
            }
            if (baki % 1000) {
                continue;
            }
            int b = baki / 1000;
            if (i + j + b == n) {
                cout << i << " " << j << " " << b << '\n';
                return 0;
            }
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=2e6;
const int inf=1<<30;
int i,j,k,m,n,p,ans;
int a[N],b[N];
int main()
{
	scanf("%d%d",&n,&k);
	printf("%d",1+(n-2)/(k-1));
}

Measured memory_bytes: 256
// abc161_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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,m,cnt=0;
  ll sum=0;
  cin>>n>>m;
  vector<int> a(n);
  rep(i,n) {
    cin>>a.at(i);
    sum+=a.at(i);
  }

  rep(i,n){
    if (4*m*a.at(i) >= sum) cnt++;
  }

  cout<<((cnt>=m) ? "Yes" : "No")<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A,B;
    cin >> A >> B;
    if(A == 1 && B != 1){
        cout << "Alice" << endl;
    }
    else if(A != 1 && B == 1){
        cout << "Bob" << endl;
    }
    else if(A > B){
        cout << "Alice" << endl;
    }
    else if(A < B){
        cout << "Bob" << endl;
    }
    else cout << "Draw" << endl;
 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#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 ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
map<int, int> ans;
map<int, vector<int>> g;
int main()
{
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> v1(a), v2(b);
    rep(i, a)
    {
        cin >> v1[i];
    }
    rep(i, b)
    {
        cin >> v2[i];
    }
    ll ans = INF;
    rep(i, m)
    {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, (ll)v1[x] + v2[y] - c);
    }
    sort(ALL(v1));
    sort(ALL(v2));
    ans = min(ans, (ll)v1[0] + v2[0]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int f[10];

int main(){
  int a,b,c,d,i;
  cin >> a >> b >> c >> d;
  for (i=0;i<10;++i) {
    f[i]=0;
  }
  f[a]+=1;
  f[b]+=1;
  f[c]+=1;
  f[d]+=1;
  if (f[1]==1 && f[4]==1 && f[7]==1 && f[9]==1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,t = map(int, input().split())
    print(b*(t//a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i, N):
            dif = abs(A[i] - A[j])
            if dif > ans:
                ans = dif
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	vi d(N); rep(i, N) cin >> d[i];
	sort(all(d));
	cout << d[N / 2] - d[N / 2 - 1] << endl;

	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	s <- getLine
	let
		r = length $ filter ( == 'R' ) s
		b = n - r
	putStrLn $ which "Yes" "No" $ r > b

Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <cstring>
#include <cstdio>

typedef long long ll;
using namespace std;
/*
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7
*/

struct node
{
    int ai;
    int bi;
};
node arr[100];
int dad[100];

bool check(int n)
{
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(dad[i]==i)
        {
            ++cnt;
        }
    }
    if(cnt==1)
        return true;
    return false;
}
int find(int x){

   return x==dad[x]?x:(dad[x]=find(dad[x]));
}

int main()
{

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int ai,bi;
        cin>>ai>>bi;
        arr[i].ai = ai;
        arr[i].bi = bi;
    }
    int ans = 0;
    for(int i=0;i<m;i++)
    {
        for(int k=0;k<=n;k++)
            dad[k]=k;
        for(int j=0;j<m;j++)
        {
            if(j==i)
                continue;
            int fx=find(arr[j].ai);
            int fy=find(arr[j].bi);
            dad[fx]=fy;
        }
        if(check(n)==true)
            {
                ans++;

            }
    }
    cout<<m-ans<<endl;
    return 0;
}


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

#define pb push_back

int main(){

	vector<int> A;
	for(int i = 0; i < 3; i ++){
		int a;
		cin >> a;
		A.pb(a);
	}
	sort(A.begin(), A.end());
	cout << A[2] * 10 + A[1] + A[0] << endl;

	return 0;
}

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

int main(){
	int n = 0;
	int m = 0;
	string s;
	cin >> s;
	for(int i = 0;i<s.size();i++){
		if(s[i]=='0'){
			n = n+1;
		}
		else{
			m = m+1;
		}
	}
	if(m>n){
		cout << n*2;
	}
	else{
		cout << m*2;
	}
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:
    print(A - 1, B)
else:
    print(A, B - 1)



Measured memory_bytes: 6988
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int n,a,b,c,x,y,aa[100010],ba[100010];
bool r=true;
string s;
char ca,cb;


int main(){
    cin>>s;
    for(int i=0;i<s.length()/2;i++){
        r=r and s[i]==s[s.length()-1-i];
    }
    cout<<(r ? "Yes":"No")<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

void swap(pair<string, int> &a, pair<string, int> &b)
{
  pair<string, int> temp = a;
  a = b;
  b = temp;
}

int main()
{ 
  int n;
  cin >> n;
  vector<pair<string, int>> r(n);
  vector<int> index(n);
  for(int i = 0; i < n; i++)
  {
    string s;
    int p;
    cin >>s >> p;
    r[i] = {s, p};
    index[i] = i;
  }
  for(int i = 0; i < n - 1; i++)
  {
    for(int j = 0; j < n - 1 - i; j++)
    {
      if(r[j].first > r[j + 1].first){
        swap(r[j], r[j + 1]);
        int temp = index[j];
        index[j] = index[j + 1];
        index[j + 1] = temp;
      }else if(r[j].first == r[j + 1].first){
        if(r[j].second < r[j + 1].second){
          swap(r[j], r[j + 1]);
          int temp = index[j];
          index[j] = index[j + 1];
          index[j + 1] = temp;
        }
      }
    }
  }
  for(auto e : index)
  {
    cout << e + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 1000000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;
		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}



int main(){
	erats();
	vector<int> data(1000100,0);
	int n;
	while(cin>>n&&n!=0){
		int cnt=0;
		for(int i = 0; i < p; i++){
			int left = n - prime[i];
			if(left<0||left<(n/2))
				break;
			if(isPrime[left])
				cnt++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


ll isq(ll a){
	ll lw=0, hi=a+2;
	while(hi - lw > 1){
		ll md= (hi + lw) >>1;
		( md <= a/md? lw: hi ) = md;
	}
	return lw;
}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int q;
	cin >>q;
	rep(zz, q){
		ll a,b; cin >>a >>b;
		ll lw=0, hi = max(a,b)*3;
		while(hi - lw > 1){
			ll md= (hi + lw) >> 1, lmx = 0;
			for(ll i=max(md/2-1, 1LL); i<=min(md/2+1, md);i++){
				ll y = i + (i>=a);
				ll x = md +1 - i + (i<=md-b+1);
				lmx = max(lmx, y*x);
			}
			if( lmx < a*b) lw = md; else hi = md;
		}
		cout << lw << "\n";
	}
	return 0;
	
}


Measured memory_bytes: 256
SS=input()
T=input()
can=False
for i in reversed(range(len(SS)-len(T)+1)):
    can1=True
    for j in range(len(T)):
        if SS[i+j]==T[j] or SS[i+j]=="?":
            continue
        can1=False
        break
    if can1:
        can=True
        break
if can:
    S=""
    for j in range(len(SS)):
        if i<=j<i+len(T):
            S+=T[j-i]
        elif SS[j]=="?":
            S+="a"
        else:
            S+=SS[j]
    print(S)
else:
    print("UNRESTORABLE")
    

Measured memory_bytes: 38356
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = tuple(map(int, input().split()))

    # I = A.count(1)
    # J = A.count(2)
    # K = A.count(3)

    I = 0
    J = 0
    K = 0
    for a in A:
        if a == 1:
            I += 1
        elif a == 2:
            J += 1
        else:
            K += 1

    dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] 

    # def output(lst):
    #     for tmp in lst:
    #         print (tmp)

    for k in range(K + 1):
        for j in range(K + J + 1 - k):
            for i in range(N + 1 - k  - j):
                if i == j == k == 0:
                    continue
                tmp = N
                if i > 0:
                    tmp += i * dp[k][j][i - 1]
                if j > 0:
                    tmp += j * dp[k][j - 1][i + 1]
                if k > 0:
                    tmp += k * dp[k - 1][j + 1][i]
                dp[k][j][i] = tmp / (i + j + k)

    print (dp[K][J][I])

    # output(dp)

if __name__ == '__main__':
    main()


Measured memory_bytes: 506120
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var q = int.Parse(ReadLine());
            var answers = new List<int>();
            var isPrime = new bool[100001];
            for(var i = 3; i < isPrime.Length; i += 2)
            {
                isPrime[i] = true;
            }
            isPrime[2] = true;
            for(long i = 3; i < isPrime.Length; i += 2)
            {
                if(!isPrime[i])
                {
                    continue;
                }
                for(long j = i * i; j < isPrime.Length; j += i)
                {
                    isPrime[j] = false;
                }
            }

            var sumLike2017 = new int[100001];
            for(var i = 3; i < sumLike2017.Length; i += 2)
            {
                if(isPrime[i] && isPrime[(i + 1) / 2])
                {
                    sumLike2017[i] = 1;
                }
                sumLike2017[i] += sumLike2017[i - 2];
            }

            for(var i = 0; i < q; i++)
            {
                var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
                var l = line[0];
                var r = line[1];

                answers.Add(sumLike2017[r] - (l == 1 ? 0 : sumLike2017[l - 2]));
            }

            answers.ForEach(value => WriteLine(value));
        }
    }
}


Measured memory_bytes: 17824
n,m,q=map(int,input().split())
abcd=[[0]*4 for i in range(q)]
for i in range(q):
    abcd[i]=list(map(int,input().split()))

def dfs(nn,anni,vmax):
    if nn==n:
        qsum=0
        for j in range(q):
#            print(j,abcd[j][1],abcd[j][0])
            if a[abcd[j][1]-1]-a[abcd[j][0]-1]==abcd[j][2]:
                qsum=qsum+abcd[j][3]
#        print(qsum,a)
        return qsum
    a[nn]=anni
#    vmax=0
    for i in range(10):
        if a[nn]+i<=m:
            v=dfs(nn+1,a[nn]+i,vmax)
            vmax=max(v,vmax)
    return vmax

vmax=0
a=[0]*n
print(dfs(0,1,vmax))


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

int H[100001];

int main() {
  int N;
  int i;
  scanf ("%d", &N);
  
  scanf("%d", &H[0]);
  H[0]--;
  for (i=1;i<N;i++) {
      scanf("%d", &H[i]);
      if (H[i]<H[i-1]) {
          printf ("No");
          return 0;
      }
      if (H[i]>H[i-1]) H[i]--;
  }
  
  printf("Yes");
  return 0;
}




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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0;
char c;
string s;
vector <ll> V;

int main()
{
    cin >> n >> k;
    for (int i=0;i<n;i++){
        cin >> x;
        V.push_back(x);
    }
    sort(V.begin(), V.end());
    for (int i=0;i<k;i++){
        sol+=V[i];
    }
    cout << sol;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<vector>
std::vector<int>g[100005];
int son[100005];
int vis[100005];
int p[100005];
int seq[100005];

void dfs(int u,int ban){
    vis[u] = son[u] = 1;
    for(int v: g[u]){
        if(v!=ban && !vis[v]){
            dfs(v,ban);
            p[v] = u;
            son[u] += son[v];
        }
    }
    vis[u] = 0;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    p[1] = -1;
    dfs(1,-1);
    int cur = n, size = 0;
    while(cur!=-1){
        seq[++size] = cur;
        cur = p[cur];
    }
    int L = 1, R = size;
    while(R-1>L){
        R--;
        if(L+1!=R) L++;
    }
    //printf("L = %d, R = %d\n",L,R);
    for(int i = 1; i <= n; i++) son[i] = 0;
    int start = seq[R], ban = seq[R-1];
    dfs(start,ban);
    int my = son[start], your = n-son[start];
    if(my>your) printf("Fennec\n");
    else printf("Snuke\n");
    return 0;
}


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

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    a *= 1000;
    int h[n];
    int ans    = 0;
    double tmp = 10000000;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        int aa = t * 1000 - h[i] * 0.006 * 1000;
        int diff;
        diff = abs(a - aa);
        // cout << "aa: " << aa << "   diff: " << diff << "   tmp: " << tmp
        //      << endl;
        if (diff < tmp) {
            tmp = diff;
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x = int(open(0).read().split()[0])

import heapq

s = {0} 
hq = [0]

prices = list(range(100, 106))

tmp = 0

while tmp<x:
    tmp = heapq.heappop(hq)
    for price in prices:
        new = tmp+price
        if new not in s:
            s.add(new)
            heapq.heappush(hq, new)

print(int(tmp == x))

Measured memory_bytes: 77552
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ATwoIntegers {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int X, Y;
        cin >> X >> Y;
        if (X % Y == 0) {
            cout << -1 << endl;
            return;
        }
        cout << X * (Y + 1) << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ATwoIntegers solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		HashMap<String, Integer> vote = new HashMap<>();
		String temp;
		for (int i = 0; i < N; i++) {
			temp = scan.next();

			if (vote.containsKey(temp)) {
				vote.put(temp, vote.get(temp) + 1);
			} else {
				vote.put(temp, 1);
			}
		}

		int max = Collections.max(vote.values());

		ArrayList<String> anser = new ArrayList<String>();
		for (Map.Entry<String, Integer> map : vote.entrySet()) {
			if (map.getValue() == max) {
				anser.add(map.getKey());
			}
		}

		Collections.sort(anser);

		for (String s : anser) {
			System.out.println(s);
		}

	}

}


Measured memory_bytes: 83844