akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint dx = {-1, 1, 0, 0};
vint dy = {0, 0, 1, -1};
int h, w;
vstr s;

bool check(int x, int y) {
    if (s[x][y] == '.') return true;
    rep(i, 4) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        if (nx < 0 || nx >= h) continue;
        if (ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#') return true;
    }
    return false;
}

int main() {
    cin >> h >> w;
    s.resize(h);
    rep(i, h) cin >> s[i];

    bool ans = true;
    rep(i, h) rep(j, w) if (check(i, j) == false) ans = false;

    yns(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n, m, d, p, r[11];

int main()
{
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
        
        if(n == 0 && m == 0) { break; }
        
        for(int i = 0; i < 11; i++)
        {
            r[i] = 0;
        }
        
        while(n--)
        {
            scanf("%d", &d);
            scanf("%d", &p);
            
            r[p] += d;
        }
        
        for(int i = 10; i >= 0; i--)
        {
            if(m >= r[i])
            {
                m -= r[i];
                
                r[i] = 0;
            }
            else
            {
                r[i] -= m;
                
                break;
            }
        }
        
        int sum = 0;
        
        for(int i = 0; i <= 10; i++)
        {
            sum += i * r[i];
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll R; cin >> R;
  fin(R * 2. * PI);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define INF             1e9
#define INFL            1e19
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cout << endl;
#define HOISE           cout << "hoise" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cout << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 200000 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 1000000007;
const double PY = acos(-1.0);

int main()
{
//    READ;
//    WRITE;
    FASTIO;

    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0, j = 1; i < n; i++){
        int x;
        cin >> x;
        if(x == j){
            cnt++;
            j++;
        }
    }
    if(cnt == 0) cout << -1;
    else cout << n - cnt;

    return 0;
}




Measured memory_bytes: 256
import  java.util.Scanner;

public class Main {
public static void main(String[] args) {
				Scanner sc = new Scanner(System.in);
				int a = sc.nextInt();
				int b = sc.nextInt();
				
				System.out.println(a * b + " " + 2 * (a + b) );
				
				
		}
}

Measured memory_bytes: 26084
N=input()

if N[len(N)-1]==str(2) or N[len(N)-1]==str(4) or N[len(N)-1]==str(5) or N[len(N)-1]==str(7) or N[len(N)-1]==str(9):
    print("hon")
elif N[len(N)-1]==str(0) or N[len(N)-1]==str(1) or N[len(N)-1]==str(6) or N[len(N)-1]==str(8):
    print("pon")
else:
    print("bon")


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


// DEFINE TO MAKE WRITING SMALL
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<ll,ll>> vpll;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define F first
#define S second
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define lb(arr,x) lower_bound(arr.begin(),arr.end(),x)
#define ub(arr,x) upper_bound(arr.begin(),arr.end(),x)
#define er(arr,x) equal_range(arr.begin(),arr.end(),x)
// #define sort(arr) sort(arr.begin(),arr.end())
#define reverse(arr) reverse(arr.begin(),arr.end()

#define scan(x) cin>>x
#define print(x) cout<<x
#define newline cout<<"\n"
#define mod 1000000007
#define MAX 1000007

#define INF 1e9
#define test int t;cin>>t;while(t--)
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);

// GLOBAL VARIABLES
ll fact[MAX] = {0};
bool isPrime[MAX];

// POWER USING BINARY EXPONENTIATION
ll power(ll a,ll n){
    ll res = 1;
    ll x = a;
    while(n){
        if(n&1) res = (res*x);
        x = (x*x);
        n >>= 1;
    }
    return res;
}

// EUCLIDEAN THEOREM FOR GCD
ll gcd(ll a,ll b){
	return (!b) ? a : gcd(b,a%b);  
}

// Nth FIBONACCI NUMBER TO FIND IT
pair<ll,ll> fibonacci(ll n){
	if(n == 0){
		return {0,1}; 
	}
	pair<ll,ll> p = fibonacci(n >> 1);
	ll a = ((p.first%mod) * ((2*(p.second)%mod)%mod - (p.first)%mod))%mod;
	ll b = ((p.first%mod) * (p.first%mod))%mod + ((p.second%mod) * (p.second%mod))%mod;
	
	if(n & 1) return {b,(a+b)%mod};
	else return {a,b};
}

// FATORIAL OF A NUMBER MOD WITH mod VARIABLE
void factorial(){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2;i<MAX;i++){
        fact[i] = (i*fact[i-1])%mod;
    }
}

// CALCULATE THE INVERSE OF THE FUNCTION
ll inverse(ll n){
    ll res = 1;
    ll x = n;
    ll MOD = mod-2;
    while(MOD){
        if(MOD & 1) res = (res*x)%mod;
        MOD >>= 1;
        x = (x*x)%mod;
    }
    return res;
}

// FINDING THE COMBINATION WITH N,R
ll combination(ll n,ll r){
    return (((fact[n] * inverse(fact[r]))%mod) * 1ll * inverse(fact[n-r]))%mod;
}

// FINDING THE PRIME NUMBERS USING SEIVE METHOD
void seive(int n){
    for(int i=0;i<3001;i++) isPrime[i]=true;
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            for(int j=i*i;j<=n;j+=i){
                isPrime[j] = false;
            }
        }   
    }
}




