akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,p;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>p;
    a=pow(p,1.0/(ld)n);
    for(ll i=a;i>=ans;i--){
        b=pow(i,n-1);
        c=__gcd(i,p/b);
        if(c>=ans&&p%b==0){
            ans=c;
        }
    }
    Cout(ans);
    return 0;
    return 0;
}


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


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
  map<long long, long long> tab;
  long long acc = 0;

  for(long long i = 0; i < M; i++){
    if(N != 1 && s[i] == 1 && c[i] == 0) goto err;
    if(tab.count(s[i]) > 0) {
      if(tab[s[i]] != c[i]) goto err;
      continue;
    }
    acc += (c[i] * pow(10,N-s[i]));
    tab[s[i]] = c[i];
  }

  if(N == 1 && acc == 0) {
    cout << 0 << endl;
  }
  else {
    cout << ((acc < pow(10,N-1)) ? (acc+pow(10,N-1)) : acc) << endl;
  }
  return;

  err:
  cout << -1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> s(M);
  std::vector<long long> c(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&s[i]);
    scanf("%lld",&c[i]);
  }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


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

int main() {

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            int k = (N - R * i - G * j) / B;
            if (k >= 0 && (N - R * i - G * j) % B == 0)
                ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int candi[2][105]={0};
int dp[2][105]={0};
int main(){
	int N;
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &candi[0][i]);
	}
	for(int i=0; i<N; i++){
		scanf("%d", &candi[1][i]);
	}
	int sum=0;
	for(int i=0; i<N; i++){
		sum+=candi[0][i];
		dp[0][i]=sum;
	}
	dp[1][0]=candi[0][0]+candi[1][0];
	for(int i=1; i<N; i++){
		dp[1][i]=max(dp[1][i-1], dp[0][i])+candi[1][i];
	}
	printf("%d", dp[1][N-1]);
}

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

// 
int main() {
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 || i % 5 == 0) {
        } else {
            sum += i;
        }
    }
    cout << sum;
}


Measured memory_bytes: 3564
n = gets.strip.to_i
h=gets.strip.split.map(&:to_i)

h[0]=h[0]-1

(1...n).each do |i|
  h[i] = h[i]-1 if h[i] > h[i-1]

  if h[i] < h[i-1]
    puts 'No'
    exit
  end

end

puts 'Yes'



Measured memory_bytes: 9604
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    int64_t w,h,x,y;
    cin >> w >> h >> x >> y;
    bool onCenter = (x == w*0.5 && y == h*0.5);
    cout << (w*h*0.5) << ' ' << (onCenter ? 1 : 0) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//mayank srivastava
//d katana monster

