akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n,ans=0;

int dgts(int x){return x>0?dgts(x/10)+1:0;}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> n;
	rep(n+1) ans+=dgts(i)%2;
	print1(ans);
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ls = len(s)
lt = len(t)
a = []
for i in range(ls-lt+1):
  if s[i] == '?' or s[i] == t[0]:
    exists = True
    for j in range(1, lt):
      if s[i+j] != '?' and s[i+j] != t[j]:
        exists = False
        break
    if exists:
      a.append((s[:i]+t+s[i+lt:]).replace('?','a'))
if len(a) == 0:
  print("UNRESTORABLE")
else:
  print(min(a))

Measured memory_bytes: 9080
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

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

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	cin >> N;

	vector<pair<int, int>> ab(N);
	vector<pair<int, int>> cd(N);
	for (size_t i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	for (size_t i = 0; i < N; i++)
	{
		int c, d;
		cin >> c >> d;
		cd[i] = make_pair(c, d);
	}

	sort(ab.begin(), ab.end(), [](auto &l, auto &r) {
		return l.first < r.first;
	});

	sort(cd.begin(), cd.end(), [](auto &l, auto &r) {
		return l.first < r.first;
	});

	int ans = 0;
	vector<bool> matched(N, false);
	for (int i = 0; i < N; i++)
	{
		int match_idx = -1;
		int match_y = -1;
		for (int j = 0; j < N; j++)
		{
			if (cd[i].first < ab[j].first || cd[i].second < ab[j].second)
			{
				continue;
			}
			if (matched[j])
			{
				continue;
			}

			if (match_y < ab[j].second)
			{
				match_y = ab[j].second;
				match_idx = j;
			}
		}

		if (match_idx != -1)
		{
			matched[match_idx] = true;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,K;
    scanf("%lld",&n);
    vector<ll> a(n);
    for(ll& x: a)
        scanf("%lld", &x);
    const ll MAX  = 1e18 ;   
    vector<vector<ll> > dp(n+1, vector<ll> (n+1,MAX) );
    vector<vector<ll> > sz(n+1, vector<ll> (n+1,0) );
    
    
    for(int l = 1; l<=n; l++)
    {
        for(int i =1; i<=n -l +1; i++)
        {
            int j = i + l-1;
            if(l==1)
                {
                    dp[i][j] = 0;
                    sz[i][j] = a[i-1];
                }
            else if (l==2)
                {
                    dp[i][j] = a[i-1] + a[j-1];
                    sz[i][j] = a[i-1] + a[j-1];
                }
            else 
                {
                    for(int x = i; x<j; x++)
                        {
                            dp[i][j] = min(dp[i][j], dp[i][x] + dp[x+1][j] +sz[i][x] + sz[x+1][j]);
                        }
                        sz[i][j] = sz[i][i] + sz[i+1][j];
                }
        }
    }
    
    cout<<dp[1][n]<<"\n";

}

Measured memory_bytes: 2816
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main (){
	int D, G;
	scanf("%d",&D);
	scanf("%d",&G);
	std::vector<int>p(D+1);
	std::vector<long long>c(D+1);
	for (int i=0; i<D; i++){
		scanf("%d",&p[i]);
		scanf("%lld",&c[i]);
	}
	//printf("=== read end === \n");
	long long ans = 0;
	long long n = 0;
	long long n_min = 10000000000;
	//printf("i_max=%d\n",1<<D);
	for (int i=0; i<(1<<D); i++){
		ans = 0;
		n=0;
		for (int j=0; j<D; j++){
			if ((i & (1<<j))!=0){ // j番目の問題をカンストさせる。
				ans += 100*(j+1)*p[j]+c[j];
				n += p[j];
			}
		}
		//printf("========\n");
		//printf("i=%d\n",i);
		//printf("ans=%lld\n",ans);
		//printf("n=%lld\n",n);
		if (ans>=G){
			n_min = fmin(n_min, n);
		} else {
			for (int j=D-1; j>=0; j--){
				if ((i & (1<<j))==0){
					//printf("%d is not count max\n",j);
					if (ans + 100*(j+1)*(p[j]-1)<G){
						ans += 100*(j+1)*(p[j]-1)<G;
						n += p[j]-1;
					} else {
						n += int(ceil((double)(G-ans)/(100*(j+1))));
						ans += 100*(j+1)*int(ceil((double)(G-ans)/(100*(j+1))));
						//printf("G=%d\n",G);
						//printf("ans=%lld\n",ans);
						//printf("j=%d\n",j);
						//printf("ceil=%f\n",ceil((double)(G-ans)/(100*(j+1))));
						//printf("test n=%lld\n",n);
						break; //終了
					}
				}
			}
			if (ans<G){
				n=1000000000;
			}
			//printf("n=%lld\n",n);
			n_min = fmin(n_min, n);	
		}
	}
	printf("%lld\n",n_min);
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct Place{ int x,y; };
struct State
{
    Place h,g;
    int p;
};

const int INF=123456789;
int z[20][20][20][20][10];
inline void init()
{
    rep(a,20)rep(b,20)rep(c,20)rep(d,20)rep(e,10) z[a][b][c][d][e]=INF;
}

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

int main()
{
    int h,w;
    while(cin >>h >>w,h)
    {
        vector<string> s(h);
        rep(i,h) cin >>s[i];

        string pattern;
        cin >>pattern;
        int P=pattern.size();
        vector<int> pat(P);
        rep(i,P)
        {
            if(pattern[i]=='6') pat[i]=0;
            else if(pattern[i]=='4') pat[i]=1;
            else if(pattern[i]=='2') pat[i]=2;
            else if(pattern[i]=='8') pat[i]=3;
            else if(pattern[i]=='5') pat[i]=4;
        }

        Place a,b;
        rep(i,h)rep(j,w)
        {
            if(s[i][j]=='A') a=Place{j,i};
            if(s[i][j]=='B') b=Place{j,i};
        }

        init();
        z[a.y][a.x][b.y][b.x][0]=0;
        queue<State> que;
        que.push(State{a,b,0});
        #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
        while(!que.empty())
        {
            State now=que.front(); que.pop();
            a=now.h;
            b=now.g;
            int idx=now.p;
            int nowZ=z[a.y][a.x][b.y][b.x][idx];

            // ???????????????
            int nbx=b.x+dx[pat[idx]], nby=b.y+dy[pat[idx]];
            if(!IN(nbx,nby))
            {
                nbx=b.x;
                nby=b.y;
            }
            Place nb=Place{nbx,nby};
            int nidx=(idx+1)%P;

            // ????????????
            rep(i,5)
            {
                int nax=a.x+dx[i], nay=a.y+dy[i];
                if(IN(nax,nay) && s[nay][nax]!='#' && z[nay][nax][nby][nbx][nidx] > nowZ+1)
                {
                    z[nay][nax][nby][nbx][nidx] = nowZ+1;
                    Place na=Place{nax,nay};
                    que.push(State{na,nb,nidx});
                }
            }
        }

        int ans=INF,ax=-1,ay=-1;
        rep(i,h)rep(j,w)rep(k,P)
        {
            if(ans>z[i][j][i][j][k])
            {
                ans=z[i][j][i][j][k];
                ax=j;
                ay=i;
            }
        }

        if(ans==INF) printf("impossible\n");
        else printf("%d %d %d\n", ans,ay,ax);
    }
    return 0;
}

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

int main() {
	int N,K; cin >> N >> K;
	int S=1;
	int count=1;

	while(S < (N-K+1)) {
		S = S + K - 1;
		count++;
	}

	cout << count << endl;
}

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

int main(){


    int a,b,c;
    cin >> a >> b >> c;
    int d = (100*a)+(10*b)+c;
    if(d%4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;

    }

}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
h = []
m.times do
  h << gets.split.map(&:to_i)
end
i = 0
h.sort_by{|u, v| v}.reverse.each do |x, y|
  break if a[i] >= y
  x.times do
    a[i] = y
    i += 1
    break if i >= n
    break if a[i] >= y
  end
  break if i >= n
end
puts a.inject(:+)

Measured memory_bytes: 21776
#include <cstdio>

#define re register
#define mod 998244353
int N, ans = 1, E, R, B, G, RB, RG, BG;
char s[300010];

int main() {
	scanf("%d%s", &N, s);
	E = N;
	for(re int i = 0; i < N * 3; ++i) {
		if(s[i] == 'R') {
			if(BG) ans = 1LL * ans * BG % mod, --BG;
			else {
				if(!B && !G) ans = 1LL * ans * E % mod, --E, ++R;
				if(B) ans = 1LL * ans * B % mod, --B, ++RB;
				if(G) ans = 1LL * ans * G % mod, --G, ++RG;
			}
		}
		if(s[i] == 'G') {
			if(RB) ans = 1LL * ans * RB % mod, --RB;
			else {
				if(!R && !B) ans = 1LL * ans * E % mod, --E, ++G;
				if(B) ans = 1LL * ans * B % mod, --B, ++BG;
				if(R) ans = 1LL * ans * R % mod, --R, ++RG;
			}
		}
		if(s[i] == 'B') {
			if(RG) ans = 1LL * ans * RG % mod, --RG;
			else {
				if(!R && !G) ans = 1LL * ans * E % mod, --E, ++B;
				if(R) ans = 1LL * ans * R % mod, --R, ++RB;
				if(G) ans = 1LL * ans * G % mod, --G, ++BG;
			}
		}
	}
	return !printf("%d\n", ans);
}


Measured memory_bytes: 512
import math
 
A,B,H,M = map(int,input().split())
 
w_long = 0.5
w_short = 6
 
minute = H * 60 + M
 
R_long = minute * w_long
R_short = M * w_short
 
R = abs(R_long-R_short)
 
if R == 0 or R == 360:
    print(abs(A-B))
elif R == 180:
    print(A+B)
else:
	cosR = math.cos(math.radians(R))
 
	ans2 = A**2 + B**2 - 2*A*B*cosR
	print(math.sqrt(ans2))

Measured memory_bytes: 9544
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int ll
#define xx first
#define yy second
#define pb push_back
#define all(x) begin(x), end(x)
#define OUT(x) { cout << x; exit(0); }
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const db eps = 1e-9;
const db pi = acos(-1.0);
const db dinf = 1e250;
const ll INF = (ll)(2e18);
const int inf = (int)(1e9 + 7);
//------------------------------------------//

vi a, b;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cout << fixed << setprecision(10);
    cin.tie(0);

#ifdef _MY
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;

    a = vi(n);
    b = vi(n);
    for (auto& it : a) cin >> it;
    for (auto& it : b) cin >> it;

    priority_queue<pii> s;
    for (int i = 0; i < n; ++i)
        s.push({ b[i], i });
    
    int res = 0;
    int p = 0;
    while(s.size())
    {
        int i = s.top().yy;
        int cur = (b[i] - a[i]) / (b[(i + 1) % n] + b[(i - 1 + n) % n]);
        res += cur;
        b[i] -= a[i];
        b[i] %= b[(i + 1) % n] + b[(i - 1 + n) % n];
        b[i] += a[i];
        s.pop();
        if (b[i] < a[i]) OUT(-1);
        if (b[i] > a[i]) s.push({ b[i], i });
        if (b[i] > a[i] && cur == 0) OUT(-1);
    }

    cout << res;


    return 0;
}

Measured memory_bytes: 9584
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int n = s.size();
    rep(i,n){
        if(i%2==0){
            if(s[i]=='0')a++;
            if(s[i]=='1')b++;
        }
        if(i%2==1){
            if(s[i]=='1')a++;
            if(s[i]=='0')b++;
        }
    }
    cout << min(a,b) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstdlib>
//#include<cmath>
using namespace std;

typedef struct {
	string s;
	int t;
}Unit;

int main(void)
{
	int n, q, T = 0;
	Unit p;
	cin >> n >> q;
	queue<Unit>A;
	for (int i = 0; i < n; i++) {
		cin >> p.s >> p.t;
		A.push(p);
	}
	while (!A.empty()) {
		if (A.front().t <= q) {
			T += A.front().t;
			cout << A.front().s << " " << T << endl;
			A.pop();
		}
		else {
			T += q;
			A.front().t -= q;
			A.push(A.front());
			A.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 6336
import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1

def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)

else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1

        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]

    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0])

    answer =  functools.reduce(multiply,combi)
print(answer)


Measured memory_bytes: 32296
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<limits.h>

using namespace std;

int main(void) {
	vector<string> word(3);
	for (int i = 0; i < 3; i++) cin >> word[i];

	int i;
	for (i = 0; i < 2; i++)
		if (word[i][word[i].length() - 1] != word[i + 1][0]) break;
	if (i >= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N, T = map(int, input().split())
A = list(map(int, input().split()))

MIN_Acc = list(accumulate(A, func=min))
Profits = [A[i] - MIN_Acc[i] for i in range(N)]
MAX_Profit = max(Profits)

ans = Profits.count(MAX_Profit)
print(ans)


Measured memory_bytes: 15060
#include <stdio.h>

int main(void){
	int value, num, a, num_sum = 0, sum = 0, n = 0;;
	double average;

	while(scanf("%d,%d", &value, &num) != EOF){
		sum += value * num;
		num_sum += num;
		n++;
	}
	
	average = (double)num_sum / n;
	average *= 10;
	a = (int)average % 10;
	average /= 10;
	if(a >= 5){
		average++;
	}
	printf("%d\n%d\n", sum, (int)average);
	
	return 0;
}

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

int main() {
  double w,h,x,y; cin >>w>>h>>x>>y;
  cout << fixed << setprecision(10);
  cout << w*h/2 << " ";
  
  if(x == w/2 && y == h/2)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

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

using namespace std;

using ll = long long;

int main (void){
  int k, n;
  cin >> n >> k;
  cin.ignore();
  int a[n];
  ll c[200000] = {0};
  for(int i = 0; i < n; i++){
    cin >> a[i];
    c[a[i]-1]++;
  }
  cin.ignore();

  sort(c, c + 200000);
  ll sum;
  for(int i = 0; i < k; i++){
    sum += c[200000 - 1 - i];
  }
  cout << n - sum << endl;
  return 0;
}
  


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int t = scan.nextInt();

        System.out.println((t/a)*b);
        scan.close();

	}

}

Measured memory_bytes: 23764
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_e
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// int main() {
//   ios::sync_with_stdio(false);
//   cin.tie(nullptr);
// 
//   int n;
//   cin >> n;
//   auto as = make_v<int>(n);
//   // auto diff = make_v<int>(n+1);
//   map<int, int> diff2;
//   for (int i = 0; i < n; ++i) {
//     cin >> as[i];
//     // if (i+1 - as[i] >= 0) {
//       // diff[i+1 - as[i]]++;
//       diff2[i+1 - as[i]]++;
//     // }
//   }
//   int ans = 0;
//   debug(diff);
//   for (int i = 0; i < n; ++i) {
//     ans+=diff2[as[i]+i+1];
//     // if (as[i] + i+1 <= n) ans += diff[as[i] + i+1];
//     // if (as[i] + i+1 <= n) ans += diff[as[i] + i+1];
//   }
//   cout << ans << endl;
// 
//   return 0;
// }

#define int long long
signed main() {

  int n;
  int A[200004];
  int B[200005];
  map<int,int> mp;

  cin >> n;
  for(int i=1;i<=n;i++){scanf("%lld",&A[i]);B[i]=A[i]-i;mp[B[i]]++;}
  int a = 0;
       
  for(int i=1;i<=n;i++){
    a += mp[-(A[i]+i)];
  }
  cout<<a;
  return 0;
}


Measured memory_bytes: 27792
#include <bits/stdc++.h> 
using namespace std;
 
typedef signed long long ll;
 
int main() {
	ll a, b, k, aa, bb;
	cin >> a >> b >> k;
	aa = max(0LL, a - k);
	bb = (aa > 0) ? b : max(0LL, b - (k - a));
	cout << aa << " " << bb << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int N = 100;

int min(int a, int b){ return a < b ? a : b; }

int main(){
  int i, j, k, l, v;
  int n, p[N+1], m[N+1][N+1];

  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ){
    scanf("%d %d", &p[i-1], &p[i]);
  }

  for ( i = 1; i <= n; i++ ) m[i][i] = 0;
  for ( l = 2; l <= n; l++ ){
    for ( i = 0; i <= n-l+1; i++ ){
      j = i+l-1;
      m[i][j] = (1<<21);
      for ( k = i; k <= j-1; k++ ){
	m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
	v = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	//	printf("m[%d,%d] + m[%d,%d] + p[%d]p[%d]p[%d] = %d\n", i, k, k+1, j, i-1, k, j, v);
      }
    }
  }

  /*  for ( int i = 1; i <= n; i++ ){
    for ( int j = 1; j <= n; j++ ){
      printf("%6d ", m[i][j]);
    }
    printf("\n");
    }*/

  printf("%d\n", m[1][n]);
  
  return 0;
}



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

int main(){
  int64_t N;
  cin >> N;
  deque<char> dq;
  for(int i=1;;i++){
    int64_t temp=pow(26,i);
    if(N<=temp){
      N--;
      while(N>0){
        dq.push_front(N%26+'a');
        N/=26;
      }
      if(i>dq.size()){
        cout << string(i-dq.size(),'a');
      }
      for(int j=0;j<dq.size();j++){
        cout << dq.at(j);
      }
      cout << endl;
      return 0;
    }else{
      N-=temp;
    }
  }
  return 0;
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var hashSet = new HashSet<int>();

            var days = int.Parse(Console.ReadLine());

            var scoreDownCoefficients = Console.ReadLine().Split(" ")
                .Select((x, i) => (score: int.Parse(x), dayNumber: i + 1))
                .OrderByDescending(x => x.score)
                .ToArray();

            var x = 1;
            foreach (var i in Enumerable.Range(2, days))
            {
                var scoreUpNumber = Console.ReadLine().Split(" ")
                    .Select((x, i) => (score: int.Parse(x), dayNumber: i + 1))
                    .OrderBy(x => hashSet.Contains(x.dayNumber))
                    .OrderByDescending(x => x.score);

                hashSet.Add(x);

                Console.WriteLine(x);
                x += 1;
                x = (x % 26) + 1;
            }
        }
    }
}


