akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N + 1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    vector<i64> kaisa(N + 1);
    for (int i = 2; i <= N; i++) {
        kaisa[i] = A[i] - A[i - 1];
    }
    set<i64> st;
    i64 res = 0;
    i64 onaji = 0;
    i64 minuscnt = 0;
    for (int i = 1; i <= K; i++) {
        st.insert(A[i]);
        if (kaisa[i] < 0) minuscnt++;
    }
    if (minuscnt > 0) res++;
    else onaji = 1;
    
    for (int i = K + 1; i <= N; i++) {
        if (kaisa[i - K + 1] < 0) minuscnt--;
        if (kaisa[i] < 0) minuscnt++;
        if (kaisa[i] < 0) {
            res++;
            st.erase(A[i - K]);
            st.insert(A[i]);
            //cerr << A[i - K] << " " << A[i] << " " << res << endl;
        } else {
            st.erase(A[i - K]);
            auto itr = st.end();
            itr--;
            if (minuscnt == 0) {
                onaji = max(onaji, 1LL);
            }
            else if (A[i - K] < *st.begin() && A[i] > *--st.end()) {
                res += 0;
            } else {
                res++;
            }
            //if (A[i] == 9) cerr<<minuscnt<<"\n";
            //cerr << A[i - K] << " " << *st.begin() << " " << A[i] << " " << *itr << " " << res << endl;
            st.insert(A[i]);
        }
    }
    cout << res + onaji << "\n";
    return 0;
}


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

int gcd(int m, int n) {
    int temp;
    while(m%n != 0) {
        temp = n;
        n = m%n;
        m = temp;
    }
    return n;
}

