akhauriyash/Code-Regression huggingface dataset:
/*
    NEVER GIVE UP!
    THE EXPERT IN ANYTHING WAS ONCE A BEGINNER
*/

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define f(i,a,b) for(ll i=a; i<=b; i++)
#define fi(i,a,b) for(ll i=a; i>=b; i--)
#define fa(x,b) for(auto x:b)
#define TC ll test_case; cin>>test_case; for(ll number=1 ; number <= test_case ; number ++ )
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (ll)(a).size()
#define sp(x) cout << fixed << setprecision(x);
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
#define endl "\n"

const ld pi = acos(-1);
const ll M=1e9+7,N=1e7+5,INF=1e18;


void solve()
{
    ll n,na=1,nb=1;
    cin >> n;
    vll a(n),b(n),ra(n),rb(n);
    bool isa=false,isb=false;

    f(i,0,n-1)
    {
        cin >> ra[i];
        a[i]=ra[i];
    }

    f(i,0,n-1)
    {
        cin >> rb[i];
        b[i]=rb[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    while(!isa)
    {
        isa=true;
        
        f(i,0,n-1)
        {
            if(a[i]!=ra[i])
            {
                isa=false;
                break;
            }
        }

        if(!isa)
        {
            next_permutation(a.begin(),a.end());
            na++;
        }
    }

    while(!isb)
    {
        isb=true;
        
        f(i,0,n-1)
        {
            if(b[i]!=rb[i])
            {
                isb=false;
                break;
            }
        }

        if(!isb)
        {
            next_permutation(b.begin(),b.end());
            nb++;
        }
    }

    cout << abs(na-nb) ;
}

int32_t main()
{
    FIO
    solve();
    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

set<int> st;

pii pp[MAXN];

int used[MAXN];

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, 0, n) {
		int l, r;
		scanf("%d%d", &l, &r);
		pp[i] = mp(l, r);
	}
	sort(pp, pp + n);
	REPN(i, 1, m) {
		st.insert(i);
	}
	int cnt_r = 0;
	REP(i, 0, n) {
		int r = pp[i]._2;
		if (st.lower_bound(r) != st.end()) {
			cnt_r++;
			st.erase(st.lower_bound(r));
			used[i] = 1;
		}
	}
	st.clear();
	REPN(i, 1, m - cnt_r) {
		st.insert(i);
	}
	int cnt_l = 0;
	REP(i, 0, n) {
		if (!used[i] && !st.empty() && *st.begin() <= pp[i]._1) {
			cnt_l++;
			st.erase(st.begin());
		}
	}
	int ans = n - cnt_r - cnt_l;
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 11904
import Foundation
 
let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合
 
var A = Int(split[0])!
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
var B = Int(split[1])!
var C = Int(split[2])!

if (A+B >= C){
    print("Yes")
}else{
    print("No")
}


Measured memory_bytes: 14068
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

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

typedef unsigned long long ull;
typedef unsigned long ul;

const static int NMAX = 100000;
int N;
int dp[3][NMAX];
int h[3][NMAX];

int main() {
  cin>>N;
  memset(dp, 0, sizeof(dp));

  REP(i,N) cin>>h[0][i]>>h[1][i]>>h[2][i];

  REP(i,3) dp[i][0] = h[i][0];

  for(int i=1; i<N; i++) {
    for(int a=0; a<3; a++) {
      int a1 = (a+1)%3;
      int a2 = (a+2)%3;
      dp[a][i] = max(dp[a1][i-1], dp[a2][i-1]) + h[a][i];
    }
  }
  int ans[] = {dp[0][N-1], dp[1][N-1], dp[2][N-1]};
  cout << *max_element(ans, ans+3) << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
    int a[3],b,c,i;
    int min=2000;

    for(i=0;i<3;i++){
	scanf("%d",&a[i]);
	if(a[i]<min) min=a[i];
    }
    scanf("%d%d",&b,&c);
    if(b<c) printf("%d\n",min+b-50);
    else printf("%d\n",min+c-50);

    return 0;
}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	vvi m(14, vi(14));

	char ch;
	int x, y, s;
	while (cin >> x >> ch >> y >> ch >> s){
		y += 2;
		x += 2;

		m[y][x]++;
		m[y + 1][x]++;
		m[y - 1][x]++;
		m[y][x + 1]++;
		m[y][x - 1]++;

		if (s == 1) {
			continue;
		}

		m[y + 1][x + 1]++;
		m[y + 1][x - 1]++;
		m[y - 1][x + 1]++;
		m[y - 1][x - 1]++;

		if (s == 2) {
			continue;
		}

		m[y + 2][x]++;
		m[y - 2][x]++;
		m[y][x + 2]++;
		m[y][x - 2]++;
	}

	int noInkGrid = 0;
	int maxInc = 0;
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (m[i][j] == 0) {
				noInkGrid++;
			}
			maxInc = max(maxInc, m[i][j]);
		}
	}

	cout << noInkGrid << endl;
	cout << maxInc << endl;
	return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n =sc.nextInt();
    int k =sc.nextInt();
    int[]s = new int[n];
    
    for(int i=0; i<k; i++) {
    	int d = sc.nextInt();
    	for(int j=0; j<d; j++) {
    		int a = sc.nextInt();
    			s[a-1]++; 
    	}	
    }
    int cou = 0;
    for(int i=0; i<n; i++) {
    	if(s[i]==0) {
    		cou++;
    	}
    }
    System.out.println(cou);
    }
}