Measured memory_bytes: 29108
#include<stdio.h>
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main()
{
    int a,b,k;
    
    scanf("%d %d",&a,&b);
    
    k = a + b;
    if(k % 2 ==0)
    {
        k = k / 2;
        printf("%d\n",k);
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int &a:A)
        cin >> a;
    
    vector<vector<ll>> dp(N+1, vector<ll>(5));
    
    for(int i=0; i<N; i++){
        dp[i+1][0] = dp[i][0] + A[i];
        dp[i+1][1] = min(dp[i+1][0], min(dp[i][0], dp[i][1]) + (A[i]==0?2:A[i]%2));
        dp[i+1][2] = min({dp[i+1][1], min({dp[i][0], dp[i][1], dp[i][2]}) + (A[i]+1)%2});
        dp[i+1][3] = min({dp[i+1][2], min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + (A[i]==0?2:A[i]%2)});
        dp[i+1][4] = min({dp[i+1][3],  min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + A[i]});
    }
    
    
    cout << dp[N][4] << endl;
    return 0;
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    cout<<(n-1)/2+1<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, M;
std::vector<LL>d;

int main()
{
	in >> N;
	std::vector<LL>X(N), Y(N);
	rep(i, N)
	{
		in >> X[i] >> Y[i];
		if ((std::abs(X[i]) + std::abs(Y[i])) % 2 != (std::abs(X[0]) + std::abs(Y[0])) % 2)
		{
			out << -1 << std::endl;
			return 0;
		}
	}
	M = 33;
	rep(i, M) d.push_back(1LL << (M - i - 1));
	if ((std::abs(X[0]) + std::abs(Y[0])) % 2 == 0)
	{
		++M;
		d.push_back(1);
	}
	out << M << std::endl;
	rep(i, M) out << d[i] << (i < M - 1 ? " " : "\n");
	rep(i, N)
	{
		LL px = 0, py = 0;
		std::string ans;
		rep(j, M)
		{
			LL dx = X[i] - px, dy = Y[i] - py;
			if (std::abs(dx) >= std::abs(dy))
			{
				if (dx >= 0)
				{
					ans += "R";
					px += d[j];
				}
				else
				{
					ans += "L";
					px -= d[j];
				}
			}
			else
			{
				if (dy >= 0)
				{
					ans += "U";
					py += d[j];
				}
				else
				{
					ans += "D";
					py -= d[j];
				}
			}
		}
		out << ans << std::endl;
	}
	return 0;
}


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

using namespace std;

long long n;
const int MAX = 1e6 + 5;
bool prime[MAX];
vector<int> primes;

void sieve() {
	prime[1] = 1;
	for (int i = 2; i < MAX; i++) {
		if (!prime[1]) {
			for (int j = i * i; j < MAX; j += i) prime[j] = 1;
		}
	}

	for (int i = 1; i <= MAX; i++) if (!prime[i]) primes.push_back(i); 
}

void algo() {
	cin >> n;
	long long cnt = 0;

	for (int i = 0; i < primes.size() && primes[i] * primes[i] <= n; i++) {
		int t = 0;
		int u = primes[i];
		while (!(n % u)) { t++; n /= u; }
		t *= 2;
		int a = sqrt(t);
		if (a * (a + 1) > t) a--;
		if ((a + 1) * (a + 2) <= t) a++;
		cnt += a;
	}

	if (n > 1) cnt++;

	cout << cnt;
}

int main() {
	sieve();
	algo();
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int k,s,c=0;
int main()
{
	ios::sync_with_stdio(false);
    cin>>k>>s;
    for(register int x=0;x<=k;x++)
    {
        for(register int y=0;y<=k;y++)
        {
            if(s-x-y>=0&&s-x-y<=k) c++;
        }
    }
    cout<<c<<endl;
    return ~~0*~~(0-0)*~~0;
}

Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0

for i in itertools.permutations(range(2,N+1)):
    l= [1]+ list(i)
    counte = 0
    for edge in zip(l,l[1:]):
        if tuple(sorted(edge)) in edges:
            counte += 1
    if counte == N-1:
        ans+=1

print(ans)

Measured memory_bytes: 41324
import java.util.ArrayList;
        import java.util.HashSet;
        import java.util.PriorityQueue;
        import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int X = sc.nextInt();
        //String s = "atcoderandatcodeer";
        //int X = 5;
        ArrayList<String> ans= new ArrayList<>();
        for(int i=0;i<s.length();i++){
            for(int j=i+1;j<=s.length();j++){
                String cur = s.substring(i,j);
                if(ans.size()==0){
                    ans.add(cur);
                    continue;
                }
                int k=0;
                while(k<ans.size()){
                    if((cur.compareTo(ans.get(k))<=0)) break;
                    k++;
                }
                if(k<ans.size()&&(cur.compareTo(ans.get(k))==0)) continue; // the same substring
                if(ans.size()<X) ans.add(k,cur);
                else{
                    if(k<ans.size()){
                        ans.add(k,cur);
                        ans.remove(ans.size()-1);
                    }
                }
                if(ans.size()==X&&ans.get(X-1).compareTo(cur)<=0) break;
                /*while(k<ans.size()){
                    if((cur.compareTo(ans.get(k))<=0)) break;
                    k++;
                }
                if(k<ans.size()&&((cur.compareTo(ans.get(k)))==0)) continue;
                if(k==ans.size()&&k<=X) {
                    ans.add(cur);
                }
                else if(k==ans.size()&&k>X) continue;
                else if(k<ans.size()&&ans.size()<X) ans.add(k,cur);
                else{
                    ans.add(k,cur);
                    ans.remove(ans.size()-1);
                }
                if(ans.size()==X&&ans.get(X-1).compareTo(cur)==0) break;*/
            }
        }

        System.out.println(ans.get(ans.size()-1));
    }
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	int s[n+10],s1[n+10];
	for(int i=0;i<n;i++)
		cin>>s[i];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>s1[i];
		if(s[i]>s1[i])
		{
			//sum+=s1[i];
			ans+=(s[i]-s1[i]);
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
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);
		List<String> s = new ArrayList<String>();
		int i, n;
		String tmp, tmp2;
		n = sc.nextInt();

		for (i = 0; i < n; ++i) {
			tmp = sc.next();
			if (s.contains(tmp)) {
				System.out.println("No");
				i = n - 1;
				break;
			}
			s.add(tmp);
			if (i > 0) {
				tmp2 = s.get(i - 1);
				if (tmp.charAt(0) != tmp2.charAt(tmp2.length() - 1)) {
					System.out.println("No");
					i = n - 1;
					break;
				}
			}
		}

		if (i == n) {
			System.out.println("Yes");
		}

		sc.close();
	}

}


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