int main()
{
    int n, h; cin >> n >> h;
    vector<int> a(n), b(n);
    int ma = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        ma = max(ma, a[i]);
    }
    int ans = 0;
    bool apurv = false;
    sort(b.begin(), b.end(), greater<int>());
    for (int i = 0; i < n; i++)
    {
        if (ma < b[i]) 
        {
            ans++;
            h -= b[i];
        }
        if (h <= 0) 
        {
            apurv = true;
            break;
        }
    }
    if (!apurv)
    {
        ans += (h + ma - 1) / ma;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define MOD 30000000000000000
#define inf -100000000
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define MAXN 500005
using namespace __gnu_pbds; 
ll int power(ll int x,ll int y) 
{ 
    ll int res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
//set<ll int> s;
bool prime[500005];
void SieveOfEratosthenes(ll int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
     
    memset(prime, true, sizeof(prime)); 
  
    for (ll int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    
} 

int main()
{
    fast;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    ll int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k<<endl;
    }
    else if(k>a && k<=a+b)
    {
        cout<<a<<endl;
    }
    else if(k>a+b && k<=a+b+c)
    {
        cout<<a-(k-(a+b));
    }
    else
    {
        cout<<a-b<<endl;
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];

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

    vector<long> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    long ans = 0;
    for (int l = 0; l <= n; l++) {
        for (int r = 0; r <= n; r++) {
            if (l + r > min(n, k))
                break;
            priority_queue<long, vector<long>, greater<long>> q;

            for (int i = 0; i < l; i++) {
                q.push(v[i]);
            }
            for (int i = 0; i < r; i++) {
                q.push(v[n - 1 - i]);
            }
            int rem = k - (l + r);

            while (rem > 0 && !q.empty() && q.top() < 0) {
                q.pop();
                rem--;
            }

            long sum = 0;
            while (!q.empty()) {
                sum += q.top();
                q.pop();
            }

            ans = max(ans, sum);
        }
    }

    cout << ans << endl;
}


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

int main(){
    long N, M;
    cin >> N >> M;
    vector<pair<long, long>> edge(M);
    for(auto& i : edge)cin >> i.first >> i.second;

    class union_find{
    public:
        vector<long> v;
        union_find(size_t n) : v(n, -1){}
        long root(long i){
            return v[i] >= 0 ? v[i] = root(v[i]) : i;
        }
        long unite(long a, long b){
            a = root(a);
            b = root(b);
            //pair<long, long> ret(-v[a], -v[b]);
            long ret(v[a] * v[b]);
            if(a == b)return 0;
            if(v[a] > v[b])swap(a, b);
            v[a] += v[b];
            v[b] = a;
            return ret;
        }
    };

    reverse(edge.begin(), edge.end());

    union_find uf(N + 1);

    vector<long> ans;

    ans.push_back(N * (N - 1) / 2);

    for(const auto& i : edge){
        long t = *ans.rbegin();
        ans.push_back(t - uf.unite(i.first, i.second));
    }

    ans.pop_back();

    reverse(ans.begin(), ans.end());

    for(const auto i : ans)cout << i << endl;

    return 0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <fstream>
using namespace std;
typedef long long ll;

#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}


int main(){
   _;
  int x;cin>>x;
  int x1=x%500,x2=x/500;
  int a=x1/5;
  cout<<x2*1000+a*5;
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int X;
  cin >> X;
  int rem = X % 100;
  int q = X / 100;
  int cnt = rem / 5 + (rem % 5 != 0);
  cout << (cnt <= q) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int n;
	static double[] x;
	static double[] y;
	static double[] l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			if (n == 0)
				break;
			x = new double[n];
			y = new double[n];
			l = new double[n];
			for (int i = 0; i < n; ++i) {
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
				l[i] = sc.nextDouble();
			}

			double xl = -100;
			double xr = 100;

			for (int i = 0; i < 100; ++i) {
				double mxl = (2 * xl + xr) / 3;
				double mxr = (xl + 2 * xr) / 3;
				double Lmxl = len(mxl);
				double Lmxr = len(mxr);
				if (Lmxl < Lmxr) {
					xl = mxl;
				} else {
					xr = mxr;
				}
			}
			System.out.println(Math.sqrt(len(xl)));
		}
		sc.close();
	}

	static double len(double x) {
		double yl = -100;
		double yr = 100;

		for (int i = 0; i < 100; ++i) {
			double myl = (2 * yl + yr) / 3;
			double myr = (yl + 2 * yr) / 3;
			double Lmyl = calc(x, myl);
			double Lmyr = calc(x, myr);
			if (Lmyl < Lmyr) {
				yl = myl;
			} else {
				yr = myr;
			}
		}
		return calc(x, yl);
	}

	static double calc(double cx, double cy) {
		double len2 = Double.MAX_VALUE / 4;// (x-xi)^2+(y-yi)^2+z^2<=li^2
		// z^2<=li^2-(x-xi)^2-(y-yi)^2
		for (int i = 0; i < n; ++i) {
			len2 = Math.min(len2, l[i] * l[i] - (cx - x[i]) * (cx - x[i]) - (cy - y[i]) * (cy - y[i]));
		}
		return len2;
	}
}

Measured memory_bytes: 63092
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<string.h>
using namespace std;
#define LL long long int
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define PI pair<int,int>
#define mem(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(v) (int)sizeof(v)
const int inf=0x3f3f3f3f;
const int mod=10007;
const int M=20;
using namespace std;
#define N 200005
char s[N];
int ans,n;

int main()
{
    int i,n;
    while(~scanf("%s",s)){
        n=strlen(s);
        ans=n;
        stack<int>q;
        for(i=0;i<n;++i){
            if(s[i]=='S'){
                q.push(1);
            }
            if(s[i]=='T'){
                if(!q.empty()){
                    q.pop();
                    ans-=2;
                }
                else
                    ;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//#define int long long
struct edge {
	int from, to, cost;
	bool operator<(const edge& other)const {
		return cost < other.cost;
	}
};
bool comp_x(const tuple<int, int, int>&f, const tuple<int, int, int>&s) {
	return get<1>(f) <get<1>(s);
}
bool comp_y(const tuple<int, int, int>&f, const tuple<int, int, int>&s) {
	return get<2>(f) <get<2>(s);
}
class union_find_tree {
private:
	vector<int>par, rank_;
public:
	union_find_tree(int n) :par(n), rank_(n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank_[i] = 0;
		}
	}

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}
		if (rank_[x] < rank_[y]) {
			par[x] = y;
		}
		else if (rank_[x] == rank_[y]) {
			par[y] = x;
			rank_[x]++;

		}
		else if (rank_[y] < rank_[x]) {
			par[y] = x;
		}
	}
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		return par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};



//using edges = vector<edge>;

int kruskal(union_find_tree& uf, vector<edge>&  es, int V) {


	sort(es.begin(), es.end());
	int E = es.size();

	int res = 0;
	for (int i = 0; i < E; i++) {
		if (!uf.same(es[i].from, es[i].to)) {
			uf.unite(es[i].from, es[i].to);
			res += es[i].cost;
		}
	}
	return res;
}
/*
bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof)
{
	if (firstElof.first != secondElof.first) {
		return secondElof.first>firstElof.first;
	}
	else if (firstElof.first == secondElof.first) {
		return firstElof.second > secondElof.second;
	}
}
*/


signed main()
{
	int n;
	cin >> n;
	vector<tuple<int, int,int>>vs(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		get<0>(vs[i]) = i;
		get<1>(vs[i]) = x;
		get<2>(vs[i]) = y;
	}
	vector<edge> es;
	sort(vs.begin(), vs.end(), comp_x);
	for (int i = 0; i < n - 1; i++) {
		edge e;
		e.from = get<0>(vs[i]);
		e.to = get<0>(vs[i+1]);
		e.cost = get<1>(vs[i + 1]) - get<1>(vs[i]);
		es.push_back(e);
	}
	sort(vs.begin(), vs.end(), comp_y);
	for (int i = 0; i < n - 1; i++) {
		edge e;
		e.from = get<0>(vs[i]);
		e.to = get<0>(vs[i + 1]);
		e.cost = get<2>(vs[i + 1]) - get<2>(vs[i]);
		es.push_back(e);
	}
	union_find_tree uf(n);
	cout << kruskal(uf, es, n) << endl;
	
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  
  if(s=="RRR") ans = 3;
  if(s=="RRS") ans = 2;
  if(s=="RSR") ans = 1;
  if(s=="SRR") ans = 2;
  if(s=="SSR") ans = 1;
  if(s=="SRS") ans = 1;
  if(s=="RSS") ans = 1;
  if(s=="SSS") ans = 0;
 
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 3572
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
int a,b;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;

	for(int i=1;i<=9;i++){
		if(n%i==0){
			if(n/i <= 9){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
    

return 0;
}
///....


Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a) vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
using g = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    ll ans = 0;
    rep(i,1,n+1){
        if(a[i-1]==i)ans++;
        if(a[i-1]==i&&a[i]==i+1)i++;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, c = 0;
    ll a[100005] = {}, b = 0, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], b ^= a[i];
    for (int i = 0; i < n; i++) a[i] &= ~b;
    for (int i = 59; i >= 0; i--) {
        bool y = 0;
        for (int j = c; j < n; j++) if (a[j] & (1ll << i)) {
            if (j != c) a[c] ^= a[j];
            y = 1;
            break;
        }
        if (!y) continue;
        for (int j = c + 1; j < n; j++) if ((a[j] ^ a[c]) < a[j]) a[j] ^= a[c];
        c++;
    }
    for (int i = 0; i < n; i++) if ((z ^ a[i]) > z) z ^= a[i];
    cout << z + z + b;
}


Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> h(4);
    int k;
    rep(i,0,4) cin >> h[i];
    cin >> k;
    int a = h[0]*60 + h[1];
    int b = h[2]*60 + h[3];
    int ans = max(0,b-a-k);
    cout << ans << endl;
}


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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

vector<long long> sh, te;

int sh_best[100005], te_best[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    /*

        c1: walk to closest temple, then to shrine

        c2: walk to closest shrine, then to temple

        maybe save the best temple/shrine for every shrine/temple

    */

    int a, b, q; cin >> a >> b >> q;

    for(int i = 0; i < a; ++i){
        long long j; cin >> j;
        sh.push_back(j);
    }

    int pos = 0;

    for(int i = 0; i < b; ++i){
        long long j; cin >> j;
        while(pos < a && sh[pos] < j)
            ++pos;
        te.push_back(j);
        te_best[i] = pos;
        //cout << "SHRINE CLOSEST " << j << " " << sh[pos] << endl;
    }

    sh.push_back(1e11);
    te.push_back(1e11);

    pos = 0;

    for(int i = 0; i < a; ++i){
        while(pos < b && te[pos] < sh[i])
            ++pos;
        sh_best[i] = pos;
        //cout << "TEMPLE CLOSEST " << sh[i] << " " << te[pos] << endl;
    }

    long long x;

    while(q--){
        cin >> x;

        // temple first

        long long best = 1e11;

        int p = upper_bound(te.begin(), te.end(), x) - te.begin();

        if(p != b){
            best = min(best, abs(x - te[p]) + abs(te[p] - sh[te_best[p]]));
            //cout << "VISIT " << x << " " << te[p] << " " << sh[te_best[p]] << endl;
            if(te_best[p] > 0)
                best = min(best, abs(x - te[p]) + abs(te[p] - sh[te_best[p] - 1]));
        }
        if(p > 0){
            best = min(best, abs(x - te[p - 1]) + abs(te[p - 1] - sh[te_best[p - 1]]));
            if(te_best[p - 1] > 0)
                best = min(best, abs(x - te[p - 1]) + abs(te[p - 1] - sh[te_best[p - 1] - 1]));
        }

        // shrine first

        p = upper_bound(sh.begin(), sh.end(), x) - sh.begin();

        if(p != a){
            best = min(best, abs(x - sh[p]) + abs(sh[p] - te[sh_best[p]]));
            if(sh_best[p] > 0)
                best = min(best, abs(x - sh[p]) + abs(sh[p] - te[sh_best[p] - 1]));
        }
        if(p > 0){
            best = min(best, abs(x - sh[p - 1]) + abs(sh[p - 1] - te[sh_best[p - 1]]));
            if(sh_best[p - 1] > 0)
                best = min(best, abs(x - sh[p - 1]) + abs(sh[p - 1] - te[sh_best[p - 1] - 1]));
        }

        cout << best << "\n";

    }

    return 0;

}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,zs;
int main()
{
	cin>>a>>b;
	x=b;zs=1;
	for(;x>0;x/=10)
	{
		zs*=10;
	}
	a=a*zs+b;
	for(int i=1;i*i<=a;i++)
	if(i*i==a){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, t, a;
    double h[1000];
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++)
    {
        double tp;
        cin >> tp;
        double tmp = t - tp * 0.006 - a;
        if (tmp < 0)
            tmp *= -1;
        h[i] = tmp;
    }

    int idx = 0;
    double min = INF;
    for (int i = 0; i < n; i++)
    {
        // cout << i + 1 << "," << h[i] << endl;
        if (h[i] < min)
        {
            min = h[i];
            idx = i + 1;
        }
    }
    cout << idx << endl;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int, input().split()))

dif = []
S_1 = []
S_2 = []

for i in range(N-1):
    for j in range(i,i+1):
        S_1.append(W[i])
    dif.append(abs(sum(S_1)-(sum(W)-sum(S_1))))

print(min(dif))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new TreeMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			for (String key : map.keySet()) {
				if (map.get(key) == max) {
					System.out.println(key);
				}
			}
		}
	}
}

