akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD=1000000007;


#define SIZE 114514

int main(){
	int n;
	cin>>n;
	ll ans=0;
	ll x;
	vector<ll> hoge;
	for(int i=0;i<n;i++){
		cin>>x;
		hoge.pb(x);
	}
	bool flag=false;
	vi fuga;
	for(int i=0;i<n;i++){
		if(hoge[i]%2==1)fuga.pb(1);
		else if(hoge[i]>0)fuga.pb(2);
		else fuga.pb(0);
		ans=ans+(hoge[i])/2;
	}
	fuga.pb(0);
	/*rep(i,n)cout<<fuga[i]<<" ";
	cout<<endl;*/
	int j=0;
	while(j<n){
		if(fuga[j]==1){
			j++;
			while(fuga[j]==2)j++;
			if(fuga[j]==1){
				ans++;
			}
		}
		j++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2544
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] arr = new int[n];

        for(int i = 0  ; i < n ; i++)
            arr[i] = s.nextInt();

        Arrays.sort(arr);

        long sum = arr[n-1];
        int j = n-2, x = 0;
        for(int i = n-3 ; i >= 0 ; i--, x++){
            if(x == 2){
                j--;
                x = 0;
            }
            sum += arr[j];
        }

        System.out.println(sum);
    }
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<int>> dist(N + 5, vector<int>(N + 5, INF));
  for (int i = 0; i <= N; ++i) {
    dist[i][i] = 0;
  }

  vector<int> A(M), B(M), C(M);
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    dist[a][b] = dist[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }

  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  int ans = M;
  for (int i = 0; i < M; ++i) {
    int u = A[i], v = B[i];
    for (int s = 1; s <= N; ++s) {
      if (dist[s][v] == dist[s][u] + C[i]) {
        --ans;
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[301][100001];
 
signed main() {
    int N, M, K; cin >> N >> M >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
        dp[1][i] = A[i];
    }

    for(int k=1; k<K; k++) {
        deque< pair<int, int> > deq;
        deq.push_back(make_pair(0, -1));
        for(int i=k-1; i<N; i++) {
            // dp[k-1][i-1] から dp[k-1][i-M] までを見る
            int num = k + 1;
            
            int prev_max = deq.front().first;
            dp[k+1][i] = prev_max + A[i] * num;
            // printf("dp[%lld][%lld], assign = %lld\n", k+1, i+1, prev_max);

            int lb = i-M+1, val = dp[k][i];
            while(deq.size() && deq.back().first <= val) deq.pop_back();

            pair<int, int> elem = make_pair(val, i);
            deq.push_back(elem);
            while(deq.size() && deq.front().second < lb) deq.pop_front();
        }
    }
    cout << *max_element(dp[K], dp[K]+N) << endl;
    return 0;
}

Measured memory_bytes: 235392
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id
let ls = scan_lines n "%s" id

let () =
  let h = Hashtbl.create n in
  ListL.iter ls ~f:(fun s ->
      Hashtbl.modify_def 1 s id h);
  Hashtbl.length h
  |> Printf.printf "%d\n"


Measured memory_bytes: 26876
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	if (2*(a * a * b - x) / (a * a) <= b) {
		std::cout<<std::setprecision(7) << atan((2 * (a * a * b - x)) / (a * a * a)) * 180.0000000 / 3.1415926589 << endl;
	}
	else {
		std::cout << std::setprecision(7) << atan(b * b * a / (2 * x)) * 180.000000 / 3.1415926589 << endl;
	}
}


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

using namespace std;

typedef long long int ll;

const ll MAXN = 1e5 + 5;

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

  ll n;
  cin >> n;
  vector < ll > a(n), cnt(n + 1, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    if(cnt[i] >= 2) ans += (((cnt[i] - 1) * cnt[i]) / 2);
  }

  for(int i = 0; i < n; i++){
    if(cnt[a[i]] >= 2) cout << ans + 1 - cnt[a[i]] << endl;
    else cout << ans << endl;
  }
  cout << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define oo int(1e9)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long ll;
typedef double db;
const ll MOD = (ll)(1e9) + 7;
int n;
vector<db> p;
vector<vector<db>> dp;

int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
    cin >> n;
    p.resize(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    
    dp.resize(n + 1,vector<db> (n + 1));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) dp[i][0] = dp[i - 1][0]*(1 - p[i - 1]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= i; j++)
            dp[i][j] = dp[i - 1][j - 1]*p[i - 1] + dp[i - 1][j]*(1 - p[i - 1]);
    
    db ans = 0;
    for (int i = n; i > n/2; i--) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 70784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int N;
    int Nsub;
    int rank = 0;
    int ans = 0;

    cin >> N;

    Nsub = N;
    for(int i = 0; i < 7; i++){
        if(Nsub / 10 == 0){
            rank = i+1;
            break;
        }
        Nsub = Nsub / 10;
    }
    
    for(int i = 1; i < rank; i = i + 2){
        ans += 9 * (int)pow(10.0, (double)(i - 1));
    }

    if(rank % 2 == 1){
        ans += N - (int)pow(10.0, (double)(rank - 1)) + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
long long ans=0;
int n;
struct Node{
    int a[5];
    Node(int i,int j,int k,int l){
        a[0]=i,a[1]=j,a[2]=k,a[3]=l;
    }
    Node(){}
    int &operator[](const int &x){return a[x];}
    bool operator<(const Node &b)const{
        if(a[0]!=b.a[0])return a[0]<b.a[0];
        else if(a[1]!=b.a[1])return a[1]<b.a[1];
        else if(a[2]!=b.a[2])return a[2]<b.a[2];
        else return a[3]<b.a[3];
    }
}col[405];
map<Node,int> cnt;
 
void add(Node x,int k){
    cnt[Node(x[0],x[1],x[2],x[3])]+=k;
    cnt[Node(x[1],x[2],x[3],x[0])]+=k;
    cnt[Node(x[2],x[3],x[0],x[1])]+=k;
    cnt[Node(x[3],x[0],x[1],x[2])]+=k;
}
  
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d",&col[i][0],&col[i][1],&col[i][2],&col[i][3]);
        add(col[i],1);
    }
    for(int i=1;i<=n-1;i++){
        add(col[i],-1);
        for(int j=i+1;j<=n;j++){
            add(col[j],-1);
            for(int k=0;k<4;k++){
                Node num[5];
                for(int l=0;l<4;l++)
                    num[l]=Node(col[i][l],col[j][k+5-l&3],col[j][k+4-l&3],col[i][l+1&3]);
                if(!cnt[num[0]]||!cnt[num[1]]||!cnt[num[2]]||!cnt[num[3]])continue;
                long long tmp=1;
                for(int l=0;l<4;l++)tmp*=cnt[num[l]],add(num[l],-1);
                for(int l=0;l<4;l++)add(num[l],1);
                ans+=tmp;
            }
            add(col[j],1);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 20352
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int Q;
  cin >> Q;
  int N = 100000;

  vector<int> vec(N+1,1),num(N+1,0);
  vec.at(0) = 0;
  vec.at(1) = 0;
  for(int i = 2;i <= sqrt(N);i++) {
    for(int j = i+1;j <= N;j++) {
      if(j % i == 0) vec.at(j) = 0;
    }
  }

  for(int i = 2;i <= N;i++) {
    if(vec.at(i) && vec.at((i+1)/2)) num.at(i) = 1;
  }

  for(int i = 1;i <= N;i++) {
    num.at(i) += num.at(i-1);
  }

  for(int i = 0;i < Q;i++) {
    int l,r;
    cin >> l >> r;
    cout << num.at(r) - num.at(l-1) << endl;
  }



}



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

int main() {
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < S.size()-1; i++) {
    if (S.at(i) != S.at(i+1)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y>>s,x){
		int ma = 0;
		for(int i = 1;i < s;i++){
			for(int j = i;j < s;j++){
				if(i*(100+x)/100 + j*(100+x)/100 != s)continue;
				int p = i*(100+y)/100 + j*(100+y)/100;
				ma = max(p,ma);
			}
		}
		cout<<ma<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL X;

int main(void) {
    cin >> X;

    int cnt = 0;
    LL cur = 100;
    while (cur < X) {
        cur += cur * 0.01;
        cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef long long ll;

ll l, r, i, mn = 1e9;
int main()
{
    cin >> l >> r;
    if(l % 2019 == 0 || l / 2019 != r/ 2019){
        cout << 0;
        return 0;
    }
    for(ll i = l; i < min(l + 2018, r); i++){
        for(ll j = i + 1; j <= min(l + 2018, r); j++){
            mn = min(mn, i * j % 2019);
        }
    }
    cout << mn << endl;
    return 0;

}


Measured memory_bytes: 256
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

mod = 1000000007

"""
# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    A, B = map(int, sys.stdin.readline().split())
    print(A * B - (A + B) + 1)


Measured memory_bytes: 5100
L, R = [int(item) for item in input().split()]
l, ml = divmod(L, 2019)
r, mr = divmod(R, 2019)
if (l==r):
  m = 2019
  for i in range(ml, mr+1):
    for j in range(i+1, mr+1):
      m = min(m, (i*j)%2019)
  print(m)
else:
  print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   string s;cin>>s;
   int n = s.size()-2;
   cout<<s[0]<<n<<s[n+1];
}



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

using ll = long long;
ll dp[101][100010];
void solve() {
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];
    REP(i, N) {
        REP(j, W + 1) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }
    ll ans = 0;
    REP(j, W + 1) ans = max(ans, dp[N][j]);
    cout << ans << endl;
}

signed main() { solve(); }


Measured memory_bytes: 78336
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int X;

	cin >> X;

	int result = 0;

	if (400 <= X && X <= 599) {
		result = 8;
	}
	else if (600 <= X && X <= 799) {
		result = 7;
	}
	else if (800 <= X && X <= 999) {
		result = 6;
	}
	else if (1000 <= X && X <= 1199) {
		result = 5;
	}
	else if (1200 <= X && X <= 1399) {
		result = 4;
	}
	else if (1400 <= X && X <= 1599) {
		result = 3;
	}
	else if (1600 <= X && X <= 1799) {
		result = 2;
	}
	else if (1800 <= X && X <= 1999) {
		result = 1;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
int main(){
 long long int n,sum=0;
  cin>>n;
  long long int k[n*3];
  for(int i=0;i<n*3;i++){
    cin>>k[i];
  }
  sort(k,k+3*n);
  reverse(k,k+3*n);
  for(int i=1;i<2*n;i+=2){
    sum+=k[i];
  }
  cout<<sum<<endl;
}

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


int main()
{
    int n,k;
    scanf("%d%d",&n,&k);

    vector<long long> arr(n);
    vector<long long > distance(n,INT_MAX);

    for(int i = 0; i < n; i++)
        cin >> arr[i];


    distance[0] = 0ll;

    for(int i = 0; i < n; i++)
    {
        int j = 1;
        while(j <= k)
        {
            if(i + j < n)
            {
                distance[i + j] = min(distance[i+j], distance[i] + abs(arr[i+j] - arr[i]));
            }
            else
                break;
            j++;
        }
    }

    cout <<  distance[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,a[666666]={};
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout); 
	cin>>n;
	for(int i=1;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<n;i++) cout<<a[i]<<endl;
	cout<<a[n]; 
	return 0;
}

Measured memory_bytes: 4352
import sys
from itertools import accumulate
from bisect import bisect
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    ac = [0] + list(accumulate(A))

    def calc(lst): return abs(max(lst) - min(lst))
    def sm(l,r): return ac[r+1] - ac[l]
    def get_min_max(l,r):
        if r-l <= 1: return [A[l], A[r]]
        med = ac[l] + sm(l,r) / 2
        i = bisect(ac, med, l+1, r+1)
        r1 = [sm(l,i-1), sm(i,r)]
        if i-1 == l: return r1
        r2 = [sm(l,i-2), sm(i-1,r)]
        return r1 if calc(r1) < calc(r2) else r2

    ans = 10**18
    for R_left in range(2,N-1):
        PQ_mm = get_min_max(0, R_left-1)
        RS_mm = get_min_max(R_left, N-1)
        ans = min(ans, calc(PQ_mm + RS_mm))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 110488
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> c(n-1);
	vector<int> s(n-1);
	vector<int> f(n-1);
	for( int i = 0; i < n-1; ++i ){
		cin >> c[i] >> s[i] >> f[i];
	}
	for( int offset = 0; offset < n-1; ++offset ){
		int t = s[offset];
		for( int i = offset; i < n-1; ++i ){
			t += c[i];
			if( i == n-2 ) break;
			if( t <= s[i+1] ) t = s[i+1];
			else if( t % f[i+1] != 0 ){
				t += f[i+1] - ( t % f[i+1] );
			}
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    string S;
    cin >> S;
    long Q;
    cin >> Q;
    long T, F;
    string C;
    long reverse_count = 0;
    string head, tail;

    for(size_t i=0;i<Q;i++)
    {
        cin >> T;

        if(T == 1) reverse_count++;
        else
        {
            //cerr << "反転" << reverse_count << endl;
            cin >> F >> C;
            //反転状態の場合は逆になる
            if(reverse_count % 2 == 0)
            {
                if(F == 1) head= C + head;
                else tail+=C;
            }else
            {
                if(F == 2) head=C + head;
                else tail+=C;
            }
        }
        //cerr << S << endl;
    }
    S = head + S + tail;
    if(reverse_count % 2 != 0)
    {
        //cerr << "最後に反転" << endl;
        reverse(S.begin(), S.end());
    }
    cout << S << endl;
    return 0;
}

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

int main(void){
    int A;
    int B;
    int sumA;
    int flag = 0;
//    char *heap;

    scanf("%d",&A);
    scanf("%d",&B);

    for(int i=1;i<=1000;i++){
        if(i*8/100 == A && i*10/100==B){
            sumA = i;
            flag = 1;
            break;
        }   
        if(flag == 0 && i==1000){
            sumA = -1; 
        }   
    
    }   
    printf("%d\n",sumA);
 //   heap = (char *)malloc(N*sizeof(char));
 //  free(heap); 

    return 0;
}

Measured memory_bytes: 128
S = int(input())

x1, y1, x2, y2 = 0, 0, 10 **9, 1
y3 = S // (10 ** 9) + 1
x3 = y3 * (10 ** 9) - S
if S < 10 ** 18: print(x1, y1, x2 ,y2, x3, y3)
else: print(0, 0, 10 ** 9, 0, 0, 10 ** 9)

Measured memory_bytes: 3064
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False


n, a, b = map(int, input().split())
tables = [n] * 2
if is_even(a) and is_even(b):
    print(abs(a - b) // 2)
elif not is_even(a) and not is_even(b):
    print(abs(a - b) // 2)
else:
    print(min(abs(1 - a), abs(b - n)) + 1 + (b - a - 1) // 2)


Measured memory_bytes: 9060
N=int(input())
d=dict()
ans=0
for i in range(1,N+1):
  if not (str(i)[0],str(i)[-1]) in d:    
    d[(str(i)[0],str(i)[-1])]=1
  else:
    d[(str(i)[0],str(i)[-1])]+=1
for j in d:
  if (j[-1],j[0]) in d:
    ans+=d[j]*d[(j[-1],j[0])]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[100005];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	int flag = 1, mx;
	while (flag)
	{
		flag = 0;
		mx = 1;
		for (int i = 1; i < n; i++)
		{
			if (a[i] % a[i - 1])
			{
				a[i] %= a[i - 1];
				flag = 1;
			}
			if (a[i] % mx)
			{
				a[i] %= mx;
				flag = 1;
			}
			if (a[i] > mx)mx = a[i];
		}
		sort(a, a + n);
	}
	printf("%d\n", a[0]);
	return 0;
}

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

struct point {
   double x;
   double y;
   double z;
};

double dis(point a, point b){
   return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
}

//参考: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1106005#1

int main(){
   int n;
   while(cin>>n, n){
      point points[n];
      for(int i=0; i<n; i++){
         cin>>points[i].x>>points[i].y>>points[i].z;
      }

      point p = {0, 0, 0};
      double r = 1, max;
      int index;
      while(r>1e-10){   //1e-10が最小
         for(int i=0; i<50; i++){
            max = 0;
            index = 0;
            for(int j=0; j<n; j++){
               double dist = dis(p, points[j]);
               if(max < dist){
                  max = dist;
                  index = j;  //最大値をとるindexを記憶
               }
            }
            p.x += (points[index].x-p.x)*r;
            p.y += (points[index].y-p.y)*r;
            p.z += (points[index].z-p.z)*r;
         }
         r /= 2;
      }
      cout << fixed << setprecision(10) << dis(p, points[index]) << endl;;
   }
}



Measured memory_bytes: 3264
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);
    long s = long.Parse(input[2]);
    long[] answers = new long[n];
    long maxNum = 1000000000;

    for(int i = 0; i < k; i++)
    {
      answers[i] = s;
    }
    for(int i = k; i < n; i++)
    {
      if(s != maxNum) answers[i] = maxNum;
      else answers[i] = maxNum-1;
    }

    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 23516
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (lli)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

const int N=4e5+5;
lli fac[N+5],inv[N+5];

lli po(lli a,lli n)
{
    if(n==0)
        return 1;
    if(n%2)
        return (a*po(a,n-1))%mod;
    return po(a*a%mod,n/2);
}

lli nCr(lli n,lli r)
{
    if(n<0||r<0||r>n)
        return 0;
    lli ans=1;
    ans=(ans*fac[n])%mod;
    ans=(ans*inv[r])%mod;
    ans=(ans*inv[n-r])%mod;
    return ans;
}

void pre(lli n)
{
    lli i;
    fac[0]=1;
    repA(i,1,n)
        fac[i]=(i*fac[i-1])%mod;
    inv[n]=po(fac[n],mod-2);
    repD(i,n,1)
        inv[i-1]=(i*inv[i])%mod;
    assert(inv[0]==1);
}


int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{
    pre(N);
    cin>>n>>k;

    k=min(n-1,k);
    lli ans=0;

    for(lli i=0;i<=k;++i)
    {
        // dbg(n,i);
        ans+=nCr(n,i)*nCr(n-1,i)%mod;
    }

    ans%=mod;
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 6528
module Main where

import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import Data.Vector.Algorithms.Search

main :: IO ()
main = do
  x <- readLn :: IO Int
  let as = VU.enumFromN 1 x
  print $ VU.sum $ VU.map (\a -> (x - 1) `div` a) as


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

struct UnionFind{
    vector<int> parent,size;
    
    UnionFind(int n): parent(n,-1),size(n,1){}
    void init(int n){ 
        parent.assign(n,-1);
        size.assign(n,1);
        return;
    }

    int root(int x){
        if (parent[x]<0) return x;
        else return parent[x] = root(parent[x]);
    }

    bool same(int x, int y){
        return root(x)==root(y);
    }

    void unite(int x,int y){
        int gx = root(x);
        int gy = root(y);
        if (gx==gy) return;
        else{
            if(size[gx]<size[gy]){
                size[gy]+=size[gx];
                parent[gx]=gy;
            } else{
                size[gx]+=size[gy];
                parent[gy]=gx;
            }
        }
    }
    int get_size(int x){
        return size[root(x)];
    }    
};

int main(){
    int N,K,L;
    cin >> N >> K >> L;
    vector<pair<int,int> > road(K),rail(L);
    for (int i=0;i<K;i++){
        cin >> road[i].first >> road[i].second;
        road[i].first -= 1;
        road[i].second -= 1;
    }
    for (int i=0;i<L;i++){
        cin >> rail[i].first >> rail[i].second;
        rail[i].first -= 1;
        rail[i].second -= 1; 
    }
    UnionFind UF1(N),UF2(N);
    for (int i=0;i<K;i++){
        UF1.unite(road[i].first,road[i].second);
    }
    for (int i=0;i<L;i++){
        UF2.unite(rail[i].first,rail[i].second);
    }
    vector<pair<int,int> > a(N);
    map<pair<int,int> ,int> c;
    for (int i=0;i<N;i++){
        a[i] = make_pair(UF1.root(i),UF2.root(i));
    }
    for (int i=0;i<N;i++){
        if (c.find(a[i])==c.end()) c[a[i]] = 1;
        else{
            c[a[i]] += 1;
        }
    }
    for (int i=0;i<N;i++){
        cout << c[a[i]];
        if (i != N-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 18048
use std::io;
use std::cmp;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let (n, m, x) = {
        let i = read::<isize>();
        (i[0], i[1], i[2])
    };

    let a = read::<isize>();

    let mut cost_0 = 0;
    let mut cost_n = 0;

    for i in a {
        if i < x { cost_0 += 1; }
        else { cost_n += 1; }
    }

    println!("{}", cmp::min(cost_0, cost_n));
}

Measured memory_bytes: 4352
N=int(input())
net=[]
y=0
for i in range(0,N):
    a,b=map(int,input().split())
    y+=b
    net.append(a+b)

net.sort(reverse=True)

t=sum(net[i] for i in range(0,N) if i%2==0)
print(t-y)

Measured memory_bytes: 51160
/*input
10 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s, w; cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe");

    return 0;
}

Measured memory_bytes: 3640
n,m = gets.split.map(&:to_i)
ways = Array.new(n){[]}
m.times do 
  a,b = gets.split.map(&:to_i)
  ways[a-1] << b-1
  ways[b-1] << a-1
end

ways.each do |way|
  puts way.size
end

Measured memory_bytes: 1916
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  REP(i,S.size()){
    if(S[i]!=T[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3912
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if(a + b > a - b){
      if(a + b > a * b){
          cout << a + b << endl;
      }else{
          cout << a * b << endl;
      }
    }else{
        if(a - b > a * b){
            cout << a - b << endl;
        }else{
            cout << a * b << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		String input;
		StringBuilder output = new StringBuilder();
		int offset = 32;
		
		//データの入力
		Scanner sc = new Scanner(System.in);
		input = sc.nextLine();
		
		//文字列を1文字ずつ変換
		for (int i = 0; i < input.length(); i++){
			int temp = input.charAt(i);
			
			if (65 <= temp && temp <= 90){
				temp += offset;
			}else if (97 <= temp && temp <= 122){
				temp -= offset;
			}
			
			output.append((char)temp);
		}
		
		System.out.println(output.toString());
	}
}


Measured memory_bytes: 26012
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    r = 0
    total = 0
    xor = 0
    for l in range(N):
        while r < N and total+A[r] == xor ^ A[r]:
            total += A[r]
            xor ^= A[r]
            r += 1
        ans += r-l
        total -= A[l]
        xor ^= A[l]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 77772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (c-a?1:0) << "\n";
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
string a;
string ans[40005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin>>a;
    int i;
    int cnt=0;
    for (i=0;i<a.length();i++)
    {
        int j;
        for (j=1;j<6;j++)
        {
            ans[cnt++]=a.substr(i,j);
        }
    }
    sort(ans,ans+cnt);
    cnt=unique(ans,ans+cnt)-ans;
    int k;
    cin>>k;
    cout<<ans[k-1]<<endl;
    return 0;
} 


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn f(a: usize, b: usize) -> usize {
    max(a.to_string().len(), b.to_string().len())
}

fn main() {
    input!{
      n: usize,
    }
    let mut a = 0;
    let mut ans = n.to_string().len();
    while a*a <= n {
        a += 1;
        if n%a != 0 {
            continue;
        }
        let b = n/a;
        ans = min(ans, f(a, b));
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{

	int k,a,b,f=1;
	scf(k),scf(a),scf(b);

	rep(i,a,b+1)
	{
		if(i%k==0)
		{
			cout<<"OK\n";
			f=0;
			break;

		}
	}

	if(f)
	cout<<"NG\n";

}

Measured memory_bytes: 3688
a = []
b = []
N,H = map(int,input().split())
for i in range(N):
    ca,cb = map(int,input().split())
    a.append(ca)
    b.append(cb)
count = 0
ma = max(a)
b.sort(reverse = True)
def ans():
    global N,H,count
    for i in range(N):
        if b[i] < ma:
            break
        H -= b[i]
        count += 1
        if H <= 0:
            return count
    count += H//ma
    if H%ma != 0:
        count += 1
    return count
print(ans())

Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

int main()
{
	int N;
	long long res = 1;
	cin >> N;
	for (int i = 2; i <= N; i++) {
		bool flag = true;
		for (int j = 2; j < i; j++) {
			if (i % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			long long val = 0, cN = N;
			while (cN >= i) {
				val += cN / i;
				cN /= i;
			}
			res = res * (val + 1) % mod;
		}
	}
	cout << res << endl;
	return 0;
}


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

int main() {
	long long n,m,i,j,k,ans,cur,res,a,b1,b2,b3;
	double b;
	cin >> a >> b;
	b1=floor(b*100+0.1);
	ans=(a*b1)/100;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3840
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
  int n;
  string m = "YES";
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i = 0; i < n-1; i++){
    if(a.at(i)==a.at(i+1)){
      m = "NO";
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin>>a[i];
  for(int i=n-1;i>=0;--i) cout<<a[i]<<(i?" ":"\n");
}

Measured memory_bytes: 1196
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e6)

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==1) return m;
	ll ans=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) ans=(ans*m)%mod;
	return ans;
}

ll binom(ll n, ll k){
	ll a=1, b=1;
	for(ll i=0; i<k; i++){
		a=((a%mod)*((n-i)%mod))%mod;
		b=((b%mod)*((k-i)%mod))%mod;
	}
	return (a*pmod(b, mod-2))%mod;
}

ll find_mid(ll a[], double v, int b, int e){
	while(e-b>1){
		if((double)a[(b+e)/2]<v) b=(b+e)/2;
		else e=(b+e)/2;
	}
	if(abs((double)a[b]-v)<abs((double)a[e]-v)) return a[b];
	else return a[e];
}

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	cout << a[n-1] << " " << find_mid(a, a[n-1]/2.0, 0, n-2) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
  string c;
  cin >> c;
  if(c[0]=='a'||c[0]=='i'||c[0]=='u'||c[0]=='e'||c[0]=='o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

while(1){
  
  int H,W;
  
  scanf("%d %d",&H,&W);
  
  if(H==0){break;}
  
  for(int i=0; i<H; i++){
  for(int j=0; j<W; j++){
    printf("%c",'#');
    }
    printf("\n");
    }
    
    printf("\n");
   
}
   

}

Measured memory_bytes: 1160
N = int(input())

L = [[0,1]]
i = 1
while True:
	d = (-2) ** i
	if d < 0:
		L.append([L[-1][0]+d,L[-1][1]])
	else:
		L.append([L[-1][0],L[-1][1]+d])

	a,b = L[-1]
	if a <= N <= b:
		break

	i += 1
		
ans = []
tmp = N
for i in reversed(range(len(L))):
	if i == 0:
		if tmp == 1:
			ans.append("1")
		else:
			ans.append("0")
		break

	add = (-2) ** i
	a,b = L[i]
	c,d = L[i-1]
	if a == c:
		if d < tmp <= b:
			ans.append("1")
			tmp -= add
			continue
	elif b == d:
		if a <= tmp < c:
			ans.append("1")
			tmp -= add
			continue

	ans.append("0")

if ans[0] == "0":
	ans.pop(0)

print("".join(ans))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

    int a,b;
    int syo_int,amari_int;
    double syo_float;

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

    syo_int = (int)(a/b);
    amari_int = (int)(a%b);
    syo_float = ((double) a)/b;

    //output
    printf("%d %d %f\n", syo_int,amari_int,syo_float);

    return 0;

}

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

int main() {
    int x,y,z;
    cin>>x>>y>>z;
    int temp1,temp2;
    temp1=x; x=y;y=temp1;
    temp2=x;x=z;z=temp2;
    cout << x <<" " << y << " " << z;
    return 0;
}


Measured memory_bytes: 256
//-----------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
//-----------------------------------------------------------------------------

int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cinsc;
}

//-----------------------------------------------------------------------------
 
 
 


int main(){
   // in_o();
    string s;
    cin>>s;
    int c = 0;
    FOR(i,0,s.size()-1){
        if(s[i]!=s[i+1])c++;
    }
    cout<<c<<endl;
    return 0;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int a1 = a;
	int b1 = b;
	int count = 0;
	while (true)
	{
		bool Time[60]; 
		for (int i = 0; i<60; i++)
		{
			if (a1>0)
			{
				Time[i] = true;
				a1--;
			}
			else if (b1>0)
			{
				Time[i] = false;
				b1--;
			}
			if(a1==0 && b1 == 0)
			{
				a1 = a;
				b1 = b;
			}
		}
		if (Time[c-1] == true)
		{
				cout << count * 60 + c << endl;
				return 0;
		}
		if (a1 == a && b1 == b)
		{
			cout << -1 << endl;
			return 0;
		}
    count++;
	}//while
	return 0;
}

Measured memory_bytes: 3108