akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll n; cin >> n;
    vector<ll> odd, even, ans;
    rep(i, n){
        ll tmp;
        cin >> tmp;
        if (i % 2 == 0){
            even.push_back(tmp);
        } else {
            odd.push_back(tmp);
        }
    }

    // n が奇数: 奇数番目の反転 -> 偶数番目
    // n が偶数: 偶数番目の反転 -> 奇数番目
    if (n % 2 == 1){
        reverse(even.begin(), even.end());
        ans = even;
        ans.insert(ans.end(), odd.begin(), odd.end());
    } else {
        reverse(odd.begin(), odd.end());
        ans = odd;
        ans.insert(ans.end(), even.begin(), even.end());
    }
    for (auto a: ans){cout << a << " ";}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  for (int i = 0; i <= N; i++) {
    if(i%3!=0&&i%5!=0)
      sum += i;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3636
import heapq
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [[] for _ in range(M)]

for i in range(N):
    a, b = list(map(int, input().split()))
    if a-1 < M:
        AB[a-1].append(-b)

ans = 0
heap = []

for i in range(M):
    for b in AB[i]:
        heapq.heappush(heap, b)
    if len(heap) >0:
        b = heapq.heappop(heap)
        ans += -b

print(ans)

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

int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]);
        }
    }
}*/
long long mod = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

long long digit_sum(long long b, long long n){
    if (n < b) return n;
    return digit_sum(b, n/b) + n % b;
}

int main(void){
    long long n, s;
    scanf("%lld %lld", &n, &s);
    int root_n = sqrtl(n);
    for (int b = 2; b <= root_n; b++){
        if (s == digit_sum(b, n)){
            printf("%d\n", b);
            return 0;
        }
    }

    int root_n_s = sqrtl(n-s);
    for (long long i = root_n_s; i >= 1 ; i--){
        if ((n-s)%i == 0){
            if (s == digit_sum((n-s)/i+1, n)){
                printf("%lld\n", (n-s)/i+1);
                return 0;
            }
        }
    }
    if (n == s){
        printf("%lld", n+1);
        return 0;
    }
    printf("-1\n");

    return 0;
}

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