int lcm(int m, int n) {
    return m*n/gcd(m,n);
}

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

    long n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    int n_gcd = gcd(n,m);
    for (int i = 0; i < n_gcd; i++) {
        if (s[n/n_gcd*i] != t[m/n_gcd*i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << n*m/n_gcd << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll N,K;
	cin>>N>>K;
	vector<ll> node(N);
	rep(i,N){
		ll t; cin>>t;
		node[i] = t-1LL;
	}
	ll loop_st;
	ll branch;
	ll loop_len;
	vector<ll> check(N,INF);
	ll bf = 0, to;
	check[0] = 0;
	while(1){
		to = node[bf];
		if(check[to] != INF){
			loop_st = to;
			branch = check[to];
			loop_len = check[bf] - check[to]+1LL;
			break;
		}
		check[to] = check[bf] + 1LL;
		bf = to;
	}
	if(K<branch){
		rep(i,N)if(check[i] == K){
			cout<<i+1<<endl; return 0;
		}
	}
	K -= branch;
	K %= loop_len;

	vector<ll> dist(N,INF);
	dist[loop_st] = 0;
	ll ans;
	bf = loop_st;
	while(1){
		if(dist[bf] == K){
			ans = bf;
		}
		to = node[bf];
		if(dist[to] != INF){
			break;
		}
		dist[to] = dist[bf]+1LL;
		bf = to;
	}
	cout<<ans+1LL<<endl;
}

// int main(){
// 	ll N;
// 	ll K;
// 	cin>>N>>K;
// 	vector<ll> node(N);
// 	rep(i,N){
// 		ll t; cin>>t;
// 		node[i] = t-1LL;
// 	}
// 	//OK
// 	vector<ll> dis(N,INF);
// 	dis[0] = 0LL;
// 	ll bf = 0LL;
// 	ll lp_len;
// 	ll sokomade = 0LL;
// 	ll loop_st;
// 	while(true){
// 		ll to = node[bf];
// 		if(dis[to] != INF){
// 			loop_st = to;
// 			sokomade = dis[to];
// 			lp_len = dis[bf] - dis[to] + 1LL;
// 			break;
// 		}
// 		dis[to] = dis[bf]+1LL;
// 		bf = to;
// 	}
// 	K -= sokomade;
// 	K %= lp_len;


// 	vector<ll> dis2(N,INF);
// 	dis2[loop_st] = 0LL;
// 	bf = loop_st;
// 	while(true){
// 		ll to = node[bf];
// 		if(dis2[to] != INF){
// 			break;
// 		}
// 		dis2[to] = dis2[bf] + 1LL;
// 		bf = to;
// 	}
// 	ll ans = 0LL;
// 	rep(i,N){
// 		if(dis2[i] == K){ans = i+1LL;break;}
// 	}
// 	cout<<ans<<endl;
// 	return 0;
// }

Measured memory_bytes: 8016
import sys


class Node(object):
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right

    def __str__(self):
        return "parent = %s, left = %s, right = %s" % (self.parent, self.left, self.right)

    def __repr__(self):
        return self.__str__()


def preorder_traverse(node_list, current):
    print(" %d" % current, end="")
    node = node_list[current]
    if node.left != -1:
        preorder_traverse(node_list, node.left)
    if node.right != -1:
        preorder_traverse(node_list, node.right)


def inorder_traverse(node_list, current):
    node = node_list[current]
    if node.left != -1:
        inorder_traverse(node_list, node.left)
    print(" %d" % current, end="")
    if node.right != -1:
        inorder_traverse(node_list, node.right)


def postorder_traverse(node_list, current):
    node = node_list[current]
    if node.left != -1:
        postorder_traverse(node_list, node.left)
    if node.right != -1:
        postorder_traverse(node_list, node.right)
    print(" %d" % current, end="")


def main():
    lines = sys.stdin.readlines()
    num_of_nodes = int(lines[0])
    node_list = [Node() for _ in range(num_of_nodes)]

    # Set filiation
    for line in lines[1:]:
        node_id, left, right = [int(x) for x in line.strip().split(" ")]
        node_list[node_id].left = left
        node_list[node_id].right = right

        if left != -1:
            node_list[left].parent = node_id
        if right != -1:
            node_list[right].parent = node_id

    # Find root node id
    for node_id, node in enumerate(node_list):
        if node.parent == -1:
            root = node_id
            break

    print("Preorder")
    preorder_traverse(node_list, root)
    print("\nInorder")
    inorder_traverse(node_list, root)
    print("\nPostorder")
    postorder_traverse(node_list, root)
    print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 7892
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
    using System.Net;

     
    public class Program
    {

        public void Proc() {
            string inpt = Reader.ReadLine();
            int ans = 0;
            for(int i=inpt.Length-2;i>=2; i--) {
                string tmp = inpt.Substring(0,i);
                if(tmp.Substring(tmp.Length/2).Equals(tmp.Substring(0, tmp.Length/2))) {
                    ans = i;
                    break;
                }
            }
            Console.WriteLine(ans);


        }




        public class Reader {
            public static bool IsDebug = false;
            private static System.IO.StringReader SReader;
            private static string InitText = @"







akasakaakasakasakaakas







";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            #if DEBUG
            Reader.IsDebug = true;
            #endif
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 13140
#include <stdio.h>
#define N 100
int n,a[N][N];
//
#define W 0
#define G 1
#define B 2
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
	int v;
	color[u] = G;
	d[u] = ++tt;
	for(v=0;v<n;v++){
		if(a[u][v] == 0)continue;
		if(color[v] == W){
			dfs_visit(v);
		}
	}
	color[u] = B;
	f[u] = ++tt;
}

void dfs(){
	int u;
	for(u=0;u<n;u++)color[u] = W;
		tt = 0;

	for(u=0;u<n;u++){
		if(color[u] == W)dfs_visit(u);
	}
	for(u=0;u<n;u++){
		printf("%d %d %d\n",u+1,d[u],f[u]);
	}
}


int main(){
	int i,j,u,k,v;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++)a[i][j]=0;
	}

	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			a[u-1][v-1] = 1;
		}
	}

	dfs();

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>

int N, M, Q, l, r;

std::vector<std::vector<int>> g(500);

