akhauriyash/Code-Regression huggingface dataset:
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ALP = ['']*26
for i in range(26):
    ALP[i] = alp[i].upper()

N = int(input())
S = input()
T = ''
for i in range(len(S)):
    tmp = ALP.index(S[i])
    tmp = (tmp + N) % 26
    T += ALP[tmp]
print(T)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	int N=n*2-1,M=m*2-1;
	vs in(n);
	rep(i,n)cin>>in[i];
	vvi dp(N+10,vi(M+10));
	rep(i,N)rep(j,M){
		int p=i/2,q=j/2;
		if(i%2&&j%2&&p<n&&q<m){
//			cout<<i<<" "<<j<<endl;
			if(in[p][q]==in[p+1][q+1]&&in[p+1][q]==in[p][q+1]||
			in[p][q]==in[p+1][q]&&in[p][q+1]==in[p+1][q+1]||
			in[p][q]==in[p][q+1]&&in[p+1][q]==in[p+1][q+1]){
				if(i)dp[i][j]=dp[i-1][j]+1;
				else dp[i][j]=1;
			}else dp[i][j]=0;
		}else if(i)dp[i][j]=dp[i-1][j]+1;
		else dp[i][j]=1;
	}
//	rep(i,N){rep(j,M)cout<<" "<<dp[i][j];cout<<endl;}
	int out=0;
	rep(i,N){
		stack<pii>st;
		rep(j,M+1){
			if(st.empty()){
				st.push({dp[i][j],j});
			}else if(st.top().first<dp[i][j]){
				st.push({dp[i][j],j});
			}else if(st.top().first>dp[i][j]){
				int target=i;
				while(!st.empty()&&st.top().first>=dp[i][j]){
					pii pre=st.top();
					st.pop();
					int area=(pre.first+1)/2*((j-pre.second+1)/2);
					out=max(out,area);
					target=pre.second;
				}
				st.push({dp[i][j],target});
			}
		}
	}
	cout<<out<<endl;
}









Measured memory_bytes: 67328
N = int(input())
A = [int(_) for _ in input().split()]
left = list(range(N + 2))
right = list(range(N + 2))
index = {A[i - 1]: i for i in range(1, N + 1)}
ans = 0
for a in range(N, 0, -1):
    i = index[a]
    l = left[i]
    r = right[i]
    ans += a * (i - l + 1) * (r - i + 1)
    left[r + 1] = l
    right[l - 1] = r
print(ans)


Measured memory_bytes: 53884
n = int(input())
h = [int(x) for x in input().split()]
cost_min = [0, abs(h[0] - h[1])]
for i in range(2, n):
    cost_min.append(min(cost_min[i - 2] + abs(h[i - 2] - h[i]),
                        cost_min[i - 1] + abs(h[i - 1] - h[i])))
print(cost_min[n - 1])

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

