akhauriyash/Code-Regression huggingface dataset:
<?php
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$k = (int)$input[1];

if ($k > (int)((($n-1) * ($n-2))/2)) {
	echo '-1';
	exit();
}
// if ($n === 2) {
// 	echo '1' . PHP_EOL;
// 	echo '1 2';
// }


$points = [];
$points[1] = [];
for ($i=2; $i <= $n; $i++) { 
	$points[$i] = [1];
	$points[1][] = $i;
}
$cnt = (int)((($n-1) * ($n-2))/2);
if ($cnt !== $k) {
	for ($i=2; $i <= $n ; $i++) { 
		for ($j=$i+1; $j <= $n; $j++) { 
			$points[$i][] = $j;
			$cnt -= 1;
			if ($cnt === $k) {
				break 2;
			}
		}
	}
}
// var_dump($points);
$g = [];
for ($i=1; $i <= $n; $i++) { 
	for ($j=$i+1; $j <= $n; $j++) { 
		$g[$i][$j] = false;
	}
}
for ($i=1; $i <= $n; $i++) { 
	foreach ($points[$i] as $p) {
		if ($i < $p && isset($g[$i][$p])) {
			$g[$i][$p] = true;
		}
	}
}

$edge = [];
for ($i=1; $i <= $n; $i++) { 
	for ($j=$i+1; $j <= $n; $j++) { 
		if ($g[$i][$j]) {
			$edge[] = $i . ' ' . $j;
		}
	}
}
echo count($edge) . PHP_EOL;
echo implode(PHP_EOL, $edge);

Measured memory_bytes: 4728
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    static int[] makePrimes( final int lim ) {
	
	BitSet isPrime = new BitSet( lim + 1 );
	isPrime.set( 0, lim + 1, true );
	isPrime.set( 0, 2, false );
	final int limIndex = ( int )sqrt( lim );
	for ( int index = 2; index <= limIndex; index++ ) {
	    if ( isPrime.get( index ) ) {
	   	for ( int i = index * index; i <= lim; i += index ) {
		    isPrime.set( i, false );
		}
	    }
	}
	final int count = isPrime.cardinality();
	int[] ans = new int[count];
	int index = 0;
	for ( int i = 0; i <= lim; i++ ) {
	    if ( isPrime.get( i ) ) {
		ans[index++] = i;
	    }
	}
	return ans;
    }
    
    public static void main( final String[] args ) {

	final int[] primes = makePrimes( 10000000 );
	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == 0 ) {
		break;
	    }

	    int index = Arrays.binarySearch( primes, n );
	    if ( index < 0 ) {
		index = min( primes.length, - index - 2 );
	    }
	    while ( index >= 3 ) {
		while ( index >= 3 && primes[ index ] - primes[ index - 1 ] > 2 ) {
		    index--;
		}
		if ( primes[ index - 1 ] - primes[ index - 2 ] == 4 &&
		     primes[ index - 2 ] - primes[ index - 3 ] == 2 ) {
		    
		    System.out.println( primes[ index ] );
		    break;
		}
		index--;
	    }	    
	}	
    }    
}

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