int main(){
    fastIO;
    string s;
    cin>>s;
    int count = 0;
    int maxi = 0;
    REP(i,0,s.size()-1){
        if(s[i]=='R') count++;
        else {
            maxi = max(count,maxi);
            count=0;
        }
    }
    maxi = max(count,maxi);
    cout<<maxi<<endl;
}




Measured memory_bytes: 3656
import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.math.*;
public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

    sort(vec.begin(),vec.end());

    int ans = 0;
    rep(i,N-2){
        rep2(j,i+1,N-1){
            auto Iter = lower_bound(vec.begin(),vec.end(),vec[i]+vec[j]);
            ans += (N - 1 - j) - (vec.end() - Iter);
        }
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
K, N = map(int, input().split())

a = list(map(int,input().split()))

A = sorted(a)

maxl = A[0] + K - A[N-1]

if maxl <= 0:
    maxl = -1 * maxl


for i in range(N-1):
    l = A[i] - A[i+1]

    if l <= 0:
        l = -1 * l
    
    if maxl < l:
        maxl = l

ans = K - maxl

print(ans)

Measured memory_bytes: 77516
using System;
using System.Collections.Generic;
using static Assistant.Input;
using System.Linq;
using Assistant;

namespace エクサウィザーズB
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            string S = Console.ReadLine();

            int countR = 0;
            int countB = 0;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R') countR++;
                else countB++;
            }

            if (countR > countB) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        //drawmap
        //drawarray
    }
}


Measured memory_bytes: 11220
#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 <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>N;
    
    double num=0;
    rep(i,0,N){
        cin>>a[i];
        num+=1.0/a[i];
    }
    num = 1.0/num;
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    string s;
    cin >> n >> s;
 
    vector<char> rgb = {'B', 'G', 'R'};
    map<char, int> mp;
    mp['R'] = 0;
    mp['G'] = 1;
    mp['B'] = 2;
 
    vector<vector<ll>> sum(3, vector<ll>(n, 0));
    rep(i, n){
        if(i!=0) {
            rep(j, 3) sum[j][i] = sum[j][i-1];
        }
        if(s[i] == 'R') ++sum[0][i];
        if(s[i] == 'G') ++sum[1][i];
        if(s[i] == 'B') ++sum[2][i];
    }
 
    // rep(i, 3){
    //     rep(j, n) cout << sum[i][j] << " ";
    //     cout << endl;
    // }
 
    ll res = 0;
    do{
        char one = rgb[0];
        char two = rgb[1];
        char three = rgb[2];
 
        int ptr = 0;
        for(int i = 0; i < n-2; ++i){
            if(s[i] == one){
                ptr = i;
                // cout << one << two << three << endl;
                // cout << i << endl;
 
                for(int j = ptr+1; j < n-1; ++j){
                    if(s[j] == two){
                        res += sum[mp[three]][n-1] - sum[mp[three]][j];
                        // cout << one << " " << two << " " << i << " " << j << " " << sum[mp[three]][n-1] - sum[mp[two]][j] << endl;
 
                        if(j+j-i < n && s[j+j-i] == three) --res;
                    }
                }
            }
        }
 
    }while(next_permutation(rgb.begin(), rgb.end()));
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define Q 5000000000000000L

string s;
long long k, pos;

