akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
   int H,W;
   
   while(true){
       cin >> H >> W;
       if( H == 0 && W == 0) break;
       for(int i = 1; i <= W; i++) cout << "#"; 
       cout << endl;
       for(int i = 1; i <= H-2 ; i++){
           cout << "#";
           for(int j = 1; j <= W-2; j++) cout << ".";
           cout << "#";
           cout << endl;
       }
       for(int i = 1; i <= W; i++) cout << "#";
       cout << endl << endl;
   }
   return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas

using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
	for (T x : s)
		cout << x + 1 << " ";
	cout << endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int cnt = 0;
	ll answer = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'A')
			cnt++;
		if (s[i] == 'C')
			cnt = 0;
		if (s[i] == 'B'){
			if (i + 1 < s.size() && s[i + 1] == 'C'){
				answer += cnt;
				i++;
			}
			else
				cnt = 0;
		}
	}
	cout << answer << endl;
	return 0;	
}

Measured memory_bytes: 764
#include<iostream>
#include<string>

using namespace std;
int main() {
	long long X;
	cin >> X;
	int a, b;
	a = X / 500;

	b = (X - 500 * a) / 5;

	int answer;
	answer = 1000 * a + 5 * b;
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

ll n, m;
ll solve(ll x){
	//cからx個 ss を作る
	ll s = n + x;
	ll c = m - 2 * x;
	if(s >= 0 && c >= 0){
		if(s >= c / 2) return c / 2;
		else return s;
	}else{
		return 0ll;
	}
}

int main(void){
	cin >> n >> m;
	ll l = 0, r = m / 2;
	while(r - l > 10){
		ll m1 = (l * 2 + r) / 3;
		ll m2 = (l + 2 * r) / 3;
		if(solve(m1) > solve(m2)){
			r = m2;
		}else{
			l = m1;
		}
	}
	ll ans = 0;
	for (ll i = l; i <= r; ++i){
		// printf("%lld %lld\n", i, solve(i));
		chmax(ans, solve(i));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int A[100], B[100], C[100];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> A[i];
	for (int i = 1; i <= N; i++)cin >> B[i];
	for (int i = 1; i <= N-1; i++)cin >> C[i];

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += B[A[i]];
		if (A[i-1]+1 == A[i])ans += C[A[i-1]];
	}
	puts(ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, n, t = 0;
	cin >> n;
	vector<int>vec(n);
	map<int, int>m;
	rep(i, n) {
		cin >> vec[i];
		if (!m.count(vec[i])) {
			m[vec[i]] = 1;
		}
		else {
			m[vec[i]]++;
		}
	}
	for (auto p : m) {
		auto key = p.first;
		auto value = p.second;
		t += (p.second - 1) * p.second / 2;
	}

	rep(i, n) {
		cout << t - (m[vec[i]] - 1) << endl;
	}
}


Measured memory_bytes: 11008
#include<iostream>
using namespace std;
int main() {
	int N, H;
	cin >> H >> N;
	int a = 0;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		cin >> a;
		ans = ans + a;
	}
	if (ans >= H) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
	int m;
	vector<int> M,N;
	vector<vector<int>> POW;
	while (cin >> m) 
		M.push_back(m);
	for (int i = 0; i < M.size(); i++) {
		int mi = M[i];
		for (int j = 0; j < 10; j++) {
			if (pow(2, j) <= mi && mi < pow(2, j + 1)) {
				N.push_back(j); mi -= pow(2, j);
				if (mi == 0)break;
				else j = -1;
			}
		}
		sort(N.begin(), N.end());
		POW.push_back(N); N.clear();
	}
	for (int i = 0; i < POW.size(); i++) {
		for (int j = 0; j < POW[i].size(); j++) {
			if (j != POW[i].size() - 1)cout << pow(2, POW[i][j]) << " ";
			else cout << pow(2,POW[i][j]) << endl;
		}
	}
	return 0;
}

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

int main()
{	
	int a[3];
	int t[4] = { 0, 0, 0, 0 };

	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);

	while (a[0] + a[1] > a[2]) {
		t[0]++;

		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
			t[1]++;
		else if (a[0] * a[0] + a[1] * a[1] > a[2] * a[2])
			t[2]++;
		else
			t[3]++;

		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
	}

	cout << t[0] << " " << t[1] << " " << t[2] << " " << t[3] << endl;

	return 0;
}



Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(),W = sc.nextInt();
		char[][] ary = new char[H][W];
		for(int i = 0; i < H; i++) {
			ary[i] = sc.next().toCharArray();
		}

		for (int i = 0; i < H; i++){
			for (int n = 0; n < W; n++) {
				if(ary[i][n] == '#') {
					System.out.print('#');
					continue;
				}
				int count = 0;
				if(i > 0) {
					if(n > 0 && ary[i-1][n-1] == '#') count++;
					if(ary[i-1][n] == '#') count++;
					if(n+1 < W && ary[i-1][n+1] == '#') count++;
				}

				if(n > 0  && ary[i][n-1] == '#') count++;
				if(n+1 < W && ary[i][n+1] == '#') count++;

				if(i+1 < H) {
					if(n > 0 && ary[i+1][n-1] == '#') count++;
					if(ary[i+1][n] == '#') count++;
					if(n+1 < W && ary[i+1][n+1] == '#') count++;
				}
				System.out.print(count);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args) {	
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int n1=a+b;
		int n2=a-b;
		int n3=a*b;
		if(n1>=n2&&n1>=n3) {
			System.out.println(n1);
		}else if(n2>=n3&&n2>=n1) {
			System.out.println(n2);
		}else {
			System.out.println(n3);
		}
		
   }
}

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