int main() {
  int a, b, k, max, cnt;
  cin >> a >> b >> k;
  cnt = 0;
  for (int i = min(a, b); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      max = i;
      if (++cnt == k) break;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 3600
module obj_module
  implicit none
  public

  type obj_type
    integer(8) :: key, val
  end type obj_type

  contains

  recursive subroutine quicksort(a)
    type(obj_type), intent(inout) :: a(:)
    type(obj_type) :: pivot, tmp
    integer :: i, j, k, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (pivot % key > a(i) % key)
        i = i + 1
      end do
      do while (a(j) % key > pivot % key)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end module obj_module

program main
  use obj_module
  implicit none
  integer(8) :: n, m, i, cost
  type(obj_type), allocatable :: stores(:)

  read (*, *) n, m
  allocate (stores(n))
  do i = 1, n
    read (*, *) stores(i) % key, stores(i) % val
  end do

  call quicksort(stores)

  cost = 0
  do i = 1, n
    if (m <= stores(i) % val) then
      cost = cost + m * stores(i) % key
      exit
    end if
    cost = cost + stores(i) % val * stores(i) % key
    m = m - stores(i) % val
  end do

  write (*, "(i0)") cost
end program main


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }

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

	int A, B, X; cin >> A >> B >> X;
	if (A <= X and (A + B) >= X)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 100000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, c, x[100000], v[100000];
int ma[100010], ma2[100010], cnt[100010], cnt2[100010], cum[100010], cum2[100010];
int ans;

signed main() {
	cin >> n >> c;
	for (int i = 0; i < n; i++)cin >> x[i] >> v[i];
	for (int i = 0; i < n; i++) {
		cum[i + 1] = cum[i] + v[i];
		ma[i + 1] = max(ma[i], cum[i + 1] - x[i]);
		cnt[i + 1] = cum[i + 1] - x[i] * 2;
	}
	for (int i = n - 1; i >= 0; i--) {
		int j = n - i;
		cum2[j] = cum2[j - 1] + v[i];
		ma2[j] = max(ma2[j - 1], cum2[j] - (c - x[i]));
		cnt2[j] = cum2[j] - (c - x[i]) * 2;
	}
	ans = max(ma[n], ma2[n]);
	for (int i = 1; i < n; i++) {
		ans = max({ ans,cnt[i] + ma2[n - i],cnt2[i] + ma[n - i] });
	}
	cout << max((int)0, ans) << endl;
}

Measured memory_bytes: 6528
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		long result = 0;
		long[][] dp = new long[s.length() + 1][13];
		dp[0][0] = 1;
		for(int i = 1; i <= s.length(); i++){
		    for(int j = 0; j < 10; j++){
		        if(s.charAt(i-1) == '?' || Character.getNumericValue(s.charAt(i-1)) == j){
		            for(int k = 0; k < 13; k++){
		                dp[i][(k*10 + j)%13] = dp[i][(k*10 + j)%13] + dp[i-1][k];
		                dp[i][(k*10 + j)%13] = dp[i][(k*10 + j)%13]%1000000007;
		            }
		        }
		    }
		}
		result = dp[s.length()][5];
		// 出力
		System.out.println(result);
	}
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll A, B, N;

  void init() {
    scanf("%lld %lld %lld", &A, &B, &N);
  }

  void solve() {
    ll x = min(B-1, N);
    cout << A*x/B-A*(x/B) << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main() {
	int a, b, c, d, e, k;
	int m[5];

	//cin >> a >> b >> c >> d >> e >> k;

	for (int i = 0; i < 5; i++) {
		cin >> m[i];
	}
	cin >> k;

	int sum = 0;

	for (int i = 0; i < 4; i++) {
		for (int j = i+1; j <= 4; j++) {
			if (k < m[j] - m[i]) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    
    public static double mathmet(double X1,double Y1,double X2,double Y2){
        
        double rt = Math.sqrt(Math.pow((X2 - X1),2) + Math.pow((Y2 - Y1),2));
        
        return rt;
    }
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        
       System.out.println(mathmet(x1,y1,x2,y2)); 
        
       sc.close();
    }
}


Measured memory_bytes: 27968
#include <cstdio>
const int S=1000003,mod=1000000007;
int n,f[S][3],fact[S],invf[S],g[S],res=0;
inline int ksm(int a,int x)
{
	int s=1;
	while (x)
	{
		if (x&1) s=1ll*s*a%mod;
		x>>=1;a=1ll*a*a%mod;
	}
	return s;
}
inline int C(int n,int m){if (!n) return m?0:1;if (n<m) return 0;return 1ll*fact[n]*invf[m]%mod*invf[n-m]%mod;}
int main()
{
	scanf("%d",&n);
	fact[0]=1;for (int i=1;i<S;++i)fact[i]=1ll*fact[i-1]*i%mod;
	invf[S-1]=ksm(fact[S-1],mod-2);
	for (int i=S-2;i>=0;--i) invf[i]=invf[i+1]*(i+1ll)%mod;
	f[0][0]=1;
	for (int i=1;i<=n;++i)
	{
		f[i][0]=(f[i-1][1]+f[i-1][2])%mod;
		f[i][1]=(f[i-1][0]+f[i-1][2])%mod;
		f[i][2]=(f[i-1][0]+f[i-1][1])%mod;
	}
	int sum=ksm(ksm(3,mod-2),n-1);
	for (int i=1;i<=n;++i)
		g[i]=f[i][1]*1ll*C(n,i)%mod*sum%mod;
	for (int i=1;i<=n;++i)
		res=(res+1ll*g[i]*ksm(3ll*n*i%mod,mod-2))%mod;
//	res=1ll*res*ksm(n,mod-2)%mod;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 23552
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let main = {
  let (a, b, c) = toTuple(readInts())
  for i in 1...b {
    if a * i % b == c { print("YES"); return }
  }
  print("NO")
}
main()


Measured memory_bytes: 13488
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	char kazu[11] = { "0123456789" },x[1000];
	int ans[1000] = { 0 }, i = 0, j, k;
	while (1){
		cin >> x;
		if (x[0] == '0') break;
		for (j = 0; x[j] != '\0'; j++){
			for (k = 0; k < 10;k++){
				if (x[j] == kazu[k]){
					ans[i] += k; break;
				}
			}
		}
		i++;
	}
	for (j = 0; j < i; j++){
		printf("%d\n",ans[j]);
	}
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, x;
    cin >> n >> x;
    vec m(n);
    rep(i, n) cin >> m[i];

    int res = n;
    rep(i, n) x -= m[i];

    sort(all(m));

    while (x >= m[0]) {
        x -= m[0];
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())
    dis = abs(B - A)
    if W >= V:
        print('NO')
        exit()
    dis_V = V - W
    time = dis // dis_V if dis % dis_V == 0 else (dis // dis_V) + 1
    
    if T >= time:
        print('YES')
    else:
        print('NO')



if __name__ == "__main__":
    main()

Measured memory_bytes: 61912
/**
 * author:    Ziel
 * created:   04.05.2020 10:45:42
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int h, w;
	cin >> h >> w;
	
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	vector<vector<int>> ans(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		vector<int> v;
		int cnt = 0;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '.')
				cnt++;
			else
				v.pb(cnt), cnt = 0;
		}
		v.pb(cnt);
		int it = 0;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#')
				it++;
			else
				ans[i][j] += v[it];
		}
	}
	for (int j = 0; j < w; j++) {
		vector<int> v;
		int cnt = 0;
		for (int i = 0; i < h; i++) {
			if (a[i][j] == '.')
				cnt++;
			else
				v.pb(cnt), cnt = 0;
		}
		v.pb(cnt);
		int it = 0;
		for (int i = 0; i < h; i++) {
			if (a[i][j] == '#')
				it++;
			else {
				if (!ans[i][j])
					ans[i][j] += v[it];
				else
					ans[i][j] += v[it] - 1;
			}
		}
	}
	int mx = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)
			mx = max(mx, ans[i][j]);
	}
	cout << mx;
	return 0;
}

/*
	Raise your standard.
*/

Measured memory_bytes: 20224
N, X, Y = map(int, input().split())

X = X-1
Y = Y-1

dis = Y-X
dis = dis/2
ans_list = [0]*(N-1)

for i in range(N-1):
  for j in range(i+1,N):
    normal = j-i
    a = abs(i-X)
    b = abs(j-Y)
    cut = a+b+1
    ans = min(normal, cut)
    ans_list[ans-1] += 1
for i in ans_list:
  print(i)

Measured memory_bytes: 3444
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

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

void solve(int n) {
    int old = 0;
    int left = 0, right = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "lu") {
            left = 1;
            if (old == 0 && right == 1) {
                ans++;
                old = 1;
            }
        } else if (s == "ru") {
            right = 1;
            if (old == 0 && left == 1) {
                ans++;
                old = 1;
            }
        } else if (s == "ld") {
            left = 0;
            if (old == 1 && right == 0) {
                ans++;
                old = 0;
            }
        } else {
            right = 0;
            if (old == 1 && left == 0) {
                ans++;
                old = 0;
            }
        }
    }
    cout << ans << endl;
}

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        solve(n);
    }
    return 0;
}

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

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    for(int i{0}; i<B; ++i){
        if(A*i%B == C){
            cout << "YES" << endl;
            return(0);
        }
    }
    cout << "NO" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int w, h;