Measured memory_bytes: 65320
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

struct edge{
  int src,dst;
  ll weight;
};

int main(){
  int R,C;cin>>R>>C;
  int N;cin>>N;
  vector<vector<edge> > g(R+C);
  repeat(i,N){
    int r,c;ll a;cin>>r>>c>>a;r--;c--;
    g[r].push_back({r,R+c,a});
    g[R+c].push_back({R+c,r,a});
  }
  bool isok=true;
  vector<bool> used(R+C,false);
  vll weight(R+C,0);
  repeat(i,R+C){
    if(used[i])continue;
    debug(i);
    debug(isok);
    ll minr=INF,minc=INF;
    queue<edge> Q;
    Q.push({-1,(int)i,0});
    while(!Q.empty()){
      edge e = Q.front();
      Q.pop();
      if(used[e.dst]){
        isok &= weight[e.dst]==e.weight;
        continue;
      }
      used[e.dst]=true;
      weight[e.dst] = e.weight;
      if(e.dst<R) minr=min(minr,weight[e.dst]);
      else minc=min(minc,weight[e.dst]);
      for(edge f:g[e.dst]){
        int w = f.weight - weight[e.dst];
        Q.push({f.src,f.dst,w});
      }
    }
    debug(isok);
    cerr<<"!"<<endl;
    isok &= (minr+minc)>=0;
    debug(isok);
  }
  debugArray(weight,R+C);
  cout<<(isok?"Yes":"No")<<endl;
  return 0;
}


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