int main(){
	int ans = 0;
	bool flag;
	string s;

	while( getline(cin,s) ){
		flag = true;
		for(int i=0 ; i<s.size() ; i++){
			if(s[i]!=s[s.size()-i-1]){
				flag = false;
				break;
			}
		}
		if(flag) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

// 整数スキャン（複数）
/*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

// n個の整数のスキャン
/*
ll a[n] = {};
rep(i,n){
    scanf("%lld",&a[i]);
}
*/

// 文字列スキャン
/*
string s;
cin >> s;
*/


int main() {
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    int max=x;

    if(max<y){
        max=y;
    }
    if(max<z){
        max=z;
    }




    int ans = 0;
    ans = x+y+z+(max*9);

    cout << ans << endl;
   
    return 0;
}
 
 


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 1e6+7;
int n = 0, q = 0;

struct Query{
	int id, l, r;
	bool operator< (Query a) const{
		return r < a.r;
	}
}query[maxn];



int v[maxn], sum[maxn], ans[maxn];

int lowbit(int x){
	return x & (-x);
}

void change(int i, int a){
	while(i <= n){
		sum[i] += a;
		i += lowbit(i);
	}
}

int getsum(int i){
	int sum_t = 0;
	while(i > 0){
		sum_t += sum[i];
		i -= lowbit(i);
	}
	return sum_t;
}
#define ll long long
int main() {
	ll k;cin>>k;
	ll tmp=0;
	ll ans=0;
	map<ll,ll>mp;
	int cnt=100000000;
	while(cnt--){
		ans=ans*10ll+7;
		tmp++;
		ans%=k;
		if(ans==0) return cout<<tmp<<endl,0;
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  ll N;cin >> N;
  int D_sum=0;
  ll n=N;
  while(N!=0){
    D_sum += N%10;
    N/=10;
  }
  if(n%D_sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 768
#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() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<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 = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int A[100] = 
{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};

void solve() {
	int at; cin >> at; at--;
	cout << A[at] << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
var square = function(x) {return Math.pow(x, 3);}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
process.stdin.on('data', function(ab) {
	var result = ab.split(" ");
	var a = result[0];
	var b = result[1];
	console.log(a*b , 2*a+2*b);
});

Measured memory_bytes: 15432
import math
def ip():return int(input())
def imp():return map(int,input().split())
def impstr():return map(str,input().split())
def limp():return list(map(int,input().split()))
def limpstr():return list(map(str,input().split()))

x,n=imp()
l=limp()
if n==0:
    print(x)
    exit()
else:
    k=0
    while True:
        if x-k not in l:
            print(x-k)
            exit()
        if x+k not in l:
            print(x+k)
            exit()
        k+=1



Measured memory_bytes: 62152
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int k,x;
	cin >> k >> x;
	for(int i = x - k + 1;i <= x + k - 1;i++){
		cout << ((i == x - k + 1) ? "" : " ") << i;
	}
	cout << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,b,c,d,memo[200000],ma,mi,bb,cc,aa,aaa;
bool f,ff;
string s;

signed main() {
    cin >> n >> a >> b >> c >> d >> s;
    a--,b--,c--,d--;
    ma = max(max(a,b),max(c,d));
    mi = min(min(a,b),min(c,d));
    repo(i,mi,ma) {
        if (s[i] == '#') bb++,cc=0;
        else cc++,bb=0;
        if (cc==3) {
            if (!f && max(a,b) < i) {
                f = true;
                aa = i-1;
            }
        }
        if (bb>=2) {
            if ((a < i && i < c) || b < i && i < d) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    if (c > d) {
        if (f && aa <= min(c,d)) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else cout << "Yes" << endl;

}

Measured memory_bytes: 640
#include<stdio.h>

int main(void) {

	int a, b;

	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n");
	}
	
	else if (a > b) {
		printf("a > b\n");
	}

	else {
		printf("a == b\n");
	}

	return(0);

}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <stdio.h>
#include <list>

using namespace std;

//#define EPS (1e-10)
//
//struct Point{
//    Point(double _x = 0, double _y = 0){
//        x = _x;
//        y = _y;
//    }
//    double x;
//    double y;
//
//    Point operator + (Point p){
//        return Point(x + p.x, y+ p.y);
//    }
//
//    Point operator - (Point p){
//        return Point(x - p.x, y - p.y);
//    }
//
//    Point operator * (double a){
//        return Point(a * x, a * y);
//    }
//
//    Point operator / (double a){
//        return Point(x / a, y / a);
//    }
//
//    double abs(){
//        return sqrt(norm());
//    }
//
//    double norm(){
//        return x * x + y * y;
//    }
//
//    bool operator < (const Point &p) const{
//        return x!=p.x ? x < p.x : y < p.y;
//    }
//
//    bool operator == (const Point &p) const{
//        return fabs(x - p.x) && fabs(y - p.y) < EPS;
//    }
//
//};
//
//typedef Point Vector;
//
//double dot(Vector a, Vector b){
//    return a.x * b.x + a.y * b.y;
//}

int main() {

    int count = 0;
    int a;scanf("%d",&a);
    int b;scanf("%d",&b);
    int c;scanf("%d",&c);
    int x;scanf("%d",&x);

    for(int i=0; i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if((500*i + 100*j + 50*k) == x){
                    count++;
                }
            }
        }
    }

    printf("%d",count);

    return 0;

}

Measured memory_bytes: 256
def gen_divs(n):
    divs = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n // i)
    return divs


def divthensub(v, div):
    while v % div == 0:
        v //= div
    if v % div == 1:
        return True
    else:
        return False


n = int(input())
if n == 2:
    print(1)
else:
    print(len([i for i in gen_divs(n) if divthensub(n, i)]) + len(gen_divs(n - 1)) + 2)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> island[n];
    repi(i, m, 0)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        island[a].push_back(b);
        island[b].push_back(a);
    }
    for (int one : island[0])
    {
        for (int two : island[one])
        {
            if (two == n - 1){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

class Time
{
  public:
    Time(int hour, int min, int sec);
    Time(int time);
    void Show();
    int Get_time();
    int Diff_time(Time other);

  private:
    int m_time;
};

Time::Time(int hour, int min, int sec)
{
  m_time = hour * 3600 + min * 60 + sec;
}

Time::Time(int time)
{
  m_time = time;
}

void Time::Show()
{
  int buf_time = m_time;
  int hour = buf_time / 3600;
  buf_time -= hour * 3600;
  int min = buf_time / 60;
  buf_time -= min * 60;
  int sec = buf_time;

  cout << hour << ' ' << min << ' ' << sec << endl;
}

int Time::Get_time()
{
  return m_time;
}

int Time::Diff_time(Time other)
{
  return m_time - other.Get_time();
}

int main(void)
{
  int h1, m1, s1, h2, m2, s2;
  for (int i = 0; i < 3; ++i)
  {
    cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
    Time time1(h1, m1, s1);
    Time time2(h2, m2, s2);
    int diff = time2.Diff_time(time1);
    Time job_time(diff);

    job_time.Show();
  }
  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		if (b == 'H') {
			cout << "H";
		}
		else {
			cout << "D";
		}
	}
	else {
		if (b == 'H') {
			cout << "D";
		}
		else {
			cout << "H";
		}
	}
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    //let n = read::<u32>();
    let v = read_vec::<u32>();
    let x = v[0];
    let a = v[1];

    if x < a {
        println!("0");
    } else {
        println!("10");
    }
}


Measured memory_bytes: 4352
/*  I won't be silenced                       */
/*  You can't keep me quiet                   */
/*  Won't tremble when you try it             */
/*  All I know is I won't go speechless       */
/*  'Cause I'll breathe                       */
/*  When they try to suffocate me             */
/*  Don't you underestimate me                */
/*  'Cause I know that I won't go speechless  */

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;
ll mod=1000000007;

int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);

ll t=1;
//cin>>t;
while(t--)
{
ll n;
cin>>n;
ll i;
map<string,ll>mp;

for(i=0;i<n;i++)
{
string s;
cin>>s;
mp[s]++;
}



 cout<<"AC x "<<mp["AC"]<<endl;
 cout<<"WA x "<<mp["WA"]<<endl;
 cout<<"TLE x "<<mp["TLE"]<<endl;
 cout<<"RE x "<<mp["RE"]<<endl;


}
return 0;
}














Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
using namespace std;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(fabs(a - c) <= d){
        cout << "Yes" << "\n";
    }
    // 分けないと実行時間が9msになる
    else if((fabs(a - b) <= d) && (fabs(b - c) <= d)){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
int ans;

struct cube{
	int p[100];
	void roll(int t){
		if (t == 0){
			swap(p[0], p[27]);
			swap(p[1], p[28]);
			swap(p[2], p[29]);
			swap(p[14], p[15]);
			swap(p[18], p[20]);
		}
		else if (t == 1){
			swap(p[0], p[23]);
			swap(p[3], p[26]);
			swap(p[6], p[29]);
			swap(p[15], p[17]);
			swap(p[9], p[20]);
		}
		else if (t == 2){
			swap(p[6], p[21]);
			swap(p[7], p[22]);
			swap(p[8], p[23]);
			swap(p[12], p[17]);
			swap(p[9], p[11]);
		}
		else{
			swap(p[2], p[21]);
			swap(p[5], p[24]);
			swap(p[8], p[27]);
			swap(p[11], p[18]);
			swap(p[12], p[14]);
		}
	}
	bool ok(){
		REP(i, 9){
			if (p[0] != p[i]){
				return false;
			}
			if (p[21] != p[21 + i]){
				return false;
			}
		}
		REP(i, 3){
			if (p[12] != p[12 + i])return false;
			if (p[15] != p[15 + i])return false;
			if (p[18] != p[18 + i])return false;
			if (p[9] != p[9 + i])return false;
		}
		return true;
	}
};

void solve(int cnt, cube c){
	//cout << "!" << cnt << endl;
	//REP(i, 3){
	//	REP(j, 3){
	//		cout << c.p[i * 3 + j] << " ";
	//	}
	//	cout << endl;
	//}
	//REP(i, 4){
	//	REP(j, 3){
	//		cout << c.p[9 + i * 3 + j] << " ";
	//	}
	//	cout << endl;
	//}
	//REP(i, 3){
	//	REP(j, 3){
	//		cout << c.p[27 - i * 3 + j] << " ";
	//	}
	//	cout << endl;
	//}
	if (c.ok()){
		//cout << "!" << endl;
		ans = min(cnt, ans);
		return;
	}
	if (cnt == 8 || ans == cnt){
		return;
	}
	cube buf;
	REP(i, 4){
		buf = c;
		buf.roll(i);
		solve(cnt + 1, buf);
	}
}

int main(){
	cin >> n;
	REP(i, n){
		ans = 10;
		cube c;
		REP(j, 30)cin >> c.p[j];
		solve(0, c);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3120
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=10005;
const int MAXM=100000005;
const int INF=1000000005;
int k,n,m,l,fa[MAXN];
double ans,sum;
int x[MAXN],y[MAXN];
struct node{
	int x,y;
	double z;
}s[MAXM];
bool cmp(const node A,const node B){
	return A.z>B.z;
}
void Add(int x,int y,double z){
	s[++l].x=x,s[l].y=y,s[l].z=z;
}
int find(int x){
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}
void Kruskal(){
	sort(s+1,s+m+1,cmp);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	int i,j;
	for(i=1,j=1;i<=m&&j<=n-1;i++){
		int x=find(s[i].x),y=find(s[i].y);
		if(x!=y){
			fa[x]=y;
			ans+=s[i].z;
			j++;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		double c=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
		sum+=c;
		Add(a,b,c);
	}
	Kruskal();
	printf("%.3lf\n",sum-ans);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int l[n];
	int max=0;
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> l[i];
		sum = sum + l[i];
		if(max<l[i]){
			max = l[i];
		}
	}
	
	if(max*2>=sum){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	
	return 0;
}

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

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	long long int n, k;
	cin >> n >> k;
	long long int ans = 0;
	for(int b = k+1; b <= n; b++){
		int rem = b-1;
		int count = (n - rem)/b;
		count++;
		ans += (long long int)count*(b-k);
		count--;
		int maxa = count*b + rem;
		int mod = n%b;
		if(mod >= k && mod < rem){
			ans += mod - k + 1;
		}
	}
	if(k == 0){
		ans -= n;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import collections

N=int(input())
L=list(map(int,input().split()))
M=collections.Counter(L)
K={}
T=0
for i,j in (M.items()):
	K[i]=(j*(j-1)//2,(j-1)*(j-2)//2)
	T+=K[i][0]
for i in L:
	print(T-K[i][0]+K[i][1])

Measured memory_bytes: 39196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int a[3];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout << a[0]+a[1]<< "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,X,T;
    scanf("%d %d %d",&N,&X,&T);
    if (N <= X){
        printf("%d",T);
    }else if(N%X == 0){
        printf("%d",N/X*T);
    }else{
        printf("%d",(N/X+1)*T);
    }
}

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

int main() {

  int N;
  cin >> N;

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

  int count = 0;
  int max_ = 0;

  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      if (H[i+1] <= H[i]) {
        count++;
      } else {
        max_ = max(max_, count);
        count = 0;
      }
    } else {
      max_ = max(max_, count);
    }
  }

  cout << max_ << endl;

}

Measured memory_bytes: 640
//file_name:ABC100_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }

    int count = 0;
    rep(i,n){
        while(a[i]>0){
            if(a[i]%2==0){
                count++;
                a[i] = a[i] / 2;
            }else{
                break;
            }
        }
    }

    int ans = 0;
    ans = count;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL A,B,C;
  cin >> A >> B >> C;
  LL cnt = 0;
  FOR(j, 1, 101)
  {
    LL i = 101 - j;
    if (A % i == 0 && B % i == 0)
    {
      cnt++;
      if(cnt==C){
        cout << i << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 888
#include <iostream> // cout, endl, cin

#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdio> // printf
#include <map> // map

#include <set> // set

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 5248
#ifndef KHOKHO
    #include<bits/stdc++.h>
#endif // KHOKHO
using namespace std;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(5e6+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e12+1))
#define MX ((long long)(1e16+1))
#define EP ((double)(1e-11))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008
#define double long double
#define LG 5
ll f[500];
vector<pair<ll,ll> > v;

struct node{
    node *L,*R;
    ll x;
    node(){
        L=NULL;
        R=NULL;
        x=0;
    }
    void updt(){
        x=0;
        if(L)x+=L->x;
        if(R)x+=R->x;
    }
};

ll wi,wx,wl,wr;

void updt(ll l,ll r,node *& x){
   // cout<<l<<" "<<r<<endl;
    if(wi<l||r-1<wi)return;
    if(!x)x=new node();
    if(l==r-1){
        x->x+=wx;
        return;
    }
    updt(l,(l+r)/2,x->L);
    updt((l+r)/2,r,x->R);
    x->updt();
}

ll goo(ll l,ll r,node *& x){
    if(wr<l||r-1<wl)return 0;
    if(!x)return 0;
    if(wl<=l&&r-1<=wr){
        return x->x;
    }
    return goo(l,(l+r)/2,x->L)+goo((l+r)/2,r,x->R);
}
ll a[ARRS];
ll s[ARRS];

#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    node * root=NULL;
    ll n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        a[i]-=m;
        s[i]=s[i-1]+a[i];
    }
    ll pas=0;
    wi=0;
    wx=1;
    updt(-MX,MX,root);
    for(int i=1; i<=n; i++){
        wl=-MX;
        wr=s[i];
        //cout<<-MX<<" "<<s[i]<<endl;
        pas+=goo(-MX,MX,root);
        wi=s[i];
        //cout<<wi<<endl;
        updt(-MX,MX,root);
    }
    cout<<pas;
    return 0;
}


Measured memory_bytes: 190336
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
ll a[10005];
int main(){
   boost;
   ll n;
   ll x,k,d;
   cin>>x>>k>>d;
   x=abs(x);
   ll u=x%d;
   ll mov=x/d;
   if(mov>k){
   	  cout<<x-k*d<<endl;
   	  return 0;
   }
   if(mov==k){
   	  cout<<u<<endl;
   	  return 0;
   }
   k-=(x/d);
   
   if(k%2)cout<<d-u;
   else cout<<u;
   
}
   
	
 
    


Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		
		List<Integer> list = new ArrayList<>();
		
		int begin = 0;
		char now = '1';
		
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) != now) {
				list.add(i-begin);
				now = s.charAt(i);
				begin = i;
			}
		}
		list.add(n-begin);
		if(now == '0')
			list.add(0);

		int result = 0;
		int sum = 0;
		int left = 0;
		int right = 0;
		for(int i = 0; i < list.size(); i+=2) {
			int nextLeft = i;
			int nextRight = Math.min(i+k*2+1, list.size());
			
			while(nextLeft > left) {
				sum -= list.get(left);
				left++;
			}
			
			while(nextRight > right) {
				sum += list.get(right);
				right++;
			}
			result = Math.max(sum, result);
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 26004
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define fi first
#define se second

const int maxn=1e4+10,MOD=1e9+7;
int d,f[maxn][101][2];
string k;
vector<int> num;
int calc(int i,int mod,int ok)
{
    //cout<<i<<" "<<mod<<"\n";
    if(i==num.size()) return(mod==0);
    if(f[i][mod][ok]!=-1) return f[i][mod][ok];
    int ret=0;
    int lim=(ok?9:num[i]);

    forinc(dig,0,lim)
    {
        int m=mod,ok1=ok;
        if(ok==0&&dig<lim) ok1=1;
        ret=(ret+calc(i+1,(m+dig)%d,ok1))%MOD;
    }
    return f[i][mod][ok]=ret;
}
main()
{
    cin>>k;
    cin>>d;
    for(auto &v:k) num.push_back(v-'0');
    memset(f,-1,sizeof f);
    int kq=calc(0,0,0);
    cout<<(kq-1+MOD)%MOD;
}


Measured memory_bytes: 17152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)


int main(){
    ll H,W,D; cin >> H >> W >> D;
    ll lw = (H*W+D-1)/D;
    vector<vector<pair<ll,ll>>> list(D,vector<pair<ll,ll>>(lw));
    rep(i,H){
        rep(j,W){
            ll a; cin >> a;
            --a;
            list[a%D][a/D] = make_pair(i,j);
        }
    }
    vvl d(D,vl(lw+1,0));
    rep(i,D){
        rep(j,lw-1){
            d[i][j+2] = d[i][j+1] + abs(list[i][j+1].first - list[i][j].first) + abs(list[i][j+1].second - list[i][j].second);
        }
    }
    ll Q; cin >> Q;
    rep(i,Q){
        ll a,b; cin >> a >> b;
        --a;--b;
        cout << d[b%D][(b/D)+1] - d[a%D][a/D+1] << endl; 
    }
    // debug2(d);

    return 0;
}

Measured memory_bytes: 10240
s = input()
n = len(s)
ans = 0
#数字の間を全探索
for i in range(2**(n-1)):
    f = ""
    for j in range(n):
        f += s[j]
        #iを右にj個削り、１桁目のビットが１かどうか
        if i>>j & 1 == 1:
            f += "+"
    #print(f)
    ans += eval(f)
print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b,c;
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b); read(c);
	if (c<=a+b) printf("%d\n",b+c);
	else printf("%d\n",b+a+b+1);
	return 0;
}

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

using namespace std;

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

    bool flag = false;
    //iつる
    for(int turu=0; turu<=X; ++turu){
        int kame = X - turu;
        if( (turu * 2) + (kame * 4) == Y) flag = true;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
n,m=map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]

man = lambda x,y:abs(x[0] - y[0]) + abs(x[1] - y[1])

for i in range(n):
    a,b = ab[i]
    cost = float('INF')
    pos = 0
    for j in range(m):
        c,d = cd[j]
        c = man(ab[i], cd[j])
        if c < cost:
            cost = c
            pos = j+1
    print(pos)


Measured memory_bytes: 39792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = list(input())
    s.sort()
    s = "".join(s)

    if s == "abc":
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61928
N = int(input())
v = list(map(int, input().split()))
for i in range(N-1):
    s_v = sorted(v)
    n = (s_v[0] + s_v[1])/2
    v.remove(s_v[0])
    v.remove(s_v[1])
    v.append(n)
print(v[0])

Measured memory_bytes: 3064