int main(){
    long long N;
    scanf("%lld", &N);
    long long ans = N / 11;
    ans *= 2;
    N %= 11;
    if(0 < N){
        if(N <= 6)ans++;
        else ans += 2;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    string S, T; cin >> S >> T;
    int cnt = 0;
    rep(i, sz(S)) cnt += (S[i] == T[i]);
    cout << cnt << "\n";
}

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

int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	string S, T;
	cin >> S;
	cin >> T;

	T.pop_back();

	if (T == S)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
namespace aoj{
	class program{
	
	static void Main() {

	char[] sep = new char[] {' '};
	string[] tmp=Console.ReadLine().Split(sep,
	StringSplitOptions.RemoveEmptyEntries);

	gcd g = new gcd(int.Parse(tmp[0]), int.Parse(tmp[1]));
	g.exe();

	}
}

class gcd{
	int x;
	int y;
	
	public gcd(int a, int b){
		x=a;
		y=b;
		if(x<y) swap();
	}
	int solve(int a, int b){
			y=a%b;
			x=b;
	return (y==0) ? x : solve(x,y);
	}

	void swap(){
		int tmp=x;
		x=y;
		y=tmp;
	}
	public void exe(){
		Console.WriteLine("{0}", solve(x,y));
	}
}
}

Measured memory_bytes: 19948
import collections

N, X, Y = [int(x) for x in input().split()]

c = collections.Counter()

for i in range(1, N + 1):
    for j in range(i, N + 1):
        if (i == X and j == Y) or (i == Y and j == X):
            c[1] += 1
        else:
            c[min([j - i, abs(X - i) + 1 + abs(Y - j), abs(X - j) + 1 + abs(Y - i)])] += 1

for i in range(1, N):
    print(c[i])


Measured memory_bytes: 9568
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n,m;
    while(cin>>n>>m){
        int arr[n];
        for(int i=0;i<n;i++)arr[i]=-1;
        bool pos=1;
        for(int i=0;i<m;i++){
            int c,s;
            cin>>c>>s;
            if(arr[c-1]!=-1){
                if(arr[c-1]!=s){
                    pos=0;
                }
            }
            else{
                arr[c-1]=s;
            }
        }
        if(pos){
            if(n>1){
                if(arr[0]==0){
                    pos=0;
                }
            }
        }
        if(pos){
            if(n>1){
                arr[0]=max(1LL,arr[0]);
            }
            for(int i=0;i<n;i++){
                if(arr[i]==-1){
                    cout << 0;
                }
                else{
                    cout<< arr[i];
                }
            }
            cout << endl;
        }
        else cout << "-1\n";
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3600
#include <iostream>

int main(){
    std::string s, t, u;
    int a, b;
    std::cin >> s >> t >> a >> b >> u;

    if(u == s){
        --a;
    }else{
        --b;
    }

    std::cout << a << " " << b << std::endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int n; cin >> n;
	vector<int> V;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		V.push_back(tmp);
	}

	sort(V.begin(), V.end());

	ll ans = 0;
	if (n % 2 == 0) {
		for (int i = 0; i < n / 2 - 1; i++) ans -= 2 * V[i];
		ans -= V[n / 2 - 1];
		ans += V[n / 2];
		for (int i = n / 2 + 1; i < V.size(); i++) ans += 2 * V[i];
	}
	else { // Nが奇
		// 両端が大きい
		ll ans1 = 0;
		for (int i = 0; i < (n - 1) / 2; i++) ans1 -= 2 * V[i];
		ans1 += V[(n - 1) / 2] + V[(n + 1) / 2];
		for (int i = (n + 3) / 2; i < V.size(); i++) ans1 += 2 * V[i];

		// 両端が小さい
		ll ans2 = 0;
		for (int i = 0; i < (n - 3) / 2; i++) ans2 -= 2 * V[i];
		ans2 -= (V[(n - 3) / 2] + V[(n - 1) / 2]);
		for (int i = (n + 1) / 2; i < V.size(); i++) ans2 += 2 * V[i];

		ans = max(ans1, ans2);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
// abc134_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N+1);
    REPN(i, 1, N+1) cin >> A[i];

    vector<int> x(N+1);
    REPN_REV(n, 1, N+1){

        int tmp = 0;
        for (int i=2*n; i <= N; i+=n){
            tmp = (tmp + x[i]) % 2;
        }
        x[n] = A[n] ^ tmp;
    }

    vector<int> ans;
    REPN(i, 1, N+1){
        if (x[i]) {
            ans.emplace_back(i);
        }
    }

    int m = ans.size();
    print(m);
    if (m == 0) return 0;

    REP(i, m-1){
        cout << ans[i] << " ";
    }
    cout << ans[m-1] << endl;


    return 0;
}


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

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

    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
        return 0;
    }

    vector<int> ans(2*n+5);
    vector<int> used(2*n+5);


    if (x == 2 * n - 2) {
        ans[n-2] = x - 1;
        ans[n-1] = x;
        ans[n  ] = x + 1;
        ans[n+1] = x - 2;

        used[x-1] = 1;
        used[x] = 1;
        used[x+1] = 1;
        used[x-2] = 1;
    } else {
        ans[n-2] = x + 2;
        ans[n-1] = x;
        ans[n  ] = x - 1;
        ans[n+1] = x + 1;

        used[x+2] = 1;
        used[x] = 1;
        used[x-1] = 1;
        used[x+1] = 1;
    }

    cout << "Yes" << endl;
    int k = 1;
    for(int i = 0; i < 2*n-1; ++i) {
        while(used[k]) k++;
        if(ans[i] == 0) {
            used[k] = 1;
            cout << k << endl;
        } else {
            cout << ans[i] << endl;
        }
    }
    return 0;
}



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

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