int main(){
	cin>>s;
	cin>>k;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='1'){
			pos++;
			if(pos>=k){
				cout<<1;
				return 0;
			}
		}
		else{
			cout<<s[i];
			return 0;
		}
	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();

	int A[301][301];
	rep1(i, N) {
		rep1(ii, N) {
			A[i][ii] = getint();
		}
	}

	//int shouryaku[301][301] = {};
	//rep1(k, N) {
	//	rep1(i, N) {
	//		if (k == i) continue;
	//		rep1(j, i - 1) {
	//			if (k == j) continue;
	//			if (A[i][j] > A[i][k] + A[k][j]) {
	//				printf("-1");
	//				return 0;
	//			}
	//			else if (A[i][j] == A[i][k] + A[k][j]) {
	//				shouryaku[i][j] = 1;
	//			}
	//		}
	//	}
	//}

	//ll goukei = 0;
	//rep1(i, N) {
	//	rep1(ii, i - 1) {
	//		if (shouryaku[i][ii] == 0) goukei += A[i][ii];
	//	}
	//}

	ll goukei = 0;
	rep1(i, N) {
		rep1(j, i - 1) {
			bool OK = 1;
			rep1(k, N) {
				if (k == j || k == i) continue;
				if (A[i][j] > A[i][k] + A[k][j]) {
					printf("-1");
					return 0;
				}
				else if (A[i][j] == A[i][k] + A[k][j]) {
					OK = 0;
					break;
				}
			}
			if(OK) goukei += A[i][j];
		}
	}

	printf("%lld", goukei);

	Would you please return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=100005;
int n,ans=0,num,head[maxn],t[maxn<<1],ne[maxn<<1],bit[maxn],f[maxn];
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
	ne[++num]=head[y];head[y]=num;t[num]=x;
}
inline void dfs(int x,int f){
	int l=0,v=0;
	forE(i,x)if(t[i]!=f){
		dfs(t[i],x);
		l|=(bit[x]&bit[t[i]]);
		bit[x]|=bit[t[i]];
	}
	if(!bit[x])bit[x]=1;
	else{
        while((1<<v)<l||(1<<v)&bit[x])v++;
        bit[x]=(bit[x]>>v<<v)|(1<<v);
	}
	ans=max(ans,v);
}
int main(){
	read(n);rep(i,1,n)head[i]=-1;
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		addedge(x,y);
	}dfs(1,-1);
	printf("%d\n",ans);
	return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; ++i)
        if (i != a && i != b)
            cout << i << endl;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////


int main(){
	int h,w ; cin >> h >> w;
	int a,b ; cin >> a >> b;
	int ans = h * w;
	ans -= a*w + b*h - a*b;
	cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=500005;
int n,a[MAX],c[3];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++){
        if(a[i]%2) c[0]++;
        else if(a[i]%4) c[1]++;
        else c[2]++;
    }
    if((n-max(c[1],1)+1)/2<=c[2]) printf("Yes\n");
    else printf("No\n");
}


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

int main() {
	string s; cin >> s;
	int res = 0,ans = 0;
	for (int i=0; i<=2; ++i) {
		if (s[i] == 'R') res++;
		else {
			ans = max(ans,res);
			res = 0;
		}
	}
	ans = max(ans,res);
	cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{for (int i=0;i<5;++i){
    int x ;
    cin>>x ;
    if (x==0){
        cout << i+1 << endl;
        return 0;
    }
}
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    ll N;cin>>N;
    vector<ll> a(N);
    REP(i,N){
        ll k;cin>>k;
        a[k-1]=i;
    }
    REP(i,N){
        cout<<a[i]+1;
        if(i!=N-1)cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  int ans =0;
  for(int i=0;i<n;i=i+2){
    if(a[i]%2==1)ans++;
  }
  cout<<ans;
  
  

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
//const ll MOD=1e9+7;
const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;}
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;}
    return false;
}