Measured memory_bytes: 46312
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,a,b,c,d;
    cin>>n>>a>>b;
    c=min(a,b);

    cout<<c<<' ';
    d=a+b;
    if(d<=n)cout <<0<<endl;
    else cout<<d-n<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n = sc.nextInt();
        ArrayList<Integer>[] g=new ArrayList[n+1];
        for (int i=1;i<=n;i++)g[i]=new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            int a=sc.nextInt(),b=sc.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        int[] d_1=new int[n+1];
        int[] d_n=new int[n+1];
        for (int i = 0; i < n + 1; i++) {
            d_1[i]=-1;
            d_n[i]=-1;
        }
        dfs(d_1,0,1,g);
        dfs(d_n,0,n,g);
        int f=0,s=0;
        for (int i = 1; i < n + 1; i++) {
            if(d_1[i]<=d_n[i])f++;
            else s++;
        }
        //out.println(Arrays.toString(d_1));
        //out.println(Arrays.toString(d_n));
        out.println(f>s?"Fennec":"Snuke");
        out.close();
    }
    static void dfs(int[] d,int dist,int node,ArrayList<Integer>[] g){
        if(d[node]>=0)return;
        d[node]=dist;
        for (Integer children:g[node]){
            dfs(d,dist+1,children,g);
        }
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

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

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

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

Measured memory_bytes: 88920
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
		{
			var s = Console.ReadLine().Split(' ');
			int a = int.Parse(s[0]);
			int b = int.Parse(s[1]);
			var l = Console.ReadLine().Split(' ');
			List<long> h = new List<long>(); 
			foreach (var c in l)
			{ h.Add(long.Parse(c)); }
			h.Sort();
			long w=0;
			for(int i=0;i<h.Count - b;i++)
			{
				w += h[i];
			}
			Console.WriteLine(w);
		}
}