using namespace std;

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef double R;
constexpr R EPS = 1e-8;

typedef vector<R> vec;
typedef vector<vec> mat;

int rank_of(const mat& A) {
	const int n = A.size();
	const int m = A[0].size();

	mat B(A);
	int res = 0;
	int col = -1;

	for(int i = 0; i < n; ++i) {
		int pivot = -1;
		for(;;) {
			if(++col == m) goto rank_end;

			for(int j = i; j < n; ++j) {
				if(abs(B[j][col]) > EPS) {
					pivot = j;
					break;
				}
			}
			if(pivot != -1) break;
		}

		B[i].swap(B[pivot]);
		++res;

		for(int j = col + 1; j < m; ++j) {
			B[i][j] /= B[i][col];
		}

		for(int j = i + 1; j < n; ++j) {
			if(abs(B[j][col]) > EPS) {
				for(int k = col + 1; k < m; ++k) {
					B[j][k] -= B[j][col] * B[i][k];
				}
			}
		}
	}

rank_end:;
	return res;
}

int rank_of(const mat& A, const vec& b) {
	const int n = A.size();

	mat B(A);
	for(int i = 0; i < n; ++i) {
		B[i].emplace_back(b[i]);
	}
	return rank_of(B);
}

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

	int n, m;
	cin >> n >> m;

	mat A(n, vec(m, 0));

	for(int i = 0; i < m; ++i) {
		int s, t;
		cin >> s >> t;
		A[s - 1][i] = 1;
		A[t - 1][i] = -1;
	}

	cout << m - rank_of(A) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 24492
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
else
N, M = gets.split.map(&:to_i)
@lines = {}
M.times do
  s, t = gets.split.map(&:to_i)
  (@lines[s-1] ||= []) << t-1
end
# p lines
@dp = Array.new(N, 0)
# binding.pry
@check2 = Array.new(N, false)
def dfs(i)
  if @check2[i]
    return @dp[i]
  end
  @check2[i] = true
  res = 0
  # if @lines[i]
  #   @lines[i].each do |to|
  #     pre = dfs(to) + 1
  #     res = pre if res < pre
  #   end
  # end
  if @lines[i]
    presize = @lines[i].size - 1
    while presize >= 0
      pre = dfs(@lines[i][presize]) + 1
      res = pre if res < pre
      presize -= 1
    end
  end
  return @dp[i] = res
end

ans = 0
# binding.pry
N.times do |i|
  if !@check2[i]
    pre = dfs(i)
    ans = pre if ans < pre
  end
end
# puts @dp.max
puts ans
end

Measured memory_bytes: 24016
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int n;
int a[MAX],b[MAX];
ll ans=0;