int main( ) {
  int x, a, b;
  cin >> x >> a >> b;
  
  if(abs(x - a) > abs(x - b)){
    cout << 'B' << endl;
  }else{
    cout << 'A' << endl;
  }
    

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  vector<int> a(2);
  int k;
  cin >> a[0] >> a[1] >> k;
  for (int i = 0; i < k; ++i) {
    int t = i % 2;
    a[1 - t] += a[t] / 2;
    a[t] /= 2;
  }
  cout << a[0] << " " << a[1] << endl;
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }

const int inf = 1e9 + 7;
mt19937 rng( (int)chrono::steady_clock::now().time_since_epoch().count() );

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

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafClover

  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;

  vector<int> sor(n); iota(all(sor), 0);
  sort(all(sor), [&](int i, int j) { return a[i] > a[j]; });

  vector<LL> ans(n);
  int mn = inf, cnt = 0;
  for (int i = 0; i < sz(sor); ++i) {
    asMn(mn, sor[i]); ++cnt;

    if (i + 1 < sz(sor) && a[ sor[i] ] == a[ sor[i + 1] ]) continue ;

    ans[mn] += (LL)cnt * (a[ sor[i] ] - (i + 1 < sz(sor) ? a[ sor[i + 1] ] : 0) );
  }

  for (const auto &i : ans) cout << i << '\n';

  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
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;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for (ll i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  for (ll i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    ll a = distance(A.begin(), lower_bound(A.begin(), A.end(), B.at(i)));
    ll c = -distance(C.end(), upper_bound(C.begin(), C.end(), B.at(i)));
    ans += a * c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input!{
        x: i128,
    };

    let mut n: i128 = 0;
    for i in 1..(1000 as i128){
        let tmp = i.pow(5) - (i-1).pow(5);
        // println!("{}", tmp);
        if tmp > 1E9 as i128{
            n = i;
            break;
        }
    }
    // println!("n = {}", n);
    for i in ((-n-1)..n+1).rev(){
        for j in ((-n-1)..n+1).rev(){
            if i.pow(5) - j.pow(5) == x{
                println!("{} {}", i, j );
                return;
            }
        }
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cin.ignore();
        cout << 1 << '\n';
        return 0;
    }
    vector<string> s(n);
    for (auto &si:s) {
        cin >> si;
        si += si.substr(0, n-1);
    }
    for (size_t i=0; i<n-1; i++) s.push_back(s[i]);
    int cnt=0;
    size_t a = 0, b = n - 1;
    while (b >= n/2) {
        bool good = true;
        for (size_t i=0; i<n; i++) {
            for (size_t j=0; j<i; j++) {
                if (s[i+a][j+b] != s[j+a][i+b]) {
                    good = false;
                    break;
                }
            }
            if (!good) break;
        }
        if (good) cnt += n;
        if (a + b < n) a++;
        else b--;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int main(){
  string s;
  cin >> s;
  map<char,int> m;
  for(auto it:s){
    m[it]++;
  }
  for(char c='a';c<='z';c++){
    if(m[c]%2 == 1){
      cout <<"No"<<endl;
      return 0;
    }
  }
  cout <<"Yes"<<endl;
      return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int N;
	int A[100];
	cin >> N;

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

	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
			cout << "DENIED" << endl;

			return 0;
		}
	}

	cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=3e5;
const int inf=1e9;
int main(){
	int s,w;cin>>s>>w;
	if(s <= w) cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;
}


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

int main() {
 int x,sum=1,si,ni,nni;
  cin >>x;
  for(int i=10000000; i>=1; i/=10 ){
   ni=x/i;
      si=ni-nni*10;
      nni=ni;
      sum+=si;
  }
  sum--;
  if(x%sum==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
 }




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

int n;
char s[3005];
int dp[3005][3005],sum[3005];
int mod = 1e9+7;

int main() {
	scanf("%d",&n);
	scanf("%s",s);
	dp[0][0] = 1;
	sum[0] = 1;
	for (int i=1; i<n; i++) {
		for (int j=0; j<=i; j++) {
			int sub = 0;
			if (j-1 >= 0) sub = sum[j-1];
			if (s[i-1] == '>') {
				dp[i][j] = (sum[i-1]-sub+mod)%mod;
			}
			else {
				dp[i][j] = sub;
			}
		}
		sum[0] = dp[i][0];
		for (int j=1; j<=i; j++) {
			sum[j] = sum[j-1]+dp[i][j];
			sum[j] %= mod;
		}
	}
	printf("%d\n",sum[n-1]);
	return 0;
}


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

int main(int argc, char *argv[]) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(a + b > c + d){
        printf("Left");
    }
    else if(a + b == c + d){
        printf("Balanced");
    }
    else{
        printf("Right");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

int A;
int B;

void th(char before[]){
    int alpha[]={1,3,5,7,9,11,15,17,19,21,23,25};
    int str_int;
    char str[5];
    for(int i=0;alpha[i]<26;i++){
        for(int j=0;j<26;j++){
            for(int k=0;k<4;k++){
                str_int=(int)(before[k]-'a');
                str[k]=(char)((alpha[i]*str_int+j)%26)+'a';
            }
            str[4]='\0';
            if(strcmp(str,"that")==0||strcmp(str,"this")==0){
                A=alpha[i];
                B=j;
                return;
            }
        }
    }
    return;
}

char complex(char before){
    int str_int;
    char str;
    str_int=(int)(before-'a');
    str=(char)((A*str_int+B)%26+'a');
    return (str);
}

int main(void){
    char before[257][257],after[257][257];
    int len;
    int n;
    
    cin>>n;
    for(int l=0;l<n;l++){
    int i=0;
    while(scanf("%s",before[i])){
        if(strlen(before[i])==4){
            th(before[i]);
        }
        i++;
        if(getchar()=='\n')break;
    }
    for(int j=0;j<i;j++){
        len=strlen(before[j]);
        for(int k=0;k<len;k++){
            after[j][k]=complex(before[j][k]);
        }
        after[j][len]='\0';
        printf("%s",after[j]);
        if(j!=i-1)printf(" ");
    }
    printf("\n");
    }
    return(0);
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#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 <deque>
#include <climits>
#include <typeinfo>
#include <utility> 

using namespace std;

int main()
{
	int A,P;
	cin >> A >> P;
	P = P + A * 3;
	
	cout << P/2 << endl;
	return 0;
}


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

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

    int ans = 0;
    for (int i = 0; pow(2, i) <= n; i++) {
        ans = pow(2, i);
    }

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


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int r;
    cin >> r;
    cout << 3*r*r;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n,m;
    cin>>n>>m;
    int sum = 0;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int k=sum/(4*m);
    if(sum%(4*m)!=0){
        k++;
    }

    sort(a.rbegin(),a.rend());
    rep(i,m){
        if(a[i]<k){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
    
return 0;
}


Measured memory_bytes: 256
// Author : heyuhhh
// Created Time : 2020/09/19 20:24:04
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    int n;
    cin >> n;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    for (int i = 2; i < n; i++) {
        if (a[i].fi == a[i].se && a[i - 1].fi == a[i - 1].se && a[i - 2].fi == a[i - 2].se) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3660
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

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); }

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

int a[100010], b[25][100010], cnt[25];
PII dp[1LL<<20];
signed main(void)
{
  int n, m;
  cin >> n >> m;
  REP(i, n) {
    cin >> a[i];
    cnt[a[i]-1]++;
    b[a[i]-1][i] = 1;
  }

  REP(i, m) FOR(j, 1, n) b[i][j] += b[i][j-1];
  // REP(i, m) {
  //   REP(j, n) {
  //     cout << b[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  REP(i, 1LL<<20) dp[i] = {INF, INF};
  dp[0] = {0, 0};

  REP(i, (1LL<<m)-1) {
    // cout << "i:" << i << endl;
    REP(j, m) if(!(i>>j&1)) {
      // [ dp[i].second, dp[i].second+cnt[j] ) ????????????????¨????j?????°
      int tmp = dp[i].second == 0 ? 0 : b[j][dp[i].second-1];
      int kind = b[j][dp[i].second+cnt[j]-1] - tmp;
      // cout << j << " " << kind << " ";
      // cout << dp[i].second+cnt[j]-1 << " " << b[j][dp[i].second+cnt[j]-1] << " " << dp[i].second-1 << " " << tmp << endl;
      chmin(dp[i|1LL<<j], MP(dp[i].first+cnt[j]-kind, dp[i].second+cnt[j]));
      // cout << dp[i|1LL<<j].first << endl;
    }
  }
  // REP(i, 1LL<<m) cout << dp[i].first << "," << dp[i].second << " "; cout << endl;
  cout << dp[(1LL<<m)-1].first << endl;

  return 0;
}

Measured memory_bytes: 19452
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int count=0, n = in.nextInt();
        int[] ans = new int[n];

        for (int i = 1; i <=n; ++i) {
            ans[i-1] = in.nextInt();
            if (ans[i-1] %2 ==1 && i %2 ==1){
                count++;
            }
        }
        System.out.println(count);
    }}

Measured memory_bytes: 26980
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while b:
        a,b =b,a%b
    return a

X=int(input())

if 360%X==0:
    print(360//X)
else:
    g =gcd(360,X)
    print(360//g)


Measured memory_bytes: 9172
// by syu
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

func main() {
	n := in.Int()
	c := 0
	for i := 0; i <= n; i++ {
		if i&1 == 0 {
			continue
		}
		d := divisors(i)
		if len(d) == 8 {
			c++
		}
	}
	Pln(c)
}
func divisors(n int) (r []int) {
	for i := 1; i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
		}
	}
	return
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


Measured memory_bytes: 640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

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); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

ll n;
ll a[128000];

ll plus_f(int, ll);
ll minus_f(int, ll);

ll plus_f(int i, ll sum) {
  if (i == n) return 0;
  sum += a[i];
  ll d = max(0LL, -sum + 1);
  return d + minus_f(i + 1, sum + d);
}

ll minus_f(int i, ll sum) {
  if (i == n) return 0;
  sum += a[i];
  ll d = max(0LL, sum + 1);
  return d + plus_f(i + 1, sum - d);
}

void solve() {
  cout << min(plus_f(0, 0LL), minus_f(0, 0LL)) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	scanf("%lld", &n);
	for (int i = 0 ; i <= n-1 ; i++) {
	  scanf("%lld", &a[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 2560