ll gcd(ll x,ll y){
	if (y==0) return x;
	return gcd(y,x%y);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    ll ans=1;
    rep(i,N) ans=ans*gcd(A[i],i)%MOD;
    cout << ans << endl;
}

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	lli n, a, cnt[65], ans = 0, bigmod = 1000000007, temp;
	scanf("%lld", &n);
	memset(cnt, 0, sizeof cnt);
	for (lli i = 0; i < n; i++) {
		scanf("%lld", &a);
		for (lli j = 0; j < 60; j++)
			if (a & (1ll << j))
				cnt[j]++;
	}
	for (lli i = 0; i < 60; i++) {
		temp = (1ll << i) % bigmod;
		temp = (temp * cnt[i]) % bigmod;
		temp = (temp * (n - cnt[i])) % bigmod;
		ans = (ans + temp) % bigmod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < 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++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  map<string, string> mp;
  mp["Sunny"] = "Cloudy";
  mp["Cloudy"] = "Rainy";
  mp["Rainy"] = "Sunny";
  cout << mp[s] << endl;
  
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL << 60;
const int MOD = (int) 1e9 + 7;

signed main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int ans = 0;
    if (v[0] > x) {
        ans += v[0] - x;
        v[0] = x;
    }
    for (int i = 0; i < n - 1; i++) {
        int d = v[i] + v[i + 1];
        if (v[i] + v[i + 1] > x) {
            ans += d - x;
            v[i + 1] -= (d - x);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	int x=700;
	cin>>s;
	if(s[0]=='o')x+=100;
	if(s[1]=='o')x+=100;
	if(s[2]=='o')x+=100;
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner sc=new Scanner(System.in);
         for(int i=1; i>0; i++){
         int x=sc.nextInt();
         int y=sc.nextInt();
         if(x==0&&y==0)
             break;
         if(x<y){
             System.out.println(x+" "+y);
         }else if(y<x){
        	 System.out.println(y+" "+x);
         }else if(y==x){
        	 System.out.println(x+" "+y);
         }
         }
    }
}


Measured memory_bytes: 34840
# 配列を大きめにとって配った方がすっきりかけるのかも

n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]

#if j == 0 and k == 0 and s == 0:
dp[0][0][0] = 1
for j in range(n):
    for k in range(n):
        for s in range(n*X):

            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s+x[j]] += dp[j][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]

print(ans)

Measured memory_bytes: 92124
#include <algorithm>
#include <string.h>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
	int a[5];
	while(1){
		for(int i = 0; i < 5; i++){
			if(scanf("%d",&a[i]) == EOF){
				return 0;
			}
		}
		sort(a,a+5);
		for(int i = 4; i > 0; i--){
			printf("%d ",a[i]);
		}
		printf("%d\n",a[0]);
	}
	return 0;
}

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

int main() {
  int time[5];
  int m = 100;
  int m_id = 0; 
  for(int i = 0; i < 5; i++) {
    cin >> time[i];
    int k = time[i] - 1 - ((time[i] - 1) / 10 * 10);
    if(k < m) {m = k; m_id = i;}
  }
  m = (m + 1) % 10;
  
  int ans = 0;
  for(int i = 0; i < 5; i++) {
    if(i != m_id) {
      ans += ((time[i] - 1) / 10 * 10) + 10;
    } else{
      ans += time[i];
    }
  }
    
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int a[1000],N,i,j,kari,cnt=0;
   scanf("%d",&N);
   
   for(i=0;i<N;i++)
   scanf("%d",&a[i]);

 for(j=0;j<N;j++){
   for(i=N-1;i>0;i--){
   if(a[i-1]>a[i]){
      kari=a[i-1];
      a[i-1]=a[i];
      a[i]=kari;
      cnt=cnt+1;
   }
   
}
}
for(i=0;i<N;i++){
printf("%d",a[i]);
while(i!=N-1){
putchar(' ');
break;
}
}
putchar('\n');
printf("%d\n",cnt);

   return 0;
}


Measured memory_bytes: 2044
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let chars: Vec<char> = vec!['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
    fn rec(s: &mut String, l: usize, n: usize, max: usize, chars: &Vec<char>) {
        if l == n {
            println!("{}", s)
        } else {
            for i in 0..max + 2 {
                s.push(chars[i]);
                rec(s, l + 1, n, std::cmp::max(max, i), chars);
                s.pop();
            }
        }
    }
    let mut s = "a".to_string();
    rec(&mut s, 1, n, 0, &chars);
}


Measured memory_bytes: 5500
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ > 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on

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

    nxt2(ll, a, b);
    nxt2(ll, c, d);

    ll res = b * d;
    res = max(res, a * d);
    res = max(res, b * c);
    res = max(res, a * c);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		for(;;) {
			int x = scan.nextInt();
			int y = scan.nextInt();

			if(x == 0 && y == 0)
				break;

			System.out.println(String.format(x < y ? "%1$d %2$d" : "%2$d %1$d", x, y));
		}
	}
}



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