Measured memory_bytes: 37760
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
string s;
ll k,m=5e15;
int main(){
cin>>s>>k;
for (int i=0;i<s.size()&&k&&s[i]=='1';++i) if (--k==0) return write(1);  
for (int i=0;i<s.size();++i) if (s[i]!='1') return pc(s[i]),0; 
write(1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

//n段登る方法
ll up(int n) {
    if (n == 0) {
        return 0;
    }
    if (n == 1) {
        return 1;
    }
    if (n == 2) {
        return 1;
    }
    if (n == 3) {
        return 2;
    }
    if (n >= 4) {
        return up(n-1) + up(n-2);
    }
}

int main() {
    int N, M;
    ll ans = 1;
    cin >> N >> M;
    vector<ll> up(N+10);
    rep(i, N+10) {
        if (i == 0 || i==1) {
            up[i] = i;
            continue;
        }
        up[i] = (up[i-1] + up[i-2])%1000000007;
    }
    
    if (M==0) {
        cout << up[N+1]%1000000007 << endl;
        return 0;
    }
    vector<int> A(M);
    rep(i, M) {
        int a;
        cin >> a;
        A[i] = a;
    }
    rep(i, M) {
        if (i == 0) {
            ans *= up[A[i]];
            ans %= 1000000007;
            continue;
        }
        ans *= up[A[i]-A[i-1]-1];
        ans %= 1000000007;
    }
    ans *= up[N-A[M-1]];
    ans %= 1000000007;
    cout << ans << endl;
}

Measured memory_bytes: 1408
import sys

N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7


def main():
    _ = int(sys.stdin.readline().rstrip())
    Arr = [int(x) for x in sys.stdin.readline().rstrip().split()]

    K = 43

    #
    A = Arr[0]
    B = Arr[1]

    S = A + B
    X = 0
    for i in range(2, len(Arr)):
        X ^= Arr[i]

    # print(S, X)

    # 次を満たすa, b が見つかるか？
    #  a+b=S, a^b=X, a<=A

    # 桁DP : 桁を一つずつ決めていくようなDP
    # dp[今の桁数 = 0:42][繰り上がりがあるか = 0,1][今までがA以下かどうか 0=以下、1=より大きい] = 最大値
    # 値は最大値。満たすものがなければ -1
    dp = [[[-1 for x in [0, 1]] for _ in [0, 1]] for _ in range(K)]

    dp[0][0][0] = 0  # 最初

    v = 1
    for i in range(K - 1):  # 桁数
        cx = X & 1  # current X
        cs = S & 1  # current S
        ca = A & 1  # current A
        for j in range(2):  # 繰り上がりある／ない
            for k in range(2):  # 今までの範囲が A 以下かどうか
                if dp[i][j][k] == -1:  #
                    continue

                for na in range(2):
                    for nb in range(2):
                        ni = i + 1
                        nj = 0
                        nk = k
                        if na ^ nb != cx:  # a ^ b = A か？
                            continue

                        ns = na + nb + j
                        if ns % 2 != cs:  # a + b = S か？
                            continue

                        # ここで遷移は確定

                        if ns >= 2:  # 繰り上がり処理
                            nj = 1

                        if ca < na:
                            nk = 1
                        elif ca == na:
                            nk = k
                        else:
                            nk = 0

                        dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | (v * na))

        X >>= 1
        S >>= 1
        A >>= 1
        v <<= 1
        # print(v)

    a = dp[K - 1][0][0]
    if a == -1 or a == 0:
        print(-1)
    else:
        print(Arr[0] - a)


main()

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int p, q, r, m;
int main() {
    cin >> p >> q >> r;
    m = max(max(p, q), r);
    cout << p + q + r - m << endl;
    return 0;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    double x=0;
    rep(i,n){
        x+=a[i];
    }
    x/=n;
    double y=101;
    ll ans=0;
    rep(i,n){
        if(y>abs(a[i]-x)){
            y=abs(a[i]-x);
            ans=i;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repe(i, n) REPN(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n--;
	ll diff = abs(b-a);

	rep(i, n+1){
        ll a1 = i * c;
        ll a2 = i * d;
        ll b1 = -(n - i) * d;
        ll b2 = -(n - i) * c;
        if (a1 + b1 <= diff && diff <= a2 + b2) {
			puts("YES");
            return 0;
        }
	}

	puts("NO");
	return 0;
}


Measured memory_bytes: 256
import sys
S = input()
T = input()
N = len(S)

for i in range (1,N+1):
  S1 = S
  x = S1[N-1-(i-1):N]
  S2 = x + S1
  S2 = S2[:-i]
  if S2 == T:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long a, b, k;
	std::cin >> k;
	std::cin >> a >> b;

	for (long long i = a; i <= b; i++)
	{
		if (i % k == 0) {
			std::cout << "OK" << std::endl;
			return 0;
		}
	}

	std::cout << "NG" << std::endl;

	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String[] input = sc.nextLine().split(" ");
        int h = Integer.parseInt(input[0]);
        int n = Integer.parseInt(input[1]);

        int attack = 0;
        String[] skills = sc.nextLine().split(" ");
        for (String skill : skills) {
            attack += Integer.parseInt(skill);
        }

        System.out.println(h > attack ? "No" : "Yes");
    }
}

Measured memory_bytes: 46244
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }
signed main() {
    string s;
    cin >> s;
    vector<vector<int>> two(s.size(), vector<int>(335));
    REP(i, s.size()) {
        if (s[i] == 'R') {
            two[i][0] = i + 1;
        } else {
            two[i][0] = i - 1;
        }
    }
    vector<int> ans(s.size());
    for (int j = 1; j < 20; j++) {
        REP(i, s.size()) { two[i][j] = two[two[i][j - 1]][j - 1]; }
    }
    REP(i, s.size()) { ans[two[i][19]]++; }
    REP(i, s.size()) { cout << ans[i] << " "; }
}

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

using namespace std;

int n, m, cnt;

char ch;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> ch;
            cnt += ch == '#';
        }
    }
    cout << (cnt == (n + m - 1) ? "Possible" : "Impossible");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> Pi;