int data[50][50];	//data[row][col]

bool isRange(int r, int c) {
	return (r >= 0 && r < h && c >= 0 && c < w);
}

int main() {
	while (cin >> w >> h) {
		if (!w) break;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> data[i][j];
		
		int ans = 0;
		bool used[50][50] = {false};
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (!data[i][j] || used[i][j]) continue;
				ans++;
				
				//nurima-su (i, j) kara ikeru masu wo by bfs.
				queue<P> que;	//row, col
				que.push(P(i, j));
				while (!que.empty()) {
					int r = que.front().first;
					int c = que.front().second;
					que.pop();
					
					if (used[r][c]) continue;	//itidosika sirabenai (edakari)
					used[r][c] = true;	//visit
					
					for (int dr = -1; dr <= 1; dr++) {
						for (int dc = -1; dc <= 1; dc++) {
							if (dr == 0 && dc == 0) continue;
							if (!isRange(r + dr, c + dc) || !data[r + dr][c + dc]) continue;	//ikeruka hantei
							que.push(P(r + dr, c + dc));
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    int n;
    cin >> n;

    stack<char> st;
    string s;
    cin >> s;

    int left = 0;

    for (char c :  s) {
        if (c == '(') {
            st.push('(');
        } else {
            if (st.empty()) {
                left++;
            } else {
                st.pop();
            }
        }
    }

    int right = st.size();

    rep(i, left) {
        cout << '(';
    }
    cout << s;
    rep(i, right) {
        cout << ')';
    }

    cout << endl;


}

Measured memory_bytes: 256
/************************* In the name of Allah *************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef string          str;
typedef pair<ll,ll>     pll;

#define F               first
#define S               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = 1e9 + 7,
         INF = 1e18,
         MAXN = 1e5 + 10;

int main(){
    fast_io
    int n, k;
    string s;
    cin >> n >> k >> s;
    char last = s[0];
    int t = 1;
    vector < int > v;
    for (int i = 1; i < n; i ++)
    {
        if (s[i] == last)
            t ++;
        else
        {
            v.push_back(t);
            t = 1;
            last = s[i];
        }
    }
    v.push_back(t);
    int ans = 0;
    for (int i = 0; i < k && 2 * i + 1 < v.size(); i ++)
        ans += 2;
    /*
    for (int i = 0; i < k && 2 * i + 1 <= v.size(); i ++)
    {
        if (2 * i + 1 < v.size())
            ans += 2;
        else
            ans += 1;
    }
    */
    if ((int)(v.size()) % 2 == 0 && k >= (int)(v.size()) / 2)
        ans --;
    for (int i = 0; i < v.size(); i ++)
        ans += v[i] - 1;
    cout << ans;
    return 0;
}

/*
 __  __       _         _ _  _____ _           _                __ _
|  \/  |     | |       | (_)/ ____| |         | |              / _(_)
| \  / | __ _| |__   __| |_| (___ | |__   ___ | | _____  _   _| |_ _
| |\/| |/ _` | '_ \ / _` | |\___ \| '_ \ / _ \| |/ / _ \| | | |  _| |
| |  | | (_| | | | | (_| | |____) | | | | (_) |   < (_) | |_| | | | |
|_|  |_|\__,_|_| |_|\__,_|_|_____/|_| |_|\___/|_|\_\___/ \__,_|_| |_|
*/


Measured memory_bytes: 972
n, k = map(int, input().split())
h = list(map(int, input().split()))

costs = [float('inf') for _ in range(n)]
costs[0] = 0

for x in range(n):
    for y in range(x + 1, min(x + k + 1, n)):
        costs[y] = min(costs[y], costs[x] + abs(h[x] - h[y]))

print(costs[n - 1])

Measured memory_bytes: 56800
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int a[200000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k;cin>>n>>k;
  int count=1;
  // REP(i,n){
  //   cin>>a[i];
  //   if(a[i]==1)count=i;
  // }
  n-=k;
  if(n==0){
    P(1);
    return 0;
  }
  while(n>0){
    n-=k-1;
    count++;
  }
  P(count);


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????°?????£?¨?
		int num = 0;
		
		//a?????????
		int a = sc.nextInt();
		//b?????????
		int b = sc.nextInt();
		//c?????????
		int c = sc.nextInt();
		//??°????????? a???b????????????????????????????????????
		for(int i = a; i <= b; i++){
			//?????¶???c???i??§?????£?????°???0????????°
			if(c % i == 0){
				//?????¶????????£?§£??????????????????
				num++;
			}
		}
		//??¨???
		System.out.println(num);
	}
}

Measured memory_bytes: 26312
N, K = gets.split.map(&:to_i)
b = Array.new(N, 0)
a = gets.split.map(&:to_i)
a.each do |e|
    b[e - 1] += 1
end
b.sort!
puts 0 < N - K ? b[0, N - K].inject(&:+) : 0

Measured memory_bytes: 18432
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    ll s = 0;
    FOR(x, a)
    {
        s ^= x;
    }
    REP(i, N)
    {
        OUT(s ^ a[i]);
    }
}

Measured memory_bytes: 4840
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    answer = 'NO'
elif abs(A - B) - abs((V - W)* T) > 0:
    answer = 'NO'
else:
    answer = 'YES'
print(answer)

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 20001;

int G[101][101];
int color[101], d[101];
int t = 0;

int main(void)
{
	int n, k, v, u;
	queue<int>Q;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int i = 0; i < k; i++) {
			cin >> v;
			G[u][v] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
		d[i] = MAX;
	color[1] = 1;
	d[1] = 0;
	Q.push(1);
	while (Q.size()) {
		u = Q.front();
		Q.pop();
		for (int v = 1; v <= n; v++) {
			if (G[u][v] && color[v] == 0) {
				color[v] = 1;
				d[v] = d[u] + 1;
				Q.push(v);
			}
		}
		color[u] = 2;
	}
	for (int i = 1; i <= n; i++) {
		if (d[i] == MAX)
			d[i] = -1;
	}
	for (int i = 1; i <= n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3132
import copy
import numpy as np

s = input()
n = 3
ans = 0

for i in range(1,3 ** n):
    x = copy.deepcopy(s)
    y = str(np.base_repr(i,3)).rjust(3,'0') #3進数に変換
    if (y[0] == "0" and s[0] == "0") or (y[1] == "0" and s[1] == "0") or (y[2] == "0" and s[2] == "0"):
        continue
    z = 1
    for j in range(3):
        if y[j] == "1": #フラグが立っていたら
            x = x[:j+z] + "+" + x[j+z:]
            z += 1
        if y[j] == "2": #フラグが立っていたら
            x = x[:j+z] + "-" + x[j+z:]
            z += 1
    if eval(x) == 7:
        print(x +"=7")
        exit()

Measured memory_bytes: 12476
function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = Number(input[0]);
  var B = Number(input[1]);
  var C = Number(input[2]);
  var D = Number(input[3]);
  var ans = 0;
  var i=0;
  var l=0;
  while(true){
    if(A<B){
      ans+=i;
      break;
    }
    B*=2;
    i++;
  }
  while(true){
    if(B<C){
      ans+=l;
      break;
    }
    C*=2;
    l++;
  }
  if(D>=ans){
    console.log("Yes");
  }else{
    console.log("No");
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29672
#include <queue> 
#include <string> 
#include <iostream> 
#include <cstdlib>
using namespace std; 
int main() {
  priority_queue<int> Q;
  string word;
  int num;
  
  while (cin >> word) {
    if (word == "insert") {
      
    }
    else if (word == "extract") {
      num = Q.top();
      cout << num << endl;
      Q.pop();
    }
    else if (word == "end") {

    }
    else {
      num = atoi(word.c_str());
      Q.push(num);
    }
  }
}

Measured memory_bytes: 5440
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String str = sc.next();
            if(str.equals("-")) break;
            int S = str.length();
            int m = sc.nextInt();
            for(int i = 0; i < m; i++) {
                int h = sc.nextInt();
                str = str.substring(h) + str.substring(0,h);
            }
            System.out.println(str);
        }
    }
}


Measured memory_bytes: 26284
AC = 0
WA = 0
TLE = 0
RE = 0
N = int(input())
for i in range(N):
	a = input()
	if(a == "AC"):
		AC = AC + 1
	if(a == "WA"):
 		WA = WA + 1
	if(a == "TLE"):
		TLE = TLE + 1
	if(a=="RE"):
		RE = RE + 1
print("AC x "+ str(AC))
print("WA x "+ str(WA))
print("TLE x "+ str(TLE))
print("RE x "+ str(RE))

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1000000+10;
int n,k,a[N];
int main() {
	scanf("%d%d",&k,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1]=a[1]+k;
	int mx=0;
	for(int i=1;i<=n;i++){
		mx=max(mx,a[i+1]-a[i]);
	}
	cout<<k-mx<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 105000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9

#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define rui(n) scanf("%u",&n)
#define rui2(a,b) scanf("%u %u",&a,&b)
#define rui3(a,b,c) scanf("%u %u %u",&a,&b,&c)
#define rs(str) scanf("%s",str)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64
#define ui unsigned int

using namespace std;

const ll mod = 1e9 + 7;

//Date:2018-8-11
//Author：HarryBlackCat

const char nc[20] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};
string ans;

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	int m, n, k, t, s;
	while(cin >> m) {
		if(m == 0){
			puts("0");
			continue;
		}
		
		ans = "";
		n = -2;
		s = m;
		while(m != 0) {
			k = m % n;
			t = m / n;
			if(k < 0) {
				k -= n;
				t++;
			}
			m = t;
			ans.push_back(nc[k]);
		}
		//cout << s << "=";
		for(int i = ans.length() - 1; i >= 0; i--) {
			cout << ans[i];
		}
		puts(""); 
	}
	return 0;
}

