akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int Q;
  cin >> Q;
  vector<int> l(Q), r(Q);
  REP(i, Q)
  cin >> l[i] >> r[i];
  // 素数列挙（エラトステネスの篩）
  vector<bool> is_prime(100001);
  REP(i, 100001)
  is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i * i <= 100000; i++)
  {
    if (is_prime[i])
    {
      for (int j = 2; i * j <= 100000; j++)
        is_prime[i * j] = false;
    }
  }
  // 2017に似た数の列挙
  vector<bool> is_like_prime(100001);
  REP(i, 100001)
  is_like_prime[i] = false;
  for (int i = 3; i <= 100000; i += 2)
  {
    if (is_prime[i] && is_prime[(i + 1) / 2])
      is_like_prime[i] = true;
  }
  // 累積和
  vector<int> c(100001);
  c[0] = 0;
  REP(i, 100000)
  c[i + 1] = c[i] + (is_like_prime[i + 1] ? 1 : 0);
  REP(i, Q)
  cout << c[r[i]] - c[l[i] - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
  string s, t;
  bool flag = true;
  cin >> s >> t;
  rep(i,0,s.size()) {
      if(s[i]!=t[i]) flag=false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3132
# abc057_b.py
def calc(p1, p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])


N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
    dist = 10**9
    ans = 0
    for j in range(M):
        now_dist = calc(ab[i], cd[j])
        if dist > now_dist:
            dist = now_dist
            ans = j+1
    print(ans)


Measured memory_bytes: 9164
#include<stdio.h>
#include<math.h>

struct Point{double x,y;};

void koch(int n,Point a,Point b){
  if(n == 0) return;

  Point s,t,u;

  double rad3 = M_PI * 60.0 /180.0;

  s.x=(a.x * 2.0 + b.x) / 3.0;
  s.y=(a.y * 2.0 + b.y) / 3.0;
  
  t.x=(a.x + b.x * 2.0) / 3.0;
  t.y=(a.y + b.y * 2.0) / 3.0;

  u.x=((t.x - s.x) * cos(rad3) - (t.y - s.y) * sin(rad3)) + s.x;
  u.y=((t.x - s.x) * sin(rad3) + (t.y - s.y) * cos(rad3)) + s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);  
}

int main(void){
  Point a,b;
  int n;

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
 
  scanf("%d",&n);

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){long s;
cin >> s;
long cnt = 0; long i = s; long k;
map<long, long> mp;
while(mp[i] == 0){
    cnt++;
    mp[i] = 1;
    if(i % 2 == 0){
        k = i/2;
    }
    else k = 3 * i + 1;
    i = k;
}

show(cnt+1);

return 0;
}

Measured memory_bytes: 256
import sys, heapq
# def LI(): return list(map(int, sys.stdin.readline().split()))
# def LS(): return list(sys.stdin.readline())

N = int(input())
H = list(map(int, sys.stdin.readline().split()))

res = 0
cnt = 0
for i in range(N - 1):
    if H[i] < H[i + 1]:
        res = max(res, cnt)
        cnt = -1
    cnt += 1

res = max(res, cnt)
print(res)

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

bool IsPrime(int num){
  if (num < 2) {
		return false;
	}else if (num == 2) {
		return true;
	}else if (num % 2 == 0) {
		return false;
	} // 偶数はあらかじめ除く
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
	    // 素数ではない
      return false;
    }
  }
  // 素数である
  return true;
}