int main()
{
  cin>>n;
  FOR(i,0,n)cin>>a[i]>>b[i];
  RFOR(i,n,0){
    ll tmp=(ans+a[i])%b[i];
    if(tmp!=0)ans+=b[i]-tmp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)

int main() {
    int n, a; cin >> n;
    int b = 0;
    rep(i, 0, n) {
        cin >> a;
        b |= a;
    }
    cout << __builtin_ctz(b) << endl;
}

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

int main() {
	int N; cin >> N;
	int s[110];
	int sum=0;
	for(int i=0; i<N; ++i){
	    cin >> s[i];
	    sum += s[i];
	}
	if(sum%10) cout << sum << endl;
	else{
	    sort(s, s+N);
	    bool flag=true;
	    for(int i=0; i<N; ++i){
	        if((sum-s[i])%10){
	            flag=false;
	            sum -= s[i];
	            break;
	        }
	    }
	    if(flag) cout << 0 << endl;
	    else cout << sum << endl;
	}
	return 0;
}


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

int fizzBuzz(int n) {
  int res = 0;
  if (n % 3 != 0 && n % 5 != 0) res = n;
  return res;
}

int main() {
  int N; cin >> N;
  long long ans = 0;

  for (int i=1; i<=N; i++) {
    ans += fizzBuzz(i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007  //998244353
#include<string.h>
#define inf 1000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)
			sum+=i;
	}
	cout1(sum);
}
int main(){
    int t=1;
	//cin>>t;
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
    
}

Measured memory_bytes: 3624
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]

a = []
H = t[0]
W = t[1]
for i in range(H):
    a.append(input())


#print(t)



#print(H)
#print(W)
#print(a)



#上と下に入れる行を作る
b = ''
for i in range(W+2):
    b += '.'
#print(b)

'''
c = 'rei'
c = '.' + c
print(c)

'''
#上と下と右と左に空きマスを挿入する
a.insert(0, b)
for i in range(1, 1+H):
    a[i] = '.' + a[i] + '.'
a.append(b)

#print(a)




#周りの爆弾の数を数える
def countbomb(l, h, w):
    count = 0
    for i in range(w-1, w+2):
        if(l[h-1][i] == '#'):
            count += 1
        if(l[h+1][i] == '#'):
            count += 1
    if(l[h][w-1] == '#'):
        count += 1
    if(l[h][w+1] == '#'):
        count += 1
    return count

#print(countbomb(a, 3, 4))



for i in range(1, H+1):
    d = ''
    for j in range(1, W+1):
        if(a[i][j] == '#'):
            d += '#'
        else:
            d += (str(countbomb(a, i, j)))
    print(d)

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

using namespace std;

const int N = 6e2 + 7;

int n;
int m;
double res;
double d[N];
vector<int> g[N];
void f(int block){
    d[n] = 0;
    for(int i = n - 1; i >= 1; i --){
        double sum = 0, mx = 0;
        int sz = (int)g[i].size();
        for(auto to: g[i]){
            sum += d[to];
            mx = max(mx, d[to]);
        }
        if(i == block && sz > 1) sum -= mx, sz --;

        d[i] = sum / sz + 1;
    }
    res = min(res, d[1]);
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i ++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    res = 1e18;
    for(int i = 0; i < n; i ++) f(i);

    cout << setprecision(20) << res << "\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INFTY = (1 << 30);

struct Node
{
    int node;
    int cost;
    Node(int n = 0, int c = INFTY) : node(n), cost(c) {}
};

bool operator<(const Node &n1, const Node &n2)
{
    return n1.cost < n2.cost;
}

class Dks
{
    vector<vector<int>> cost;
    vector<int> state, parent, dist;

public:
    Dks(int n = 0)
    {
        cost.resize(n);
        state.resize(n);
        parent.resize(n);
        dist.resize(n, INFTY);
    }

    void load_cost()
    {
        int node, n_v, v, c;
        for (int i = 0; i < cost.size(); i++)
        {
            cin >> node >> n_v;
            cost.at(node).resize(cost.size(), INFTY);
            for (int j = 0; j < n_v; j++)
            {
                cin >> v >> c;
                cost.at(node).at(v) = c;
            }
        }
    }

    void dks(int node)
    {
        int min_value;
        dist[node] = 0;
        while(true)
        {
            node = -1;
            min_value = INFTY;
            for(int i = 0;i<cost.size();i++){
                if(state[i] == 0 && dist[i] < min_value){
                    node = i;
                    min_value = dist[i];
                }
            }
            if(node == -1) break;
            state[node] = 1;

            for (int j = 0; j < cost.size(); j++)
            {
                if(cost[node][j] == INFTY) continue;
                if (state[j] == 0 && dist[j] > dist[node] + cost[node][j])
                {
                    dist[j] = dist[node] + cost[node][j];
                    parent[j] = node;
                }
            }
        }
    }

    void print(){
        for(int i=0;i<cost.size();i++){
            cout << i << " " << (dist[i] == INFTY ? -1 : dist[i]) << endl;
        }
    }
};

int main()
{
    int N;
    cin >> N;
    Dks dks(N);
    dks.load_cost();
    dks.dks(0);
    dks.print();
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
ll f[310][310];
int n,m,a[310];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(res i=1;i<=n;++i) cin>>a[i];
	memset(f,0x3f,sizeof(f)),f[0][0]=0;
	for(res i=1;i<=n+1;++i)
	  for(res j=0;j<=m;++j)
	    for(res k=0;k<i;++k) if(j>=i-k-1) chkmin(f[i][j],f[k][j-(i-k-1)]+max(0,a[i]-a[k]));
	ll minn=1e18;
	for(res i=0;i<=m;++i) chkmin(minn,f[n+1][i]);
	cout<<minn<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			if (s == "AAA" || s == "BBB") {
				Console.WriteLine("No");
			} else {
				Console.WriteLine("Yes");
			}


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <unistd.h>
#include <sstream>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int mod=998244353;

void solve()
{
    int n,k;cin>>n>>k;
    vector<pair<int,int>> v;
    for(int i=0;i<k;i++)
    {
        int l,r;cin>>l>>r;
        v.pb({l,r});
    }
    sort(v.begin(),v.end());
    int dp[n+1],pre[n+1];
    for(int i=0;i<=n;i++)
        dp[i]=pre[i]=0;
    dp[1]=1;pre[1]=1;
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<k;j++)
        {
            int l=max(0LL,i-v[j].S);
            int u=max(0LL,i-v[j].F);
            int sum=(pre[u]-pre[max(0LL,l-1)]+mod)%mod;
            dp[i]=(dp[i]+sum)%mod;
        }
        pre[i]=(pre[i-1]+dp[i])%mod;
    }
    cout<<dp[n];
}

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

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string w;

  cin >> w;

  bool flag = true;
  while (w.size() > 0) {
    char c = w.front();
    w.erase(0, 1);
    if (int(w.find(c)) != -1) w.erase(w.find(c), 1);
    else flag = false;
  }

  if (flag) printf("Yes\n");
  else printf("No\n");
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << " " << 2*a + 2*b << endl; 
}
  


Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n;
vl a;