int main() {
    ll N, M, d, t;
    cin >> N;
    map<int, int> mpD;
    rep(i,N) {
        cin >> d;
        ++mpD[d];
    }
    cin >> M;
    map<int, int> mpT;
    rep(i,M) {
        cin >> t;
        ++mpT[t];
    }
    for (auto x : mpT) {
        if (x.second > mpD[x.first]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}



Measured memory_bytes: 22304
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).expect("ERROR");
    let vec: Vec<i32> = buf
        .split_whitespace()
        .map(|n| n.parse::<i32>()
        .unwrap()).collect();
    if vec[0] == vec[1] {
        print!("{}", vec[2]);
    } else if vec[0] == vec[2] {
        print!("{}", vec[1]);
    } else if vec[1] == vec[2] {
        print!("{}", vec[0]);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    int n = 0;
    string s;
    cin >> n;
    cin >> s;
    if (n >= 3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
}


Measured memory_bytes: 256
//JOI2018 1 Microwave
//20181208
//F_Naru
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int A,B,C,D,E;
  cin >> A >> B >> C >> D >> E;
  int second=0;
  int now_C=A;
  while(now_C<B and now_C<0){
    second+=C;
    now_C++;
  }
  if(now_C!=B and now_C==0){
    second+=D;
  }
  while(now_C<B and now_C>=0){
    second+=E;
    now_C++;
  }
  cout << second << endl;
  
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=1000006;
const ll INF=-1e12;
const double pi=acos(-1);



void solve(int T){
    int n;
    cin>>n;
    string a[]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
    cout<<a[n%10];
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int dmin = 100;
  for (int i = 0; i < N; i++) {
    int A, d = 0;
    cin >> A;
    
    while (A % 2 == 0) {
      A /= 2;
      d++;
    }
    
    dmin = min(dmin, d);
  }
  
  cout << dmin << endl;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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(){
  ll N,M,ans=0;
  cin>>N>>M;
  ll A[N];
  REP(i,N){
    cin>>A[i];
    A[i]/=2;
  }
  
  ll CNT[N];
  REP(i,N){
    CNT[i]=0;
    ll P=A[i];
    while(P%2==0){
      CNT[i]++;
      P/=2;
    }
  }
  
  ll T=CNT[0];
  if(N>=2){
    REP(i,N){
      if(T!=CNT[i]){
        co(0);
        return 0;
      }
    }
  }
  
  ll S=A[0];
  REP(i,N){
    S=lcm(S,A[i]);
    if(S>M){
      co(0);
      return 0;
    }
  }
  ans=(M/S+1)/2;
  co(ans);
  return 0;
}

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

using namespace std;

int main(void)
{
    int n;
    int count = 0;
  	int even_count = 0;
    cin >> n;

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

    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        if ((a[i] % 2) == 0)
        {
            if ((a[i] % 3) == 0 || (a[i] % 5) == 0)
            {
                count++;
            }
          even_count++;
        }
    }

    if (count == even_count)
    {
        cout << "APPROVED";
    }
    else
    {
        cout << "DENIED";
    }

    return 0;
}

Measured memory_bytes: 256
import math

def resolve():
    k=int(input())
    ans=0
    a=0
    b=0
    for h in range(1,k+1):
        for i in range(1,k+1):
            for j in range(1,k+1):
                 a=math.gcd(h,i)
                 b=math.gcd(i,j)
                 ans+=math.gcd(a,b)
    print(ans)
if __name__ == "__main__":
    resolve()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

string s;

int main(){
	cin >> s;
	ll ans = s.size();
	rep(i,s.size()-1){
		if(s[i] != s[i+1])ans = min(ans,max((ll)i+1,(ll)(s.size()-i-1)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
def judge(k:int, a:list):
    mi = ma = 2
    for ai in a[::-1]:
        # miをaiの倍数に切り上げる
        if mi%ai:
            mi = -(-mi//ai) * ai
            
        # maをaiの倍数-1に切り上げる
        ma = (ma//ai + 1) * ai - 1

        if ma < mi:
            return False, (-1,-1)
        
    return True, (mi,ma)
 
k = ni()
a = list(li())
 
tf, (mi,ma) = judge(k,a)
if tf:
    print(mi,ma)
else:
    print(-1)
    

Measured memory_bytes: 14256
import math

def main():
    n, k = map(int, input().split())

    ans = 0
    for amari in range(k, n):
        max_shou = (n - amari) // (amari + 1)
        if amari > 0:
            ans += n - amari
        for shou in range(1, max_shou + 1):
            start = (amari + 1) * shou + amari
            nokori = n - start + 1
            ans += math.ceil(nokori / shou)

    print(ans)

if __name__ == '__main__':
    main()

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans;
    if(x>y){
        ans=min(a+b,2*c)*y;
        ans+=min(a,2*c)*(x-y);
    }
    else{
        ans=min(a+b,2*c)*x;
        ans+=min(b,2*c)*(y-x);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> dis(h,vector<int>(w,-1));
    int ndis;
    if(s[0][0] == '.') ndis = 0;
    else ndis = 1;
    priority_queue<T,vector<T>,greater<T>> q;
    q.push(T(ndis,0,0));
    auto isIn = [&](int pf,int ps) {
        return pf >= 0 && pf < h && ps >= 0 && ps < w;
    };
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        if(dis[get<1>(t)][get<2>(t)] != -1) continue;
        int ch = get<1>(t);
        int cw = get<2>(t);
        int nh = get<1>(t);
        int nw = get<2>(t)+1;
        dis[ch][cw] = get<0>(t);
        if(isIn(nh,nw)) {
            if(s[ch][cw] == s[nh][nw] || s[ch][cw] == '#') q.push(T(dis[ch][cw],nh,nw));
            else q.push(T(dis[ch][cw]+1,nh,nw));
        }
        nh += 1;
        nw -= 1;
        if(isIn(nh,nw)) {
            if(s[ch][cw] == s[nh][nw] || s[ch][cw] == '#') q.push(T(dis[ch][cw],nh,nw));
            else q.push(T(dis[ch][cw]+1,nh,nw));
        }
    }
    cout << dis[h-1][w-1] << endl;
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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 <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
using namespace std;

int stat[100];
int main()
{
	std::ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	int _m = n;
	while(_m--)
	{
		int k;
		cin >> k;
		while(k--)
		{
			int num;
			cin >> num;
			stat[num]++;
		}
	}
	int cnt = 0;
	for(int i = 1; i <= m; i++)
	{
		if(stat[i] == n)
		cnt++;
	}
	cout << cnt;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    for(auto &a:A){
        cin >> a;
    }

    int ans=0;
    sort(A.begin(),A.end());
    A.push_back(MOD);
    vector<bool> judge(1000001,true);
    for(int i=0; i<N; i++){
        if(judge[A[i]]==true){
            if(A[i]!=A[i+1]){
                ans++;
            }
            for(int j=1; A[i]*j<=1000000; j++){
                judge[j*A[i]]=false;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4692
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
ll n,k;
int main()
{
	cin>>n>>k;
	ll ans=0;
	for(ll b=k+1;b<=n;b++)
	{
		ll bs=0;
		while(bs<=n)
		{
			ll l=bs+k; 
			ll r=bs+b-1;
			if(l<=n)
			{
				ans+=min(r,n)-max(l,1ll)+1;
			}
			bs+=b;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List

main = 
  zipWith id [h,m,s] . repeat <$> readLn
  >>= putStrLn . (intercalate ":") . map show
  where
  h x = x `div` 3600
  m x = x `mod` 3600 `div` 60
  s x = x `mod` 3600 `mod` 60


Measured memory_bytes: 3636
#include <stdio.h>
int main(){int i,p,q,l,r,N,M,Q,v,a[501][501]={};scanf("%d %d %d",&N,&M,&Q);for(i=M;i--;){scanf("%d %d",&l,&r);a[l][r]++;}for(i=Q;i--;printf("%d\n",v)){scanf("%d %d",&p,&q);if(q-p<=N>>1)for(v=0,l=p;l<=q;l++)for(r=l;r<=q;v+=a[l][r++]);else{for(v=M,l=1;l<p;l++)for(r=l;r<=N;v-=a[l][r++]);for(l=p;l<=q;l++)for(r=q;++r<=N;v-=a[l][r]);for(l=q+1;l<=N;l++)for(r=l;r<=N;v-=a[l][r++]);}}return 0;}

Measured memory_bytes: 1792