akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int A, B, C; 
    cin >> A >> B >> C;
    int a = 0;
    int ans = 0;
    if (A % 2 == B % 2 && A % 2 != C % 2) {
        ans++;
        A++;
        B++;
    }
    if (B % 2 == C % 2 && A % 2 != C % 2) {
        ans++;
        B++;
        C++;
        
    }
    if (A % 2 == C % 2 && A % 2 != B%2) {
        ans++;
        A++;
        C++;
    }
    //cout << A <<" "<< B <<" "<< C<<endl;
    if (A % 2 == B % 2 && A % 2 == C % 2) {
        a=max({ A,B,C });
        ans += (3 * a - (A + B + C))/2;
    }
    cout << ans;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int time_once = 1900 * M + 100 * (N-M);
    // prob = 1 / 2^M * (1 - 1/2^M)^k;
    int prob = 1;
    for(int i = 0; i < M; ++i) {
        prob *= 2;
    }
    cout << time_once * prob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	ll ans = 0;
	vector<pair<int,int>> cnt(n);
	sort(a,a+n);
	int itr = 0;
	cnt[0].second = a[0];
	cnt[0].first++;
	for(int i=1; i<n; i++){
		if(a[i]!=a[i-1]){
			itr++;
			cnt[itr].second=a[i];
		}
		cnt[itr].first++;
	}
	sort(cnt.begin(),cnt.end());
	for(int i=0; i<cnt.size()-k; i++){
		ans += cnt[i].first;
	}
	cout << ans << endl;

}

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

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as[i] = a;
        sum += a;
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(5));
    for (int i = 0; i < n; i++) {
        dp[i + 1][0] = dp[i][0] + as[i];
        dp[i + 1][1] = min(min(dp[i][0], dp[i][1]) + (as[i] ? as[i] & 1 : 2), dp[i + 1][0]);
        dp[i + 1][2] = min(min(dp[i][1], dp[i][2]) + (as[i] & 1 ? 0 : 1), dp[i + 1][1]);
        dp[i + 1][3] = min(min(dp[i][2], dp[i][3]) + (as[i] ? as[i] & 1 : 2), dp[i + 1][2]);
        dp[i + 1][4] = min(min(dp[i][3], dp[i][4]) + as[i], dp[i + 1][3]);
    }
    cout << dp[n][4] << endl;
}


Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N+1][N+1];
  int m = x.size();
  int n = y.size();
  int maxL=0, i, j;

  x = ' ' + x;
  y = ' ' + y;

  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=1;j<=n;j++)c[0][j] = 0;
  
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i] == y[j])c[i][j] = c[i-1][j-1]+1;
      else c[i][j] = max(c[i-1][j], c[i][j-1]);
      maxL = max(maxL, c[i][j]); 
    }
  }
  return maxL;
}