#define ll long long
#define FOR(x,y,z) for(ll x = y; x <= (ll)z; x++)
#define line cout << endl

using namespace std;




void B() {
	int k;
	string s;
	cin >> k >> s;
	if (s.length() > k) {
		FOR(i, 0, k - 1)
		{
			cout << s[i];
		}
		cout << "...";
	}
	else {
		cout << s;
	}
}





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




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

int main(){
  int Q;
  scanf("%d",&Q);
  int l[Q],r[Q];
  for(int i = 0;i < Q;i++){
    scanf("%d%d",&l[i],&r[i]);
  }
  int S[100001];  //S[i]は0からiまでの間に含まれる２０１７に似た数の数
  S[0] = 0;
  S[1] = 0;
  S[2] = 0;
  for(int i = 3;i < 100001;i++){
    int j;
    for(j = 2;j < i;j++){
      if(i%j == 0){
        S[i] = S[i-1];
        break;
      }
    }
    if(j != i)continue;
    int k;
    for(k = 2;k < (i+1)/2;k++){
      if(((i+1)/2)%k == 0){
        S[i] = S[i-1];
        break;
      }
    }
    if(k != (i+1)/2)continue;
    S[i] = S[i-1] + 1;
  }
  for(int i = 0;i < Q;i++){
    printf("%d\n",S[r[i]]-S[l[i]-1]);
  }
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  long long int max=1;
  for(long long int i=1; i*i<=n; i++){
    if(n%i==0) max=i;
  }
  cout << max + n/max - 2 << endl;
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back

using namespace std;

const int N  = 1e6 + 69, INF = 1e9, mod = 1e9 + 7;

const ll INFLL = 1e18;

int n, K;
ll dp[N][2], tree[N], A[N], B[N];

void upd(int pos,ll x){
        while(pos < N){
                tree[pos] = max(tree[pos],x);
                pos += (pos & -pos);
        }
}

ll get(int pos){
        ll res = 0;
        while(pos){
                res = max(res, tree[pos]);
                pos -= (pos & -pos);
        }
        return res;
}

int main(){

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

        ll ans = B[1];

        upd(A[1],B[1]);

        for(int i = 1; i <= n ; i++){
                ll answer = get(A[i] - 1);
                answer += B[i];
                ans = max(ans, answer);
                upd(A[i], answer);
        }

        cout << ans << endl;
}


Measured memory_bytes: 12032
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
int main() {
	string t;
	cin >> t;
	for (int i = 0; i < t.length(); i++) if (t[i] == '?') t[i] = 'D';
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3720
#include<stdio.h>
int main(void)
{
  int N,sen,hyaku,zyu,iti;

  scanf("%d",&N);

  iti=N%10;
  zyu=(N%100-iti)/10;
  hyaku=(N%1000-iti-zyu*10)/100;
  sen=(N-hyaku*100-iti-zyu*10)/1000;

  if(iti==zyu && zyu==hyaku){
    printf("Yes\n");
  } else if(zyu==hyaku && hyaku==sen){
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

#define N 505

int n,k;

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>k;
}

int main(){
	init();
	cout<<(k/2)*(k-k/2)<<endl;
	return 0;
}

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

int main() {
    int N, C, K, a[100000], ti;
    cin >> N >> C >> K;

    for (ti = 0; ti < N; ti++) cin >> a[ti];
    sort(a,a+N,less<int>());

    int r = 0, to;
    for (ti = 0; ti < N; r++) {
        to = ti;
        while (a[ti] <= a[to]+K && ti < N && ti-to+1 <= C) ti++;
    }

    cout << r << endl;
}

Measured memory_bytes: 640
//Binary search tree 3

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node
{
  int key;
 struct Node *p, *l, *r;
};

struct Node *root,*NIL;

struct Node *min(struct Node *x)
{
  while(x->l != NIL) x = x->l;
  return x;
}

struct Node *ser(struct Node *x)
{
  struct Node *y = x->p;
  if(x->r != NIL) return min(x->r);

  while(y != NIL && x == y->r)
    {
      x = y;
      y = y->p;
    }
  return y;
}

void insert(int key)
{
 struct Node *y = NIL;
 struct Node *x = root;
 struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = key;
  z->r = NIL;
  z->l = NIL;

  while(x != NIL)
    {
      y = x;
      if(z->key < x->key) x = x->l;
      else x = x->r;
    }

  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key)
    {
      y->l = z;
    }else{
    y->r = z;
  }
}

struct Node *find(struct Node *x, int key)
{
  while(x != NIL && key != x->key)
    {
      if(key < x->key) x = x->l;
      else x = x->r;
    }
  return x;
}

void delete(struct Node *x)
{
  struct Node *y;
  struct Node *z;

  if(x->l == NIL || x->r == NIL) y = x;
  else y = ser(x);

  if(y->l != NIL) z = y->l;
  else z = y->r;

  if(z != NIL) z->p = y->p;

  if(y->p == NIL) root = z;
  else if(y == y->p->l) y->p->l = z;
  else y->p->r = z;

  if(y != z) x->key = y->key;

  free(y);
      
}

void pre(struct Node *x)
{
  if(x == NIL) return;
  printf(" %d",x->key);
  pre(x->l);
  pre(x->r);
}

void in(struct Node *x)
{
  if(x == NIL) return;
  in(x->l);
  printf(" %d",x->key);
  in(x->r);
}


int main()
{
  int i,n,num;
  char alp[20];
  //Node *imp;
  
  scanf("%d",&n);

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

      if(alp[0] == 'i')
	{
	  scanf("%d",&num);
	  insert(num);

	}
      else if(alp[0] == 'f')
	{
	  scanf("%d",&num);

	  if(find(root,num)) printf("yes\n");
	  else printf("no\n");
	}

      else if(alp[0] == 'd')
	{
	  scanf("%d",&num);

	  delete(find(root,num));
	}

      else if(alp[0] == 'p')
	{
	  in(root);
	  printf("\n");
	  pre(root);
	  printf("\n");
	}
    }
  
return 0;

}




Measured memory_bytes: 20556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b-1; i >= a; i--)
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