int main() {
    std::cin >> N >> M >> Q;
    for (int i = 0; i < M; ++i) {
        std::cin >> l >> r;
        std::vector<int> &p = g[l - 1];
        p.push_back(r);
        size_t k = p.size() - 2;
        while (p[k] > p[k + 1]) {
            std::swap(p[k], p[k + 1]);
            --k;
        }
    }
    for (int i = 0; i < Q; ++i) {
        std::cin >> l >> r;
        int ans = 0;
        for (int j = l - 1; j < r; ++j) {
            std::vector<int> &p = g[j];
            size_t f = 0, e = p.size(), m;
            while (f < e) {
                m = (f + e) >> 1;
                if (p[m] > r) e = m;
                if (p[m] <= r) f = m + 1;
            }
            ans += f;
        }
        std::cout << ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;

void GetPrimeFactors(ull n, map<ull, ull>& factors)
{
    for(ull i = 2; i * i <= n; i++)
    {
        while(n % i == 0)
        {
            factors[i]++;
            n /= i;
        }
    }

    if(n != 1)
    {
        factors[n] = 1;
    }
}

int main()
{
    ull n;
    cin >> n;

    map<ull, ull> factors;
    GetPrimeFactors(n, factors);
    ull count = 0;
    for(auto it = factors.begin(); it != factors.end(); it++)
    {
        ull e = 1;
        ull left = it->second;
        while(left >= e)
        {
            count++;
            left -= e;
            e++;
        }
    }

    cout << count;

    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int AA;
      cin >> AA;
      A.at(AA-1)++;
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
import sys
from collections import defaultdict
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    roads = [list(input().split()) for _ in range(M)]
    road_num = defaultdict(int)
    for road in roads:
        road_num[road[0]] += 1
        road_num[road[1]] += 1
    for i in range(1, N+1):
        print(road_num[str(i)])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
N = int(input())
s = input()
#print(s)
d = ['S','W']
for i in d:
    for j in d:
        ans = [i,j]
        for k in range(2,N):
            if s[k-1] == 'o':
                if ans[-1] == 'S':
                    ans.append(ans[-2])
                else:
                    if ans[-2] == 'S':
                        ans.append('W')
                    else:
                        ans.append('S')
            else:
                if ans[-1] == 'S':
                    if ans[-2] == 'S':
                        ans.append('W')
                    else:
                        ans.append('S')
                else:
                    ans.append(ans[-2])
        #print(ans)
        flg = True
        if ans[-1] == 'S':
            if s[-1] == 'o':
                if ans[-2] != ans[0]:
                    flg = False
            else:
                if ans[-2] == ans[0]:
                    flg = False
        else:
            if s[-1] == 'x':
                if ans[-2] != ans[0]:
                    flg = False
            else:
                if ans[-2] == ans[0]:
                    flg = False
        if ans[0] == 'S':
            if s[0] == 'o':
                if ans[-1] != ans[1]:
                    flg = False
            else:
                if ans[-1] == ans[1]:
                    flg = False
        else:
            if s[0] == 'x':
                if ans[-1] != ans[1]:
                    flg = False
            else:
                if ans[-1] == ans[1]:
                    flg = False
        if flg == True:
            print(''.join(ans))
            exit()

print(-1)


Measured memory_bytes: 82016
#include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int n; (n = in);) {
		vector<int> v;
		if ((int) in)
			v  = {0, 1};
		else
			v = {1};
		for (int i: range(2, n + 1)) {
			bool b = (int) in, l = !(v.size() % 2);
			if (l == b)
				v.back()++;
			else if (i % 2)
					v.push_back(1);
			else {
				int t {v.back()};
				v.pop_back();
				if (v.size())
					v.back() += t + 1;
				else
					v = {0, t + 1};
			}
		}
		int r {};
		for (size_t i = 0; i < v.size(); i += 2)
			r += v[i];
		outl(r);
	}
}


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

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define len(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define fore(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long ll;
typedef double db;
typedef pair<int, int> pi;
typedef pair<int, pi> ti;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ti> vti;
typedef vector<vpi> vvpi;

const int inf = (int)0x3f3f3f3f3f3f3f3f;
const int ninf = (int)0xc0c0c0c0c0c0c0c0;
const ll M = (ll)1e9 + 7;
const int N = 1e6 + 3;

int n, spf[N], a[N], expo[N];
vi pr;

void sieve() {
    fore(i, 2, N) {
        if (!spf[i]) {
            spf[i] = i;
            pr.pb(i);
        }
        for (int j = 0; i * pr[j] < N; ++j) {
            spf[i * pr[j]] = pr[j];
            if (i % pr[j] == 0) break;
        }
    }
}

int pw(int a, int b) {
    int res = 1;
    for (; b; b >>= 1, a = a * a % M) if (b & 1) res = res * a % M;
    return res;
}

main() {
    sieve();
    scanf("%lld", &n);
    fort(i, 1, n) scanf("%lld", a + i);
    fort(i, 1, n) {
        int x = a[i];
        while (x != 1) {
            int tmp = spf[x], cnt = 0;
            while (spf[x] == tmp) {
                x /= tmp;
                ++cnt;
            }
            maxi(expo[tmp], cnt);
        }
    }
    int LCM = 1;
    fore(i, 0, N) (LCM *= pw(i, expo[i])) %= M;
    bug(LCM);
    int ans = 0;
    fort(i, 1, n) {
        int lcm = LCM, x = a[i];
        while (spf[x]) (lcm *= pw(spf[x], M - 2)) %= M, x /= spf[x];
        (ans += lcm) %= M;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 18036
s = input()
total = int(s[0])

op = ['+', '-']
for i in op:
    for j in op:
        for k in op:
            cmd = s[0] + i + s[1] + j + s[2] + k + s[3]
            if eval(cmd) == 7:
                print(cmd + "=7")
                exit()

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int H;
int N;
int A[100000];
int main(){
  rd(H);
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = A[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A += A[e98WHCEY];
      }
    }
    if(H<=cTE1_r3A){
      wt_L("Yes");
      wt_L('\n');
    }
    else{
      wt_L("No");
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int H, N, A[1d5];
// {
//   rd(H,N,A(N));
//   wt(if[H<=sum(A(N)),"Yes","No"]);
// }


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int t;

vector<pair<int, int>> a;

void input() {
  cin >> n >> t;

  a.resize(n);
  for (auto&& i : a) {
    cin >> i.second >> i.first;
  }
}

void solve() {
  sort(a.begin(), a.end());

  auto it = upper_bound(a.cbegin(), a.cend(), make_pair(t, INF));

  if (it == a.cbegin()) {
    cout << "TLE\n";

    return;
  }

  --it;

  int mino = INF;
  int sz = distance(a.cbegin(), it);

  for (int i = 0; i < sz + 1; ++i) {
    mino = min(mino, a[i].second);
  }

  cout << mino << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 384
from math import sqrt


def factor(N):
    f = {}
    for i in range(2, int(sqrt(N))+1):
        e = 0
        while N % i == 0:
            e += 1
            N /= i
        if e != 0:
            f[i] = e
    if N != 1:
        f[N] = 1
    return f


def solver(N):
    f = {}
    for i in range(1, N+1):
        for p, e in factor(i).items():
            if f.get(p) is None:
                f[p] = 0
            f[p] += e
    ans = 1
    for p, e in f.items():
        ans *= (e+1)
    ans %= 10**9+7
    return ans


if __name__ == "__main__":
    N = int(input())
    print(solver(N))


Measured memory_bytes: 9260
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	int h[N_MAX];
	cin>>n;
	int cnt_max=0;
	int cnt=0;
	REP(i,n){
		cin>>h[i];
	}
	REP(i,n-1){
		if(h[i]>=h[i+1]){
			cnt++;
		}else{
			cnt_max=max(cnt_max,cnt);
			cnt=0;
		}
	}
	cnt_max=max(cnt_max,cnt);
	cout<<cnt_max<<endl;
	return 0;
}


Measured memory_bytes: 640
n=int(input())
a=sorted(map(int, input().split()))
if n%2: b = [i if not(i%2) else i+1 for i in range(n)]
else: b = [i if i%2 else i+1 for i in range(n)]
if a==b:print((2**(n//2))%(10**9+7))
else: print(0)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

long long dt(const long long &a, const long long &b){
    long long bn = max(a, b);
    long long sn = min(a, b);
    return min(bn-sn, 24-bn+sn);
}

long long f(const vector<long long> &time){
    long long ret = INFLL;
    long long n = time.size();
    for(long long i=0; i<n; i++){
        for(long long j=i+1; j<n; j++){
            chmin(ret, dt(time[i], time[j]));
        }
    }
    return ret;
}

int main(){
    Init();
    long long n, ans = 0;
    cin >> n;
    map<ll, ll> cnt;
    bool chk3 = false;
    for(long long i=0; i<n; i++){
        long long d;
        cin >> d;
        cnt[d]++;
        if(cnt[d] >= 3) chk3 = true;
    }

    // ------------------------例外処理------------------------
    if(n == 1){
        cout << min((24 - cnt.begin()->first)%24, cnt.begin()->first) << endl;
        return 0;
    }

    if(n == 2 && cnt.size() == 1){
        long long t = cnt.begin()->first;
        long long rt = 24-t;
        cout << min(t, rt-t) << endl;
        return 0;
    }

    if(chk3 || cnt[0] >= 1){
        cout << 0 << endl;
        return 0;
    }
    // ------------------------例外処理------------------------

    // 12及び2個あるものの処理の処理
    vector<bool> f2(13, false);
    for(ll i=1; i<=11; i++){
        if(cnt[i] >= 2){
            cnt[i] = 0;
            f2[i] = true;
        }
    }
    f2[12] = (cnt[12] >= 1 ? true : false);
    if(f2[12]) cnt[12] = 0;

    // 残った時差を正・負の方向両方で全探索する
    vi num;
    for(ll i=1; i<=11; i++) if(cnt[i] >= 1) num.push_back(i);
    long long size = num.size();

    for(ll i=0; i<(1LL<<size); i++){
        vi time;
        time.push_back(0);
        if(f2[12]) time.push_back(12);
        for(ll i=1; i<=11; i++) if(f2[i]){ time.push_back(i); time.push_back(24-i); }

        for(ll mask=0; mask<size; mask++){
            if(i&(1LL<<mask)) time.push_back(24-num[mask]);
            else time.push_back(num[mask]);
        }
        chmax(ans, f(time));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream &s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n);
  REP (i, n) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> ans(n);
  REP (i, n) {
    for (int j = n - i - 1; j >= 0; j--) {
      if (a[j] == j) {
        a.erase(a.begin() + j);
        ans[n - 1 - i] = j;
        break;
      }
      if (j == 0) {
        cout << -1 << endl; return 0;
      }
    }
  }
  REP (i, n) cout << ans[i] + 1 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, LL> P;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL add(LL a, LL b) { return (a + b) % kMod; }
LL sub(LL a, LL b) { return (a - b + kMod) % kMod; }

int main() {
  int N, M; cin >> N >> M;
  vector<LL> S(N), T(M); cin >> S >> T;
  vector<vector<LL>> dp(N + 1, vector<LL>(M + 1));

  for (int i = 0; i <= N; ++i) dp[i][0] = 1;
  for (int j = 0; j <= M; ++j) dp[0][j] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      dp[i + 1][j + 1] = add(dp[i+1][j], dp[i][j+1]);
      if (S[i] != T[j]) dp[i + 1][j + 1] = sub(dp[i + 1][j + 1], dp[i][j]);
    }
  }
  cout << dp[N][M] << endl;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> like(M, N);

    rep(i, N) {
        int K;
        cin >> K;
        rep(j, K) {
            int A;
            cin >> A;
            like[A - 1]--;
        }
    }

    int ans = 0;

    rep(i, M) {
        if (like[i] == 0) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

const int MOD = 1000000007;

int main() {
    int X, A, B;
    cin >> X >> A >> B;

    if (A >= B) {
        printf("%s\n", "delicious");
        return 0;
    }
    if (B - A <= X) {
        printf("%s\n", "safe");
        return 0;
    }
    if (B - A > X) {
        printf("%s\n", "dangerous");
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

ll a[55];

ll solve(int N, ll K) 
{
    ll x_tot = 0;
    for0(i,N) {
        ll x_min = (a[i]+K+1)/(N+1);
        x_tot += x_min;
    }
    return x_tot;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int N; 
    cin >> N;
    for0(i,N) {
        cin >> a[i];
    }
    
    ll K = 0;
    while (true) {
        ll mink = solve(N,K);
        //pr(K) pr(mink) nl
        if (mink <= K) 
            break;
        else 
            K = mink;
    }
    cout<<K<<endl;
    return 0;
}


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

int main() {
  char s[4];
  scanf("%s", &s);
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  for (int tmp=0; tmp<(1<<3); tmp++) {
    bitset<3> s(tmp);
    vector<char> op(3);
    int sum = a;
    if (s.test(0)) {
      sum += b;
      op.at(0) = '+';
    }
    else {
      sum -= b;
      op.at(0) = '-';
    }
    if (s.test(1)) {
      sum += c;
      op.at(1) = '+';
    }
    else {
      sum -= c;
      op.at(1) = '-';
    }
    if (s.test(2)) {
      sum += d;
      op.at(2) = '+';
    }
    else {
      sum -= d;
      op.at(2) = '-';
    }
    if (sum == 7) {
      cout << a << op[0] << b << op[1] << c << op[2] << d << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int nt=0,nx=0,ny=0;
	bool flag=true;
	rep(i,n){
		int t,x,y;
		cin>>t>>x>>y;
		int dl=t-nt-(abs(nx-x)+abs(ny-y));
		if(!(dl>=0 && dl%2==0)) flag=false;
		nt=t,nx=x,ny=y;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include"stdio.h"
int main(){
    int N,D,res=1,i;
    scanf("%d%d",&D,&N);
    N+=N/100;
    for(i=0;i<D;i++){
        res*=100;
    }
    res*=N;
    printf("%d",res);
    return 0;
}


Measured memory_bytes: 1736
MOD = 10 ** 9 + 7

N = gets.to_i
C = gets.split.map(&:to_i).sort

x = 2 ** (2 * N - 1) % (2*MOD)
ans = 0
N.times do |i|
  ans = (ans + C[N - 1 - i] * (2 + i) * x /2) % MOD
end

puts ans

Measured memory_bytes: 21872
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>
#include <cstring>

using namespace std;

#define INF 1<<29

int n;
int h[150];
double dp[150][300];
       
double S(long a, long b, long height){
  a -= height;
  b -= height;
  //cout << height << endl;
  if(a == 0 && b == 0) return 0;
  if(a * b < 0){
    // cout << a << " " << b << " " << height<< " = " << (double)((a*a) + (b*b)) / (double)(abs(a) + abs(b)) / (double)2.0 << endl;
    return (double)((a*a) + (b*b)) / (double)(abs(a) + abs(b)) / (double)2.0;    
  }else{
    // cout << a << " " << b << " " << height<< " = " << (double)abs(a - b) / (double)2.0 + min(abs(a), abs(b)) << endl;    
    return (double)abs(a + b) / (double)2.0;
  }
}

double dfs(int i, int y){
  if(i == n) return 0;
  if(dp[i][y] >= 0) return dp[i][y];  
  //cout << i << " " << y << endl;
  double res = numeric_limits<double>::max()/100;
  for(int j=1;j<300;j++){
    res = min(res, dfs(i+1, j) + S(y, j, h[i]));
  }
  //cout << res << endl;
  dp[i][y] = res;
  return dp[i][y];
  return res;
}

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

  memset(dp, -1, sizeof(dp));
  double res = dfs(0, 1);
  printf("%.10f\n", res);
  return 0;
}



Measured memory_bytes: 3548
#include <iostream>
#include <string>
bool judge(std::string s, std::string p)
{
	int n = s.length();
	int m = p.length();
	char h = p[0], pos = 0;
	pos = s.find(h, pos);
	bool v;
	while (v = (pos >= 0))
	{
		for (int i = 0; v && i < m; ++i)
			v = p[i] == s[(pos + i) % n];
		if (v) break;
		pos = s.find(h, pos + 1);
	}
	return v;
}
int main()
{
	std::string s, p;
	std::cin >> s >> p;
	std::string r = judge(s, p) ? "Yes" : "No";
	std::cout << r << "\n";
	return 0;
}


Measured memory_bytes: 3204
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;


int main() {
	int A, B, X;
	string Ans;
	cin >> A >> B >> X;
	if (A > X) {
		Ans = "NO";
	} else {
		if (X - A <= B) {
			Ans = "YES";
		} else {
			Ans = "NO";
		}
	}
	cout << Ans << endl;
}


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

typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int x, ans;
  cin >> x;
  
  ans = x>0 ? 0 : 1;
  cout << ans << endl;
}


Measured memory_bytes: 3632
//============================================================================
// Name        : Hello.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int n;
	cin>>n;

	long double s=0.;

	long double a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		s+=1/a[i];

	}

	cout<<1/s<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline 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;}



signed main() {

    long double a, b, c;

    cin >> a >> b >> c;
    
    long double ra = sqrtl(a), rb = sqrtl(b), rc = sqrtl(c);
    
    cout << ((a+b+2*ra*rb<c)?"Yes\n":"No\n") ;


  
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 a, b, n;
  cin >> a >> b >> n;
  i64 x;
  if (n > b - 1) {
    x = b - 1;
  } else {
    x = n;
  }
  cout << (a * x / b) - a * (x / b) << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>
#define ll long long
#define m 100005 
#define min(a,b) a<b ? a : b

int main()
{
	ll n,k;
	scanf("%lld %lld",&n,&k);
	ll ar[m],dp[m];
	for(int i = 1; i<=n ; i++)
		scanf("%lld",&ar[i]);

	dp[1] = 0;
	
	for(ll i = 2; i<=n; i++)
	{
		dp[i] = dp[i-1] + fabs(ar[i] - ar[i-1]);
		for(int j = 1; j <= k; j++) 
            if(i - j > 0) 
            	dp[i] = min(dp[i], fabs(ar[i] - ar[i-j]) + dp[i-j]);
	}
	
	printf("%lld\n",dp[n]);	
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <map>
using namespace std;
#define INF 0x3f3f3f3f

int main(){
	long long n, m;
	scanf("%lld%lld", &n, &m);
	if (n > m) {
		swap(n, m);
	}
	if (n == 1) {
		if (m == 1) {
			printf("1\n");
		}
		else {
			printf("%lld\n", m - 2);
		}
	}
	else {
		long long sum = n * m - 2 * m - 2 * n + 4;
		printf("%lld\n", sum);
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	S = inputStr()
	print(S[:3])


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 70908
import sys
input=sys.stdin.readline
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p,0))

    while q:
        V,P,S=q.pop()
        if S==0:
            #下に遷移していくときの処理
            q.append((V,P,1))
            for new_v in G[V-1]:
                if new_v==P:continue
                score[new_v-1]+=score[V-1]
                q.append((new_v,V,0))


n,q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]

score=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    score[p-1]+=x

G=Graph(ab)
#print(G,score,sep='\n')
dfs(G,1,-1)
print(*score)

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

int n, dice[100][6];

void turnDice2(int second, char s) {
	int tmpNumber;
	if (s == 'E'){
		tmpNumber = dice[second][0];
		dice[second][0] = dice[second][3];
		dice[second][3] = dice[second][5];
		dice[second][5] = dice[second][2];
		dice[second][2] = tmpNumber;
	} 
	else if (s == 'W'){
		tmpNumber = dice[second][0];
		dice[second][0] = dice[second][2];
		dice[second][2] = dice[second][5];
		dice[second][5] = dice[second][3];
		dice[second][3] = tmpNumber;
	} 
	else if (s == 'S'){
		tmpNumber = dice[second][0];
		dice[second][0] = dice[second][4];
		dice[second][4] = dice[second][5];
		dice[second][5] = dice[second][1];
		dice[second][1] = tmpNumber;
	} 
	else if (s == 'N'){
		tmpNumber = dice[second][0];
		dice[second][0] = dice[second][1];
		dice[second][1] = dice[second][5];
		dice[second][5] = dice[second][4];
		dice[second][4] = tmpNumber;
	} 
	else if (s == 'R') {
		tmpNumber = dice[second][1];
		dice[second][1] = dice[second][2];
		dice[second][2] = dice[second][4];
		dice[second][4] = dice[second][3];
		dice[second][3] = tmpNumber;
	}
}

bool makeDice2TopEqualToDice1(int second, int result) {
	switch (result) {
		case 0:
			break;
		case 1:
			turnDice2(second, 'N');
			break;
		case 2:
			turnDice2(second, 'W');
			break;
		case 3:
			turnDice2(second, 'E');
			break;
		case 4:
			turnDice2(second, 'S');
			break;
		case 5:
			turnDice2(second, 'S');
			turnDice2(second, 'S');
			break;
		case -1:
			return false;
	}
	return true;
}

bool checkDice2EqualToDice1(int first, int second) {
	for (int i=0; i<6; i++) {
		if (dice[first][i] != dice[second][i])
			return false;
	}
	return true;
}

bool checkDice() {
	for (int i=0; i<n-1; i++) {
		for (int j=1; j<n; j++) {
			if (i == j) {
				continue;
			}
			for (int k=0; k<6; k++) {
				if (dice[i][0] == dice[j][k]) {
					makeDice2TopEqualToDice1(j, k);
					for (int l=0; l<4; l++) {
						turnDice2(j, 'R');
						if (checkDice2EqualToDice1(i, j)) {
							return false;
						}
					}
				}
			}
		}
	}
	return true;
}
int main(int argc, char const* argv[])
{
	cin >> n;
	for (int i=0; i<n; i++) {
		for (int j=0; j<6; j++) {
			cin >> dice[i][j];
		}
	}
	if (checkDice()) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    for (int i = 0; i < N; ++i)
        cin >> x[i];

    vector<int> y(M);
    for (int i = 0; i < M; ++i)
        cin >> y[i];

    sort(x.begin(), x.end(), greater<int>());
    int Z = x[0] + 1;
    while (Z <= X)
        ++Z;

    bool war = false;
    if (Z <= Y) {
        for (int i = 0; i < M; ++i) {
            if (y[i] < Z) {
                war = true;
                break;
            }
        }
    } else {
        war = true;
    }
    if (war)
        cout << "War\n";
    else
        cout << "No War\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) { ans += i; }
    }
    cout << ans << endl;
    return 0;
}


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

inline int abs(int a){
	return a<0?-a:a;
}

inline int max(int a,int b){
	return a<b?b:a;
}

int a[2001];
int main()
{
    int n,z,w;
    scanf("%d%d%d",&n,&z,&w);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if (n!=1) printf("%d",max(abs(a[n]-w),abs(a[n-1]-a[n])));
    else printf("%d",abs(a[n]-w));
}

Measured memory_bytes: 256
#include <cstdio>


void print_sharp_dot(int h, int w)
{
	int i,j;

	for (i = 0; i < h; i++) {
		if ((i % 2) == 0) {
			for (j = 0; j < w; j++) {
				if ((j % 2) == 0)
					printf("#");
				else if ((j % 2) == 1)
					printf(".");
			}
			printf("\n");
		} else if ((i % 2) == 1) {
			for (j = 0; j < w; j++) {
				if ((j % 2) == 0)
					printf(".");
				else if ((j % 2) == 1)
					printf("#");
			}
			printf("\n");
		}
	}
}

int main()
{
	int h,w;

	while (true) {
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		print_sharp_dot(h, w);

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2604
K = int(input())
[A, B] = list(map(int, input().split()))
if (B-A-1)>=K:
    print('OK')
else:
    x=A//K
    if A<=(x+1)*K<=B or A%K==0 or B%K==0:
        print('OK')
    else:
        print('NG')

Measured memory_bytes: 9192