int main() {
	int X;
	cin >> X;
	while (true) {
		if (IsPrime(X)) {
			break;
		}
		X++;
	}
  cout << X << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<string,int> mmap;
	int n; cin>>n;
	string s;
	int ans = 0;
	while(n--) {
		cin>>s;
		if(mmap.count(s)==0) {
			ans++;
			mmap[s]=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 19216
//mangesh2102000

#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000007

const int N = 25;
const int INF = 1e18L + 5;

int can[N][N];
int dp[(1<<N)];

void solve(int t)
{	
	int n;
	cin >> n;	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin >> can[i][j];
		}
	} 	

	dp[0] = 1;
	for(int mask=0;mask<(1<<n);mask++)
	{
		int a = __builtin_popcountll(mask);
		for(int b=0;b<n;b++)
		{
			if(can[a][b] and !(mask & (1<<b)))
			{	
				dp[(mask)|(1<<b)] += dp[mask];
				if(dp[(mask)|(1<<b)] >= mod)
					dp[(mask)|(1<<b)] -= mod;
			}
		}
	}

	// for(int mask=0;mask<(1<<n);mask++)
	// {
	// 	cout << mask << " - " << dp[mask] << "\n";
	// }

	cout << dp[(1<<n)-1];
    //cout << "Case #" << t << ": ";    
}   


int32_t main()
{
    IOS;
    int t;
    t=1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 18688
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
int main(){
  int N,K;
  cin >> N >> K;
  int A[N];
  for(int i=0;i<N;++i){
    cin >> A[i];
  }
  int num_min=1;
  int res=0;
  pair<int,int>p[1];
  for(int i=0;i<N;++i){
      if(A[i]==num_min){
        res=i;
        break;
      }
  }
  p[0]={A[res],res};
  int num_left=res;
  int num_right=res;
  int ans=0;
  int left_tmp=0;
  if(num_left>0){
    while(left_tmp<num_left){
    left_tmp+=K-1;
    ++ans;
  }
  }
    if(num_left<N-1){
    while(left_tmp<N-1){
    ++ans;
    left_tmp+=K-1;
    }
  }
  cout << ans;  
  }

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

map<ll, int> prime_factor(ll n){
	map<ll, int> res;
	for(ll i = 2; i*i<=n; i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1) res[n]++;
	return res;
}

set<ll> all_divisor(ll n){
	set<ll> res;
	for(ll i = 1; i*i<= n; i++){
		if(n%i==0){res.insert(i);res.insert(n/i);}
	}
	return res;
}


int main(){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    ll sum = 0;
    rep(i, n) cin >> a[i], sum += a[i];
    auto s = all_divisor(sum);

    auto ok = [&](ll x) {
        vector<int> b;
        rep(i, n) {
            if(a[i] % x > 0) b.push_back(a[i]%x);
        }
        sort(all(b));
        int N = b.size();
        vector<ll> sumL(N+1, 0), sumR(N+1, 0);
        rep(i, N) sumL[i+1] = sumL[i] + b[i];
        drep(i, N) sumR[i] = sumR[i+1] + (x-b[i]);
        ll ret = INF;
        rep(i, N) chmin(ret, max(sumL[i], sumR[i+1]));
        return ret <= k;
    };
    ll ans = 1;
    for(auto p : s) {
        if(ok(p)) ans = p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	int K;
	cin >> s >> K;
	for (int i = 0; i != s.length(); ++i) {
		if (s[i] != 'a') {
			int a = 'z' - s[i] + 1;
			if (a <= K) {
				K -= a;
				s[i] = 'a';
			}
		}
	}
	s[s.length() - 1] = 'a' + (((s[s.length() - 1] - 'a') + K) % 26);
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
ll mat[22][22];
ll dp[22][1<<21];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    rep(i,1,n+1){
        rep(j,1,n+1){
            cin>>mat[i][j];
        }
    }
    dp[0][0]=1;
    rep(i,1,n+1){
        rep(j,0,1<<n){
            if(__builtin_popcount(j)!=i-1)continue;
            rep(k,1,n+1){
                ll nst = j|(1<<(k-1));
                if(j^(1<<(k-1)) && mat[i][k]==1) dp[i][nst]=soma(dp[i][nst],dp[i-1][j]);
            }
        }
    }
    cout<<dp[n][(1<<(n))-1]<<"\n";
    return 0;  
}

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        p: [usize; n],
    }
    let mut cnt = 0;
    for i in 0..p.len()-2 {
        if std::cmp::max(p[i], std::cmp::max(p[i+1], p[i+2])) != p[i+1]
            && std::cmp::min(p[i], std::cmp::min(p[i+1], p[i+2])) != p[i+1]
        {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        if (a % 2 == b % 2 && a % 2 == c % 2)
        {
            int max = Math.Max(a, Math.Max(b, c));
            int answer = (max - a) / 2 + (max - b) / 2 + (max - c) / 2;
            Console.WriteLine(answer);
        }
        else
        {
            if (a % 2 == b % 2)
            {
                a += 1;
                b += 1;
            }
            else if (a % 2 == c % 2)
            {
                a += 1;
                c += 1;
            }
            else
            {
                b += 1;
                c += 1;
            }
            int max = Math.Max(a, Math.Max(b, c));
            int answer = (max - a) / 2 + (max - b) / 2 + (max - c) / 2 + 1;
            Console.WriteLine(answer);
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
n=int(input())
p=[list(map(int,input().split())) for _ in range(n)]
point=[0]*n
for j in range(3):
    r=[row[j] for row in p]
    for i in range(n):
        if i==0:
            if r[i] not in r[1:]:
                point[0]+=r[i]
        elif i==n-1:
            if r[i] not in r[:n-1]:
                point[n-1]+=r[i]
        else:
            p0=r[:i]+r[i+1:]
            if r[i] not in p0:
                point[i]+=r[i]
for i in point:
    print(i)


Measured memory_bytes: 5632
//Sorting Five Numbers

#include<stdio.h>
#define swap(type, x, y)        do{type t = x; x = y; y = t;} while(0)
//????????????????????????
void bubbleSort(int a[]){
    int i,j;
    
    for(i = 0; i < 5; i++){
        for(j = 4; j >i; j--){
            if(a[j] > a[j-1]) swap(int, a[j], a[j-1]);
        }
    }
}

int main(void){
    int i;
    int a[5];
    
    
    for(i = 0; i < 5; i++){
        scanf("%d", &a[i]);
    }
    
    bubbleSort(a);
    
    for(i = 0; i < 5; i++){
        if(i) printf(" ");
        printf("%d", a[i]);
    }
    putchar('\n');
    
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//必要な量の満腹度をとって、おわり
int main(){
  ll n,d,x;
  cin >> n >> d >> x;
  int a[n];
  REP(i,n)
  {
    cin >> a[i];
  }
  ll res =0;

  ll tmp;
  ll cnt = 0;

  REP(i,n)
  {
    tmp = 0;
    cnt = 1;
    while(cnt <= d)
    {
      ++tmp;
      cnt += a[i];
    }
    res += tmp;
  }

  res += x;

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    sta = True
    A = [int(a) for a in input().split()]
    for i in range(N):
        if A[i] % 2 == 0:
            if A[i] % 3 == 0 or A[i] % 5 == 0:
                pass
            else:
                sta = False
    if sta:
        print("APPROVED")
    else:
        print("DENIED")
main()

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

const int LOG = 60;
const int N = 2e5 + 5;

ll m;
int n;
int a[N], where[N];
vector<int> poses[N];
int link[LOG][N];
ll cost[LOG][N];
int used[N];

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

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

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        where[i] = (int) poses[a[i]].size();
        poses[a[i]].push_back(i);
    }

    for (int i = 0; i < n; i++) {
        int j = where[i];
        j = (j + 1) % (int) poses[a[i]].size();
        j = poses[a[i]][j];
        j = (j + 1) % n;
        link[0][i] = j;
        if ((int) poses[a[i]].size() > 1) {
            cost[0][i] = i <= j ? j - i : n - i + j;
        } else {
            cost[0][i] = n + 1;
        }
//        cout << i << " -> " << link[0][i] << " cost = " << cost[0][i] << "\n";
    }

    for (int j = 1; j < LOG; j++) {
        for (int i = 0; i < n; i++) {
            link[j][i] = link[j - 1][link[j - 1][i]];
            cost[j][i] = min(inf64, cost[j - 1][i] + cost[j - 1][link[j - 1][i]]);
        }
    }

//    for (int j = 0; j <= 2; j++) {
//        cout << j << " : ";
//        for (int i = 0; i < n; i++) {
//            cout << link[j][i] << " ";
//        }
//        cout << "\n";
//    }

    int v = 0;
    ll dist = m * n;

    for (int j = LOG - 1; j >= 0; j--) {
        if (cost[j][v] > dist) continue;
        dist -= cost[j][v];
        v = link[j][v];
    }

//    cout << "v = " << v << "\n";

    vector<int> res;

    if (dist == 0) {v = n;}
  
    for (int i = v; i < n; i++) {
        int x = a[i];
        if (used[x]) {
            while (1) {
                int y = res.back();
                used[y] = 0;
                res.pop_back();
                if (x == y) break;
            }
        } else {
            used[x] = 1;
            res.push_back(x);
        }
    }

    for (int x : res) {
        cout << x << " ";
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 156408
from itertools import permutations

A = [int(input()) for _ in range(5)]
ans = 10**100
for A_perm in permutations(A, 5):
    t = 0
    for dish in A_perm:
        if t % 10 != 0:
            t += 10 - t % 10
        t += dish
    ans = min(ans, t)
print(ans)


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    REP0 (i, N)
    {
        std::cout << S[i];
        std::cout << T[i];
    }
    std::cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll t = 0, h = 0;
    REP(i, n){
        string x, y;
        cin >> x >> y;
        if(x == y){
            t++;
            h++;
        }else if(x < y){
            h += 3;
        }else{
            t += 3;
        }
    }
    cout << t << ' ' << h << endl;
    return 0;
}



Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll n, x;
vector<ll> a;
ll dp[3001][3001][2];

ll calc(int l, int r, int t){
	if(dp[l][r][t]!=-1) return dp[l][r][t];
	if(l==r) return dp[l][r][t]=(t?a[l]:-a[l]);

	if(t){
		if(a[l]+(dp[l+1][r][0]=calc(l+1, r, 0))>a[r]+(dp[l][r-1][0]=calc(l, r-1, 0))){
			return dp[l][r][t]=a[l]+dp[l+1][r][0];
		}
		else return dp[l][r][t]=a[r]+dp[l][r-1][0];
	}
	else{
		if(-a[l]+(dp[l+1][r][1]=calc(l+1, r, 1))<-a[r]+(dp[l][r-1][1]=calc(l, r-1, 1))){
			return dp[l][r][t]=-a[l]+dp[l+1][r][1];
		}
		else return dp[l][r][t]=-a[r]+dp[l][r-1][1];
	}
}

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n){
  	cin >> x;
  	a.pb(x);
  }
  rep(i, 0, n-1){
  	rep(j, i, n-1){
  		dp[i][j][0]=-1;
  		dp[i][j][1]=-1;
  	}
  }
  cout << calc(0, n-1, 1);
}

Measured memory_bytes: 85744
import java.util.*;
import static java.util.stream.Collectors.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            s.nextLine();
            Map<Integer, Long> map
                = Arrays.stream(s.nextLine().split(" "))
                    .map(Integer::valueOf)
                    .collect(groupingBy(k -> k, counting()));
            long sum = map.entrySet().stream()
                        .mapToLong(e -> e.getKey() * e.getValue())
                        .sum();
            int q = Integer.parseInt(s.nextLine());
            for (int i = 0; i < q; i++) {
                int b = s.nextInt(), c = s.nextInt();
                Long t = map.remove(b);
                if (t != null) {
                    map.merge(c, t, Long::sum);
                    sum += (c - b) * t;
                }
                System.out.println(sum);
            }
        }
    }
}


Measured memory_bytes: 76032
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 1e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int n, d;
string s;
ll dp[maxn][105][2];

ll solve_dp (int pos, int m, int small){
    if (pos == n) return (m == 0);

    ll &ans = dp[pos][m][small];
    if (ans != -1) return ans;

    int lim = 9;
    if (small) lim = s[pos] - '0';

    ans = 0;
    for (int i = 0; i <= lim; i++){
        int next = (i < lim) ? 0 : small;
        ans = (ans + solve_dp(pos + 1, (m + i) % d, next)) % mod;
    }

    return ans;
}

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

    memset(dp, -1, sizeof dp);

    cin >> s >> d;

    n = sz(s);

    cout << (solve_dp(0, 0, 1) - 1 + mod) % mod << "\n";

    return 0;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int N;
  string S;

  CIN(N >> S);

  int c = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      c++;
    }
  }

  COUT(c);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		int b = 0;

		for (int i = 0; i < n; i++) {
			p[i] = scanner.nextInt();
		}

		for (int i = 0; i < n; i++) {
			q[i] = scanner.nextInt();
		}

		int result = num(p, n) - num(q, n);
		System.out.println(Math.abs(result));
	}

	private static int num(int[] p, int n) {
		int a = 0;
		int inversion;
		for (int i = 0; i < n - 1; i++) {
			inversion = 0;
			for (int j = i + 1; j < n; j++) {
				if (p[i] > p[j]) {
					inversion++;
				}
			}
			a += inversion;
			a *= (n - i - 1);
		}
		return a;
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(x, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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;
}

int main(){
  cout << fixed << setprecision(15);
  ll ans = 0;
  
  int switches_num; //スイッチの数
  int bulbs_num; //電球の数
  cin >> switches_num >> bulbs_num;
  vector<vector<int>> connection(bulbs_num); //電球に結びついたスイッチ
  rep(i, bulbs_num){
    int lights; cin >> lights;
    rep(j, lights){
      int x; cin >> x;
      connection[i].push_back(x);
    }
  }
  vector<int> how_light(bulbs_num); //connection[i]で結びついた電球のうちいくつが付いたときに電気がつくのか
  rep(i, bulbs_num){
    cin >> how_light[i];
  }
  
  rep(i, 1 << 10){
    int count = 0;
    bitset<10> bit(i);
    rep(j, bulbs_num){
      int lights = 0;
      rep(k, connection[j].size()){
        if(bit.test(connection[j][k] - 1)){
          lights++;
        }
      }
      if(how_light[j] == lights % 2){
        count++;
      }
    }
    if(count == bulbs_num){
      ans++;
    }
  }
  int i = 0;
  while(10 - i > switches_num){
    ans /= 2;
    i++;
  }
 
  cout << ans << endl;
  return 0;
}

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

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

    int ans = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i-1] != s[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_map>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int MOD = 1e9 + 7;
const int INF = 1e9;

int used[1000000];

signed main()
{
	int n, k;
	cin >> n >> k;
	vector <int> a(n);
	for (int & e : a)
        cin >> e;

    sort(all(a));
    int sum = 0;
    for (int i = 0; i < k; ++i)
        sum += a[i];

    cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld a,b;
	char op;

	cin >> a >> op >> b;

	if (op == '+')
	{
		cout << a+b << endl;
	}else
	{
		cout << a-b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
import math

def isPrime(x):
     if x <= 1:
          return False
     if x == 2:
          return True
     root_x = int(math.sqrt(x)) + 1
     for num in range(2, root_x):
          if x%(num) == 0:
               return False
     return True

input = []
for line in sys.stdin:
     input.append(int(line))
##input = [2, 4, 7, 1, 2, 3, 1, 11, 4576435353, 2342342]
count = 0
for num in set(input):
     if isPrime(num):
          count += 1

print count

Measured memory_bytes: 7452
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
  int n;
  cin >> n;
  int a[n+1],c[n+1];
  rep (i,n){
    cin >> a[i];
    --a[i];
    c[i]=a[i];
  }
  ll cnt = 0;
  rep(i,n){
    if (i == a[i]){
      cnt++;
      a[i]=c[i+1];
      a[i+1]=c[i];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4400
import sys
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    cum = [0 for _ in range(n + 1)]
    for i, ai in enumerate(a):
        cum[i + 1] = cum[i] + ai
        # cum[i + 1] %= MOD

    ans = 0
    for i in range(n - 1):
        total = cum[-1] - cum[i + 1]
        total %= MOD
        ans += a[i] * total
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 109520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,n_1,n_2) for(int i=(int)(n_1);i<=(int)(n_2);++i)
#define ll long long
#define P pair<int,int>

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(10,vector<int>(10,0));
    REP(i,1,n){
        int h=i;
        int t=i%10;
        while(h>=10) h/=10;
        a[h][t]++;
    }
    ll int ans=0;
    rep(i,10){
        rep(j,10){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,i,j,hirou,hirou_min=1000000000;
  int x[100];
  
  scanf("%d",&n);
  j=hirou=0;
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }

  for(i=1;i<=100;i++){
    hirou=0;
    for(j=0;j<n;j++){
      hirou+=((x[j]-i)*(x[j]-i));
    }
    if(hirou_min>hirou){
      hirou_min=hirou;
    }
  }
  printf("%d",hirou_min);
}
  

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll x, y, z;
  cin >> x >> y >> z;
  ll ans = (x - z) / (y + z);
  cout << ans << endl;
  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
   int r; cin >> r;
   long double ans = 2 * r * M_PI;
   cout << setprecision(18) << ans << endl;
}


Measured memory_bytes: 3788
import java.util.HashSet;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int d[] = new int[k];
        HashSet<Integer> result = new HashSet<Integer>();
        for(int i=0;i<k;i++) {
        	d[i]=sc.nextInt();
        	int a[] = new int[d[i]];
        	for(int j=0;j<d[i];j++) {
        		a[j] = sc.nextInt();
        		result.add(a[j]);
        	}
        }
        System.out.println(n-result.size());
    	sc.close();
	}
}

Measured memory_bytes: 46012
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

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

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	ll res = i + j + l + o;
	if (i == 0 || j == 0 || l == 0)res -= i % 2 + j % 2 + l % 2;
	else
	{
		int cnt = i % 2 + j % 2 + l % 2;
		if (cnt == 1 || cnt == 2)--res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain

# floor(A x / B) - A * floor(x / B)
#
# x = B * x1 + x2  : (x2 < B) とする
#
# = floor(A (B*x1+x2) / B) - A floor((B*x1+x2) / B)
# = A x1 + floor(A x2 / B) - A x1
# = floor(A x2 / B)


def solve(A: int, B: int, N: int):
    if N >= B:
        x2 = B - 1
    else:
        x2 = N

    return (A * x2) // B


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    answer = solve(A, B, N)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
/*
	Author: Luis Manuel D�az Bar�n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;

int N;
ll hi[lim];
ll ai[lim];


// SegmentTree
ll t[lim << 2];
void update(int idx, int L, int R, int ii, ll upd)
{
	if(L == R)
	{
		t[idx] = upd;
		return;
	}
	int le = 2*idx + 1, ri = le + 1, mid = (L + R) / 2;
	if(ii <= mid)
		update(le, L, mid, ii, upd);
	else update(ri, mid + 1, R, ii, upd);
	//
	t[idx] = max(t[le], t[ri]);
}

ll retrieve(int idx, int L, int R, int QL, int QR)
{
	if(L >= QL && R <= QR)
	{
		return t[idx];
	}
	if(L > QR || R < QL)
		return 0;
	int le = 2*idx + 1, ri = le + 1, mid = (L + R) / 2;
	ll a1 = retrieve(le, L, mid, QL, QR);
	ll a2 = retrieve(ri, mid + 1, R, QL, QR);
	//
	return max(a1, a2);
}
// << SegmentTree

void solve()
{
	cin >> N;
	for(int i = 0; i < N; i++)	
		cin >> hi[i];
	
	for(int i = 0; i < N; i++)
		cin >> ai[i];

	ll answ = 0;
	//
	for(int i = 0; i < N; i++)
	{
		ll mx = retrieve(0, 0, N, 0, hi[i] - 1);
		ll upd = mx + ai[i];
		update(0, 0, N, hi[i], upd);
		answ = max(answ, upd);
	}
	cout << answ << endl;
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 9600
s = input()
acgt = set({'A','C','G','T'})
s = s + 'Z' #dummy
ans = [-1]*(len(s))
def dfs(i):
    if ans[i] != -1:
        return ans[i]
    elif s[i] not in acgt:
        ans[i] = 0
        return 0
    else:
        ans[i] = dfs(i+1) + 1
        return ans[i]
for i in range(len(s)):
    dfs(i)
print(max(ans))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

class tWord{
public:
	string word;
	vector<int> page;
	tWord( string w );
};
tWord::tWord( string w ){
	word = w;
	page.clear();
}

bool operator<( const tWord &l, const tWord &r ){
	return l.word < r.word;
}

int main(){
	vector<tWord> words;
	string line;
	int n;
	char w[31];

	// input
	while(1){
		getline( cin, line );
		if( line.size()==0 ) break;
		sscanf(line.c_str(), "%s %d", w, &n);
		int i;
		for( i=0; i<words.size(); i++ ){
			if( words[i].word == w ){
				break;
			}
		}
		if( i == words.size() ){
			string ww = w;
			words.push_back(ww);
		}
		words[i].page.push_back(n);
	}

	// output
	sort( words.begin(), words.end() );
	for( int i=0; i<words.size(); i++ ){
		if( words[i].word != "" ){
			cout << words[i].word << endl;
			sort( words[i].page.begin(), words[i].page.end() );
			cout << words[i].page[0];
			for( int j=1; j<words[i].page.size(); j++ ){
				cout << " " << words[i].page[j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main(){
  long long N;
  cin >> N;

  long long k = 2;
  while(1){
    long long test = k*(k-1);
    if(test == 2*N){
      break;
    }else if(test > 2*N){
      cout << "No" <<"\n";
      return 0;
    }else{
      k++;
    }
  }

  cout << "Yes" << "\n";
  cout << k << "\n";

  int sum[k] = {};
  sum[0]= 1;
  for(int i=1;i<k;i++){
    sum[i] = sum[i-1] + i;
  }

  for(int i=0;i<k-1;i++){
    cout << k-1 << " ";
    for(int j=0;j<i;j++){
      cout << sum[i] + j << " ";
    }
    for(int j=i;j<k-1;j++){
      cout << sum[j] + i;
      if(j != k-2){
        cout << " ";
      }
    }
    cout << "\n";
  }

  cout << k-1 << " ";
  for(int j=0;j<k-1;j++){
    cout << sum[j] + j;
    if(j != k-2){
      cout << " ";
    }
  }
  cout << "\n";

  return 0;
}


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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  vector<int> X(N);
  long long ans = 0;
  for (int i=0; i<N; i++) cin >> X[i];
  for (int i=0; i<N-1; i++){
    ans += min(A*(X[i+1]-X[i]), B);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    dist = [-1]*N
    dist[0] = 0
    
    for _ in range(N-1):
        a,b,c = map(int,input().split())
        edge[a-1].append((b-1,c))
        edge[b-1].append((a-1,c))
        
    que = deque([0])
    while que:
        now = que.pop()
        for fol,d in edge[now]:
            if dist[fol] != -1:
                continue
            dist[fol] = dist[now]+d
            que.append(fol)
            
    for i in range(N):
        print(dist[i]%2)

if __name__ == "__main__":
    main()


Measured memory_bytes: 66080
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll K; cin >> K;
    const ll N = 50;
    vector<ll> a(N,N-1+K/N);
    ll rem = K%N;
    for(int i=0;i<rem;i++){
        a[i] += N - (rem-1);
    }
    for(int i=rem;i<N;i++){
        a[i] -= rem;
    }

    cout << N << endl;
    for(int i=0;i<N;i++){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 256