vector<vector<int> > G;

const int MAX_N = 1e5 + 10;
const int INF = 1e9;

int N;
//vector<int> G[MAX_N];
int used1[MAX_N], used2[MAX_N], used3[MAX_N], dist1[MAX_N], dist2[MAX_N], dist3[MAX_N];
bool ng[MAX_N];

void bfs1(int s){
    for(int i = 0; i < N; i++) dist1[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist1[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        cerr << v << endl;
        used1[v] = 1;
        for(auto nv: G[v]){
            if(used1[nv] == 0){
                dist1[nv] = dist1[v] + 1;
                Q.push(nv);
                //used1[nv] = true;
            }
        }
    }
}

void bfs2(int s){
    for(int i = 0; i < N; i++) dist2[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist2[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        cerr << v << endl;
        used2[v] = 1;
        for(auto nv: G[v]){
            if(used2[nv] == 0){
                dist2[nv] = dist2[v] + 1;
                Q.push(nv);
                //used1[nv] = true;
            }
        }
    }
}

void bfs3(int s){
    //for(int i = 0; i < N; i++) dist2[i] = 1e9;

    queue<int> Q;
    Q.push(s);
    dist3[s] = 0;

    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        cerr << v << endl;
        used3[v] = 1;
        for(auto nv: G[v]){
            if(used3[nv] == 0 && !ng[nv]){
                dist3[nv] = dist3[v] + 1;
                Q.push(nv);
                //used1[nv] = true;
            }
        }
    }
}

signed main(){
    int u, v; cin >> N >> u >> v;u--, v--;
    G.resize(N);
    rep(i, 0, N-1){
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs1(v);
    bfs2(u);
    //rep(i, 0, N) ng[i] = false;
    rep(i, 0, N){
        if(dist1[i] > dist2[i]) ng[i] = false;
        else ng[i] = true;
    }
    rep(i, 0, N) dist3[i] = INF;
    bfs3(u);
    int ans = 0;
    rep(i, 0, N) if(dist3[i] != INF){
        ans = max(ans, dist1[i]);
    }
    cout << ans - 1 << endl;

}


Measured memory_bytes: 8320
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))
N,x=miipt()
l=miipt()
l+=[0,0]
ans=0
d=[0]*(N+2) # [N+1]を[-1]として使う暴挙
#d[0]=1
d[-1]=1
#d[N-1]=1
d[N]=1
nxt=[0,N-1]
while True:
    f=False
    nnxt=[]
    for i in nxt:
        if d[i-1] and d[i+1]:
            df=max(l[i-1],l[i+1])+l[i]-x
            if df>0:
                l[i]-= df
                ans+=df
            continue
        j,k=(i-1,i+1) if d[i-1] else (i+1,i-1)
        d[i]=1

        f=True

        nnxt.append(k)
        df=l[i]+l[j]-x

        if df>0:
            l[i]-= df
            ans+=df           
    if not f:
        break
    nxt=nnxt
