akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void input(int *n, double x[], int u[]);
 
int main(int argc, char *argv[]){
  int n;
  double sum = 0;
  char cx[128], cu[3], *endptr;

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
    scanf("%s %s", cx, cu);

    if(cu[0] == 'J'){
      sum += strtol(strtok(cx, " "), &endptr, 10);
    }
    else{
      sum += 380000.0 * strtod(strtok(cx, " "), &endptr);
    }
  }

  printf("%lf\n", sum);
 
  return 0;
}

/////////////////////////////////////////////////////////////////////////

void input(int *n, double x[], int u[]){
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, a, b; cin >> n >> a >> b;
    if(a > b) cout << 0 << endl;
    else if(n == 1 && a!=b) cout << 0 << endl;
    else if(n == 1 && a == b) cout << 1 << endl;
    else{
        cout << (b - a)*(n - 2) + 1 << endl;
    }
}

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

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

ll ceil_ll(ll a, ll x){
    if(a%x) return a/x+1;
    return a/x;
}

int main(){
    ll n;
    cin >> n;
    ll a = 1;
    ll b = 1;

    for(int i=0; i<n; i++){
        ll x, y;
        cin >> x >> y;
        ll c = max(ceil_ll(a, x), ceil_ll(b, y));
        a = x * c;
        b = y * c;
    }
    ll ans = a + b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<ll> l(87);
	l[0] = 2;
	l[1] = 1;

	for (int i = 2; i < 87; i++) {
		l[i] = l[i - 1] + l[i - 2];
	}
	
	dunk(l[n]);

	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k, s;
  cin >> k >> s;
  long long ans = 0;
  for(int x = 0; x <= k; x++)
    for(int y = 0; y <= k; y++)
      if(0 <= s-x-y && s-x-y <= k) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";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); } }
#define here  cout<<"Here"<<endl;

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,K,idx=0;cin>>N>>K;
  vector<int> v;
  string S;cin>>S;
  if(S.at(0)=='0'){v.push_back(0);}
  for(int i=0;i<S.size();){
    int j=i;
    while(j<S.size()&&S[j]==S[i])j++;
    v.push_back(j-i);
    i = j;
  }
  if(S.back()=='0')v.push_back(0);

  vector<int> sums((int)v.size()+1,0);
  REP(i,0,v.size())sums[i+1]=sums[i]+v[i];

  int res=0;
   for(int left=0;left<sums.size();left+=2){
     int right=(left+K*2+1>=sums.size()?sums.size()-1:left+K*2+1);
     res=max(res,sums[right]-sums[left]);
   }
   print(res)


}


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

using ll = long long;

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

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min({a * b, a * c, b * c}) << endl;
	}

	return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;