struct Q{
	long val;
	int a,b,c;
};
bool operator<(const Q &l,const Q &r){
	return l.val<r.val;
}

int main(){
	int x,y,z,k;
	cin >> x >> y >> z >> k;
	vector<long> e[3];
	for(int i=0;i<x;i++){
		long d;
		cin >> d;
		e[0].push_back(d);
	}
	for(int i=0;i<y;i++){
		long d;
		cin >> d;
		e[1].push_back(d);
	}
	for(int i=0;i<z;i++){
		long d;
		cin >> d;
		e[2].push_back(d);
	}
	for(int i=0;i<3;i++){
		sort(e[i].begin(),e[i].end());
		reverse(e[i].begin(),e[i].end());
	}
	priority_queue<Q> que;
	que.push(Q{e[0][0]+e[1][0]+e[2][0],0,0,0});
	vector<long> ans;
	map<Pi,int> m;
	m[Pi(P(0,0),0)]++;
	while(ans.size()<k){
		Q q=que.top();que.pop();
		ans.push_back(q.val);
		int h=q.a,i=q.b,j=q.c;
		if(h+1<x && m[Pi(P(h+1,i),j)]==0){
			que.push(Q{e[0][h+1]+e[1][i]+e[2][j],h+1,i,j});
			m[Pi(P(h+1,i),j)]++;
		}
		if(i+1<y && m[Pi(P(h,i+1),j)]==0){
			que.push(Q{e[0][h]+e[1][i+1]+e[2][j],h,i+1,j});
			m[Pi(P(h,i+1),j)]++;
		}
		if(j+1<z && m[Pi(P(h,i),j+1)]==0){
			que.push(Q{e[0][h]+e[1][i]+e[2][j+1],h,i,j+1});
			m[Pi(P(h,i),j+1)]++;
		}
	}
	for(long g:ans) cout << g << endl;
	return 0;
}


Measured memory_bytes: 896
n = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(1, n-1):
  if (p[i-1] < p[i] < p[i+1]) or (p[i-1] > p[i] > p[i+1]):
    c += 1
    