"""for i in range(0,N-1):
    d=l[i]+l[i+1]-x
    if d>0:
        ans+=d
        l[i+1]-=d"""
print(ans)

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

int main(){
  long int H;
  cin>>H;
  
  int p=-1;
  while(H>0){
    H/=2;
    p++;
  }
  
  long int ans=1;
  
  for(int i=0;i<p;i++){
    ans=ans*2+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
  ll n ;
  cin >> n ;
  cout << (n*(n+1))/2 << el ; 
  ro ;

}































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

int n;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n), ans(n);
    for (auto& i : a) cin >> i;

    ll water = a[n - 1];
    for (int i = n - 2; i > 0; --i) {
        water = a[i] - water;
    }
    ans[0] = a[0] - water;
    for (int i = 0; i < n - 1; i++) {
        ll have = ans[i] / 2;
        ans[i + 1] = (a[i] - have) * 2;
    }
    for (auto& i : ans) cout << i << " ";
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
long long a[200000], vs[405][406],vs1[100006],d[500][500],white[500][500];
vector<int>v[200000];
char s[405][405];
void f(int n, int m)
{
    int i, k=0,j=0;
    vs[n][m]=1;
    for(i=0;i<=1; i++)
    for(k=0; k<=1; k++){
            char ch=s[n+i][m+k]; j=0;
        if(abs(i+k)==1&&ch!='*'){
            if(ch=='#'&&s[n][m]=='.') j=1;
            if(vs[n+i][m+k]==0||d[n][m]+j<d[n+i][m+k]){
                d[n+i][m+k]=d[n][m]+j;
                f(n+i,m+k);
            }
        }
    }
}
int main()
{
    IO;
    long long i, j, m, k, n, t, l=0, mx,ll,mxx,mx1;
    cin>>n>>m;
    for(i=0; i<=n+1; i++)
        for(j=0; j<=m+1; j++) s[i][j]='*';
    for(i=1; i<=n; i++)
        for(j=1; j<=m; j++) cin>>s[i][j];

    if(s[1][1]=='#')d[1][1]++;
    f(1,1);
    cout<<d[n][m]<<endl;
    return 0;

}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        char ch;
        cin>>ch;
        if(ch >= 'A' && ch<='Z') cout<<"A";
        else cout<<"a";

    }
    
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const long long mod=998244353;
int n,s;
long long a[3005],dp[3005];
int main()
{
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    memset(dp,0,sizeof(dp));
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        dp[0]++;
        for(int j=s;j>=a[i];j--)
            dp[j]=(dp[j]+dp[j-a[i]])%mod;
        ans=(ans+dp[s])%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    int h,w,n;
    cin>>h>>w>>n;
    set<pii> pos;
    rep(i,n){
        int x,y;
        cin>>y>>x;
        x--,y--;
        pos.insert(pii(y,x));
    }
    
    vector<int> c(10,0);
    set<pii> used;
    for(auto elm : pos){
        int y,x;
        tie(y,x) = elm;
        for(int i=-2;i<=0;i++){
            for(int j=-2;j<=0;j++){
                int ddy = y+i;
                int ddx = x+j;
                if( ddy<0 || ddx<0 || ddy+2>=h || ddx+2>=w || used.count(pii(ddy,ddx)) )continue;
                used.insert(pii(ddy,ddx));
                
                int sum = 0;
                rep(ii,3){
                    rep(jj,3){
                        if(pos.count(pii(ddy+ii,ddx+jj)))sum++;
                    }
                }
                c[sum]++;
            }
        }
    }
    rep(i,c.size()){
        if(i==0)cout<<(h-2)*(w-2)-used.size()<<endl;
        else cout<<c[i]<<endl;
    }
}