Measured memory_bytes: 256
L,M=map(int,input().split())
count=0
if L==1 and M==1:
    print(1)
elif L==1 or M==1:
    print(L+M-3)
if L==2 or M==2:
    print(0)
if L>=3 and M>=3:
    print((L-2)*(M-2))

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

using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

int n;
string s;
map<char, int> v{{'#', 0}, {'.', 1}};

int tb[200000][2];

int dp(int i, int color){
	if(i == n) return 0;
	
	if(tb[i][color] != -1) return tb[i][color];
	
	if(color == v['#']){
		return tb[i][color] = dp(i+1, v['#'])+(s[i] == '.');
	}else{
		int take = dp(i+1, (s[i] == '#' ? v['.'] : v['#'])) + 1;
		int notTake = dp(i+1, v[s[i]]);

		return tb[i][color] = min(take, notTake);	
	}	
}

int main(){
	FAST_IO();
	
	memset(tb, -1, sizeof(tb));
	cin >> n >> s;
	cout << min(dp(0,v['#']), dp(0,v['.']) ) << endl;
	
	return 0;
}

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

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

	long N;
	cin >> N;

	int a[N];
	bool az = true;
	for(long i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] == 1)
			az = false;
	}

	if (az) {
		cout << 0 << endl;
		return 0;
	}

	long s[N] = {};
	bool box[N] = {};
	long c = 0;
	for (long i = N; i > 0; i--) {
		if (i != 1)
			for (long x = i; x <= N; x += i) {
				if(box[x-1]) s[i-1]++;
			}
		if (a[i-1] != (s[i-1] % 2)) {
			c++;
			s[i-1]++;
			box[i-1] = true;
			if (i != 1) s[0]++;
		}
	}

	cout << c << endl;
	if (c > 0) {
		long i = 0;
		for (; i < N; i++) {
			if (box[i]) {
				cout << i+1;
				break;
			}
		}
		for (i++; i < N; i++) {
			if (box[i]) cout << " " << i+1;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3456
include Math

a, b, h, m = gets.chomp.split(' ').map(&:to_i)

rm = m.to_f / 60 * 360
rh = (h * 60 + m).to_f / (12 * 60) * 360

dif = (rm -rh).abs
dif = dif >= 180 ? 360 - dif : dif

dis = a**2 + b**2 - 2 * a * b * Math.cos(dif * Math::PI / 180)
puts Math.sqrt(dis)


Measured memory_bytes: 14704
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int h = n/3600;
		int m = (n%3600)/60;
		int s = (n%3600)%60;
		
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26248
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);
		List<Integer> hs = Arrays.asList( scanner.nextLine().split(" ") ).stream().map(x -> Integer.parseInt(x) ).collect(Collectors.toList());
		
		int count = 0;
		for(int h : hs) {
			if(h >= k) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 51692
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  
  string S;
  cin >> S;
  
  int zero = 0 , one = 0;
  
  for (int i = 0; i < S.size() ; i++){
    if (S.at(i) == '0')
      zero++;
    else
      one ++;
  }
  
  if (zero < one)
    cout << zero * 2 << endl;
  else
    cout << one * 2 << endl;
}

Measured memory_bytes: 512
#標準入力
n = int(input())
#入力。標準入力を文字列として取り込み
hai_l = list(map(int, input().split()))

#リストをソートしてから、隣同士の比較
#→やらない。setで重複削除したリストを作って、リスト長をチェック。一致してたらOK
if len(set(hai_l)) == len(hai_l):
	print('YES')
else:
	print('NO')



Measured memory_bytes: 100564
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;

using namespace std;

int main(){
	
	ll n , m , k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1 , 0) , b(m + 1, 0);
	
	for(ll i = 1; i <= n; i++){
		ll input;
		cin >> input;
		a[i] = input + a[i - 1];
	}
	
	for(ll i = 1; i <= m; i++){
		ll input;
		cin >> input;
		b[i] = input + b[i - 1];
	}
	
	ll ans = 0;
	ll mx = m;
	for(ll i = 0; i <= n; i++){
		if(a[i] > k)break;
		while(b[mx] + a[i] > k){
			mx--;
		}
		ans = max(ans , i + mx);
	}
	cout << ans << endl;		
	
	return 0;
}
 