//ABC129 D
int main(void) {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> hc(2000,vector<int>(2000, 0));
	vector < vector < int >> wc(2000, vector<int>(2000, 0));
	vector<string> mp;
	rep(0, h) {
		string s;
		cin >> s;
		mp.push_back(s);
	}

	rep(0, h) {
		int count = 0;
		int lastIndex = 0;
		for (int j = 0; j < w; j++) {
			if (mp[i][j] == '.') {
				count++;
				if (j == w - 1) {
					for (int k = lastIndex; k <= j; k++) {
						if (hc[i][k] != -1)
							hc[i][k] = count;
					}
				}
			}
			else {
				for (int k = lastIndex; k < j; k++) {
					if(hc[i][k] != -1)
					hc[i][k] = count;
				}
				count = 0;
				hc[i][j] = -1;
				lastIndex = j;
			}	
		}
	}

	rep(0, w) {
		int count = 0;
		int lastIndex = 0;
		for (int j = 0; j < h; j++) {
			if (mp[j][i] == '.') {
				count++;
				if (j == h - 1) {
					for (int k = lastIndex; k <= j; k++) {
						if (wc[k][i] != -1)
							wc[k][i] = count;
					}
				}
			}
			else {
				for (int k = lastIndex; k < j; k++) {
					if (wc[k][i] != -1)
					wc[k][i] = count;
				}
				count = 0;
				wc[j][i] = -1;
				lastIndex = j;
			}
			
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (hc[i][j] == -1 || wc[i][j] == -1) continue;
			ans = max(ans, (hc[i][j] + wc[i][j] - 1));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

//T とか u とかわけわからん変数が大量にある。
//場合分けが煩雑になってしまった。構成法がダメだったから。
// int Q;
//
// void solve() {
// 	cin >> Q;
// 	while(Q--) {
// 		ll a, b;
// 		cin >> a >> b;
// 		ll lv = 1, rv = 1000000000;
// 		while(rv - lv > 1) {
// 			ll m = (lv + rv) / 2;
// 			if(a * b - 1 > m * m + m) lv = m;
// 			else rv = m;
// 		}
// 		ll T = lv;
// 		debug(T);
// 		int minus = 0;
// 		ll u = (a * b - 1) / b;
// 		if(u) debug(u, (a * b - 1) / u, (a * b - 1) / (u + 1));
// 		if(u != 0 && (a * b - 1) / u - (a * b - 1) / (u + 1) <= 1) minus++;
// 		ll d = (a * b - 1) / a;
// 		ll l = (a * b - 1) / (a + 1), r = (a != 1 ? (a * b - 1) / (a - 1) : d);
// 		if(l == d && d == r) minus++;
// 		if(a == u) minus--;
// 		else cout << (a * b - 1) / (T + 1) + T - minus << "\n";
// 	}
// }

ll Q, A, B;

void solve() {
	cin >> Q;
	while(Q--) {
		cin >> A >> B;
		if(A > B) swap(A, B);
		if(B - A <= 1) cout << 2 * A - 2 << "\n";
		else {
			ll C = ll(sqrt(A * B) - eps);
			if(C * (C + 1) >= A * B) cout << 2 * C - 2 << "\n";
			else cout << 2 * C - 1 << "\n";
		}
	}
}
int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
# Algorithms and Data Structures 1
# Prime Numbers
# Name: Ryuya Asada
# ID s1260064


import math


def isPrimes(n: int) -> bool:
    if n == 2:
        return True

    if n % 2 == 0:
        return False

    for i in range(3, int(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False

    return True


def main():
    number_of_numbers = int(input())
    number_of_primes = 0

    for i in range(0, number_of_numbers):
        n = int(input())
        if isPrimes(n):
            number_of_primes += 1

    print(number_of_primes)



if __name__ == "__main__":
    main()



Measured memory_bytes: 5676
/*
	1041:Kyudo:A Japanese Art of Archery
*/
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int n, sum = 0;
		
		cin >> n;
		if(n == 0) { break; }
		
		for(int i = 0; i < n / 4; i++) {
			int a;
			cin >> a;
			
			sum += a;
		}
		
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import sys
def main():
    input = sys.stdin.readline
    N,M,Q=map(int, input().split())
    ABCD=[tuple(map(int, input().split())) for _ in range(Q)]

    def f(l):
        res=0
        for a,b,c,d in ABCD:
            if l[b]-l[a]==c: res+=d
        return res

    ans=0
    l=[]
    stk=[(1,1)]
    while stk:
        o,v=stk.pop()
        if o==1:
            stk.append((0,1))
            l.append(v)
            if len(l)==N+1:
                ans = max(ans, f(l))
            else:
                for i in range(l[-1],M+1):
                    stk.append((1,i))
        else:
            l.pop()
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"


template <typename T, typename K> struct P {
	T a; K b;
};

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
vector <P <ll, ll> >prime_factorize( ll N );
ll pow( ll a, ll n );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
int main( void ){
	// initialize();
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;

}

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

/*
 * @fn eratosthenes
 * @brief O(NloglogN)~=(N)
 * @param N: その数まで
 * @return 0 or 1 の配列 (boolは都合が悪い)
 */
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

/*
 * @fn prime_factorize
 * @brief O(√N): 素因数分解
 * @param N: 素因数分解する数
 * @return vec: (a: 素数, b: 個数)
 */
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
/*
 * @fn pow
 * @brief a^n
 * @param a: 基数
 * @param n: 指数
 */
ll pow( ll a, ll n ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp27 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = st[0];
            int K = st[1];

            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int index_1 = Array.IndexOf(A, 1);

            if (N <= K) {
                Console.WriteLine(1);
            } else {
                Console.WriteLine(Math.Ceiling((double)(N - 1) / (K - 1)));
            }
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    int x = 1001;
    int y = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        x = min(x,a[i]);
        y = max(y,a[i]);
    }
    cout << y - x << endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

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

    double ans;
    if (a * a * b / 2.0 < x) {
        ans = atan2(2 * b - 2 * x / a / a, a);
    } else {
        ans = atan2(b, 2 * x / a / b);
    }

    ans = ans / PI * 180;

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// vector<int> vec(3); = vector<int> vec={0,0,0}
// vec.at()
// sort(num.begin(),num.end(), greater<int>());
// reverse(num.begin(),num.end());
 
// 切り上げ　a/b+1
//  1からNの総和　N*(N+1)/2
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
 
  if(a == b && a == c){
  	cout << 1 << endl;
  }
  else if(a==b || b==c || a==c){
  	cout << 2 << endl;
  }else{
  	cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,d[100],i,j,k,s;
long long x;
int main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",d+i);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if(d[i]==d[j]||d[j]==d[k]||d[k]==d[i])continue;
                if((long long)d[i]+d[j]+d[k]-max(d[i],max(d[j],d[k]))*2>0){
                    
                    s++;
                }
            }
        }
    }
    printf("%d",s);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const int dh[4] = {0, 1, 0, -1};
const int dw[4] = {1, 0, -1, 0};

int H, W;
vector<string> M;

int main() {
	cin >> H >> W;
	M.resize(H);
	rep(h, H) cin >> M[h];

	int max_dist = 0;
	rep(h, H) rep(w, W) {
		if (M[h][w] == '#') continue;
		vector<vector<int>> dist(H, vector<int>(W, -1));
		queue<pair<int, int>> que;
		que.push(make_pair(h, w));
		dist[h][w] = 0;
		while (!que.empty()) {
			pair<int, int> p = que.front();
			que.pop();

			rep(i, 4) {
				int nh = p.first + dh[i];
				int nw = p.second + dw[i];
				if (nh<0 || nh>=H || nw<0 || nw>=W) continue;
				if (M[nh][nw] == '#') continue;
				if (dist[nh][nw] != -1) continue;

				dist[nh][nw] = dist[p.first][p.second] + 1;
				que.push(make_pair(nh, nw));
			}
		}
		rep(i, H) rep(j, W) {
			// cout << dist[i][j] << endl;
			if (dist[i][j] > max_dist) max_dist = dist[i][j];
		}
	}
	cout << max_dist << endl;

}

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

int main(int argc, char *argv[]) {
  std::vector<int> a;
  int x;
  while (std::cin >> x)
    a.push_back(x);

  for (auto &v : a) {
    if (v % 2 == 0) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }

  auto max = std::max_element(a.begin(), a.end());
  long area = 1;
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != max)
      area *= *it;
  }
  std::cout << area << std::endl;
}


Measured memory_bytes: 256
mylistA=[]
mylistB=[]
N,L=map(int,input().split())
for i in range(1,N+1):
  y=L+i-1
  mylistA.append(y)
  
mylistB=list(map(abs,mylistA))
x=min(mylistB)
z=mylistB.index(x)
print(sum(mylistA)-mylistA[z])


Measured memory_bytes: 3060
from collections import deque
 
def bfs():
  que = deque([])
  que.append(0)
  
  while que:
    now = que.popleft()
    for next in g[now]: #部屋1から行ける場所で回す
      if d[next] == 0:
        que.append(next)
        d[next] = now +1
        
n,m = map(int,input().split())
g = [[] for i in range(n)]
d = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  g[a].append(b)
  g[b].append(a)
  
bfs()
print('Yes')
for i in range(1,n):
  print(d[i])



Measured memory_bytes: 37076
H, N = map(int, input().split())
l = []
for i in range(N):
    a, b = map(int, input().split())
    l.append((a, b))
inf = 1e10
dp = [inf] * (H+1)
dp[0] = 0
for i in range(1, H+1):
    for j in range(N):
        (a, b) = l[j]
        if i >= a:
            dp[i] = min(dp[i], dp[i-a]+b)
        else:
            dp[i] = min(dp[i], b)
print(dp[H])

Measured memory_bytes: 42476
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


print(
    "NO"
    if ii(str)
    .replace("eraser", "")
    .replace("erase", "")
    .replace("dreamer", "")
    .replace("dream", "")
    else "YES"
)


Measured memory_bytes: 3188
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll long long

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define $ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

#define mod 1000000007

#define Mod 998244353

#define MOD 1234567891

#define pi acos(-1)

using namespace std;

ll n, i, ans=1e18;

main()
{$
    cin >> n;

    for (i=1; i*i<=n; i++) if (n%i==0) ans=min(ans, i+n/i);

    cout << ans-2;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import math

num = int(input())
array_str = input().split(" ")
array = [int(n) for n in array_str]

value=0
a=0
b=0
modbase=int(7+math.pow(10,9))
for i in range(len(array)-1):
  bindex=i*(-1)-1
  b+=array[bindex]
  a=array[bindex-1]
  value+=a*b
print(value%modbase)

Measured memory_bytes: 32988
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec: Vec<(i32, i32)> = vec![];
    for _ in 0..N {
        vec.push((read(), read()));
    }

    use std::cmp::{max, min};
    let mut z_max = std::i32::MIN;
    let mut z_min = std::i32::MAX;
    let mut w_max = std::i32::MIN;
    let mut w_min = std::i32::MAX;
    for (x, y) in vec {
        let z = x - y;
        let w = x + y;
        z_max = max(z_max, z);
        z_min = min(z_min, z);
        w_max = max(w_max, w);
        w_min = min(w_min, w);
    }
    println!("{}", max(z_max - z_min, w_max - w_min));
}


Measured memory_bytes: 3708
S = input()
N = len(S)
a,b = 0,0
l = [0]

for i in range(N):
  if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
    a += 1
    b = 1
  else:
    if b:
      l.append(a)
      b = 0
      a = 0
else:
  if a:
    l.append(a)
  print(max(l))

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const ll INF = 1e15;

int main() {
  ll x;
  cin >> x;
  bool ok[100500];
  REP(i, 100500) ok[i] = false;

  FOR(i, 100, 106) ok[i] = true;
  REP(i, 100010) {
    if (!ok[i]) continue;
    FOR(j, 100, 106) ok[i + j] = true;
  }

  if (ok[x]) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vll = vector<ll>;
using vvll = vector<vll>;

int main()
{
  int N, A,charge;
  cin >> N >> A;
  charge = N % 500;
  if(charge>A)
    cout << "No" << endl;
    else
      cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll gcd(ll m, ll n){
  if(n==0) return m;
  return gcd(n, m%n);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vll A(N);
  vll A_gcd_before(N, -1);
  vll A_gcd_after(N, -1);
  REP(i, N) cin >> A[i];

  A_gcd_before[1] = A[0];
  A_gcd_after[N-2] = A[N-1];

  FOR(i, 2, N){
    A_gcd_before[i] = gcd(A_gcd_before[i-1], A[i-1]);
  }
  RFOR(i, N-3, 0){
    A_gcd_after[i]  = gcd(A_gcd_after[i+1], A[i+1]);
  }

  ll ans = A_gcd_after[0];
  FOR(i, 1, N-1){
    ans = max(ans, gcd(A_gcd_before[i], A_gcd_after[i]));
  }
  ans = max(ans, A_gcd_before[N-1]);

  cout << ans << "\n";

  return 0;
}

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

using namespace std;

const int maxn = 111111;
int a[maxn];

int main (){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    a[n] = a[n - 1] + 1;
    sort(a, a + n);
    int k = 0;
    int sum = 1;
    for (int i = 0; i < n; i++){
        if (a[i] == a[i + 1])
            sum ++;
        else{
            if (sum % 2 == 1)
                k ++;
            sum = 1;
        }
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 640
n= True
while True:
    for i in range(3):
        p = list(input())
        if p[0] == '0':
            n= False
            break
        
        a, b = 0, 0
        del p[0]
        for j in p:
            if j == 'A': a += 1
            else: b += 1
        if a > b: a += 1
        else: b += 1
        print(a, b)
    if not n: break



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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
    in(n);
    unordered_map<string, int> m;
    rep(i, n) {
        string s;
        cin >> s;
        ++m[s];
    }
    out(m.size());
    return 0;
}


Measured memory_bytes: 17560
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  int sum = 1900*M+100*(N-M);
  cout << sum*(1<<M) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define yo cout<<"i got here\n";
using namespace std;///give dp,bs a try
const int mod = 1e9+7,siz = 1e6+5;
int t,n,m,k,a[siz];
int32_t main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);

   cin>>n;
   for(int i = 1;i<=n;i++) cin>>a[i];
   sort(a+1,a+1+n); int ans = 0;
   for(int i = 1;i<n-1;i++)
   {
       for(int j = i+1;j<n;j++)
       {
           for(int k = j+1;k<=n;k++)
           {
               if(a[i]+a[j]>a[k] and a[i]!=a[j] and a[j]!=a[k]) ans++;
           }
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3672
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	ll n, k;
	cin >> n >> k;
	std::vector<ll> v(n);

	rep(i, n)
	{
		cin >> v[i];
		v[i]--;
	}
	if (k == 1)
	{
		cout << v[0] << endl;
		return 0;
	}
	ll arr[200005] = {0};
	arr[0] = 1;

	ll i = 0, index = 0, size;
	while (true)
	{
		k--;
		if (arr[v[i]] == 1)
		{
			i = v[i];
			index = i;
			break;
		}
		arr[v[i]] = 1;

		if (k == 0)
		{
			cout << v[i] + 1 << endl;
			return 0;
		}

		i = v[i];
	}


	if (k == 0)
	{
		cout << i + 1 << endl;
		return 0;
	}



	ll c = 0, x = 0;
	memset(arr, 0, sizeof(arr));
	arr[i] = 1;


	while (1)
	{
		c++;
		i = v[i];
		if(arr[i]==1)
			break;
		arr[i] = 1;
		
	}


	// cout<<c<<"->"<<k<<endl;
	// cout<<k%c<<endl;
	ll rem = k % c;

	//cout<<rem<<endl;



	ll ans = index;
	while (rem--)
	{
		ans = v[index];
		index = v[index];
	}
	cout << ans +1 << endl;
	return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int x,y,z;
    cin >> x >> y >> z;
    cout << x*y/2 << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int MAXN = 200010 ;
struct tjz
{
	int u, v, w;
}edge[MAXN];
int n, m;
bool cmp(tjz x, tjz y)
{
	return x.w < y.w;
}
int f[MAXN], ans;
int getfa(int x)
{
	if (f[x] == x) return x;
	return f[x] = getfa(f[x]);
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) cin >> edge[i].u >> edge[i].v >> edge[i].w ;
	sort(edge + 1, edge + m + 1, cmp);
	for (int i = 1; i <= n; ++i) f[i] = i;
	for (int i = 1; i <= m; ++i)
	{
		int fa1 = getfa(edge[i].u);
		int fa2 = getfa(edge[i].v);
		if (fa1 != fa2)
		{
			f[fa1] = fa2;
			ans += edge[i].w;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4316
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m;
	cin>>n>>m;
	VV(pii) vv(n);
	VV(pii) rv(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		c*=-1;
		vv[a].PB(pii(b,c));
		rv[b].PB(pii(a,c));
	}
	vll v(n,INFL);
	v[0] = 0;
	rep(i,n){
		rep(j,n){
			for(pii x: vv[j]){
				mins(v[x.F], v[j]+x.S);
			}
		}
	}
	ll pre = v[n-1];
	rep(i,n){
		rep(j,n){
			for(pii x: vv[j]){
				mins(v[x.F], v[j]+x.S);
			}
		}
	}
	ll post = v[n-1];
	if(pre > post){
		cout<<"inf"<<endl;
	}
	else{
		cout<<-v[n-1]<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int n,m; cin >> n >> m;
  vi box(n,1),red(n); red[0] = 1;
  rep(i, m){
    int x,y; cin >> x >> y; x--; y--;
    box[x]--;
    box[y]++;
    if(red[x] == 1) red[y] = 1;
    if(box[x] == 0) red[x] = 0;
  }
  int ans = 0;
  rep(i, n) if(red[i]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#coding:utf-8
min = 0
L = list(map(int,input().split()))
for i in range(len(L)):
    min += L[i]
for i in range(3):
    for j in range(3):
        if i != j:
            if L[i]+L[j] < min :
                min = L[i]+L[j]
print(min)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
 using namespace std;
 
 const int limit = 50;
 int n, m;
int a[limit], b[limit];
 bool graph[limit][limit];
 bool visited[limit];

 void dfs(int v) 
 {
 visited[v] = true;
 for (int v2 = 0; v2 < n; ++v2) 
 {
 if (graph[v][v2] == false) continue;
 if (visited[v2] == true) continue;
 dfs(v2);
 }
 }

 int main(void) {

 cin >> n >> m;
 for (int i = 0; i < m; ++i) {
 cin >> a[i] >> b[i];
 a[i]--, b[i]--;
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }

 int ans = 0;

 for (int i = 0; i < m; ++i) 
 {
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

 for (int j = 0; j < n; ++j)
 visited[j] = false;

 dfs(0);

 bool bridge = false;
 for (int j = 0; j < n; ++j)
 if (visited[j] == false)
 bridge = true;
 
 if (bridge) ans += 1;

 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true; } 
 
 cout << ans << endl; return 0;
 }

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
x = 1
ans = 0
while x**2<=N:
    if N%x==0:
        div = N//x
        if div-1>x:
            ans += div-1
    x += 1

print(ans)

Measured memory_bytes: 63992
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (getType(x) == getType(y)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
	static int getType(int i) {
		switch (i) {
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
			return 1;
			case 4:
			case 6:
			case 9:
			case 11:
			return 2;
		}
		return 0;
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int n,k;
char s[100005];
int main()
{
    scanf("%s",s+1);
    int l=strlen(s+1);
    int ans=0;
    for(int i=2;i<=l;i++)
    {
        if(s[i]==s[i-1])
        {
            ans++;
            if(s[i]=='0') s[i]='1';
            else s[i]='0';
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    string ans;
    ans += s1[0] - 'a' + 'A';
    ans += s2[0] - 'a' + 'A';
    ans += s3[0] - 'a' + 'A';

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
n = input()
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
  print("0")
  sys.exit()  

for aa in a:
  ans = ans * aa
  if ans > 10**18:
    print("-1")
    sys.exit()
print(ans)

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

using namespace std;

int main()
{
    int no_of_people, no_of_foods;
    cin >> no_of_people >> no_of_foods;

    vector <int> no_of_likes(no_of_foods + 1, 0);

    for(int p = 1; p <= no_of_people; p++)
    {
        int no_of_liked_foods;
        cin >> no_of_liked_foods;

        for(int f = 1; f <= no_of_liked_foods; f++)
        {
            int food;
            cin >> food;

            no_of_likes[food]++;
        }
    }

    int no_of_liked_foods = 0;
    for(int i = 1; i <= no_of_foods; i++)
        no_of_liked_foods += (no_of_likes[i] == no_of_people);

    cout << no_of_liked_foods;
    return 0;
}


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

int main() {
    lint n, k;
    cin >> n >> k;

    lint ma = (n-1)*(n-2)/2;
    if(k > ma) {
        cout << -1 << endl;
        return 0;
    }

    lint m = (n-1) + ma - k;
    cout << m << endl;

    lint i = 1, j = 2;
    while(m--) {
        cout << i << " " << j << endl;
        if(++j > n)  i++, j = i+1;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
P p[250005];
llint dist[505][505];
bool used[505][505];
llint dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

void bfs(llint x, llint y)
{
	deque<P> deq;
	deq.push_back(P(x, y));
	
	while(deq.size()){
		x = deq.front().first, y = deq.front().second;
		deq.pop_front();
		for(int i = 0; i < 4; i++){
			llint nx = x + dx[i], ny = y + dy[i];
			if(nx < 1 || nx > n || ny < 1 || ny > n) continue;
			if(dist[nx][ny] <= dist[x][y]) continue;
			
			if(used[nx][ny]){
				dist[nx][ny] = dist[x][y];
				deq.push_front(P(nx, ny));
			}
			else{
				if(dist[nx][ny] <= dist[x][y] + 1) continue;
				dist[nx][ny] = dist[x][y]+1;
				deq.push_back(P(nx, ny));
			}
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint pos;
	for(int i = 1; i <= n*n; i++){
		cin >> pos;
		pos--;
		p[i] = P(pos%n+1, pos/n+1);
	}
	
	for(llint x = 1; x <= n; x++){
		for(llint y = 1; y <= n; y++){
			dist[x][y] = min(min(abs(x), abs(y)), min(abs(n+1-x), abs(n+1-y)));
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= n*n; i++){
		llint x = p[i].first, y = p[i].second;
		ans += dist[x][y] - 1;
		dist[x][y]--;
		used[x][y] = true;
		bfs(x, y);
		
		/*cout << x << " " << y << endl;
		for(int x = 1; x <= n; x++){
			for(int y = 1; y <= n; y++){
				cout << dist[y][x] << " ";
			}
			cout << endl;
		}
		cout << ans << endl;*/
	}
	cout << ans << endl;
	

	
	return 0;
}

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

int main()
{
	int r, c;
	int i, j;
	int a[101][101];

	cin >> r >> c;

	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			a[i][j] = 0;
		}
	}

	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
		a[r][c] += a[i][c];
	}

	for (i = 0; i <= r; i++) {
		for (j = 0; j < c; j++) {
			cout << a[i][j] << " ";
		}
		cout << a[i][c] << endl;
	}
	return 0;
}




Measured memory_bytes: 3104
def solve():
    max_weight, list_of_weight_and_value = read()
    result = think(max_weight, list_of_weight_and_value)
    write(result)


def read():
    n, max_weight = read_int(2)
    list_of_weight_and_value = []
    for i in range(n):
        list_of_weight_and_value.append(read_int(2))
    return max_weight, list_of_weight_and_value


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(max_weight, list_of_weight_and_value):
    MAX_WEIGHT = 10 ** 9
    MAX_VALUE = 10 ** 3
    MAX_N = 100
    INVALID_VALUE = MAX_WEIGHT * MAX_N + 1

    # dp[v] means minimum weight achieves total value 'v'
    dp = [INVALID_VALUE for x in range(MAX_VALUE * len(list_of_weight_and_value) + 1)]
    dp[0] = 0

    for weight, value in list_of_weight_and_value:
        for i in range(len(dp) - 1, -1, -1):
            if dp[i] != INVALID_VALUE and i + value < len(dp):
                if dp[i + value] == INVALID_VALUE:
                    dp[i + value] = dp[i] + weight
                else:
                    dp[i + value] = min(dp[i + value], dp[i] + weight)
    for i in range(len(dp) - 1, -1, -1):
        if dp[i] != INVALID_VALUE and dp[i] <= max_weight:
            return i


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 44784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
void factorize(Int x, vector<pair<int, int>>& f)
{
    for (Int i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            int cnt = 0;
            while (x % i == 0) x /= i, cnt++;
            f.emplace_back(i, cnt);
        }
    }
    if (x != 1) f.emplace_back(x, 1);
}
int smallest = 100;
void recur(Int N, const vector<pair<int, int>>& f, int i, vector<int>& ns)
{
    if (i == f.size()) {
        Int a = 1, b = 1;
        REP(j, f.size()) a *= pow(f[j].first, ns[j]); 
        b = N / a;
        smallest = min(smallest, max((int)log10(a) + 1, (int)log10(b) + 1));
    } else {
        for (int j = 0; j <= f[i].second; j++) {
            ns[i] = j;
            recur(N, f, i+1, ns);
        }
    }
}
int main()
{
    Int N; cin >> N;
    vector<pair<int, int>> f;
    factorize(N, f);
    vector<int> ns(f.size());
    recur(N, f, 0, ns);
    cout << smallest << endl;
    return 0;
}

Measured memory_bytes: 512
while True:
    n = int(input())
    if n == 0:
        break
    ices = [0 for i in range(10)]
    for i in range(n):
        ices[int(input())] += 1
    for ice in ices:
        if ice == 0:
            print("-")
        else:
            print("*"*ice)



Measured memory_bytes: 5628