akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define M 100000

void MCO();
int m[100][100], p[100], n;

main(){	
	int i, c;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d%d",&p[i],&c);
		p[i+1] = c;
	}
	MCO();
	printf("%d\n",m[1][n]);
	
	return 0;
}

void MCO(){
	int i, j, k, l, q;
	for(i = 0; i <= n+1; i++)
		m[i][i] = 0;
	for(l = 2; l <= n; l++){
		for(i = 1;i < n-l+2; i++){
		j = i + l - 1;
		m[i][j] = M;
			for(k = i; k < j; k++){
			q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
			if(q < m[i][j]) m[i][j] = q;
			}
		}
	}
}

Measured memory_bytes: 636
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

C = [inpl() for i in range(3)]

ok = True
for i in range(3):
    X = [C[i][j] - C[(i+1)%3][j] for j in range(3)]
    if X[0] == X[1] == X[2]:
        pass
    else:
        ok = False

for j in range(3):
    X = [C[i][j] - C[i][(j+1)%3] for i in range(3)]
    if X[0] == X[1] == X[2]:
        pass
    else:
        ok = False

if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int x[n];
  REP(i, n){
    cin>>x[i];
  }
  int ans = 1'000'000;
  REPP(p, 100){
    int temp = 0;
    REP(i, n){
      temp += (x[i] - p) * (x[i] - p);
    }
    ans = min(ans, temp);
  }
  cout<<ans<<endl;
  return 0;
}


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

int dy[6] = {-1, -1, 0, 1, 1, 0};
int dx[2][6] = { {-1, 0, 1, 0, -1, -1} , {0, 1, 1, 1, 0, -1} };
int mas[105][105] = {};
bool flag[105][105] = {};
int H, W;
int dfs(int y, int x)
{
    int ret = 0;
    if(flag[y][x]) return (0);
    flag[y][x] = true;
    for(int i = 0; i < 6; i++) {
        int ny = y + dy[i], nx = x + dx[y % 2][i];
        if(ny < 0 || nx < 0 || ny > H + 1 || nx > W + 1) continue;
        if(mas[ny][nx] == 1) ret++;
        else ret += dfs(ny, nx);
    }
    return (ret);
}