Measured memory_bytes: 6420
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;
//use ac_library_rs::*;

#[fastout]
fn main() {
    input! {
        n: u64, x: u64, m: u64,
    }

    let mut rems = HashMap::new();
    let mut sum = x;
    let mut a = x;
    rems.insert(a, (1, sum));
    let mut count = 1;
    let mut rep = None;
    while count < n {
        count += 1;
        a = a * a % m;
        sum += a;
        if let Some(&(idx, sum_low)) = rems.get(&a) {
            let sum_mid = sum - sum_low;
            let diff = count - idx;
            rep = Some((sum_low, sum_mid, diff, idx, a));
            break;
        } else {
            rems.insert(a, (count, sum));
        }
    }

    if rep.is_none() {
        println!("{}", sum);
        return;
    }

    let diff = rep.unwrap().2;
    let sum_low = rep.unwrap().0;
    let sum_mid = rep.unwrap().1;
    let low_idx = rep.unwrap().3;
    let num_mid = (n - low_idx) / diff ;
    let mut ans = sum_low + sum_mid * num_mid;
    let mut a = rep.unwrap().4;
    for _ in low_idx + num_mid * diff + 1..=n {
        a = a * a % m;
        ans += a;
    }
    println!("{}", ans);
}


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

#define PI 3.14159265359