int main(){
  string s1, s2;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }

  return 0;
}



Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int main(){
    LL pre[100005];
    LL suf[100005];
    LL sum[100005];
    int a[100005];
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 1;i<=n;i++)
        scanf("%d",&a[i]);
    pre[0]=0;
    suf[n+1]=0;
    sum[0]=0;
    for(int i = 1;i<=n;i++){
        pre[i]=pre[i-1]+max(a[i],0);
        sum[i]=sum[i-1]+a[i];
    }
    for(int i = n;i>=1;i--){
        suf[i]=suf[i+1]+max(a[i],0);
    }
    LL ans=0;
    for(int i=1;i<=n-k+1;i++){
        ans=max(ans,pre[i-1]+suf[i+k]+max(sum[i+k-1]-sum[i-1],0ll));
    }
    printf("%lld\n",ans);
}
/*
1441152
*/

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
    for(int C_X = 0; C_X <= 100; C_X++){
        for(int C_Y = 0; C_Y <= 100; C_Y++){
            int H;
            for(int i = 1; i < N; i++){
                if(h[i] > 0){
                    H = h[i] + abs(x[i] - C_X) + abs(y[i] - C_Y);
                    break;
                }
            }
            for(int i = 0; i < N; i++){
                if(h[i] != max(H - abs(x[i] - C_X) - abs(y[i] - C_Y), 0)) break;
                if(i == N - 1){
                    cout << C_X << " " << C_Y << " " << H;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef long long ll;

void solve() {
  int N;
  cin >> N;
  for (int i = 0; i < 50001; i++) {
    if ((int)((double)(i)*1.08) == N) {
      cout << i << endl;
      return;
    }
  }
  cout << ":(" << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef long long ll;

ll min2(ll a,ll b){
  if(a < b){
    return a;
  }

 else{
   return b;
 }
}

int main(void){

  ll q , h , s , d;
  ll n;

  scanf("%lld %lld %lld %lld %lld",&q ,&h ,&s ,&d, &n);

  ll q4 , h2 , min;
  q4 = q * 4;
  h2 = h * 2;
  
  min = min2(s,min2(q4,h2));


  ll ans , m2 = min*2 , k;
  k = min2(m2,d);

  if(n%2 == 0){
    ans = k* (n/2);
  }

  else{
    ans = k* (n/2) + min;
  }

  printf("%lld\n",ans);

  return 0;

}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<long> H(N);
  rep(i, 0, N) {
    cin >> H[i];
  }

  int n = 0;
  int ans = 0;
  rep(i, 1, N) {
    if (H[i] <= H[i-1]) {
      ++n;
    } else {
      ans = max(ans, n);
      n = 0;
    }
  }
  ans = max(ans, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
if n % 2 == 0:
    ans = list(reversed(a[1::2])) + a[0::2]
else:
    ans = list(reversed(a[0::2])) + a[1::2]
for i in ans:
    print(i,end=" ")

Measured memory_bytes: 26020
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

// s = "aabbbc" -> [[a,2],[b,3],[c,1]]
vector<pair<char,int>> rle (string s) {
  vector<pair<char,int>> res;
  int n = (int)s.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && s[j] == s[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(s[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  string s;
  cin >> s;
  int n = s.size();

  int ans = 0;
  rep(i,n-1) {
    if (s[i] != s[i+1]) ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

const int MAXN = 55;
typedef unsigned long long ll;

ll dp[MAXN][2];
int N, P, A[MAXN];

int main(){
  scanf("%d %d", &N, &P);
  for(int i=1; i<=N; ++i) scanf("%d", &A[i]);
  dp[0][0] = 1;
  for(int i=1; i<=N; ++i){
    dp[i][0] += dp[i - 1][0], dp[i][1] += dp[i - 1][1];
    if((A[i] & 1) == 0) dp[i][0] += dp[i - 1][0], dp[i][1] += dp[i - 1][1];
    else dp[i][0] += dp[i - 1][1], dp[i][1] += dp[i - 1][0];
  }
  printf("%llu\n", dp[N][P]);
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  bool ok = (s[0] == 'A');
  int cnt = 0;
  for(int i = 1; i < s.length(); ++i)
  {
    if (s[i] == 'C') cnt += ((2 <= i && i <= s.length() - 2) ? 1 : 2);
    else ok &= ((int)'a' <= (int)s[i] && (int)s[i] <= (int)'z');
  }
  ok &= (cnt == 1);
  cout << (ok ? "AC" : "WA");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<b)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}
#define SHOWQUEUE(a) {std::queue<decltype(a.front())> tmp(a);std::cout << #a << "\t:";for(int i=0; i<static_cast<int>(a.size()); ++i){std::cout << tmp.front() << "\n";tmp.pop();}std::cout << "\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000000001;
constexpr int MOD = 1000000007;

int main() {
	INIT;
	int n;
	while (std::cin >> n) {
		int cnt = 0;
		REP(i, 10) REP(j, 10) REP(k, 10) {
			int l = n - i - j - k;
			if (IN(0, l, 10)) ++cnt;
		}
		OUT(cnt)BR;
	}
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,a,b;
	cin >> n >> a >> b;
	if ((a-b)&1){
		int A = abs(a-1), B = abs(n-a), C = abs(b-1), D = abs(n-b);
		cout << min(max(A,C)-abs(b-a)/2,max(D,B)-abs(b-a)/2);
	}
	else cout << abs(a-b)/2;
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

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

	int X=in(),Y=in();
	if((X+Y)%3){
		out(0);
		return 0;
	}
	int offset = (X+Y)/3;
	int posX = X-offset;
	if(posX<0 || posX>offset){
		out(0);
		return 0;
	}

	Combination comb(offset);
	out(comb.Caluclation(offset,posX));
	return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}

int main(){
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
int s=0;
for(int i=0;i<k;i++)
s+=a[i];
cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3564
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());

        st = new StringTokenizer(br.readLine());
        int a[] = new int[n];

        for(int i=0 ; i<n ; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }

        Arrays.sort(a);

        int min = a[0];
        int max = a[n-1];

        int minAns = Integer.MAX_VALUE;
        for(int i=min ; i<=max ; i++) {
            int total = 0;
            for(int j=0 ; j<n ; j++) {
                total += (a[j]-i)*(a[j]-i);
            }
            minAns = Math.min(minAns, total);
        }

        pw.println(minAns);
        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 22228
from collections import Counter 
n=int(input())
S=[Counter(input()) for _ in range(n)]
s=S[0]
for i in range(n):
    for k,v in s.items():
        s[k]=min(S[i][k],s[k])
s=sorted(s.items())
ans=''
for k,v in s:
    ans+=k*v
print(ans)

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

int main(){
  vector<long> jou(43,0);
  jou[0]=1;
  for(int i=1;i<43;i++){
    jou[i]=jou[i-1]*2;
  }
  long n;
  cin >> n;
  int x=0;
  for(int i=0;i<43;i++){
    if(jou[i]>n)
      break;
    x++;
  }
  cout << jou[x]-1 << endl;
}
    

    


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int i = Integer.parseInt(sc.get());
		System.out.println(i == 0 ? 1 : 0);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

#define int long long int

const int maxn = (5012);
int dp[maxn][maxn], fen[3 * maxn], pl[maxn][3];
int n;

void add(int idx) {
	for (; idx < 3 * maxn; idx += (idx & -idx)) {
		fen[idx]++;
	}
	return;
}

int get(int idx) {
	int ret = 0;
	for (; idx > 0; idx -= (idx & -idx)) {
		ret += fen[idx];
	}
	return ret;
}

void antiadd(int idx) {
	for(; idx < 3 * maxn; idx += (idx & -idx)) {
		fen[idx]--;
	}
	return;
}

int32_t main() {
	cin >> n;
	for (int i = 1; i <= 2 * n; i++) {
		char c;
		int num;
		cin >> c >> num;
		if(c == 'B') pl[num][0] = i;
		else pl[num][1] = i;
	}
	for (int i = 1; i <= n; i++) {
		add(pl[i][0]);
		dp[0][i] = i - get(pl[i][0]) + dp[0][i - 1];
	}
	for (int i = 1; i <= n; i++) {
		antiadd(pl[i][0]);
	}
	for (int i = 1; i <= n; i++) {
		add(pl[i][1]);
		dp[i][0] = i - get(pl[i][1]) + dp[i - 1][0];
	}
	for (int i = 1; i <= n; i++) {
		antiadd(pl[i][1]);
	}
	for (int i = 1; i <= n; i++) {
  		add(pl[i][1]);
		for (int j = 1; j <= n; j++) {
   			add(pl[j][0]);
			dp[i][j] = min(dp[i - 1][j] + i + j - get(pl[i][1]), dp[i][j - 1] + i + j - get(pl[j][0]));
		}
		for (int j = 1; j <= n; j++) {
			antiadd(pl[j][0]);
		}
	}
	cout << dp[n][n];
}

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

int main() {
    long long  a, b, c, d;
    cin >> a >>  b >> c >> d;
    long long ans;
    ans = a * c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d); 
    cout << ans << endl;
    return 0;
}


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

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

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

	long long L = 0;
	long long ans = 1e18;
	for (int i = 0; i < n - 1; i++) {
		L += a[i];
		R -= a[i];
		ans = std::min(ans, std::abs(L - R));
	}
	
	std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100000;
const int Pt = 1e9 + 7;
int n;
LL a[maxn + 5], rg[maxn + 5];
LL qwe(LL x, LL y) {
	LL t = 1;
	while(y > 0) {
		if(y & 1)t = t * x % Pt;
		y /= 2;
		x = x * x % Pt;
	}
	return t;
}
LL A, B;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; B = (B + rg[i]) % Pt, i++) rg[i] = qwe(i, Pt - 2);
	for(int i = 1; i <= n; i++)scanf("%lld", &a[i]);
	LL res = 0;
	LL x = 1;
	for(int i = 1; i <= n; i++) {
		if(i > 1)A = (A + rg[i]) % Pt, B = (B - rg[n - i + 2] + Pt) % Pt;
		res = (res + (A + B) % Pt * a[i]) % Pt;
		x = x * i % Pt;
	} 
	printf("%lld\n", res * x % Pt);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<cassert>

using namespace std;
const int mod = 1000000007;

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector< vector<int> > dp(H+1,vector<int>(W,0)); dp[0][0] = 1;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            for(int k = 0; k < 1 << (W - 1); ++k){
                //check if two horizontal lines are connecting
                bool ok = true;
                for(int l = 0; l < W - 2 ; ++l){
                    if(((k >> l) & 1) && ((k >> (l + 1)) & 1)){
                        ok = false;
                    }
                }
                if(ok){
                    if(j >= 1 && ((k >> (j - 1)) & 1)){
                        // the case which goes left
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }else if(j <= W - 2 && ((k >> j) & 1)){
                        //the case which goes right
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }else{
                        //the case which goes straight
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }
    }
    cout<< dp[H][K-1] << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(int argc, char **argv)
{
	int n ;
    cin>>n;
    
    int* vectorNum1 = new int[n];
    int* vectorNum2 = new int[n];
    
    for(int i =0;i<n;i++){
        cin>>vectorNum1[i];
    }
    
    for(int i =0;i<n;i++){
        cin>>vectorNum2[i];
    }
    
    // p = 1
    long double distance[4];
    for(int i=0;i<4;i++){
        distance[i] = 0.0;
    }
    
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[0]+=sum;
    }
    cout.setf(ios::fixed);
    cout<<setprecision(6)<<distance[0]<<endl;
    
    // p = 2
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[1]+= pow(sum,2);
    }
    
    
    distance[1] = sqrt(distance[1]);
    
    cout<<setprecision(6)<<distance[1]<<endl;
    
    // p = 3
    for(int i =0 ;i<n;i++){
        int sum = abs(vectorNum1[i]-vectorNum2[i]);
        distance[2]+= pow(sum,3);
    }
    
    distance[2] = cbrt(distance[2]);
    
    cout<<setprecision(6)<<distance[2]<<endl;
    
    long double max = 0;
    
    for(int i =0 ;i<n;i++){
        if(i==0){
            max = abs(vectorNum1[i]-vectorNum2[i]);
        }
        if(abs(vectorNum1[i]-vectorNum2[i])>max){
            max = abs(vectorNum1[i]-vectorNum2[i]);
        }
        
        distance[3] = max;
    }
    cout<<setprecision(6)<<distance[3]<<endl;
    
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
ll pow1(ll a, ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		{
			ans=ans*a;
		}
		a=a*a;
		b=b>>1;
	}
	return ans;
}
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	vector<string> v;
	string s;
	for(i=0;i<n;i++)
	{
		cin>>s;
		v.pb(s);
	}
	int arr1[n],arr2[m];
	memset(arr1,0,sizeof(arr1));
	memset(arr2,0,sizeof(arr2));
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
			if(v[i][j] == '#')
			{
				arr1[i] = 1;
				break;
			}
	}
	for(j=0;j<m;j++)
	{
		for(i=0;i<n;i++)
			if(v[i][j] == '#')
			{
				arr2[j] = 1;
				break;
			}
	}
	int f = 0;
	for(i=0;i<n;i++)
	{
		f = 0;
		for(j=0;j<m;j++)
			if(arr1[i] && arr2[j])
			{
				f = 1;
				cout<<v[i][j];
			}
		if(f==1)
			cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,w;cin>>h>>w;
    vector<vector<int>> a(h);
    rep(i,h){
        a[i]=vector<int>(w);
        rep(j,w){
            cin>>a[i][j];
        }
    }
    bool r=true;
    int cnt = 0;
    int x = 0, y = 0;
    int ans = 0;
    vector<vector<int>> anss;
    while(cnt<h*w-1){
        int nx,ny;
        if(y%2==0){
            if(x==w-1){
                nx=x,ny=y+1;
            }else{
                nx=x+1,ny=y;
            }
        }else{
            if(x==0){
                nx=x,ny=y+1;
            }else{
                nx=x-1,ny=y;
            }
        }
        if(a[y][x]%2==1){
            ans++;
            anss.push_back({y+1,x+1,ny+1,nx+1});
            a[ny][nx]++;
        }
        x=nx,y=ny;
        cnt++;
    }
    cout<<ans<<endl;
    /*for(vector<int> an:anss){
        for(int aa:an){
            cout<<aa<<" ";
        }
        cout<<endl;
    }*/
    for(int i=0; i<ans; i++){
        for(int j=0; j<4; j++){
            cout<<anss[i][j];
            if(j!=3)cout<<" ";
        }
        if(i!=ans-1)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 10032
//
// Created by Kiran Chavhan on 21/06/2020.
//

#include<iostream>

#define int long long
#define MOD 1000000007
using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin>>c;
    if(c>96)cout<<"a";
    else cout<<"A";
}

Measured memory_bytes: 3064
def main():
    gcd = lambda n, m : gcd(m, n % m) if m != 0 else n
    while True:
        try:
            n, m = map(int, input().split())

            g = gcd(n, m)
            l = n * m // g

            print(g, l)
        except:
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 7656
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort()

ans = 0
for i in range(n):
    ans += l[i][0] * min(m, l[i][1])
    m -= l[i][1]
    if m <= 0:
        break

print(ans)


Measured memory_bytes: 27760
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans; string s,t;
    cin >> n >> s >> t ; 
    ans = 2*n; 
    for (int i=0;i<n;i++){
        if (s[i] == t[0]){
            bool ok=true;
            for (int j=0,k=i;k<n;k++,j++){
                if (s[k] != t[j]) ok=false;
            }
            if (ok) { ans -= (n-i); break; }
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
  try (Scanner sc = new Scanner(System.in)) {
      String s=sc.next();
      int a=s.charAt(0)-'0', b=s.charAt(1)-'0', c=s.charAt(2)-'0', d=s.charAt(3)-'0';
        if(a-b-c-d ==7) System.out.printf ("%d-%d-%d-%d=7\n",a,b,c,d);
        else if(a-b-c+d ==7) System.out.printf ("%d-%d-%d+%d=7\n ",a,b,c,d);
        else if(a-b+c-d ==7) System.out.printf ("%d-%d+%d-%d=7\n",a,b,c,d);
        else if(a-b+c+d ==7) System.out.printf ("%d-%d+%d+%d=7\n",a,b,c,d);
        else if(a+b-c-d ==7) System.out.printf ("%d+%d-%d-%d=7\n",a,b,c,d);
        else if(a+b-c+d ==7) System.out.printf ("%d+%d-%d+%d=7\n",a,b,c,d);
        else if(a+b+c-d ==7) System.out.printf ("%d+%d+%d-%d=7\n",a,b,c,d);
        else if(a+b+c+d ==7) System.out.printf ("%d+%d+%d+%d=7\n",a,b,c,d);
  }
 }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define MP make_pair
#define PII pair<int, int>
typedef long long LL;
const LL P = 998244353;
const int INF = 0x3fffffff;
const int N = 100010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a,b,c;

int main(){
	cin>>a>>b>>c;
	int d = b+c-a;
	cout<<max(d,0);
	return 0;
}

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

struct string {
  char str[101];
};

int comp(const void* str1, const void* str2) {
  return strcmp(str1, str2);
}

#define BUF_SIZE 10200
int main(void) {
  FILE* fp = stdin;
  char line[BUF_SIZE];
  int i;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, len;
  sscanf(line, "%d %d", &num, &len);
  struct string *words = malloc(sizeof(struct string)*num);

  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    strncpy(words[i].str, line, len+1);
  }
  qsort(words, num, sizeof(struct string), comp);

  char buf[BUF_SIZE];
  int pos = 0;
  for(i = 0; i < num; i++) {
    char* b = words[i].str;
    char* tmp;
    for(tmp = b; *tmp != '\n'; tmp++) {
      buf[pos++] = *tmp;
    }
  }
  buf[pos] = '\0';

  printf("%s\n", buf);

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		setIO();

		int N = ni() % 1000;
		if (N == 0) N = 1000;
		out.println(1000 - N);
		
		f.close();
		out.close();
	}

	static BufferedReader f;
	static PrintWriter out;
	static StringTokenizer st;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIn(String s) throws IOException {
		f = new BufferedReader(new FileReader(s));
	}

	static void setOut(String s) throws IOException {
		out = new PrintWriter(new FileWriter(s));
	}

	static void setIn() {
		f = new BufferedReader(new InputStreamReader(System.in));
	}

	static void setOut() {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}

	static void setIO(String s) throws IOException {
		setIn(s + ".in");
		setOut(s + ".out");
	}

	static void setIO() {
		setIn();
		setOut();
	}
}


Measured memory_bytes: 32792
// atcoder/intro-heuristics
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

vec<lli> C;
int D;
const int CONTESTS = 26;
const int DAYS = 365;
lli SCORE[DAYS][CONTESTS];

using schedule = vec<int>;

void problem_B(void)
{
  schedule s(D);
  cin >> s;
  each (i, s) --i;

  static int last[CONTESTS];
  fill(last, last + CONTESTS, -1);

  lli x = 0;
  lli y = 0;
  for (int i = 0; i < D; ++i) {
    x += SCORE[i][s[i]];
    last[s[i]] = i;
    for (int j = 0; j < CONTESTS; ++j) {
      y += C[j] * (i - last[j]);
    }
    cout << x - y << endl;
  }

  return ;
}

lli calc_score(schedule s)
{
  return 0;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  C.resize(26);

  cin >> D >> C;
  for (int i = 0; i < D; ++i) {
    for (int j = 0; j < CONTESTS; ++j) {
      cin >> SCORE[i][j];
    }
  }

  problem_B();

  return 0;
}


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

int main(){
    int A, B;
    char op;
    cin >> A >> op >> B;

    int res = 0;
    if(op == '+'){
        res = A + B;
    }
    else{
        res = A - B;
    }
    cout << res << endl;
}

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

int main(){
  int N, D;
  cin >> N >> D;       //一人が監視できる木の本数は2*D+1　監視範囲が被らない良し

  if(N%(2*D+1) == 0)
    cout << N/(2*D+1) << endl;
  else
    cout << N/(2*D+1) + 1 << endl;

}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 105
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,ans,cnt[M];
char buf[M];
int main()
{
	scanf("%s", buf);
	n = ans = strlen(buf);
	REP(i,0,n-1)
	{
		if(buf[i]>='a') cnt[buf[i]-'a']++;
		else cnt[buf[i]-'0'+28]++;
	}

	REP(i,0,50) while(cnt[i] && cnt[i+1] && cnt[i+2])
	{
		cnt[i]--;
		cnt[i+1]--;
		cnt[i+2]--;
		REP(j,i+3,50)
		{
			if(!cnt[j]) break;
			cnt[j]--;
			ans--;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1120
#include<iostream>
#include<algorithm>
static const int MAX=200000;


using namespace std;
int main(){
  int R[MAX],n;
  cin>>n;

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

  int minv=R[0];
  int maxv=R[1]-R[0];

  for(int j=1;j<n;j++){
    maxv=max(maxv,R[j]-minv);
    minv=min(minv,R[j]);
  }

  cout<<maxv<<endl;

  return 0;
}

Measured memory_bytes: 3884
//ABC138A
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}
int main(){
	int n;
	scanf("%d",&n);
	int v[n];
	int i, j;
	double sigma;
	for(i=0;i<n;i++){
		scanf("%d",&v[i]);
	}
	quick_sort(v, 0, n-1);
	sigma = v[0];
	for(j=1;j<n;j++){
		sigma = (sigma + v[j])/2.0;
	}
	printf("%lf",sigma);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//ofstream cout("output.out");

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

using ll = long long;
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;

int main()
{
	fast();
	ll a, b, n, x, rs;
	ll pos;
	cin >> a >> b >> n;
	if(n < b){
		int cnt = 0;
		ll rs = -1e9;
		for(ll i = n; cnt < 1000 && i >= 0;i--, cnt++){
			ll t = (a * i) / b - a * (i / b);
			if(rs < t){
				rs = t;
			}
		}
		cout << rs;
	}
	else{
		int cnt = 0;
		ll rs = -1e9;
		for(ll i = b; cnt < 1000 && i >= 0;i--, cnt++){
			ll t = (a * i) / b - a * (i / b);
			if(rs < t){
				rs = t;
			}
		}
		cout << rs;
	}
}			

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

using namespace std;

int main() {
    string S;
    cin >> S;

    int cut = 2;
    while (cut < S.size()) {
        int h = (S.size() - cut) / 2;
        string f = S.substr(0, h);
        string b = S.substr(h, h);
        if (f == b) {
            cout << S.size() - cut << endl;
            return 0;
        }
        cut += 2;
    }

    cout << -1 << endl;
    return 0;
}

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

int n;

int main(){
  cin >> n;
  vector<int> kai(n+1, 1e9);
  kai[0] = 0;
  for(int i = 0; i < n; i++){
    kai[i+1] = min(kai[i+1], kai[i] + 1);
    
    int six = 6;
    while(i + six <= n){
      kai[i + six] = min(kai[i+six], kai[i] + 1);
      six *= 6;
    }
    int nine = 9;
    while(i + nine <= n){
      kai[i + nine] = min(kai[i+nine], kai[i] + 1);
      nine *= 9;
    }
  }
  cout << kai[n] << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
    string S;
    cin >> S;
    int N = S.length();
    S += "..";
    rep(i,N){
        if(S[i] == S[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        } else if(S[i] == S[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;

    return 0;
}

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

int main(){
    int x, temp1, temp2;
    cin >> x;
    temp1 = x / 500;
    temp2 = (x - temp1 * 500) / 5;
    cout << 1000 * temp1 + 5 * temp2 <<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2 << 28)

n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
    x, y = [int(i) for i in input().split()]
    al[x-1].add(y-1)

dp = [-1] * n


def rec(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for nv in al[v]:
        ret = max(ret, rec(nv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(n):
    ans = max(ans, rec(v))

print(ans)


Measured memory_bytes: 189772
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N, A, B;
  scanf("%d", &N);
  scanf("%d", &A);
  scanf("%d", &B);
  std::vector<int > X(N);
  for (int i=0; i<N; i++){
    scanf("%d", &X[i]);
  }
  long long ans = 0;
  for (int i=1; i<N; i++){
    ans += (long long)std::min((long long)(X[i]-X[i-1])*A, (long long)B);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <string>

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a < 10 && b < 10){
        cout<<a*b;
    }
    else{
        cout<<"-1";
    }

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main() {
    int N;
    cin >> N;
    array<array<int, 10>, 10> c {};
    for (int k = 1; k <= N; k++) {
        auto s = to_string(k);
        c[s[0] - '0'][s[s.size() - 1] - '0']++;
    }
    int ans = 0;
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) {
        ans += c[i][j] * c[j][i];
    }
    cout << ans << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

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

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define endl "\n";
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

const int N = 100005;
const int MOD = 1000000007;

void __print(int x) {cerr << x;} void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif
using ll = long long;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    n%=10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon";
    else if(n==3)
        cout<<"bon";
    else
        cout<<"pon";
}



Measured memory_bytes: 3620
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
	int i=0;
	int Prime_COUNT = 0;
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	String str_A = br.readLine();
	
	int n = Integer.parseInt(str_A);
	
	int A[];
	A = new int[n];
	 
	for(i=0;i<A.length;i++){
	    String a = br.readLine();
	    A[i] = Integer.parseInt(a);
	}
	
	for(i=0;i<A.length;i++){
	    isPrime(A[i]);
	    if(isPrime(A[i]) == true) Prime_COUNT++;
	}
	
	System.out.println(Prime_COUNT);
	return ;
    }

    public static boolean isPrime(int x){
	if(x == 2) return true;
	if(x<2 || x%2 == 0) return false;

	int i = 3;
	while(i<= Math.sqrt((double)x)){
	    if(x%i == 0) return false;
	    i = i+2;
	}

	return true;
    }
}
      



Measured memory_bytes: 29648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static int numint[];
	public static int multiplied[];

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String countstr = str;
		int countint = Integer.parseInt(countstr);
		str = br.readLine();
		String numstr[] = str.split(" ", 0);
		numint = new int[countint];
		for (int i = 1; i <= countint; i++) {
			numint[i - 1] = Integer.parseInt(numstr[i - 1]);
		}
		multiplied = new int[countint];
		multiplied[0] = numint[0];
		for (int j = 1; j < countint; j++) {
			int gcm = Euclid(j - 1);
			multiplied[j] = multiplied[j - 1] * numint[j] / gcm;
		}
		System.out.println(multiplied[countint - 1]);

	}

	public static int Euclid(int k) {
		int x = multiplied[k];
		int y = numint[k + 1];
		while (x != y) {
			if (x < y) {
				y = y - x;
			} else {
				x = x - y;
			}
		}
		return x;
	}
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    int length;
    for(int i = 1; i < n/2; i++){
        //cout << s.substr(0, n/2-i) << endl;
            //cout << s.substr(n/2-i, n/2-i) << endl;
        if(s.substr(0, n/2-i) == s.substr(n/2-i, n/2-i)){
            length = s.size() - 2*i;
            break;
        }
    }

    cout << length << endl;

    return 0;
}

Measured memory_bytes: 256