int main(){
	cin>>n;
	a=vl(n+1);
	for(auto &i:a) cin>>i;
	ll res=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		res+=min(x,a[i]);
		x-=min(x,a[i]);
		res+=min(x,a[i+1]);
		a[i+1]-=min(x,a[i+1]);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1024
n=int(input())
s=input()
ans=0
for i in range(n):
    x=list(set(s[:i+1]))
    y=list(set(s[i+1:]))
    cnt=0
    for j in range(min(len(x),len(y))):
        if i<=n//2:
            if x[j] in y:
                cnt+=1
        else:
            if y[j] in x:
                cnt+=1
    ans=max(ans,cnt)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  int q = in();
  rep(_,q){
    int b = in();
    int e = in();
    int t = in();
    rep(i,e-b){
      swap(line[b+i],line[t+i]);
    }
  }
  foreach(i,line){
    output(i);
  }
  outendl();
}



Measured memory_bytes: 3268
_item = [int(e) for e in input().split(' ')]
_sum = []
for i in range(3):
	for j in range(i, 3):
		if i != j:
			_sum.append(_item[i] + _item[j])
index = 0
for i in range(len(_sum)):
	if i == 0 or _sum[index] > _sum[i]:
		index = i
print(_sum[index])


Measured memory_bytes: 3060
from math import sqrt

def numLen(num):
  return len(str(abs(num)))

def F(a, b):
    return max(numLen(a), numLen(b))

N = int(input())
sqrtN = int(sqrt(N))