int main(){
   int X;
   cin >> X;
   if (X < 600) cout << "8" << endl;
   else if (X < 800) cout << "7" << endl;
   else if (X < 1000) cout << "6" << endl;
   else if (X < 1200) cout << "5" << endl;
   else if (X < 1400) cout << "4" << endl;
   else if (X < 1600) cout << "3" << endl;
   else if (X < 1800) cout << "2" << endl;
   else cout << "1" << endl;
}


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

using namespace std;
int main() {
  char c;
  cin >> c;
  if (c == 'A') cout << 'T' << endl;
  if (c == 'T') cout << 'A' << endl;
  if (c == 'C') cout << 'G' << endl;
  if (c == 'G') cout << 'C' << endl;

  return 0;
}

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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

vi wws,vvs,dp;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,w,a,b;
    cin >> n >> w;
    rep(i,n) {
        cin >> a >> b;
        wws.push_back(a);
        vvs.push_back(b);
    }

    dp.assign(w+1,-1);
    dp[0] = 0;

    rep(i,n) {
        rrep(j,w+1) {
            if (dp[j] >= 0 && j + wws[i] <= w) {
                dp[j+wws[i]] = max(dp[j+wws[i]], dp[j] + vvs[i]);
            }
        }
    }

    int mx = -1;
    rep(i,w+1) {
        if (dp[i] > mx) mx = dp[i];
    }

    cout << mx << '\n';

    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll              long long int