print(c)

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;
const int INF=10000000LL;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> Pa;
int N,H,ans=0,ma=0;
int a[100000],b[100000];
P C[35][35];
int main(){
	cin>>N>>H;
	for(int i=0;i<N;++i){
		cin>>a[i]>>b[i];
		ma=max(ma,a[i]);
	}
	sort(b,b+N,greater<int>());
	for(int i=0;i<N;++i){
//		cout<<b[i]<<endl;
		if(b[i]>ma){
			H-=b[i];
			ans++;
			if(H<=0)break;
		}
	}
	if(H>0){
		ans+=H/ma;
		if(H%ma>0)++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N,A,B;
    cin>>N>>A>>B;
 
    vector<char>S(N);
    int X=A+B;
    int Y=0;
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    for(int i=0;i<N;i++){
        if(S[i]=='c'){
            cout<<"No"<<endl;
        }
        else if(S[i]=='a'){
            X--;
            if(X>=0){
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
        else{
            Y++;
            if(X>0&&Y<=B){
                cout<<"Yes"<<endl;
                X--;
            }
            else{
                cout<<"No"<<endl;
            }
        }
    }   
}

Measured memory_bytes: 3724
// AOJ 0560 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0560)
#include<cstdio>
#include<string>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_M = 1000, MAX_N = 1000;
const std::string JOI = "JOI";

int M, N, K;
int S[3][MAX_M+2][MAX_N+2];

int main()
{
	scanf( "%d%d%d", &M, &N, &K );
	rep( i, M )
	{
		getchar();

		rep( j, N )
			++S[JOI.find(getchar())][i+1][j+1];
	}

	rep( k, 3 ) rep( i, M ) rep( j, N )
		S[k][i+1][j+1] += S[k][i+1][j]+S[k][i][j+1]-S[k][i][j];

	rep( i, K )
	{
		int a, b, c, d;
		scanf( "%d%d%d%d", &a, &b, &c, &d );
		--a; --b;

		rep( k, 3 )
			printf( "%d%c", S[k][c][d]-S[k][c][b]-S[k][a][d]+S[k][a][b], k==2?'\n':' ' );
	}

	return 0;
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

ll n, s;
constexpr ll f(ll b, ll n) {
	ll ans = 0;
	while (n != 0) {
		ans += n % b;
		n /= b;
	}

	return ans;
}

int main()
{
	std::cin >> n >> s;

	ll ans = -1;
	if (s == n)
		ans = n + 1;
	else {

		auto t = std::abs(n - s);
		ans = inf;
		for (int i = 1, end = std::sqrt(n); i <= end; ++i) {
			if (t%i == 0)
			{
				if (f(i + 1, n) == s)
				{
					ans = i + 1;
					break;
				}
				if (f((t / i) + 1, n) == s)
					ans = std::min(ans, (t / i) + 1);
			}
		}
	}

	if (ans == inf)
		std::cout << -1 << std::endl;
	else
		std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,n,tl,c[101],t[101],mc,ni;
	mc=-1;
	ni=0;
	scanf("%d %d",&n,&tl);
	for(i=0;i<n;i++){
		scanf("%d %d",&c[i],&t[i]);
		if(t[i]<=tl){
			if(mc==-1){
				mc=c[i];
				ni=i;
			}
			else if(c[i]<mc){
				mc=c[i];
				ni=i;
			}
		}
	}
	
	if(mc==-1)
	printf("TLE");
	else
	printf("%d",mc);
	return 0;
}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=2e5+1, M=(ll)1e9+1 ;
const int mod = 1e9+7 ;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// ll g[N][N],keep[N*N];
vl g[N],a(N),gc(N),dist(N,1),vis(N,0);

// ll solve(ll l,ll r){
//   if(l==r)
//     return l;
//   ll n1=solve(l,(l+r)/2);
//   ll n2=solve((l+r)/2 +1,r);
//   if(g[n1][n2]>0){
//     keep[g[n1][n2]]=true;
//     return n1;
//   }
//   else{
//     keep[g[n2][n1]]=true;
//     return n2;
//   }
  
// }
ll mul(ll &a,ll b){
  a=(a*b)%mod;
  
  // cout << a << " " << b << endl;
  return a;
}
  
int main(){
 ios_base::sync_with_stdio(0);
  ll n,m;
  cin >> n >> m;
  vl a(n),b(m);
  ll i;
  for(i=0;i<n;i++)  
    cin >> a[i];
  for(i=0;i<m;i++)
    cin >> b[i];
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  ll x=n*m,at=0,bt=0,ans=1;
  a.pb(-1);
  b.pb(-1);
  while(x>0){
    if(a[at]==b[bt] && x==a[at]){
      at++;
      bt++;
    }
    else if(a[at]==x){
      at++;
      mul(ans,bt);
    }
    else if(b[bt]==x){
      bt++;
      mul(ans,at);
    }
    else{
      mul(ans,bt*at-(n*m)+x);
    }
    x--;
  }
  if(!ans){
    cout << 0;
    return 0;
  }
  cout << ans;
    return 0;
}

Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> b(n-1);
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(0==i){
            sum+=b[i];
            continue;
        } 
        if(n-1==i){
            sum+=b[i-1];
            continue;
        }
        sum+=min(b[i],b[i-1]);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= printRes . solve 
    where
        printRes (xs, ys) = mapM_ putStrLn $ (unwords $ map show xs) : ys

solve :: [Int] -> ([Int], [String])
solve [a, b] = ([length ws + length bs, 100], ws ++ reverse bs)
    where
        ws = buildW 
        bs = buildB 

        buildW 
            | m == 0 = take (2 * r - 2) (cycle fills) ++ opens 50
            | otherwise = take (2 * r) (cycle fills) ++ opens m
            where
                (r, m) = a `divMod` 50
                fills = [take 100 $ cycle "#.", replicate 100 '#']
                opens n = ['#' : take 99 xs, '#' : take 99 ys]
                    where
                        (xs, ys) = buildOW n
                buildOW n 
                    | n == 1 = (repeat '.', repeat '.')
                    | otherwise = ('.' : '#' : xs, '#' : '#' : ys)
                    where
                        (xs, ys) = buildOW $ n - 1
        buildB
            | m == 0 = take (2 * r - 2) (cycle fills) ++ opens 50
            | otherwise = take (2 * r) (cycle fills) ++ opens m
            where
                (r, m) = b `divMod` 50
                fills = [take 100 $ cycle "#.", replicate 100 '.']
                opens n = [reverse $ '.' : take 99 xs, reverse $ '.' : take 99 ys]
                    where
                        (xs, ys) = buildOB n 
                buildOB n
                    | n == 1 = (repeat '#', repeat '#')
                    | otherwise = ('#' : '.' : xs, '.' : '.' : ys)
                    where
                        (xs, ys) = buildOB $ n - 1




readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
n, m, q = map(int, input().split())

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i], b[i] = a[i] - 1, b[i] - 1

ans = 0

def calc(x):
    global ans
    score = 0
    for i in range(q):
        if x[b[i]] - x[a[i]] == c[i]:
            score += d[i]
    ans = max(ans, score)

def dfs(x):
    if len(x) == n:
        calc(x)
        return

    for i in range(x[-1], m+1):
        x.append(i)
        dfs(x)
        x.pop()

dfs([1])
print(ans)


Measured memory_bytes: 78828
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
typedef pair<int, pair<int, int> > PPII;
typedef pair<int, int> PII;
static const int INF = 1ll<<60;


int N;
PII Start,End;
vector<PPII> V;
double d[1005];

void dijkstra(){
    fill(d,d+1005,INF);
    priority_queue<PII,vector<PII>,greater<PII> > que;
    que.push(PII(0,0));
    d[0]=0;
    while(!que.empty()){
        PII p=que.top();
        que.pop();
        int v=p.SE;
        //cout<<v<<endl;
        if(d[v]<p.FI)continue;
        for(int i=0;i<V.size();++i){
            double di=sqrt(abs(V[v].FI-V[i].FI)*abs(V[v].FI-V[i].FI)+abs(V[v].SE.FI-V[i].SE.FI)*abs(V[v].SE.FI-V[i].SE.FI));
            double cost=max(di-(V[i].SE.SE+V[v].SE.SE),0.0);
            if(d[i]>d[v]+cost){
                d[i]=d[v]+cost;
                que.push(PII(d[i],i));
            }
        }
    }
}

signed main(){
    cin>>Start.FI>>Start.SE>>End.FI>>End.SE;
    V.PB(PPII(Start.FI,MP(Start.SE,0)));
    V.PB(PPII(End.FI,MP(End.SE,0)));
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y,r;
        cin>>x>>y>>r;
        V.PB(PPII(x,MP(y,r)));
    }
    dijkstra();
    printf("%.10lf\n",d[1]);
    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	string s, t;
	cin >> s >> t;
	ll s_size = s.length();
	ll t_size = t.length();

	vector<int> bin[26] = {};
	for(int i = 0; i < s_size; ++i)
	{
		bin[ s[i] - 'a' ].emplace_back(i);
	}

	for(int i = 0; i < t_size; ++i)
	{
		if (bin[ t[i] - 'a' ].empty())
		{
			cout << "-1";
			return;
		}
	}

	vector<int> t_num(t_size, -1);
	
	t_num[0] = bin[ t[0] - 'a' ][0];
	for(int i = 1; i < t_size; ++i)
	{
		t_num[i] = bin[ t[i] - 'a' ][0];
		for(int j = 0; j < bin[ t[i] - 'a' ].size(); ++j)
		{
			if (bin[ t[i] - 'a' ][j] > t_num[i - 1])
			{
				t_num[i] = bin[ t[i] - 'a' ][j];
				break;
			}
		}
	}

	ll ans = 0;
	//cout << t_num[0];
	for(int i = 1; i < t_size; ++i)
	{
		//cout << " " << t_num[i];
		if (t_num[i - 1] >= t_num[i])
		{
			ans += s_size;
		}
	}
	//cout << endl;
	cout << ans + t_num.back() + 1;
	return;

}

int main()
{
	fastio;
	solve();

	return 0;
}

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

std::vector<int> a(1000);
int main() {
    int i, n;
    while(std::cin >> n, n != 0) {
        for(i=0; i<n; ++i) {
            std::cin >> a[i];
        }
        std::sort(a.begin(), a.begin()+n);
        
        int min = INT_MAX;
        for(i=0; i<n-1; ++i) {
            min = std::min(min, a[i+1] - a[i]);
        }
        std::cout << min << std::endl;
    }
}


Measured memory_bytes: 3164
#!/usr/bin/env python3
import sys
import heapq
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.V = list(range(N))
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")
            pass

        s, t, w = edge
        self.E[s].append([t, w])

        pass


def shortestPath(g: Graph, s: int):
    """ グラフgにおいて、始点sから各頂点への最短路を求める
    引数
    g: グラフ, s: 始点
    返り値
    dist: 始点からの距離が格納されたリスト
    prev: 始点から最短経路で移動する場合、各頂点に至る前の頂点のリスト
    """
    dist = [INF]*g.N
    dist[s] = 0

    prev = [None]*g.N
    Q = []
    heapq.heappush(Q, (dist[s], s))

    while len(Q) > 0:
        _, u = heapq.heappop(Q)
        for v, w in g.E[u]:
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                prev[v] = u
                heapq.heappush(Q, (dist[v], v))
    return dist, prev


def solve(K: int):
    g = Graph(K)
    for i in range(1, K):
        # 1を加える
        g.add_edge([i, (i+1) % K, 1])
        # 10倍する
        g.add_edge([i, (10*i) % K, 0])
    dist, prev = shortestPath(g, 1)
    print(dist[0]+1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()


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

int main () {
  int s;
  cin >> s;
  
  int count=0,a=s/100,b=(s-a*100)/10,c=s-a*100-b*10;
  vector<int> data = {a,b,c};
  for (int x : data) {
    if (x == 1) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int MAXN=2005;

int n,k,q;

int solve(int x,vi a)
{
    vector<int> adj;
    vector<int> vc;
    for(int i=0;i<n;++i)
    {
        int j=i;
        while(j<n&&a[j]>=x) adj.push_back(a[j]), ++j;
        if(adj.size()>=k)
        {
            sort(adj.begin(),adj.end());
            //reverse(adj.begin(),adj.end());
            for(int _=0;_<(adj.size()-k+1);++_)
                vc.push_back(adj[_]);
        } 
        adj.clear();
        i=j;
    }
    //dbg(vc);
    sort(vc.begin(),vc.end());
   // dbg(vc);
    //dbg(vc.size(),q);
    if(vc.size()>=q)
    {
        ///dbg(vc[q-1],x);
        return vc[q-1]-x;
    }
    else return INF;

}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k>>q;
    vi a(n),b(n);
    for(int i=0;i<n;++i) cin>>a[i],b[i]=a[i];
    sort(b.begin(),b.end());
    int ans=INF;
    for(int i=0;i<n;++i)
        ans=min(ans,solve(b[i],a));
    cout<<ans<<endl;
}

Measured memory_bytes: 3700
#include <stdio.h>

int main() {
	int a,b,i;
	int x[4]={1,0,0,0};
	scanf("%d",&a);
	scanf("%d",&b);
	x[a]=1;
	x[b]=1;
	for(i=1;i<=3;i++) {
		if(x[i]== 0) {
			printf("%d",i);
          	return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int r;
    scanf("%d", &r);
    double ans = (double)r * 2 * 3.141592653589;
    printf("%.10lf\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >> m;
    int k[n];
    int ct[m+1];
    for(int i=1;i<m+1;i++){
        ct[i]=0;
    }
    for(int i=0;i<n;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            int aa;
            cin >> aa;
            ct[aa]++;
        }
    }
    int cta=0;
    for(int i=1;i<m+1;i++){
        if(ct[i]==n){
            cta++;
        }
    }
    cout << cta << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int N, K;
    
    cin >> N >> K;

    vector<int> H;
    
    int h;
    for (int i = 0; i < N; i++){
        cin >> h;
        H.push_back(h);
    }

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

    long cnt = 0;
    for (int i = 0; i < N - K; i++){
        cnt += H[i];
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 1400
import sys

N,M=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[x[i+1]-x[i] for i in range(M-1)]
a.sort()

if N>=M:
    print(0)
    sys.exit()
    
print(sum(a[:M-N]))

Measured memory_bytes: 13960
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

N = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

l=[0]*N
ans=0
for a in A:
    ans+=l[a-1]
    l[a-1]+=1


for i in range(N):
    a=A[i]-1
    print(ans-(l[a]-1))


Measured memory_bytes: 77196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

struct dice{
    ll x, y, z;
};

dice roll(dice d, ll dir){
    ll x = d.x, y = d.y, z = d.z;
    if(dir == 0) d.x = y, d.y = 7 - x;
    if(dir == 1) d.x = z, d.z = 7 - x;
    if(dir == 2) d.x = 7 - y, d.y = x;
    if(dir == 3) d.x = 7 - z, d.z = x;
    return d;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H, W;
    cin >> H >> W;
    int s[105][105];
    rep(i, H + 2) rep(j, W + 2) if(i == 0 || j == 0 || i == H + 1 || j == W + 1) s[i][j] = -1;

    rep1(i,H){
        string S;
        cin >> S;
        rep1(j, len(S)){
            if(S[j - 1] == '#') s[i][j] = -1;
            else s[i][j] = S[j - 1] - '0';
        }
    }

    stack<pair<P,dice>> sk;
    sk.push({{1, 1},{6,2,3}});

    while(!sk.empty()){
        ll h = sk.top().first.first, w = sk.top().first.second;
        dice d = sk.top().second;
        sk.pop();
        if(s[h][w] != d.x) continue;
        if (h == H && w == W){
            print("YES");
            return 0;
        }

        sk.push({{h + 1, w}, roll(d, 0)});
        sk.push({{h, w + 1}, roll(d, 1)});
        sk.push({{h - 1, w}, roll(d, 2)});
        sk.push({{h, w - 1}, roll(d, 3)});

        s[h][w] = -1;
    }

    print("NO");

    return 0;
}


Measured memory_bytes: 3456
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
    ans += A[0] - x
    A[0] = x

for i in range(1, N):
    if A[i]+A[i-1] > x:
        ans += A[i]+A[i-1]-x
        A[i] -= A[i]+A[i-1]-x

print(ans)


Measured memory_bytes: 20128
def euk(a,b):
    if b==0:
        return a
    else:
        return euk(b, a%b)

def f(A,B,K):
  k=0
  for m in range(euk(A,B), 0, -1):
    if A%m == 0 and B%m == 0:
      k+=1
    if k==K:
      return m

A,B,K = map(int, input().split())
print(f(A,B,K))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] pArray = new int[n];
        for (int i = 0; i < n; i++) {
            pArray[i] = scanner.nextInt();
        }

        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            if (pArray[i] > pArray[i - 1]) {
                if (pArray[i + 1] == pArray[i - 1]
                        || pArray[i] <= pArray[i + 1]) {
                    count++;
                }
            } else {
                if (pArray[i] > pArray[i + 1]) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844