Measured memory_bytes: 62720
using System;
using System.Linq;

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

            var result = 0;
            for (var i = 0; i < B.Length; i++)
            {
                if(i == 0)
                {
                    result += B[i];
                }
                else
                {
                    result += Math.Min(B[i], B[i -1]);
                }
            }
            result += B[B.Length - 1];
            Console.WriteLine(result);
        }
    }
}


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

int main(void)
{
	int n;
	scanf("%d", &n);
	
	int *array = malloc(sizeof(int)*n);
	
	int i;
	for(i=0;i<n;i++) {
		scanf("%d", array+i);
	}
	
	int max = -1.0e9;
	int min = *array;
	
	for(i=1;i<n;i++) {
		if(*(array+i)-min > max) {
			max = *(array+i)-min;
		}
		if(*(array+i) < min) {
			min = *(array+i);
		}
	}
	
	printf("%d\n", max);
	
	free(array);
	
	return 0;
}
	
	



Measured memory_bytes: 2284
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w==0 && h==0) break;
			
			char[][] map = new char[h+2][w+2];
			int gx = -1;
			int gy = -1;
			for(int i=0;i<h+2;i++) Arrays.fill(map[i], '.');
			for(int i=0;i<h;i++){
				char[] c = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					map[i+1][j+1] = c[j];
					if(c[j]=='&'){
						gx = j+1;
						gy = i+1;
					}
				}
			}
			
			int[][] cnt = new int[h+2][w+2];
			for(int i=0;i<h+2;i++) Arrays.fill(cnt[i], Integer.MAX_VALUE);
			
			int[] a = new int[]{0,0,1,-1};
			int[] b = new int[]{1,-1,0,0};
			ArrayDeque<Integer> x = new ArrayDeque<Integer>();
			ArrayDeque<Integer> y = new ArrayDeque<Integer>();
			x.offer(0);
			y.offer(0);
			cnt[0][0] = 0;
			int p, q, r;
			while(x.size()!=0){
				p = x.poll();
				q = y.poll();
				for(int i=0;i<4;i++){
					int u = p+a[i];
					int v = q+b[i];
					if(0<=u && u<w+2 && 0<=v && v<h+2){
						if(map[q][p]=='#' && map[v][u]!='#') r = 1;
						else r = 0;
						if(cnt[v][u] > cnt[q][p] + r){
							x.offer(u);
							y.offer(v);
							cnt[v][u] = cnt[q][p] + r;
						}
					}
				}
			}
			System.out.println(cnt[gy][gx]);
		}	
	}	
}