p = (0, 0)
for i in range(1,sqrtN+1):
    if N % i == 0 and p[0] < i:
        p = (i, N//i)

print(F(p[0], p[1]))

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;


int main()
{
	cin >> n;
	if (n < 1000)
		cout << "ABC" << endl;
	else 
		cout << "ABD" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[100005];
int main()
{
   	int n;
   	cin >> n;
   	long double ans = 0.0;
   	for(int i = 0 ; i < n ; i++){
   		double x ;
   		string y;
   		cin >> x >> y;
   		if(y == "JPY")
   			ans += x;
   		else
   			ans += ((x) * 380000.0);

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

Measured memory_bytes: 256
h,w=map(int,input().split())
maze=[]
lst=['.']*(w+2)
maze.append(lst)

for i in range(h):
  lst2=list(input())
  lst2=['.']+lst2+['.']
  maze.append(lst2)

maze.append(lst)


ans=[[None]*w for i in range(h)]

dx=[1,1,1,-1,-1,-1,0,0]
dy=[1,0,-1,1,-1,0,1,-1]

for i in range(1,h+1):
  for j in range(1,w+1):
    cnt=0
    if maze[i][j]=='#':
      ans[i-1][j-1]='#'
      continue

    for k in range(8):
      s=i+dx[k]
      t=j+dy[k]
      if maze[s][t]=='#':
        cnt+=1
    ans[i-1][j-1]=str(cnt)
    
for i in range(h):
  answer=''
  for j in range(w):
    answer+=ans[i][j]
  
  print(answer)

Measured memory_bytes: 70908
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

int solve() {
	ll n, m;
	cin >> n >> m;

	vector<ll> as(n);
	REPD(i, 0, n) cin >> as[i];
	sort(as.begin(), as.end());

	ll low = as[0] * 2LL, high = as[n - 1LL] * 2LL + 1LL;
	ll mid = (high + low) / 2LL;
	while (high - low >= 2) {
		ll count = 0;
		REPD(i, 0, n) {
			count += distance(lower_bound(as.begin(), as.end(), mid - as[i]), as.end());
		}
		if (count >= m) {
			low = mid;
		}
		else {
			high = mid;
		}
		mid = (high + low) / 2LL;
	}

	vector<ll> accums(n);
	ll accum = 0;
	REPD(i, 0, n) {
		accum += as[n - 1LL - i];
		accums[n - 1LL - i] = accum;
	}

	ll res = 0;
	ll count = 0;
	REPD(i, 0, n) {
		auto iter = lower_bound(as.begin(), as.end(), high - as[i]);
		count += distance(iter, as.end());
		ll idx = distance(as.begin(), iter);
		if (idx < as.size()) {
			res += (as.size() - idx) * as[i];
			res += accums[idx];
		}
	}
	res += (m - count) * low;
	RET(res);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 4752
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;
int64_t gcd(int64_t a,int64_t b){//calc gcd
	if(a==0){
		return b;
	}else if(b==0){
		return a;
	}else if(a>b){
		return gcd(a%b,b);
	}else{
		return gcd(b%a,a);
	}
}
int main(){
	int64_t n,k;
	cin>>n>>k;
	if(n==1){
		int64_t temp;
		cin>>temp;
		if(temp==k){
			cout<<"POSSIBLE"<<endl;
		}else{
			cout<<"IMPOSSIBLE"<<endl;
		}
	}else{
		int64_t temp1,temp2;
		cin>>temp1>>temp2;
		int64_t max_num=max(temp1,temp2);
		int64_t gcd_num=gcd(temp1,temp2);
		for(int64_t i1=2;i1<n;i1++){
			int64_t temp;
			cin>>temp;
			max_num=max(max_num,temp);
			gcd_num=gcd(gcd_num,temp);
		}
		if(k<=max_num&&k%gcd_num==0){
			cout<<"POSSIBLE"<<endl;
		}else{
			cout<<"IMPOSSIBLE"<<endl;
		}
	}




}


Measured memory_bytes: 256
n=int(input())
m=[]
a=[]
r=[]
c=[]
h=[]
for i in range(0,n):
  s=str(input())
  sl=list(s)
  if sl[0]=="M":
    m.append(s)
  elif sl[0]=="A":
    a.append(s)
  elif sl[0]=="R":
    r.append(s)
  elif sl[0]=="C":
    c.append(s)
  elif sl[0]=="H":
    h.append(s)
temp=[len(m),len(a),len(r),len(c),len(h)]
from itertools import combinations
temp2=list(combinations(temp,3))
ans=[]
for i in range(0,len(temp2)):
  ans.append(temp2[i][0]*temp2[i][1]*temp2[i][2])
print(sum(ans))

Measured memory_bytes: 10172
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;

int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > p[5];
int memo[5][5][1111];
int a, b;

int solve(int k, int t, int q){

  if(memo[k][t][q]) return memo[k][t][q];
  if(k == 4) return abs(p[t][q].F-gx) + abs(p[t][q].S-gy);

  int ans = INF, d = (t+1)%5, s;
  for(int i=0;i<p[d].size();i++){
    if(!k) s = abs(sx-p[d][i].F) + abs(sy-p[d][i].S);
    else s = abs(p[t][q].F-p[d][i].F) + abs(p[t][q].S-p[d][i].S);
    ans = min(ans, solve(k+1, d, i) + s);
  }

  return memo[k][t][q] = ans;
}

int main(){

  int w,h;
  char c;

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<5;i++) p[i].clear();
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c;
	if(c == 'S') sx = j, sy = i;
	if(c == 'G') gx = j, gy = i;
	else if(c != '.') p[c-'1'].push_back(P(j,i));
      }
    }
    
    b = INF;
    for(int i=0;i<5;i++){
      memset(memo, 0, sizeof(memo));
      if(b > solve(0,i,0)) a = i, b = solve(0,i,0);
    }

    if(b == INF) cout << "NA\n";
    else cout << a+1 << " " << b << endl;

  }
}

Measured memory_bytes: 1372
a,b,c = (int(x) for x in input().split())
candy = [a, b, c]
#print(candy)
candy.sort()
#print(candy)
max_candy = candy[2]
middle_candy = candy[1]
min_candy = candy[0]

if max_candy == middle_candy + min_candy:
    print('Yes')
else:
    print('No')

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

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int A[4096];
  for(int t = 0; t < 4000;) {
    for(int i = 0; i <= a; ++i) {
      A[t + i] = 1;
    }
    t += a;
    for(int i = 1; i < b; ++i) {
      A[t + i] = -1;
    }
    t += b;
  }
  int res = -1;
  for(int t = c; t < 4000; t += 60) {
    if( A[t] > 0 ) {
      res = t;
      break;
    }
  }

  printf("%d\n", res);  
  
  return 0;
}