#define int             int64_t
#define ff              first
#define ss              second
#define pb              push_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define en              cout<<endl
using namespace std;
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}
void system_output(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
}
void solve(){
      int A,B,N;
      cin>>A>>B>>N;

      if(N<B-1){
        cout<<(((A*N)/B)-(A*(N/B)))<<endl;
        return;
      }
      else{

           int x;int m =0;
         for(int i = 1;i<=1000000;i++){
             x = i*B-1;
             if(x>N)
                break;
             m = max2((((A*x)/B)-(A*(x/B))),m);
         }
         cout<<m<<endl;
      }
          
}
signed main(void)
{
      fast();
      //w(t)
      solve();

}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
	int a[10];
	int b[10];
	int maxa1=0;
	int maxa2=0;
	int maxa3=0;
	int maxb1=0;
	int maxb2=0;
	int maxb3=0;
	int i;
	
	for(i=0;i<10;i++)
	{
		scanf("%d",&a[i]);
			if(a[i]>=maxa3)
			{
				if(a[i]>=maxa2)
				{
					if(a[i]>=maxa1)
					{
						maxa3=maxa2;
						maxa2=maxa1;
						maxa1=a[i];
					}
					else
					{
						maxa3=maxa2;
						maxa2=a[i];
					}
				}
				else
				{
					maxa3=a[i];
				}
			}
	}
	for(i=0;i<10;i++)
	{
		scanf("%d",&b[i]);
			if(b[i]>=maxb3)
			{
				if(b[i]>=maxb2)
				{
					if(b[i]>=maxb1)
					{
						maxb3=maxb2;
						maxb2=maxb1;
						maxb1=b[i];
					}
					else
					{
						maxb3=maxb2;
						maxb2=b[i];
					}
				}
				else
				{
					maxb3=b[i];
				}
			}
	}
	
	printf("%d %d\n",maxa1+maxa2+maxa3,maxb1+maxb2+maxb3);
}


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