int main()
{
    cin >> W >> H;
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cin >> mas[i][j];
        }
    }
    cout << dfs(0, 0) << endl;
    return (0);
}



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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;

  if((B-A) % 2 == 0) cout << (B - A)/2 << endl;
  else cout << min(A - 1, N - B) + (B - A - 1)/2 + 1 << endl;
}


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

 int main()
 {
    int n,i;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    int dp[n+1][3];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(i=1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
 }

Measured memory_bytes: 2560
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  int red = 0;
  for (int i = 0; i < s.length(); ++i){
    if (s[i] == 'R'){
    	red++;
    }
  }
  if (red > n - red){
  	cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll a,b;
    cin>>a>>b;
    if((a+b)%2){cout << "IMPOSSIBLE" << endl;}
    else{cout << (a+b)/2 << endl;}
    return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i] ;
	vector<ll> b(n+1);
	b[0] = 0 ; 
	rep(i,n){
		b[i+1] = b[i] + a[i];
	}
	SORT(b);
	ll now = b[0];
	ll count = 1;
	ll ans = 0; 
	rep(i,n){ 
		if(now == b[i+1]){
			count ++ ;
		} else{
			ans += (count * (count - 1 )) / 2;
			count = 1 ;
			now = b[i+1] ;
		}
	}	
	ans += (count * (count - 1 )) / 2;
	cout << ans << endl;

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main()
{
   long int n;

   scanf("%ld",&n);
   long int a[n],i;
   long int h[n+1];
   for(i=1;i<=n;++i)
        h[i]=0;
    
   for(i=0;i<n-1;++i)
      {
          scanf("%ld",&a[i]);
          h[a[i]]++;
      }
      
    for(i=1;i<=n;++i)
       printf("%ld\n",h[i]);
      
    
}

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector <int>
#define vvi         vector <vi>
#define pii         pair <int,int>
#define vii         vector <pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007
#define PI          3.1415926535897932

const int N = 10;
string g[N];
int n, m, k;

signed main()
{
        IO;
        cin >> n >> m >> k;

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

        for (int i = 0; i < (1LL << n); i++) {
            for (int j = 0; j < (1LL << m); j++) {
                vector <bool> row(6), col(6);
                for (int l = 0; l < 6; l++) {
                    int mask = (1LL << l);
                    if (mask & i) {
                        row[l] = 1;
                    }
                }
                for (int l = 0; l < 6; l++) {
                    int mask = (1LL << l);
                    if (mask & j) {
                        col[l] = 1;
                    }
                }
                int cnt = 0;
                for (int x = 0; x < n; x++) {
                    for (int y = 0; y < m; y++) {
                        if (!row[x] && !col[y] && g[x][y] == '#') {
                            cnt++;
                        }
                    }
                }
                if (cnt == k) {
                    ans++;
                }
             }
        }
        cout << ans;
}



Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>


int searchParent(int p) {
  if( p != 1 ) {
    return (int)p/2;
  }else {
    return -1;
  }
}


int searchLeft(int p, int n) {
  if( p*2 <= n ) {
    return p*2;
  }else {
    return -1;
  }
}


int searchRight(int p, int n) {
  if( p*2+1 <= n ) {
    return p*2+1;
  }else {
    return -1;
  }
}


void printHeap(int* h, int n) {
  int i;

  for( i=1; i<=n; i++) {
    printf("node %d: key = %d, ", i, h[i]);
    if( searchParent(i) != -1 ) {
      printf("parent key = %d, ", h[searchParent(i)]);
    }
    if( searchLeft(i, n) != -1 ) {
      printf("left key = %d, ", h[searchLeft(i, n)]);
    }
    if( searchRight(i, n) != -1 ) {
      printf("right key = %d, ", h[searchRight(i, n)]);
    }
    printf("\n");
  }
}


int main() {

  int n; //heapSize
  int* h; //heapPointer

  int i;

  scanf("%d", &n);

  h = (int*)malloc( sizeof(int) * (n + 1) );

  //Heapは1から始まる
  for( i=1; i<=n; i++) {
    scanf("%d", &h[i]);
  }

  printHeap(h, n);

  return 0;

}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	int n;
	while(cin >> n,n!=0)
	{
		vector<int> key(n);
		for(int i=0;i<n;i++)
			cin >> key[i];
		string s;
		cin >> s;
		int ss=s.size();

		for(int i=0;i<ss;i++)
		{
			int tmp;
			if('a'<=s[i] and s[i]<='z')
				tmp=s[i]-'a';
			else
				tmp=s[i]-'A'+(26);

			tmp-=(key[i%n]);
			while(tmp<0)
				tmp+=(2*('z'-'a'+1));
			tmp%=(2*('z'-'a'+1));

			if(tmp<26)
				s[i]=tmp+'a';
			else
				s[i]=tmp-26+'A';
			//if(s[i]<'A')s[i]+=(58);
			//else if(s[i]<'a') s[i]-=(6);
		}
		cout << s << endl;
	}

}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8近傍
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