Measured memory_bytes: 3236
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int N;
vector<int> odd, even, s;

signed main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    s.push_back(tmp);
    if (i % 2 == 0) {
      even.push_back(tmp);
    } else {
      odd.push_back(tmp);
    }
  }

  sort(ALL(s));
  sort(ALL(even));
  sort(ALL(odd));

  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    mp[s[i]] = i % 2;
  }

  vector<int> v;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      v.push_back(even[i / 2]);
    } else {
      v.push_back(odd[i / 2]);
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 != mp[v[i]]) ans++;
  }

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


Measured memory_bytes: 9720
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    long long N, M;
    cin >> N >> M;

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

    vector<long long> sumA(N + 1, 0);
    for (int i = 0; i < N; i++) sumA[i + 1] = sumA[i] + A[i];
    for (int i = 0; i < N + 1; i++) sumA[i] %= M;

    map<long long, long long> MAP;
    long long ans = 0;

    for (int i = 0; i < N + 1; i++) {
        ans += MAP[sumA[i]];
        MAP[sumA[i]]++;
    }

    cout << ans << endl;

    return 0;
}




















































































Measured memory_bytes: 5760
/* Author: shriamrut
 * Language: C++17
 * Made on:22.08.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
/*auto i2=upper_bound(cind[i].rbegin(), cind[i].rend(), range[1],[](int a, int b){return a>=b;});
 * to obtain largest val <=x
 * */
int main() {
	IOS;	
	//freopen("input.txt","r",stdin);
	string s;
	cin>>s;
	ll sum_of_digits=0;
	for(int i=0;i<s.length();i++)
		sum_of_digits+=(s[i]-'0');
	if(sum_of_digits%9==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


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

#define MOD (1000000007LL)

using namespace std;

int N, K;

long long ans = 1;

void dfs(int index, vector<vector<int>> &e, vector<long long> &cd1, vector<long long> &cd2, vector<bool> &v){
    // cout << index << endl;
    // cout << ans << endl;
    // for(int i = 0; i < N; i++) cout << cd1[i] << " " << cd2[i] << endl;

    ans *= K - cd1[index] - cd2[index];
    ans %= MOD;
    v[index] = true;;
    for(int neigh : e[index]){
        if(v[neigh]) continue;
        cd2[neigh] = cd1[index];
        cd1[neigh] = 1;
        dfs(neigh, e, cd1, cd2, v);
        cd1[index]++;
    }
}

int main(void){
    cin >> N >> K;
    vector<vector<int>> e(N);
    vector<long long> cd1(N, 0), cd2(N, 0);
    vector<bool> v(N, false);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    dfs(0, e, cd1, cd2, v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;

class Program
{
    static int[] ReadInts()
        => Console.ReadLine()
            .Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => int.Parse(s))
            .ToArray();

    static void Main(string[] args)
    {
        var numbers = Console.ReadLine()
            .Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(s => BigInteger.Parse(s))
            .ToArray();
        var a = numbers[0];
        var b = numbers[1];
        var n = numbers[2];
        var x = BigInteger.Min(b - 1, n);
        var result = a * x / b;
        Console.WriteLine(result.ToString());
    }
}


Measured memory_bytes: 28680