Measured memory_bytes: 30332
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int nmin=(1<<31)-1;
    int ans=1<<31;
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int dummy;
        cin>>dummy;
        ans=max(ans,dummy-nmin);
        nmin=min(nmin,dummy);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3068
def q4():
    import collections
    N = int(input())
    A = [int(i) for i in input().split()]

    def n_C_2(n):
        """ n個から2個選ぶ組み合わせ総数を計算 """
        ret = 0 if n < 2 else n * (n - 1) / 2
        return ret

    all_sum = 0  # 総数
    counter = collections.Counter(A)
    # all_sumを作成
    for v in counter.values():
        all_sum += n_C_2(v)

    for i in range(N):
        cnt = counter[A[i]]  # i番目の値の出現回数を取得
        ans = all_sum - n_C_2(cnt) + n_C_2(cnt - 1)
        print(int(ans))


if __name__ == '__main__':
    q4()

Measured memory_bytes: 26772
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
int N ; cin >> N;
vector<string> vec(N);
vector<string> a(N);
int count = 0;
rep(i,N){
  cin >> vec[i];
}
a = vec;
sort(a.begin(),a.end());
bool flag = false;
rep(i,N-1){
  if(a[i] == a[i+1]){
    flag = true;
  }
}
rep(i,N-1){
  if(vec[i][vec[i].length()-1] != vec[i+1][0]){
    flag = true;
}
}

if(flag) 
  cout << "No" << endl;

else
cout << "Yes" << endl;

}

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN")  cout << 7 << endl;
    if(s == "MON")  cout << 6 << endl;
    if(s == "TUE")  cout << 5 << endl;
    if(s == "WED")  cout << 4 << endl;
    if(s == "THU")  cout << 3 << endl;
    if(s == "FRI")  cout << 2 << endl;
    if(s == "SAT")  cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,d,x;
	cin>>n>>d;
	d=d*2+1;
	x=n/d;
	if(n%d!=0){
		x=x+1;
	}
	
	cout<<x<<endl;
	
	return 0;
}


Measured memory_bytes: 256