int main() {
  int n, m, c, temp, sum, result;
  vector<int> b;
  cin >> n >> m >> c;
  
  for (int i=0; i<m; i++) {
    cin >> temp;
    b.push_back(temp);
  }
  
  for (int i=0; i<n; i++) {
    sum = 0;
    for (int j=0; j<m; j++) {
      cin >> temp;
      sum+=temp*b[j];
    }
    sum+=c;
    if (sum>0) result++;
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 256
#
input()
a = list(map(int, input().split()))
input()
b = list(map(int, input().split()))

for i in range( min(len(a), len(b) ) ):
    if a[i] < b[i]:
        print(1)
        exit(0)
    if a[i] > b[i]:
        print(0)
        exit(0)

if len(a) >= len(b):
    print(0)
else:
    print(1)



Measured memory_bytes: 5628
import sys
def input():return sys.stdin.readline().strip()

from collections import deque


def main():
    N, K = map(int, input().split())
    to = [[] for _ in range(N)]
    MOD = 10**9 + 7
    for _ in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)

    MAX_N = 3 * 10 ** 5
    MOD = 10 ** 9 + 7
    fac = [0]*MAX_N
    inv = [0]*MAX_N
    finv = [0]*MAX_N
    fac[0] = 1; fac[1] = 1
    inv[1] = 1
    finv[0] = 1; finv[1] = 1

    def com_init():
        for i in range(2, MAX_N):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = -(MOD//i)*inv[MOD%i]%MOD
            finv[i] = finv[i-1]*inv[i]%MOD

    def perm(n, r):
        if n < 0:return 0
        elif r > n: return 0
        
        return fac[n]*finv[n-r]%MOD
    
    # dfs
    com_init()
    def dfs(s):
        stack = deque()
        stack.append((s, -1)) # now, par
        res = K
        while stack:
            now, par = stack.pop()

            if now == 0:
                children = len(to[now])
            else:
                children = len(to[now]) - 1

            if now == 0:
                nx_col = K - 1
            else:
                nx_col = K - 2
            
            res *= perm(nx_col, children)
            res %= MOD

            if children == 0 and now != 0:
                continue
            
            for nv in to[now]:
                if nv != par:
                    stack.append((nv, now))
        return res
    ans = dfs(0)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 65040
def main():
    X = int(input())
    for A in range(10**7):
        tmp = pow(A,5) - X
        if tmp == 0:
            print(A,0)
            exit()
        elif tmp < 0:
            for i in range(-1,-(10**7),-1):
                if tmp == pow(i,5) and pow(A,5) - pow(i,5) == X:
                    print(A,i)
                    exit()
                elif tmp > pow(i,5):
                    break
        else:
            for i in range(1,10**7):
                if tmp == pow(i,5) and pow(A,5) - pow(i,5) == X:
                    print(A,i)
                    exit()
                elif tmp < pow(i,5):
                    break



if __name__ == "__main__":
    main()

Measured memory_bytes: 65772
MOD=10**9+7
n,m=gets.split.map(&:to_i)
dp=[0]*(n+1)
dp[0]=1
m.times {dp[gets.to_i] = nil}

(0..n).each do |i|
  next if dp[i].nil?
  dp[i]+=dp[i-1] if i-1>=0 and !dp[i-1].nil?
  dp[i]+=dp[i-2] if i-2>=0 and !dp[i-2].nil?
  dp[i]%=MOD
end

p dp[n]%MOD


Measured memory_bytes: 2812
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 10000000

//Solution

int spf[N+5];

void sieve(){
    for(int i=2;i<=N;i++) spf[i] = i;
    for(int i=4;i<=N;i+=2) spf[i] = 2;
    for(int i=3;i*i<=N;i+=2){
        if(spf[i] == i){
            for(int j=i*i;j<=N;j+=i){
                if(spf[j] == j) spf[j] = i;
            }
        }
    }
}

void solve(){
    sieve();
    int n;
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int res = 1, cnt = 1;
        int num = i;
        while(num != 1){
            if(spf[num] == spf[num/spf[num]]) cnt++;
            else{
                res *= (cnt+1);
                cnt = 1;
            }
            num /= spf[num];
        }
        ans += i*res;
    }
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 81768
using System;

namespace ConsoleApp29
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            int[] arr = new int[5];
            for (int i = 0; i < array.Length; i++)
            {
                arr[i] = int.Parse(array[i]);
            }

            for(int i = 0; i < array.Length; i++)
            {
                if ( arr[i]==0)
                {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


Measured memory_bytes: 27448
import sys
import fractions

N = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

max_a = max(a)

tmp = a[0]
for i in a[1:]:
    tmp = (tmp * i) // fractions.gcd(tmp, i)

tmp -= 1
f = 0
for j in a:
    f += tmp % j
print(f)

Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;

const lint mod = 1e9 + 7;
const lint INF = mod * mod;

typedef struct RollingHash{
    const ulint hash_mod = (1ULL << 61ULL) - 1, hash_base = mod;
    const ulint mask_30bit = (1ULL << 30ULL) - 1, mask_31bit = (mask_30bit << 1ULL) + 1;
    const ulint num = hash_mod << 2LL;
    vector<ulint> pow_table, hash;
    int n;

    ulint calc_mul31(ulint a, ulint b){
        ulint au = a >> 31ULL, ad = a & mask_31bit;
        ulint mid = au * b, midu = mid >> 30ULL, midd = mid & mask_30bit;
        return midu + (midd << 31ULL) + ad*b;
    }

    ulint calc_mul61(ulint a, ulint b){
        ulint au = a >> 31ULL, ad = a & mask_31bit;
        ulint bu = b >> 31ULL, bd = b & mask_31bit;
        ulint mid = au * bd + ad * bu, midu = mid >> 30ULL, midd = mid & mask_30bit;
        return 2*au*bu + midu + (midd << 31ULL) + ad*bd;
    }

    ulint calc_mod(ulint x){
        x = (x & hash_mod) + (x >> 61ULL);
        if(x > hash_mod) x -= hash_mod;
        return x;
    }

    RollingHash(string &s){
        n = s.size();
        pow_table.resize(n+1);
        hash.resize(n+1);
        pow_table[0] = 1ULL;
        rep(i, n) pow_table[i+1] = calc_mod(calc_mul61(pow_table[i], hash_base));
        hash[0] = 0ULL;
        rep(i, n) hash[i+1] = calc_mod(calc_mul31(hash[i], hash_base) + s[i]);
    }

    ulint slice(int i, int len){
        return calc_mod(hash[i+len] +num - calc_mul61(hash[i], pow_table[len]));
    }
}Loli;

bool check(int len, Loli &rh){
    rep(i, rh.n-len+1){
        for(int j=i+len; j+len-1<rh.n; ++j){
            if(rh.slice(i, len) == rh.slice(j, len)) return true;
        }
    }
    return false;
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    Loli rh(s);

    int low = 0, high = n/2 + 1;
    while(high - low > 1){
        int mid = (high + low) / 2;
        (check(mid, rh) ? low : high) = mid;
    }

    printf("%d\n", low);
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int x,n;
    cin >> x >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int i;
    int a=0;
    int min=10000;
    int min1=0;
    int cnt =0;

    for(int j=0;j<=101;j++){
        for(int i=0;i<n;i++){
            if(j!=p[i]){
                cnt += 1;
            }
        }
        if(cnt==n){
            if(abs(j-x)<min){
                min = abs(j-x);
                min1= j;
            }
        }
        cnt = 0;
    }
    cout << min1 << endl;
    return 0;
}





Measured memory_bytes: 3624
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int A, B;  cin >> A >> B;

    int ans;
    if (B%A == 0) ans = A + B;
    else ans = B - A;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
s = gets.chomp.to_s.split(//)
count = 0
max_count = 0

s.each do |r|
    if r == "A" || r == "G" || r == "C" || r == "T"
        count += 1
        if count > max_count
            max_count = count
        end
    else
        count = 0
    end
end

puts max_count

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
vector<int> g[maxn];
ll dp[maxn],sum[maxn],fac[maxn],ifac[maxn],n;
ll fpow(ll a,ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) r = r * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return r;
}
ll C(int x,int y) {
	if (x < 0 || x < y || y < 0) return 0;
	return fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
void dfs1(int u,int fa) {
	dp[u] = 1;
	for (auto it : g[u]) {
		if (it == fa) continue;
		dfs1(it,u);
		sum[u] += sum[it];
		dp[u] = dp[u] * dp[it] % mod * C(sum[u],sum[it]) % mod;
	}
	sum[u] += 1;
}
void dfs2(int u,int fa) {
	for (auto it : g[u]) {
		if (it == fa) continue;
		ll tmp = dp[u] * fpow(dp[it],mod - 2) % mod * fpow(C(n - 1,sum[it]),mod - 2) % mod;
		dp[it] = dp[it] * tmp % mod * C(n - 1,sum[it] - 1) % mod;
		dfs2(it,u);
	}
}
int main() {
	fac[0] = 1;
	for (int i = 1; i <= maxn - 10; i++) fac[i] = fac[i - 1] * i % mod;
	ifac[maxn - 10] = fpow(fac[maxn - 10],mod - 2);
	for (int i = maxn - 10 - 1; i >= 0; i--)
		ifac[i] = ifac[i + 1] * (i + 1) % mod;
	scanf("%lld",&n);
	for (int i = 1,x,y; i < n; i++) {
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs1(1,0); dfs2(1,0);
	for (int i = 1; i <= n; i++)
		printf("%lld\n",dp[i]);
	return 0;
}

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

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

  ll r = 0, g = 0, b = 0;
  for (auto e : s) {
    if (e == 'R') {
      r++;
    } else if (e == 'G') {
      g++;
    } else if (e == 'B') {
      b++;
    }
  }

  ll m = r * g * b;
  for (int i = 0; i < n; i++) {
    for (int j = 1; i + 2 * j < n; j++) {
      if (s[i] != s[i + j] && s[i + j] != s[i + 2 * j] && s[i + 2 * j] != s[i]) m--;
    }
  }
  cout << m << endl;
}


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

vector< vector<int> > fr;
vector<int> invite;
int n, m;

bool notInvited(int p){
    for(int i=0; i < invite.size(); i++){
        if(p == invite[i])
            return false;
    }
    return true;
}

void dfs(int i, int depth){
    for(int p=1; p < n+1; p++){
        if(fr[i][p] == 1 && depth < 2){
            if(notInvited(p)){
                invite.push_back(p);
            }
            fr[i][p] = 0;
            dfs(p, depth+1);
        }
    }
}

int main(void){
    //fr = vector< vector<int> >(n+1, vector<int>(n+1, 0));
    while(1){
        invite.clear();
        cin >> n >> m;
        if(n==0&& m==0) return 0;
        fr = vector< vector<int> > (n+1, vector<int>(n+1));
        for(int i=0; i < m; i++){
            int tmp1, tmp2; cin >> tmp1 >> tmp2;
            fr[tmp1][tmp2] = 1;
            fr[tmp2][tmp1] = 1;
        }

        invite.push_back(1);

        dfs(1, 0);
        cout << invite.size() -1<< endl;
    }
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long int;

int main(){
    string S;
    cin>>S;
    if(S[2]==S[3]&&S[4]==S[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  int i,j,k;
  for(i=0;i<N;i++) {
    cin >> C[i];
    for(j=0;j<M;j++)cin >> A[i][j];
  }
  long long ans = (long long)1 << 60,temp;
  bool f;
  for(i=0;i<(1<<N);i++) {
    temp = 0;
    vector<int> vtemp(N,0);
    for(j=0;j<N;j++) {
      if(i&(1<<j)) {
        temp += C[j];
        for(k=0;k<M;k++)vtemp[k] += A[j][k];
      }
    }
    f = true;
    for(j=0;j<M && f;j++)if(vtemp[j] < X)f = false;
    if(f)ans = min(ans,temp);
  }
  cout << (ans == (long long)1<<60?-1:ans) << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

string S,T;

void output_ans(int s,int t,int k){
	rep(i,k){
		if(S[i]=='?'){
			cout << 'a';
		}else{
			cout << S[i];
		}
	}
	cout << T;
	REP(i,k+t,s){
		if(S[i]=='?'){
			cout << 'a';
		}else{
			cout << S[i];
		}
	}
}
bool scan_str(string a,string b){
	rep(i,a.size()){
		if(a[i]!='?'&&a[i]!=b[i]){
			return false;
		}
	}
	return true;
}
void solve(){
	cin >> S;
	cin >> T;
	for (int i = S.size()-T.size(); i >= 0; --i)
	{
		if(scan_str(S.substr(i,T.size()),T)){
			output_ans(S.size(),T.size(),i);
			cout << endl;
			return;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(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 >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

class Solver {
public:
	int N;
	vector<int> A;

	void solve() {
		cin >> N;
		A.resize(N);
		rep(i, N) cin >> A[i];
		sort(all(A));
		cout << A.back() - A.front() << endl;
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;

// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;

// #define cin mycin
// #define cout mycout
// #define endl '\n'

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
"""f(b)-f(a-1)を出力すればいい"""
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)
ans = b - (b//c + b//d -b//lcm(c,d))
ans1 = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//lcm(c,d)) 

print(ans-ans1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var t = sc.nextInt();
		var s = sc.nextInt();
		sc.close();

		System.out.println(s * t >= d ? "Yes" : "No");
	}
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
int main()
{
    int A,B,K;

    cin>>A>>B>>K;

    for(int i=1;i<=K;i++){
        if(i%2==1){
            A/=2;
            B+=A;
        }else{
            B/=2;
            A+=B;
        }
    }

    cout<< A << " "<<B<<endl;
 
    return 0;
}

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

using namespace std;

int main()
{
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    int ans = 0;

    int carry = N % 2;

    ans = N / 2 + carry;

    cout << ans << endl;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var ps = Input().ToInt();
		var h = ps[0];
		var w = ps[1];
		var grid = new bool[h+2, w+2];
		for(int i = 0; i < h; i++)
		{
			var s = Console.ReadLine();
			for(int j = 0; j < w; j++)
			{
				grid[i+1, j+1] = s[j]=='#';
			}
		}
		
		for(int i = 1; i <= h; i++)
		{
			for(int j = 1; j <= w; j++)
			{
				if(!grid[i, j])
					continue;
					
				if(!(grid[i, j] && (grid[i, j+1] || grid[i+1, j] || grid[i-1, j] || grid[i, j-1])))
				{
					Console.WriteLine("No");
					return;
				}
			}
		}
		Console.WriteLine("Yes");
		
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 11092
main(x,y,z,e,m){for(;scanf("%d",&e),m=e;printf("%d\n",m))for(z=0;z*z*z<=e;z++)for(y=0;y*y+z*z*z<=e;y++)if(x=e-z*z*z-y*y+y+z,m>x)m=x;exit(0);}

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

int main() {
  int a,b,c;
  	cin>>a>>b>>c;
  int k;
  	cin>>k;
  int M,m;
  M=max({a,b,c});
  m=max({a,b,c});
  for(int i=0;i<k;i++){
    M=M*2;
  }
  cout<<a+b+c+M-m<<endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
M = [list('#' * (W+2))]
M += [['#'] + list(input()) + ['#'] for _ in range(H)]
M += [list('#' * (W+2))]

n = 0
ans = 0
for y in range(1, H+1):
    for x in range(1, W+1):
        if M[y][x] == '#':
            continue
        n += 1
        M[y][x] = n
        q = set([(y, x)])
        count = -1
        while q:
            count += 1
            nq = set()
            for w, z in q:
                M[w][z] = n
                if M[w-1][z] != '#' and M[w-1][z] != n:
                    nq.add((w-1, z))
                if M[w+1][z] != '#' and M[w+1][z] != n:
                    nq.add((w+1, z))
                if M[w][z-1] != '#' and M[w][z-1] != n:
                    nq.add((w, z-1))
                if M[w][z+1] != '#' and M[w][z+1] != n:
                    nq.add((w, z+1))
            q = nq
        ans = ans if ans > count else count
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

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


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

int main() {
	long long N, COUNT = 0, X;
	vector<long long> ANS;
	cin >> N;
	for (int i = 1; ; i++) {
		ANS.push_back(i);
		COUNT += i;
		if (N <= COUNT) break;
	}
	X = COUNT - N;
	for (int i = 0; i < ANS.size(); i++) if (ANS[i] != X) cout << ANS[i] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> P;

lint H, W, N, cnt[10];
map<P, lint> mp;

int main(){
    cin >> H >> W >> N;
    for(int i=0;i<N;i++){
        lint a, b; cin >> a >> b;
        for(lint j=max(1LL, a-2);j<=min(a, H-2);j++) for(lint k=max(1LL, b-2);k<=min(b, W-2);k++) mp[P(j, k)]++;
    }

    cnt[0] = (H-2) * (W-2);
    for(auto it : mp) {cnt[it.second]++; cnt[0]--;}

    for(int i=0;i<10;i++) cout << cnt[i] << endl;
    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
    int a,b;
    cin >> a >> b;
    cout << 6-a-b;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fr(_iii_, 0, 66)cerr<<'>';cerr<<" in\n";
#define deb(x) fr(_iii_, 0, 66)cerr<<'>';cerr<<#x"="<<x<<"\n";
#define deb_array(a, _iiii_, n) fr(_iii_, _iiii_, 66)cerr<<'>'; cerr<<'\n';fr(_iii_,_iiii_,n)cerr<<a[_iii_]<<(_iii_==n-1?"\n":" ");fr(_iii_, _iiii_, 66)cerr<<'>'; cerr<<"\n"
#define deb_matrix(a, h, w) fr(_iii_, 0, 66)cerr<<'>'; cerr<<'\n';fr(_iii_, 0, h){fr(j, 0, w) {cerr << a[_iii_][j] << ' ';}cerr << '\n';}fr(_iii_, 0, 66)cerr<<'>'; cerr<<"\n"
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
//bitmask
int on_bit(int x, int pos) {x |= (1 << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};
 
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
 
int n, x, a[1234];
bool happied[1234];
 
int main() {
	// freopen("input.in","r",stdin);
	sf("%d %d", &n, &x);
	fr(i,0,n) sf("%d", a+i);
	mems(happied);
	int res = 0;
	int cc = 0;
	sort(a, a+n);
	fr(i, 0, n) {
		cc += a[i]; if(cc <= x) res++;
		if(cc > x) break;
	}
	if(cc < x) res--;
	pf("%d\n",(res<0?0:res));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
ll ans = 1;

int main()
{
	cin >> n;
	for (ll i = 2;i <= n;i++) {
		ans = (ans * i) % mod;
	}

	cout << ans << endl;

	return 0;
}


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

int dp[100005][3]={ 0 };

int ans(int*a, int*b, int*c, int n) {
    dp[1][0]=a[1];
    dp[1][1]=b[1];
    dp[1][2]=c[1];
    for (int i=2;i<=n;i++) {
        dp[i][0]=a[i]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0], dp[i-1][1]);
    }
    return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int main() {
    int n;cin>>n;
    int a[n+1], b[n+1], c[n+1];
    for (int i=1;i<=n;i++) {
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<ans(a, b, c, n)<<"\n";
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    while(cin >> n) {
        if(!n) break;
        vector<ll> a(n);
        for(auto &e: a) cin >> e;
        ll r = 1e9;
        sort(a.begin(), a.end());
        for(ll i=0; i<n-1; i++)
            r = min(r, abs(a[i+1] - a[i]));
        cout << r << endl;
    }
}



Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int x,y;cin>>x>>y;
  bool flag=false;
  rep(i,x+1){
    if((2*i+4*(x-i))==y)flag=true;
  }
	if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3644
k = int(input())
a = list(map(int, input().split()))[::-1]
l, r = 2, 2
for i in range(k):
    l = ((l-1)//a[i] + 1) * a[i]
    r = (r//a[i] + 1) * a[i] - 1
    if l > r:
        print(-1)
        exit()
print(l, r)


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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    int A, B, X;
    
    cin >> A >> B >> X;
    if(A <= X && A + B >= X) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}



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

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void sort(int &a,int &b){
  int tmp = a;
  a = b;
  b = tmp;
}

int main(){
  int num[3];
  cin >> num[0] >> num[1] >> num[2];
  for(int i=0;i < 3;i++){
    for(int j=i;j < 3;j++){
      if(num[i] > num[j]) sort(num[i],num[j]);
    }
  }
  cout << num[0] << " " << num[1] << " " << num[2] << endl;
  return 0;
}


Measured memory_bytes: 3132
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&(b==1||b==3||b==5||b==7||b==8||b==10||b==12)){
        cout<<"Yes"<<endl;
    }
    else if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	S := nextString()
	if N%2 == 1 {
		fmt.Println("No")
		return
	}
	for i := 0; i < N/2; i++ {
		if S[i] != S[i+N/2] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		log.Fatal(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int l;
int q;
int a[100001];
int s;
int b;
int f[100001][33];
int main(){
    cin>>n;
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    cin>>l>>q;
    for(int i=1;i<=n;++i){
    	int x=upper_bound(a+1,a+n+1,a[i]+l)-a-1;
    	if(a[i]+l>=a[n]) f[i][0]=n;
    	else f[i][0]=x;
    }
    for(int j=1;j<=30;j++)
        for(int i=1;i<=n;i++)
            f[i][j]=f[f[i][j-1]][j-1];
    while(q--){
		scanf("%d %d",&s,&b);
		int i=1;
		int ans=0;
		if(s>b) s^=b^=s^=b;
		for(int i=30;i>=0;--i)
			if(f[s][i]<b)
				ans+=(1<<i),
				s=f[s][i];
			printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 14080
#include <stdio.h>

int main(void){

    unsigned int a,b,c;

    //input
    scanf("%d %d %d", &a, &b, &c);

    //output
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;

}

Measured memory_bytes: 580
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n = int(readline())
a = sorted(tuple(map(int, readline().split())))
cnt = 1
cumsum = list(itertools.accumulate(a))
for i in range(1, n):
    if cumsum[i - 1] * 2 < a[i]:
        n -= cnt
        cnt = 0
    cnt += 1
print(n)


Measured memory_bytes: 13248
#include<iostream>
#include<vector>
#include<queue>

#define MAX_N 100000

#define INF (1LL<<62)
#define COST first
#define ID second

using namespace std;

typedef long long ll;
typedef pair<ll,ll> State;

int N,E;
vector<State>G[MAX_N];

void dijkstra(int st){
  priority_queue<State,vector<State>,greater<State> > que;
  que.push(State(0,st));
  ll dist[MAX_N];
  fill(dist,dist+MAX_N,INF);
  dist[st]=0;
  while(!que.empty()){
    State now = que.top();
    que.pop();
    if(dist[now.ID]<now.COST)continue;
    dist[now.ID]=now.COST;
    for(int i=0;i<G[now.ID].size();i++){
      ll cost = now.COST+G[now.ID][i].COST;
      ll to = G[now.ID][i].ID;
      que.push(State(cost,to));
    }
  }
  for(int i=0;i<N;i++){
    if(dist[i]==INF)cout << "INF" << endl;
    else cout << dist[i] << endl;
  }
}


int main(void){
  
  int st;
  cin >> N >> E >> st;

  int a,b,c;
  for(int i=0;i<E;i++){
    cin >> a >> b >> c;
    G[a].push_back(State(c,b));
  }
  
  dijkstra(st);
  
  return 0;
}

Measured memory_bytes: 21064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int a, b, c; cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X;
    cin >> X;
    ll ans = 0, c = 0;
    while (true) {
        c += X;
        c %= 360;
        ans++;
        if (c == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //N：枚数
        int Y = sc.nextInt(); //Y：宣言された金額

        int sum;//合計金額
        for(int i=0;i<=N;i++){
            for(int j=0;j<=N-i;j++){
                for(int k=0;k<=N-i-j;k++){
                    sum = i*10000+j*5000+k*1000;
                    if(sum == Y){
                        if(i+j+k == N){
                        System.out.println(i+" "+j+" "+k);
                        return;
                        }
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<iostream>
#include<set>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string s; int n;
	scanf("%d", &n);
	cin >> s; int sum = 0, a, b;
	for (int i = 0; i < n; i++)
	{
		set<char> w,f;
		w.clear();
		f.clear();
		int j;
		for (j = 0; j <= i; j++)
		w.insert(s[j]);
		b = w.size();
		for (int z = j; z < n; z++)
		{
			f.insert(s[z]);
			w.insert(s[z]);
		}
		a = b+f.size() -w.size();
		sum = max(sum, a);
	}
	cout << sum;
}


Measured memory_bytes: 256
a1=input()
a2=input()
A1=list(a1)
A2=list(a2)
i=0
for x in A1:
    if x!='C' and x!='S' and x!='R':
        A1.remove(x)
for x in A2:
    if x!='C' and x!='S' and x!='R':
        A2.remove(x)
if len(A1)==len(A2)==3:   
    if A1[0]==A2[0]:
        i+=1
    if A1[1]==A2[1]:
        i+=1
    if A1[2]==A2[2]:
        i+=1
    print(i)

Measured memory_bytes: 9108
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let m: usize = parse!(it);
    let mut ret = 0;
    let mut stack = vec![];
    for _ in 0..m {
        let (d, c): (usize, usize) = parse!(it, 2);
        let k = c / 9;
        ret += k * (d + 7);
        for _ in 0..(c % 9) {
            stack.push(d);
        }
        if k != 0 {
            ret += 2 * (k - 1);
            stack.push(9)
        }
    }

    while stack.len() > 1 {
        let a = stack.pop().unwrap();
        let b = stack.pop().unwrap();
        let c = a + b;
        ret += 1;
        if c >= 10 {
            stack.push(1);
        }
        stack.push(c % 10);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 17780
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

class RollingHash(object):
    from random import randint
    __MASK30=(1<<30)-1
    __MASK31=(1<<31)-1
    __MOD=(1<<61)-1
    __base=randint(129,__MASK31)

    def __init__(self,s:str):
        n=len(s)
        b=self.__base
        H=[0]*(n+1); P=[1]*(n+1)
        for i in range(n):
            H[i+1]=self.__modulo(self.__multiple(H[i],self.__base)+ord(s[i]))
            P[i+1]=self.__multiple(P[i],self.__base)
        self.__H=H; self.__P=P

    def __multiple(self,a,b):
        au=a>>31
        ad=a&self.__MASK31
        bu=b>>31
        bd=b&self.__MASK31
        m=ad*bu+au*bd
        mu=m>>30
        md=m&self.__MASK30
        return self.__modulo(2*au*bu+mu+(md<<31)+ad*bd)

    def __modulo(self,x):
        x=(x&self.__MOD)+(x>>61)
        if(x>self.__MOD): x-=self.__MOD
        return x

    def hash(self,l,r):
        H=self.__H; P=self.__P
        return self.__modulo(H[r]+self.__MOD*3-self.__multiple(H[l],P[r-l]))

def resolve():
    n=int(input())
    s=input()
    rh=RollingHash(s)
    def check(d):
        J={rh.hash(i,i+d):-1 for i in range(n-d+1)}
        for i in range(n-d+1):
            h=rh.hash(i,i+d)
            if(J[h]!=-1):
                if(i-J[h]>=d): return True
            else: J[h]=i
        return False
    print(bisection(0,n,check))
resolve()

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


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	int a[3];
 	cin >> a[0] >> a[1] >> a[2];
 	sort(a, a+3);

 	if (a[0] + a[1] == a[2]) {
 		cout << "Yes\n";
 	}
 	else {
 		cout << "No\n";
 	}
 	
	return 0;
}

Measured memory_bytes: 256
/*
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int N;
	cin>>N;
	vector<int> A(N);
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
	}
	vector<bool> sea(N+2);
	sea[0]=sea[N+1]=true;
	for(int i=0;i<N;i++){
		sea[i+1]=(A[i]<=0);
	}
	int current=0;
	for(int i=1;i<=N;i++){
		if(!sea[i]&&sea[i-1])
		{
			current++;
		}
	}
	vector<pair<int,int> > AandID;
	for(int i=0;i<N;i++){
		if(A[i]>0){
			AandID.push_back(make_pair(A[i],i+1));
		}
	}
	sort(AandID.begin(),AandID.end());
	int answer=current;
	for(int t=0;t<AandID.size();t++){
		int i=AandID[t].second;
		sea[i]=true;
		if(sea[i-1]&&sea[i+1]){
			current--;
		}
		else if(!sea[i-1]&&!sea[i+1]){
			current++;
		}
		if(t+1==AandID.size()||AandID[t].first<AandID[t+1].first){
			answer=max(answer,current);
		}
	}
	cout<<answer<<endl;
	return 0;
}*/
/*
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	long long N,M;
	cin>>N>>M;
	vector<long long> A(N+2);
	
	return 0;
}*/

#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
int main(void)
{
	long long N=0;
	cin>>N;
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	vector<bool> sea(N+2);
	sea[0]=sea[N+1]=true;
	for(int i=0;i<N;i++){
		sea[i+1]=(A[i]<=0);
	}
	long long current=0;
	for(int i=1;i<=N;i++){
		if(sea[i-1]&&!sea[i]){
			current++;
		}
	}
	vector<pair<long long,long long> > V;
	for(int i=0;i<N;i++){
		if(A[i]>0){
			V.push_back(make_pair(A[i],i+1));
		}
	}
	sort(V.begin(),V.end());
	long long answer=current;
	for(int t=0;t<V.size();t++){
		int a=V[t].second;
		sea[a]=true;
		if(!sea[a-1]&&!sea[a+1])
		{
			current++;
		}
		if(sea[a-1]&&sea[a+1])
		{
			current--;
		}
		if(t==V.size()-1||V[t].first<V[t+1].first){
			answer=max(answer,current);
		}
	}
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 5708
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll l,r; cin >> l >> r;
    ll L = l % 2019;
    ll R = r % 2019;
    ll m = 10000000000;
    ll x;
    if(r-l >= 2019){
        cout << 0 << "\n";
        return 0;
    }
    if(L >= R) R += 2019;
    REP(i,L,R){
        REP(j,i+1,R+1){
            x = (i % 2019) * (j % 2019) % 2019;
            //cout << x << "\n";
            //if(x == 0) cout << i << " " << j << "\n";
            m = min(m,x);
            //cout << m << "\n";
        }
    }
    cout << m << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&n,&m);
	if(m==1)
	{
		printf("0");
	}
	else
	{
		printf("%d",n-m);
	}
	return 0;
}


Measured memory_bytes: 256