void solve() {
    int n; cin >> n;
    vector<ll> a(n);
    ll cnt = 0;
    rep(i,n) cin >> a[i];
    rep(i,n){
        cnt += a[i] / 2;
        a[i] %= 2;
        if(a[i]&&a[i+1]) {
            cnt++;
            a[i]--; a[i+1]--;
        }
    }
    cout << cnt << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 1024
n = int(input())
words = {}

for i in range(n) :
    new_word = input()
    if new_word in words.keys() :
        words[new_word] += 1
    else :
        words[new_word] = 1

mx_freq = max(words.values())
mx_words = [k for k in words.keys() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 998244353
const int N = 200010;
int n , po[N];
char tmpread[N];

void read(string &s){
	scanf("%s",tmpread);
	s = (string)tmpread;
}

string a , b , x , c;

int ans = 0;

int cur[N];


void check(int k){
	if(n % k != 0 || (n / k) % 2 == 0) return;
	for(int i = 0 ;i < k;i++){
		cur[k] += po[k - i - 1] * (x[i] - '0');
		if(cur[k] >= mod) cur[k] -= mod;
	}
	a.clear();
	b.clear();
	a.resize(k);
	for(int i = 0 ;i < k;i++) a[i] = x[i];
	b.resize(n);
	for(int i = 0 ;i < n;i++){
		if(((i / k) & 1))
			b[i] = '1' - a[i % k] + '0';
		else
			b[i] = a[i % k];
	}
	cur[k] += (b <= x);
	if(cur[k] >= mod)
		cur[k] -= mod;
}

void Print(int a,int n){
	for(int i = 0 ;i < n;i++){
		putchar((((a >> i) & 1)) + '0');
	}
	puts("");
}


void make(int n){
	int ans = 0;
	int val = 0;
	for(int i = 0;i < (int)x.size();i++){
		val <<= 1;
		val |= (x[i] - '0');
	}
	for(int i = 0;i <= val;i++){
		int cur = i;
		int it =0;
		do{
			it++;
			if(cur & 1)
				cur >>= 1;
			else{
				cur |= (1 << n);
				cur >>= 1;
			}
		}while(cur != i);
		ans += it;
		if(ans >= mod)
			ans -= mod;
	}
	cout << "ans = " << ans << endl;
}

int main(){
	srand(time(0));
	po[0] = 1;
	for(int i = 1;i < N;i++) po[i] = (long long)2 * po[i - 1] % mod;
	scanf("%d",&n);
	read(x);
	assert((int)x.size() == n);
	ans = 2 * n;
	a.resize(n);
	for(int i = 0 ;i < n;i++){
		if(x[i] == '1'){
			ans += (long long)po[n - i - 1] * (2 * n) % mod;
			if(ans >= mod)
				ans -= mod;
		}
	}
	for(int i = 1;i < n;i++){
		check(i);
	}
	for(int i = 1;i < n;i++){
		ans -= (long long)cur[i] * (2 * n - 2 * i) % mod;
		if(ans < 0) ans += mod;
		for(int j = i + i;j < n;j += i){
			if(n % j == 0 && (n / j) % 2 != 0){
				cur[j] -= cur[i];
				if(cur[j] < 0) cur[j] += mod;
			}
		}
	}
	//make(n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1920
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")        
}
fn main() {

    let a: u32 = read();
    let b: u32 = read();
    let t: u32 = read();

    let ans = t / a * b;
    println!("{}", ans);
}



Measured memory_bytes: 4352
//21:00 -

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a, b, c, d;
  int ans;

  cin >> a >> b >> c >> d;
  ans = min(a, b);
  ans += min(c, d);
  cout << ans << endl;
  return 0;
}


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

int main() {
    long long N;
    cin >> N;
    vector<pair<long long,long long>> X(N);
    for(long long i=0;i<N;i++){
        long long a,b;
        cin >> a >> b;
        X.at(i) = make_pair(b,a);
    }
    sort(X.begin(),X.end());
    long long time = 0;
    string ans = "Yes";
    for(long long i=0;i<N;i++){
        time += X.at(i).second;
        if(X.at(i).first < time){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

/*
 * Union-Find tree
 * header requirement: vector
 */
class UnionFind {
private:
  std::vector<int> disj;
  std::vector<int> rank;
public:
  UnionFind(int n) : disj(n), rank(n) {
    for (int i = 0; i < n; ++i) {
      disj[i] = i;
      rank[i] = 0;
    }
  }
  int root(int x) {
    if (disj[x] == x) {
      return x;
    }
    return disj[x] = root(disj[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (rank[x] < rank[y]) {
      disj[x] = y;
    } else {
      disj[y] = x;
      if (rank[x] == rank[y]) {
	++rank[x];
      }
    }
  }
  bool is_same_set(int x, int y) {
    return root(x) == root(y);
  }
};


int main(void){
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind uf_a(n), uf_b(n);
  REP(i, 0, k) {
    int p ,q;
    cin >> p >> q;
    p--, q--;
    uf_a.unite(p, q);
  }
  REP(i, 0, l) {
    int r, s;
    cin >> r >> s;
    r--, s--;
    uf_b.unite(r, s);
  }
  map<PI, int> pool;
  REP(i, 0, n) {
    int ra = uf_a.root(i);
    int rb = uf_b.root(i);
    if (pool.count(PI(ra, rb)) == 0) {
      pool[PI(ra, rb)] = 0;
    }
    pool[PI(ra, rb)]++;
  }
  REP(i, 0, n) {
    int ra = uf_a.root(i);
    int rb = uf_b.root(i);
    cout << pool[PI(ra, rb)] << (i == n - 1 ? "\n" : " ");
  }
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	ll a , b , c , d ; cin >> a >> b >> c >> d ;
	cout << b - a + 1 - countDivisibles(a , b , c) - countDivisibles(a , b , d) + countDivisibles(a , b , (c * d) / __gcd(c , d)) << endl ; 
	return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(1e5 + 1);
  long long res = 0;
  while (n--) {
    int x;
    cin >> x;
    a[x] += x;
    res += x;
  }
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    res -= a[b] + a[c];
    a[c] += a[b] / b * c;
    a[b] = 0;
    res += a[b] + a[c];
    cout << res << '\n';
  }
}


Measured memory_bytes: 3924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final long MOD = 998_244_353;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int s = scanner.nextInt();
        final int[] array = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = scanner.nextInt();
        }

        final long[][] table = new long[n + 1][s + 1];
        table[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= s; j++) {
                table[i][j] = table[i - 1][j] * 2;
                table[i][j] %= MOD;
            }
            final int current = array[i];
            for (int j = 0; j <= s - current; j++) {
                table[i][j + current] += table[i - 1][j];
                table[i][j + current] %= MOD;
            }
        }

        System.out.println(table[n][s]);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 104672
#include <stdio.h>

int main(){
    int n[3];
    int tmp=0;

    scanf("%d %d %d",&n[0], &n[1], &n[2]);

    if (n[2]<n[1]){
        tmp = n[2];
        n[2] = n[1];
        n[1] = tmp;
    }
    if (n[1]<n[0]){
        tmp = n[1];
        n[1] = n[0];
        n[0] = tmp;
    }
    if (n[2]<n[1]){
        tmp = n[2];
        n[2] = n[1];
        n[1] = tmp;
    }

    printf("%d %d %d\n",n[0], n[1], n[2]);

    return 0;
}

Measured memory_bytes: 1756
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 10 21:07:21 2019

@author: doppe
"""

K, X = map(int, input().split())


start = X - K + 1
end = X + K
split = ""
ans = ""
for i in range (start, end):
    ans += split + str(i)
    split = " "
print(ans)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(dead_code)]
use proconio::input;
use proconio::fastout;
use proconio::marker::*;

fn type_of<T>(_: T) -> String{
    let a = std::any::type_name::<T>();
    return a.to_string();
}

#[fastout]
fn main() {
    input! {
        mut s:Chars,
    }
    s[3]='8';
    println!("{}",s.iter().collect::<String>());
}

Measured memory_bytes: 2140
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    t = 0
    ta = 10 ** 20
    ts = sum(a)
    for i in range(n-1):
        t += a[i]
        ta = min(ta, abs(t - (ts - t)))
    print(ta)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 71456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	int n = (int)s.size();
	map<char, int> mp;
	for(int i = 0; i < n; ++i) {
		mp[s[i]]++;
	}
	
	int mi = 1e9;
	char minC;
	for(char c = 'a'; c <= 'c'; ++c) {
		if( mi > mp[c] ) {
			mi = mp[c];
			minC = c;
		}			
	}
	
	for(char c = 'a'; c <= 'c'; ++c) {
		if( c == minC ) continue;
		
		if( mp[c] - mi > 1 ) {
			cout << "NO" << endl;
			return 0;
		}			
	}
	
	cout << "YES" << endl;
	
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    vector<int> a(5);
    int num[5] = {0};
    int max = 0;
    int sub = 0;
    int ans = 0;

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

    vector<int> b(a);

    for (int i = 0; i < 5; i++) {
        while (a[i] % 10 != 0) {
            a[i]++;
            num[i]++;
        }
    }

    for (int i = 0; i < 5; i++) {
        if (num[i] != 0 && max < num[i]) {
            max = num[i];
            sub = i;
        }
    }

    for (int i = 0; i < 5; i++) {
        if (i != sub) {
            ans += a[i];
        }
    }

    ans += b[sub];

    cout << ans << endl;
}


Measured memory_bytes: 256
# 入力
X=int(input())

# Xが1の場合は答えは1
if X==1:
  print(1)
  exit()

# 最大値
mx=0

# 2〜1000
for a in range(2,1000):

  i=2
  while True:
    # べき乗
    b=pow(a,i)

    # X以下の場合、最大値保存
    if b<=X:
      mx=max(mx,b)
    else:
      # Xをオーバーした場合はループを抜ける
      break

    i+=1

# 最大値を出力
print(mx)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	int a = s.back() - '0';
	if (a == 3) cout << "bon";
	else if (a == 0 or a == 1 or a == 6 or a == 8) cout << "pon";
	else cout << "hon";
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

	bool same(int x, int y) { return (find(x) == find(y)); }
} uf1, uf2;

int N, K, L;
map<pii, int> cnt;
ll ret; 

int main() {
	cin >> N >> K >> L;
	uf1.init(N);
	uf2.init(N);
	rep(i, K) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		uf1.unite(a, b);
	}

	rep(i, L) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		uf2.unite(a, b);
	}

	rep(i, N) {
		int a = uf1.find(i), b = uf2.find(i);
		cnt[mp(a, b)]++;
	}

	rep(i, N) {
		int a = uf1.find(i), b = uf2.find(i);		
		printf("%d%c", cnt[mp(a,b)], i == N-1 ? '\n' : ' ');
	}

	return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int A[N], B[N], P[N];
ll S[N], W[N];
vector< pair<int, pii> > E;

int GetPar(int v) { return P[v] == v ? v : P[v] = GetPar(P[v]); }
void Merge(int v, int u) {
	if (A[v] - B[v] < A[u] - B[u]) swap(v, u);
	int pv = GetPar(v), pu = GetPar(u);
	if (pv == pu) return;
	W[pv] = min(W[pv], max(0LL, (W[pu] + S[pu] >= A[v] - B[v] ? W[pu] : A[v] - B[v] - S[pu])));
	S[pv] += S[pu];
	P[pu] = pv;
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> A[i] >> B[i], P[i] = i, S[i] = B[i], W[i] = max(0, A[i] - B[i]);
	for (int i = 1; i <= m; i++) {
		int v, u; cin >> v >> u;
		E.push_back(make_pair(max(A[v] - B[v], A[u] - B[u]), make_pair(v, u)));
	}
	sort(all(E));
	for (auto e : E) {
		int v = e.second.first, u = e.second.second;
		Merge(v, u);
	}
	cout << max(0LL, W[GetPar(1)] + S[GetPar(1)]) << endl;

	return 0;
}


Measured memory_bytes: 7636
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

template<typename Monoid>
class SegTree {
public:
	Monoid* tree;
	size_t size;
	int32 i;
	//?????????????????????
	SegTree(size_t length) {
		--length;
		size = length & 0xffff0000 ? length & 0xffff0000 : length;
		size = size & 0xff00ff00 ? size & 0xff00ff00 : size;
		size = size & 0xf0f0f0f0 ? size & 0xf0f0f0f0 : size;
		size = size & 0xcccccccc ? size & 0xcccccccc : size;
		size = size & 0xaaaaaaaa ? size & 0xaaaaaaaa : size;
		size = length ? size << 1 : 1;
		++length;
		tree = (Monoid *)calloc(size << 1, sizeof(Monoid));
	}
	//?????????
	void set() {
		size <<= 1;
		for (i = 0;i < size;++i) tree[i].set();
		size >>= 1;
	}
	//tree[index]???data?????????
	void add(size_t index, Monoid &data) {
		index += size;
		tree[index] = tree[index] + data;
		while (index >>= 1) tree[index] = tree[index << 1] + tree[index * 2 + 1];
	}
	//[begin,end)??????????????????
	Monoid range(size_t begin, size_t end) {
		Monoid ret;
		for (begin += size, end += size;begin < end;begin >>= 1, end >>= 1) {
			if (begin & 1) ret = ret + tree[begin++];
			if (end & 1) ret = tree[end - 1] + ret;
		}
		return ret;
	}
};

struct SUM {
	int32 e;
	SUM() { set(); }
	SUM(int32 x) { e = x; }
	void set() { e = 0; }
	void update(SUM b) { e = b.e; }
	SUM operator+(SUM &other) {
		return  SUM(e + other.e);
	};
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//*
	int32 n, q;
	cin >> n >> q;
	int32 c, x,y1;
	SUM y2;
	SegTree<SUM> t(n);
	t.set();
	rep(i, 0, q) {
		cin >> c;
		if (c) {
			cin >> x >> y1;
			printf("%d\n", t.range(x, y1 + 1).e);
		}
		else {
			cin >> x >> y2.e;
			t.add(x, y2);
		}
	}
	//*/
	return 0;
}

Measured memory_bytes: 5292
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;

int		main(void)
{
	vector<int> abc(3);
	int k;
	
	cin >> abc[0] >> abc[1] >> abc[2];
	cin >> k;
	sort(rall(abc));
	int x = abc[0];

	for (int i = 0; i < k; i++)
		x *= 2;
	cout << (x + abc[1] + abc[2]) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		long inN = stdin.nextLong();
		long inK = stdin.nextLong();

		long count = 0;
		for (long b = 1; b <= inN; b++) {
			long div = inN / b;
			long mod = inN % b;
			count += div * Math.max(0, (b - inK)) + Math.max(0, (mod - inK + 1));
		}

		if (inK == 0) {
			count -= inN;
		}

		System.out.println(count);
	}

}


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

int64_t gcd(int64_t x, int64_t y){
  int64_t x0=x;
  int64_t y0=y;
  x0=max(x, y);
  y0=min(x, y);
  if(x0%y0==0){
    return y0;
  }
  else{
    return gcd(y0, x0%y0);
  }
}

int main(){
  int64_t A, B;
  cin >> A >> B;
  int64_t Ans=A*B/gcd(A, B);
  cout << Ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int x = in.nextInt();

		for ( int i = x - k + 1; i <= x + k - 1; i++ ) {
				System.out.print(i + " ");
		}

		in.close();
	}
}

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

using namespace std;

const int MAXN = 303;

int n, m;
int mat[MAXN][MAXN];
int cnt[MAXN];
bool dead[MAXN];
int id[MAXN];

bool ok(int x)
{
	int i, j;
	fill(cnt, cnt + m, 0);
	fill(dead, dead + m, false);
	fill(id, id + n, 0);
	
	for (i = 0; i < n; ++i)
		++cnt[mat[i][0]];
	
	bool again;
	do
	{
		again = false;
		for (i = 0; i < m; ++i) if (cnt[i] > x)
		{
			dead[i] = true;
			again = true;
			
			for (j = 0; j < n; ++j)
			{
				while (dead[mat[j][id[j]]])
				{
					--cnt[mat[j][id[j]]];
					++id[j];
					if (id[j] == m)
						return false;
					++cnt[mat[j][id[j]]];
				}
			}
		}
	} while (again);
	
	return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j;
    
    cin>>n>>m;
    
    for (i = 0; i < n; ++i)
	{
		for (j = 0; j < m; ++j)
		{
			cin>>mat[i][j];
			--mat[i][j];
		}
	}
	
	int lo = 0, hi = n + 1, mid;
	while (hi - lo > 1)
	{
		mid = (lo + hi) / 2;
		
		if (ok(mid))
			hi = mid;
		else lo = mid;
	}
	
	cout<<hi<<'\n';
}


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

int main() {
  int a, b;
  cin >> a >> b;

  string ans = "";
  int diff = b - a;

  if (a <= 0 && 0 <= b) {
    ans = "Zero";
  } else if (diff % 2 != 0) {
    ans = "Positive";
  } else {
    if (a > 0 && b > 0)
      ans = "Positive";
    else
      ans = "Negative";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
     
     
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
     #define trace(x) cerr << #x << ": " << x << " " << endl;

    typedef int64_t ll;

    #define endl '\n'
    #define int ll
    ll mod=1e9+7;
    ll mod1=1e9+5;
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }

    int32_t main()
    {
        IOS
       
      

        multiset<int,greater<int>>s;
        int n,m;
        cin>>n>>m;
        int a[n];
        for(int i=0;i<n;++i)
            cin>>a[i],s.insert(a[i]);
        for(int i=0;i<m;++i)
        {
            auto it=s.begin();
            int temp=*it;
            s.erase(it);
            s.insert(temp/2);
            
        }
        int sum=0;
        for(auto i:s)
            sum+=i;
        cout<<sum;



    }


Measured memory_bytes: 5760
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		String s=in.next();
		String str=in.next();
		if(s.compareToIgnoreCase(str.substring(0,str.length()-1))==0)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35764
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}


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

	cout << 180 * (N - 2) << endl;
}

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

using namespace std;

typedef long long ll;

ll ans = 1e15;
ll N, A, B, C;
ll l[10];

void dfs(vector<int> v){
	if(v.size() == N){
		ll t = 0;
		ll t1 = 0;
		ll t2 = 0;
		ll t3 = 0;
		rep(i, N){
			if(v[i] == 1){
				if(t1 > 0) t += 10;
				t1 += l[i];
			}

			if(v[i] == 2){
				if(t2 > 0) t += 10;
				t2 += l[i];
			}

			if(v[i] == 3) {
				if(t3 > 0) t += 10;
				t3 += l[i];
			}
		}
		if(t1 == 0 || t2 == 0 || t3 == 0) return;

		t += abs(t1 - A);
		t += abs(t2 - B);
		t += abs(t3 - C);

		ans = min(ans, t);
		return;
	}

	rep(i, 4){
		v.push_back(i);
		dfs(v);
		v.erase(v.end()-1);
	}
}

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

	cin >> N >> A >> B >> C;
	rep(i, N) cin >> l[i];

	vector<int> v;
	dfs(v);

	cout << ans << endl;
}


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

int main()
{
    vector<int> data = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << data[K-1] << endl;

    return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);
    int a, b, c;
    cin >> a >> b >> c;
    if (a - b < c) {
        cout << c - (a - b) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import numpy as np

N, point, q = [int(x) for x in input().split()]
r_list = [q] * N
p_list = [point] * N
reduce_list = np.array(r_list)
points_list = np.array(p_list)

for i in range(q):
    answer = int(input()) - 1
    points_list[answer] += 1

points_list = points_list - reduce_list

for p in points_list:
    if p <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 16384
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var a int
	res := "APPROVED"
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if a%2 == 0 {
			if a%3 != 0 && a%5 != 0 {
				res = "DENIED"
			}
		}
	}

	fmt.Println(res)
}


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

int main() {
	long long A,B,N;
	cin >>A>>B>>N;
	if(B==1){
		cout <<0;
	} 
	else{
		long long p;
		p=N/B;
		long long m;
		m=0;
		for(int i=1;i<=p;i++){
			m=max(m,(A*(B*i-1))/B-A*((B*i-1)/B));
		}
		m=max(m,(A*N)/B-A*(N/B));
			cout <<m;
	}


}

Measured memory_bytes: 3676
from collections import deque


n, m = map(int, input().split())
tree = [[] for i in range(n)]
path = {}
for i in range(m):
    tmp1, tmp2, cost = map(int, input().split())
    tree[tmp1-1].append([tmp2-1, cost])

q = deque()
q.append([-1, 0])
pos_cost = [-float("inf")]*n
pos_cost[0] = 0
path = {}

def judge(start):
    q2 = deque()
    q2.append(start)
    visited = [False]*n
    visited[start] = True
    while q2:
        pos = q2.popleft()
        for next_pos, cost in tree[pos]:
            if not visited[next_pos]:
                q2.append(next_pos)
                visited[next_pos] = True
    if visited[n-1]:
        print("inf")
        exit()

while q:
    prev_pos, pos = q.popleft()
    if prev_pos*10000 + pos in path:
        judge(pos)
        continue
    path[prev_pos*10000 + pos] = 1
    for next_pos, cost in tree[pos]:
        if pos_cost[pos] + cost > pos_cost[next_pos]:
            pos_cost[next_pos] = pos_cost[pos] + cost
            q.append([pos, next_pos])
print(pos_cost[n-1])

Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		BitterAlchemy solver = new BitterAlchemy();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}


	static class BitterAlchemy {

		private Scanner scanner;
		private int n;
		private int x;
		private int[] m;
		private int output;

		public BitterAlchemy(){
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			n = scanner.nextInt();
			x = scanner.nextInt();
			m = new int[n];
			for(int i=0; i<n;i++) {
				m[i] = scanner.nextInt();
			}
		}
		public void solve() {
			int min = 1000;
			output=0;
			for(int i=0;i<n;i++) {
				x -= m[i];
				output++;
				if(m[i] < min) {
					min = m[i];
				}
			}

			while(min<=x) {
				x-=min;
				output++;
			}
		}
		public void writeOutput() {
			System.out.println(output);
		}

	}


}


Measured memory_bytes: 23124
#include<stdio.h>

int main(){ int aa, bb, cc;
	while (1) {
		scanf ("%d %d", &aa, &bb);
		if (aa == 0 && bb == 0) break;
		if (aa < bb) printf("%d %d\n", aa, bb);
		else printf("%d %d\n", bb, aa);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main
{
    private static final int MAX_N = (int) 1e6 + 16;
    private static int[] primes = new int[MAX_N];
    private static int[] acc = new int[MAX_N];

    private static void init()
    {
        int[] number = new int[MAX_N];
        number[0] = 1;
        number[1] = 1;
        for (int i = 2; i < MAX_N; i++)
        {
            if (number[i] == 0)
            {
                primes[i] = 1;
                for (int j = 2*i; j < MAX_N; j += i)
                {
                    if (j < 0) break;
                    number[j] = 1;
                }
            }
        }

        for (int i = 1; i < MAX_N; i++)
        {
            acc[i] = primes[i] + acc[i-1];
        }
    }

    public static void main(String[] args)
    {
        init();
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while (in.hasNext())
        {
            sb.append(String.format("%d\n", acc[in.nextInt()]));
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 38428
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <string>
class dice{
private:
    int a,b,c,d,e,f;
    std::vector <int> list={0,1,2,3,4,5};
    std::vector <int> listb={0,1,2,3,4,5};
public:
    dice(int i,int j,int k,int l,int m,int n){
        a=i;
        b=j;
        c=k;
        d=l;
        e=m;
        f=n;           for(int ine=0;ine<6;ine++){
            list[ine]=listb[ine];
        }
    }
    void print(){
//        std::cout <<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<< f<<std::endl;
        if(list[0]==0)std::cout<<a<<std::endl;
        if(list[0]==1)std::cout<<b<<std::endl;
        if(list[0]==2)std::cout<<c<<std::endl;
        if(list[0]==3)std::cout<<d<<std::endl;
        if(list[0]==4)std::cout<<e<<std::endl;
        if(list[0]==5)std::cout<<f<<std::endl;
    }
    void move(int in){
        for(int ine=0;ine<6;ine++){
            list[ine]=listb[ine];
        }
        if(in==0){
           listb[0]=list[3];
           listb[2]=list[0];
           listb[3]=list[5];
           listb[5]=list[2];
        }
        if(in==1){
           listb[0]=list[4];
           listb[4]=list[5];
           listb[5]=list[1];
           listb[1]=list[0];
        }
        if(in==2){
            listb[0]=list[2];
            listb[2]=list[5];
            listb[5]=list[3];
            listb[3]=list[0];
        }
        if(in==3){
            listb[0]=list[1];
            listb[1]=list[5];
            listb[5]=list[4];
            listb[4]=list[0];
        }
        for(int ine=0;ine<6;ine++){
            list[ine]=listb[ine];
        }
    }
};

int main()
{
    std::string str,input;
    int aa,ba,ca,da,ea,fa,in;
    std::cin >>aa>>ba>>ca>>da>>ea>>fa;
    dice n(aa,ba,ca,da,ea,fa);
    std::cin >> str;
    for(int i=0;i<str.size();i++){
    input=str.substr(i,1);
    if(input=="E")in=0;
    if(input=="S")in=1;
    if(input=="W")in=2;
    if(input=="N")in=3;
    n.move(in);
    }
    n.print();
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

ll pw(ll a, ll n)
{
    ll ans = 1;
    while (n > 0)
    {
        if (n % 2 != 0)
            ans = ans * a;
        a = a * a;
        n = n / 2;
    }
    return ans;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    cout << k*pw(k-1, n-1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <tuple>
#include <stack>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>s;
    
     for(ll i=0;i<s.size();i++){
        if(s[i]=='h'&&s[i+1]=='i')i++;
         else {
             o=1;
             break;
         }
     }
     
    
    if(o==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++)
        cin>>l[i];
    long long int times=0;
    for(int i=0;i<n-2;i++)
        for(int j=i+1;j<n-1;j++)
    {
        if(l[i]==l[j])
            continue;
        else
        {
            for(int k=j+1;k<n;k++)
                if(l[k]!=l[i]&&l[k]!=l[j]&&l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[k]+l[j]>l[i])
                    {
                    //cout<<l[i]<<" "<<l[j]<<" "<<l[k]<<"\n";
                    times++;
                   }
        }
    }
    cout<<times;
}


Measured memory_bytes: 3628