int main()
{
    long long x,y,h,no;
    int g;
    cin>>x>>y;
    h=y/x;
    no=1;
    while(no<=h)
    {
        g++;
        no*=2;
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

const int MAXN = 53;

int n, m;
char a[MAXN][MAXN], b[MAXN][MAXN];

bool contain(int r, int c) {
    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < m; ++j) {
            if(a[r + i][c + j] != b[i][j]) {
                return false;
            }
        }
    }
    return true;
}

bool judge() {
    for(int i = n - m; i >= 0; --i) {
        for(int j = n - m; j >= 0; --j) {
            if(contain(i, j)) {
                return true;
            }
        }
    }
    return false;
}

int main() {
    while(2 == scanf("%d%d", &n, &m)) {
        for(int i = 0; i < n; ++i) {
            scanf("%s", a[i]);
        }
        for(int i = 0; i < m; ++i) {
            scanf("%s", b[i]);
        }
        printf("%s\n", judge() ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 128
if __name__ == "__main__":
  s = input().strip()
  ind_day = {"SUN": 7, "MON": 1, "TUE": 2, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6}
  key = ind_day[s]
  if key < 7:
    print(7 - key)
  else:
    print(key)

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int l, r;

	while(scanf("%d%d", &l, &r)==2)
	{
		int ans=2019*2019;
		int a=l;
		for(int i=0;i<2019 && a<r;i++,a++)
		{
			int b=a+1;
			for(int j=0;j<2019 && b<=r;j++,b++)
			{
				ans=min(ans, (a%2019)*(b%2019)%2019);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

struct RollingHash{
    vector<int64_t> hash;
    vector<int64_t> base_pow;
    int64_t base, mod;
    static const int64_t DEFAULT_BASE = 1009, DEFAULT_MOD = 1e9+7;

    RollingHash(string S="", int64_t base=DEFAULT_BASE, int64_t mod=DEFAULT_MOD):base(base), mod(mod){
        if(S.size() > 0) initialize(S);
    }

    void initialize(string& S){
        int N = S.size();
        vector<int> s(N);
        for(int i=0; i<N; i++) s[i] = S[i];
        initialize(s);
    }

    void initialize(vector<int>& S){
        int sz = S.size();
        hash.resize(sz+1);
        base_pow.resize(sz+1);
        hash[0] = 0;
        base_pow[0] = 1;
        for(int i=1; i<=sz; i++){
            hash[i] = (hash[i-1] * base + S[i-1]) % mod;
            base_pow[i] = base_pow[i-1] * base % mod;
        }
    }

    // 0-indexed, [a, b)
    int64_t between(int a, int b){
        return (mod + hash[b] - hash[a] * base_pow[b-a] % mod) % mod;
    }
};

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ok = 0, ng = N/2+1;
    RollingHash rh1(S, 1007, 1e9+7);

    while(ng-ok>1){
        int len = (ng+ok)/2;
        set<int64_t> val;
        vector<int64_t> v(N);
        bool success = false;
        for(int i=0; i+len<=N; i++){
            if(i >= len) val.insert(v[i-len]);
            v[i] = rh1.between(i, i+len);
            if(val.count(v[i])){
                success = true;
                break;
            }
        }
        (success ? ok : ng) = len;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S;
int p,ch[1<<8];
ll bnf();

ll getNum(){
  ll res=0;
  while(isdigit(S[p])) res=res*10+S[p++]-'0';
  return res;
}

ll get(ll &a,ll b,char c){
  if(c=='+')a+=b;
  if(c=='-')a-=b;
  if(c=='*')a*=b;
  return a;
}

ll calc(int c){
  ll res,t;
  if(S[p]=='(') p++,res=bnf(),p++;
  else res=getNum();
  while(p<S.size()&&S[p]!=')'&&ch[S[p]]>c)t=S[p++],get(res,calc(ch[t]),t);
  return res;
}

ll bnf(){
  ll res=calc(-1),t;
  while(p<S.size()&&S[p]!=')')t=S[p++],get(res,calc(ch[t]),t);
  return res;
}

int main(){
  cin>>S; 
  ll res=bnf();
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++) {
	ch['+']=i,ch['-']=j,ch['*']=k;
	p=0;
	res=max(res,calc(-100));
      }
  
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3192