akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;
deque<int> Q;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T;
	
	if(S==T) return _P("0\n");
	
	int R=N-1;
	int ma=0;
	int dif=0;
	for(i=N-1;i>=0;i--) {
		if(i==0 || T[i]!=T[i-1]) {
			R=min(i,R);
			while(R>=0 && T[i]!=S[R]) R--;
			if(R<0) return _P("-1\n");
			
			if(i==R) {
				Q.clear();
			}
			else {
				if(Q.empty()) dif=0;
				else dif++;
				Q.push_back(R+dif);
			}
			
			R--;
		}
		
		ma=max(ma,(int)Q.size()+1);
		if(Q.size() && Q.front()-dif>=i) Q.pop_front();
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 6300
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;

const int N=200005;
const int inf=1000000000;

int n,a[N],rmq[2][N][20],bin[20],lg[N];
struct data
{
	int l,r,x,y;
	
	bool operator < (const data &p) const
	{
		return a[x]>a[p.x];
	}
};
priority_queue<data> que;

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void prepare()
{
	for (int i=1;i<=n;i+=2) rmq[1][i][0]=i;
	for (int i=2;i<=n;i+=2) rmq[0][i][0]=i;
	bin[0]=1;
	for (int i=1;i<=17;i++) bin[i]=bin[i-1]*2;
	for (int i=1;i<=n;i++) lg[i]=log(i)/log(2);
	for (int j=1;j<=lg[n];j++)
		for (int i=1;i+bin[j]-1<=n;i++)
			rmq[0][i][j]=a[rmq[0][i][j-1]]<a[rmq[0][i+bin[j-1]][j-1]]?rmq[0][i][j-1]:rmq[0][i+bin[j-1]][j-1],
			rmq[1][i][j]=a[rmq[1][i][j-1]]<a[rmq[1][i+bin[j-1]][j-1]]?rmq[1][i][j-1]:rmq[1][i+bin[j-1]][j-1];
}

int get_mn(int ty,int l,int r)
{
	int w=lg[r-l+1];
	return a[rmq[ty][l][w]]<a[rmq[ty][r-bin[w]+1][w]]?rmq[ty][l][w]:rmq[ty][r-bin[w]+1][w];
}

data get(int l,int r)
{
	int p=get_mn(l&1,l,r-1),q=get_mn((p&1)^1,p+1,r);
	return (data){l,r,p,q};
}

int main()
{
	n=read();a[0]=inf;
	for (int i=1;i<=n;i++) a[i]=read();
	prepare();
	que.push(get(1,n));
	for (int i=1;i<=n/2;i++)
	{
		data u=que.top();que.pop();
		int l=u.l,r=u.r,x=u.x,y=u.y;
		printf("%d %d ",a[x],a[y]);
		if (l<x-1) que.push(get(l,x-1));
		if (x+1<y-1) que.push(get(x+1,y-1));
		if (y+1<r) que.push(get(y+1,r));
	}
	return 0;
}

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> L = {2,1};
  for(int64_t i = 2; i <= N; i++){
    int64_t tmp = L.at(i-1)+L.at(i-2);
    L.push_back(tmp);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    int K;
    cin>>K;
    vector<LL>A(K);
    REP(i,K)cin>>A[i];
    if(A.back()!=2){
        cout<<"-1"<<endl;return 0;
    }
    reverse(A.begin(),A.end());
    PLL pi=MP(2LL,3LL);
    REP(i,K-1){
        LL tmp=A[i+1];
        //cout<<pi.first<<" "<<pi.second<<" "<<tmp<<endl;
        if(tmp>pi.second||tmp==0){
            cout<<"-1"<<endl;return 0;
        }
        LL lt=pi.first/tmp;
        LL xmin=-1,xmax=-1;
        if(pi.first%tmp==0){
            xmin=tmp*lt;
        }else if(tmp*(lt+1LL)<=pi.second){
            xmin=tmp*(lt+1LL);
        }
        lt=pi.second/tmp;
        xmax=lt*tmp+(tmp-1);
        //cout<<xmin<<" "<<xmax<<"!"<<endl;
        if(xmin<=0||xmax<=0){
            cout<<"-1"<<endl;return 0;
        }
        pi=MP(xmin,xmax);
    }
    cout<<pi.first<<" "<<pi.second<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct Team {
  string name;
  int pt, id;
  bool operator<(const Team& a) const {
    if (pt != a.pt) return pt > a.pt;
    return id < a.id;
  }
};

int n;
Team teams[12];

int main() {
  bool flag = false;
  while (cin >> n, n) {
    if (flag) {
      cout << endl;
    }
    int win, lose, draw;
    rep (i,n) {
      cin >> teams[i].name >> win >> lose >> draw;
      teams[i].id = i;
      teams[i].pt = win * 3 + draw;
    } 
    sort(teams, teams + n);
    rep (i,n) {
      cout << teams[i].name << "," << teams[i].pt << endl;
    }
    flag = true;
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[][] count = Enumerable.Repeat(0, 10).Select(_ => new int[10]).ToArray();
        for (int i = 1; i <= n; i++)
        {
            var a = i.ToString();
            count[a.First() - '0'][a.Last() - '0']++;
        }
        long res = 0;
        for (int i = 1; i <= n; i++)
        {
            var b = i.ToString();
            res += count[b.Last() - '0'][b.First() - '0'];
        }
        Console.WriteLine(res);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


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

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

  if (a == b && b == c && c == a)
    cout << 1 << endl;
  else if (a != b && b != c && c != a) 
    cout << 3 << endl;
  else 
    cout << 2 << endl;
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]

if m > 1 and n < 2:
    print(int(m * (m - 1) / 2))
elif m < 2 and n > 1:
    print(int(n * (n - 1) / 2))
elif m > 1 and n > 1:
    print(int(n * (n - 1) / 2 + (m * (m - 1) / 2)))
else:
    print(int(0))

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

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int solve(int N) {
    vector<double> a(N);
    REP(i, N) { cin >> a[i]; }
    double ave = accumulate(ALL(a), 0) / (double)N;
    int ans = 0;
    REP(i, N) {
        if (a[i] <= ave) {
            ans += 1;
        }
    }
    return ans;
}

int main() {
    int N;
    while (cin >> N && N) {
        cout << solve(N) << endl;
    }
}


Measured memory_bytes: 3268
/*
  Contest 077
  A - Rotation
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    std::string a, b;
    std::getline(std::cin, a);
    std::getline(std::cin, b);
    std::string r = "YES";
    for (int i = 0; i < 3; ++i) {
        if (a[i] != b[2 - i]) {
            r = "NO";
            break;
        }
    }
    std::cout << r << std::endl;

    return 0;
}


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

int main(){
    long int N;
    cin >> N;
    long int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    long int S[N+1];
    long int nextsame[N+1];
    for(int i= 0; i<N+1;i++){
        nextsame[i]=0;
     }
    long int count = 0;
    long int sum;
    S[0]=0;
    for(int i=0;i<N;i++){
        S[i+1] = S[i] +A[i];
    }
    sort(S,S+N+1);
//    for(int i= 0;i<N+1;i++){
//        cout << S[i]<<endl;
//    }
    for(int i=0;i<N;i++){
        if(S[i]==S[i+1]) {
            nextsame[i+1]=nextsame[i]+1;
            count += nextsame[i+1];
        }else{
            nextsame[i+1]=0;
        }
//        cout << "count"<<count<<"nextsame"<<nextsame[i]<<"\n";
    }
    cout << count << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    lint ret = inf;
    for (int i = 1; i <= 100; ++i) {
        lint temp = 0;
        for (int j = 0; j < n; ++j) {
            temp += (i - x[j]) * (i - x[j]);
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define mp std::make_pair
#define pb push_back
using ll = long long;
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }

ll arr[200005], pre[200005], suf[200005], rem[200005];
void solve(int n, ll *ans)
{
	std::set<int> se = {n - 1};
	for (int i = 0; i < n; i++)
		rem[i] = 0;
	for (int i = n - 2; i >= 0; i--)
	{
		ans[i] = ans[i + 1];
		if (arr[i + 1] >= arr[i])
		{
			int x = 0;
			while (arr[i] << (x << 1) <= arr[i + 1])
				x++;
			rem[i] = x - 1;
			if (rem[i])
				se.insert(i);
			continue;
		}
		ll cur = arr[i + 1];
		while (cur < arr[i])
		{
			int x = *se.begin();
			if (!--rem[x])
				se.erase(x);
			ans[i] += x - i << 1;
			cur <<= 2;
		}
	}
}
int main()
{
	// freopen("caddi2018-E.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", arr + i);
	solve(n, suf);
	std::reverse(arr, arr + n);
	for (int i = 0; i < n; i++)
		arr[i] <<= 1;
	solve(n, pre);
	ll ans = 1e18;
	for (int i = 0; i <= n; i++)
		ans = std::min(ans, pre[n - i] + i + suf[i]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6528
// Being an artist , being me. Thats best excuse of me for being Crazy.
// 1 cheez uthao and finish that... 
// dp first... aaw se 
// World only gives a damn about your results not your fucking efforts.. 
// f 
#include<bits/stdc++.h>
using namespace std; 
int feel(string s, string t, int m, int n) {
	if(m == 0 or n == 0 ) return 0;
	if(s[m - 1] == t[n -1] ) 
		return 1 + feel(s, t, m - 1, n - 1);
	else 
		return max( feel(s, t, m, n - 1), feel(s, t, m - 1, n) );
}
int main() {
	string s, t;
	int ss, ts ;
	cin >> s >> t;
	ss = s.size();
	ts = t.size();

	int dp[ss + 1][ts + 1];
	memset(dp, 0, sizeof(dp));
	// cout << feel(s, t, ss, ts);

	for(int i = 1; i <= ss; ++i ) {
		for(int j = 1; j <= ts; ++j ) {
			if( s[i - 1] == t[j - 1] ) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			} else {
				dp[i][j] = max( dp[i - 1][j], dp[i][j - 1]);
			}
			// cout << dp[i][j] << " "; 
		} //cout << endl;
	}
	// for(int i = 0; i <= ss; ++i ) {
	// 	for(int j = 0; j <= ts; ++j ) {
	// 		cout << dp[i][j] << " ";
	// 	} cout << endl; 
	// }
	string ans = "";
	// for(int i = ss; i > 0; --i ) {
	// 	for(int j = ts; j > 0; --j ) {
	// 		if( dp[i][j] == dp[i - 1][j -1 ] + 1) {
	// 			// cout << s[i - 1] << ' ';
	// 			ans = s[i - 1] + ans ;
	// 			--i;
	// 			--j;
	// 		} else if( dp[i - 1][j] == max(dp[i - 1][j], dp[i][j - 1]) ) {
	// 			--i;
	// 		} else {
	// 			--j;
	// 		}

	// 	}
	// }
	int i = ss, j = ts;
	while( i > 0 and j > 0 ) {
		if( s[i - 1] == t[j - 1] ) {
			ans = s[i - 1] + ans;
			i-- , j-- ;
		} else if ( dp[i][j - 1] > dp[i - 1][j] ) {
			--j;
		} else --i;
	} 
	cout << ans; 

}

Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}
int main(){
    int n,m;cin>>n>>m;
    cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    cout << (1000-n%1000)%1000 << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
int n, N[20];
int solve(int i, int m){
  int res;
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i+1,m) || solve(i+1, m-N[i]);
  return res;
}

int main(){
  int i, q, Q[200], check=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&N[i]);
    scanf("%d",&q);
  for(i = 0; i < q; i++)
    scanf("%d",&Q[i]);
 
  for(i = 0; i < q; i++){
    check = solve(0,Q[i]);
    if(check == 1) printf("yes\n");
    else if(check == 0) printf("no\n");
  }
  return 0;
}

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

using namespace std;

const int64_t INF = 1LL << 60;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int64_t T;
  cin >> N >> T;
  vector<int64_t> A, B, C;
  for (int i = 0; i < N; i++) {
    int64_t a, b;
    cin >> a >> b;
    if (a == 0) {
      C.emplace_back(b + 1);
    } else {
      A.emplace_back(a);
      B.emplace_back(b);
    }
  }
  vector<int> idx(A.size());
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(),
       [&](int a, int b) { return A[b] * (B[a] + 1) < A[a] * (B[b] + 1); });
  vector<int64_t> NA, NB;
  for (int i : idx) {
    NA.emplace_back(A[i]), NB.emplace_back(B[i]);
  }
  A = NA, B = NB;
  sort(C.begin(), C.end());
  for (int i = 0; i < (int)C.size() - 1; i++) {
    C[i + 1] += C[i];
  }
  vector<int64_t> dp(31, T + 1);
  dp[0] = 0;
  for (int i = 0; i < (int)A.size(); i++) {
    for (int j = (int)dp.size() - 2; j > -1; j--) {
      if (dp[j] > T) continue;
      chmin(dp[j + 1], (A[i] + 1) * (dp[j] + 1) + B[i]);
    }
  }
  int res = 0;
  for (int i = 0; i < (int)dp.size(); i++) {
    if (dp[i] > T) continue;
    int p = 0;
    if (!C.empty()) p = upper_bound(C.begin(), C.end(), T - dp[i]) - C.begin();
    res = max(res, i + p);
  }
  cout << res << '\n';
  return 0;
}


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

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

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

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

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

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 998244353LL
#define EPS 1e-8

int n;
vector<int> accb;
vector<int> accr;
VV(LL) memo;

LL dfs(int i, int b){
	LL &r = memo[i][b];
	if(r >= 0){ return r; }
	r = 0;
	if(i == 2 * n){
		r = 1;
	}
	else{
		if(b < accb[i]){
			r += dfs(i + 1, b + 1);
		}
		if(i - b < accr[i]){
			r += dfs(i + 1, b);
		}
		if(r >= MOD){ r -= MOD; }
	}
	return r;
}

void mainmain(){
	string s;
	cin >> s;
	n = s.size();
	int b = 0, r = 0;
	for(int i = 0; i < 2 * n; ++i){
		if(i < n){
			b += s[i] - '0';
			r += '2' - s[i];
		}
		accb.push_back(b);
		accr.push_back(r);
	}
	
	initvv(memo, 2 * n + 1, 2 * n + 1, -1LL);
	
	LL ans = dfs(0, 0);
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 127488
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 2000005;
const int N = 2e6;
const int mod = 1e9+7;

int fac[maxn],inc[maxn],ans;
LL fpm(LL p,LL k) {
	LL res=1ll;
	while (k) {
		if (k&1) (res*=p)%=mod;
		(p*=p)%=mod;k>>=1;
	}
	return res;
}
LL comb(int n,int m) {
	return (LL)fac[n]*inc[m]%mod*(LL)inc[n-m]%mod;
}
LL f(int x1,int y1,int x2,int y2) {
	return (comb(x2+y2+2,y2+1)+comb(x1+y1,y1)-comb(x1+y2+1,y2+1)-comb(x2+y1+1,y1))%mod;
}

int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6;

int main()
{
	#ifdef Amberframe
		freopen("agc018e.in","r",stdin);
		freopen("agc018e.out","w",stdout);
	#endif
	scanf("%d %d %d %d %d %d",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%d %d %d %d %d %d",&y1,&y2,&y3,&y4,&y5,&y6);
	fac[0]=inc[0]=1;
	for (int i=1;i<=N;i++) fac[i]=(LL)fac[i-1]*i%mod;
	inc[N]=fpm(fac[N],mod-2);
	for (int i=N;i>=2;i--) inc[i-1]=(LL)inc[i]*i%mod;
	
	for (int i=y3;i<=y4;i++)
		ans=(ans-f(x3-1-x2,i-y2,x3-1-x1,i-y1)*f(x5-x3,y5-i,x6-x3,y6-i)%mod*(LL)(x3+i))%mod;
	for (int i=x3;i<=x4;i++)
		ans=(ans-f(i-x2,y3-1-y2,i-x1,y3-1-y1)*f(x5-i,y5-y3,x6-i,y6-y3)%mod*(LL)(i+y3))%mod;
	for (int i=y3;i<=y4;i++)
		ans=(ans+f(x4-x2,i-y2,x4-x1,i-y1)*f(x5-x4-1,y5-i,x6-x4-1,y6-i)%mod*(LL)(x4+i+1))%mod;
	for (int i=x3;i<=x4;i++)
		ans=(ans+f(i-x2,y4-y2,i-x1,y4-y1)*f(x5-i,y5-y4-1,x6-i,y6-y4-1)%mod*(LL)(i+y4+1))%mod;
	printf("%d",ans<0?ans+mod:ans);
	return 0;
}

Measured memory_bytes: 15872
<?php
 fscanf(STDIN,"%d %d %d",$a,$b,$c);
 $weight = $a*$c -$b;
 echo $weight."\n";
 $preweight = $weight;
 for($i=0;$i<9;$i++){
   $weight =( ($preweight*$a) - $b);
   echo $weight."\n";
   $preweight = $weight;
 }
?>

Measured memory_bytes: 3700
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** マップのキーの一覧 */
	private static final List<String> KEYS = Arrays.asList("AC", "WA", "TLE", "RE");

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<String, Integer> map = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				String s = scanner.next();
				map.put(s, map.getOrDefault(s, 0) + 1);
			});
			KEYS.stream().forEach(key -> System.out.println(key + " x " + map.getOrDefault(key, 0)));
		}
	}
}


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

int main(){
  int a,b,c,d,e;
  cin>>a>>b;
  c=b;
  while(c>0){
    c/=10;
    a*=10;
  }
  d=a+b;
  e=sqrt(d);
  if(d%e==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

int64_t mod(int64_t a, int64_t b) {
  if (a >= 0) {
    return a % b;
  } else {
    int64_t bb = ((-a) % b);
    if (bb == 0) {
      return 0;
    } else {
      return b - bb;
    }
  }
}
int main() {
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<int64_t> A(N);

  int64_t DIV = 1000000007LL;

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

  vector<int64_t> PLUSS;
  vector<int64_t> MINUSS;
  vector<int64_t> ZEROS;
  for (auto a : A) {
    if (a > 0) {
      PLUSS.push_back(a);
    } else if (a < 0) {
      MINUSS.push_back(a);
    } else {
      ZEROS.push_back(a);
    }
  }

  // ゼロ以下
  if (PLUSS.size() + MINUSS.size() < K) {
    cout << "0" << endl;
    return 0;
  } else if (PLUSS.size() == 0 && K % 2 == 1) {
    if (ZEROS.size() > 0) {
      cout << "0" << endl;
      return 0;
    } else {
      sort(MINUSS.begin(), MINUSS.end(),
           [](int64_t a, int64_t b) { return a > b; });
      int64_t cumul = 1;
      int j = 0;
      while (j < K) {
        if (j + 2 <= K) {
          cumul = mod(cumul * mod(MINUSS[j] * MINUSS[j + 1], DIV), DIV);
          j += 2;
        } else {
          cumul = mod(cumul * MINUSS[j], DIV);
          j++;
        }
      }
      cout << cumul << endl;
      return 0;
    }
  } else if (MINUSS.size() + PLUSS.size() == K && MINUSS.size() % 2 == 1) {
    if (ZEROS.size() > 0) {
      cout << "0" << endl;
      return 0;
    } else {
      int64_t cumul = 1;
      for (auto p : PLUSS) {
        cumul = mod(cumul * p, DIV);
      }
      int j = 0;
      while (j < MINUSS.size()) {
        if (j + 2 <= MINUSS.size()) {
          cumul = mod(cumul * mod(MINUSS[j] * MINUSS[j + 1], DIV), DIV);
          j += 2;
        } else {
          cumul = mod(cumul * MINUSS[j], DIV);
          j++;
        }
      }
      cout << cumul << endl;
      return 0;
    }
  }

  sort(PLUSS.begin(), PLUSS.end(), [](int64_t a, int64_t b) { return a > b; });
  sort(MINUSS.begin(), MINUSS.end());

  int64_t cumul = 1;
  int plus_idx = 0;
  int minus_idx = 0;
  int cnt = 0;
  while (true) {
    if (cnt == K) {
      break;
    } else if (cnt + 1 == K) {
      cumul = mod(cumul * PLUSS[plus_idx], DIV);
      plus_idx++;
      cnt++;
    } else if (minus_idx + 1 >= MINUSS.size()) {
      cumul = mod(cumul * PLUSS[plus_idx], DIV);
      plus_idx++;
      cnt++;
    } else if (plus_idx + 1 >= PLUSS.size()) {
      cumul =
          mod(cumul * mod(MINUSS[minus_idx] * MINUSS[minus_idx + 1], DIV), DIV);
      minus_idx += 2;
      cnt += 2;
    } else if ((plus_idx + 2 <= PLUSS.size()) &&
               (minus_idx + 2 <= MINUSS.size())) {
      int64_t plus_pair = PLUSS[plus_idx] * PLUSS[plus_idx + 1];
      int64_t minus_pair = MINUSS[minus_idx] * MINUSS[minus_idx + 1];
      if (plus_pair >= minus_pair) {
        cumul = mod(cumul * PLUSS[plus_idx], DIV);
        plus_idx += 1;
        cnt++;
      } else {
        cumul = mod(cumul * mod(minus_pair, DIV), DIV);
        minus_idx += 2;
        cnt += 2;
      }
    } else {
      cnt++;
    }
  }

  cout << cumul << endl;
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
map<char,string> m;
unsigned int binToUInt(const std::string &str)
{
  unsigned int val = 0;
  for(int i = 0; i < (int)str.size(); ++i) {
    switch (str[i]) {
      case '0':
        val *= 2;
        break;
      case '1':
        val = val * 2 + 1;
        break;
    }
  }
  return val;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  m[' '] = "101";
  m['\''] = "000000";
  m[','] = "000011";
  m['-'] = "10010001";
  m['.'] = "010001";
  m['?'] = "000001";
  m['A'] = "100101";
  m['B'] = "10011010";
  m['C'] = "0101";
  m['D'] = "0001";
  m['E'] = "110";
  m['F'] = "01001";
  m['G'] = "10011011";
  m['H'] = "010000";
  m['I'] = "0111";
  m['J'] = "10011000";
  m['K'] ="0110";
  m['L'] = "00100";
  m['M'] = "10011001";
  m['N'] = "10011110";
  m['O'] = "00101";
  m['P'] = "111";
  m['Q'] = "10011111";
  m['R'] = "1000";
  m['S'] = "00110";
  m['T'] = "00111";
  m['U'] = "10011100";
  m['V'] = "10011101";
  m['W'] = "000010";
  m['X'] = "10010010";
  m['Y'] = "10010011";
  m['Z'] = "10010000";
  while(1){
    string s,encode = "",encode2="";
    vector<string> decode;
    getline(cin,s);
    if(cin.eof())break;
    rep(i,s.size()){
      encode += m[s[i]];
    }
    while(encode.size()%5){
      encode += "0";
    }
    rep(i,encode.size()){
      encode2 += encode[i];
      if((i+1)%5==0){
        decode.pb(encode2);
        encode2.clear();
      }
    }
    string decode2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
    rep(i,decode.size()){
      int k = binToUInt(decode[i]);
      decode[i] = decode2[k];
    }
    rep(i,decode.size()){
      cout << decode[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int h, w;
char a[1010][1010];
int steps[1010][1010];

struct Point
{
	int r, c;
	int dist;
};

int dr[] = {-1, 0, 1, 0};
int dc[] = { 0,-1, 0, 1};

std::queue<Point> q;

void doSearch()
{
	Point curPoint, newPoint;
	
	while (q.empty() == false)
	{
		curPoint = q.front();
		q.pop();
		
		for (int d = 0 ; d < 4 ; d++)
		{
			newPoint.r = curPoint.r + dr[d];
			newPoint.c = curPoint.c + dc[d];
			
			if (steps[newPoint.r][newPoint.c] == 0)
				continue;
			
//			if ((1 <= newPoint.r && newPoint.r <= h) 
//				&& (1 <= newPoint.c && newPoint.c <= w) )
//			{
//				int dist = ;

				if (steps[newPoint.r][newPoint.c] == -1)
				{
					newPoint.dist = curPoint.dist + 1;
					steps[newPoint.r][newPoint.c] = newPoint.dist;
					q.push(newPoint);
				}
//			}
		}
	}
}



int main()
{
	FILE *fin = stdin;//fopen("a2.txt", "r");
	fscanf(fin, "%d%d\n", &h, &w);
	for (int r = 1 ; r <= h ; r++)
	{
		fscanf(fin, "%s\n", &(a[r]));
		for (int c = w ; c >= 1 ; c--)
		{
			a[r][c] = a[r][c - 1];
			if (a[r][c] == '#') {
				steps[r][c] = 0;
			} else if (a[r][c] == '.') {
				steps[r][c] = -1;
			}
		}
		a[r][0] = ' ';
	}
	
	for (int r = 1 ; r <= h ; r++)
		for (int c = 1 ; c <= w ; c++)
		{
			if (steps[r][c] == 0)
			{
				Point curPoint;
				curPoint.r = r;
				curPoint.c = c;
				curPoint.dist = 0;
				q.push(curPoint);
			}
		}
		

	doSearch();
		

	int maxDist = -1;
	for (int r = 1 ; r <= h ; r++)
	{
		for (int c = 1 ; c <= w ; c++)
		{
//			printf("%d ", steps[r][c]);
			if (maxDist < steps[r][c])
				maxDist = steps[r][c];
		}
		
//		printf("\n");
	}		
	printf("%d\n", maxDist);
		

	return 0;
}



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

bool isPair(int i, int a, int b){
  int ansa = 0;
  int ansb = 0;
  for(int j = 0;j < a+b;j++){
    if(i & 1){
      ansa++;
    }else{
      ansb++;
    }
    i >>= 1;
  }

  return a == ansa && b == ansb;
}

string makeBit(int i, int hoge){
  stack<char> st;
  char tmp;
  for(int j = 0;j < hoge;j++){
    if(i & 1){
      tmp = 'A';
    }else{
      tmp = 'B';
    }
    st.push(tmp);
    i >>= 1;
  }

  string ans = "";
  while(!st.empty()){
    ans += st.top();
    st.pop();
  }

  return ans;
}


bool check(string s){
  int a_cnt = 0;
  int b_cnt = 0;
  for(int i = 0;i < s.size()-1;i++){
    if(s[i] == 'A'){
      a_cnt++;
    }else{
      b_cnt++;
    }

    if(max(a_cnt,b_cnt) >= 5 && min(a_cnt,b_cnt) <= 3){
      return false;
    }
  }
  return true;
}

int main(){
  int l,r;
  vector<string> v;
  cin >> l >> r;
  int tmp = 1 << (l+r);

  for(int i = 0;i < tmp;i++){
    if(isPair(i,l,r)){
      v.push_back(makeBit(i,l+r));

    }
  }

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

  for(int i = 0;i < v.size();i++){
    if(check(v[i])){
      cout << v[i] << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 3248
n, x, y = map(int, input().split())
distance = [0] * n
for i in range(1, n):
    for j in range(i+1, n+1):
        distance[min([abs(j-i), abs(x-i)+abs(y-j)+1])] += 1

print('\n'.join(map(str, distance[1:])))

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,l,n) for(int i=l;i<n;i++)

int main(){
	char s[5];
	scanf("%s",s);
	if( strcmp(s,"AAA")==0 ){
		printf("No");
	}else if( strcmp(s,"BBB")==0 ){
		printf("No");
	}else printf("Yes");
	return 0;
}


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

using namespace std;

int main()
{
    string S;
    cin >> S;

    for(int i = 0; i + 1 < S.size(); i++)
    {
        if(S[i] == S[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }

        if(i + 2 < S.size() && S[i] == S[i + 2])
        {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }

    cout << "-1 -1";
    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	public static void main(String arg[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int S[] = new int[n+1];
		int key = 0;
		int ans = 0;

		for(int i=0; i<n; i++){
			S[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int T[] = new int[q];
		for(int i=0; i<q; i++){
			T[i] = sc.nextInt();
		}
		for(int i=0; i<q; i++){
			key = T[i];
			if(binarySearch(S, key, n) == 1){
				ans++;
			}
		}
		System.out.println(ans);
	}
	
	public static int binarySearch(int A[], int key, int n){
		int mid = 0;
		int left = 0;
		int right = n;
		while (left < right){
			mid = (left + right) / 2;
			if(A[mid]==key){
				return 1;
			} else if(key < A[mid]){
				right = mid;
			} else {
				left = mid + 1;
			}
		}
		return -1;
	}

}



Measured memory_bytes: 68004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)1e9+7
#define eb emplace_back

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, Y; cin >> N >> Y;
    rep(y, N + 1) rep(z, (N - y) + 1) { //対称性から
        if (y + z > N) continue;
        int x = N - y - z;
        if (x < 0 || x > N) continue;
        if (-5000 * y - 9000 * z == Y - 10000 * N) {
            cout << x << " " << y << " " << z << endl;
            return 0;
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int main()
{
  long long sum,temp;
  
  int n,m;
  cin>>n>>m;
  priority_queue<long long> q;
  for(int i=0;i<n;i++)
  {
    cin>>temp;
   	q.push(temp);
  }
 
  for(int i=0;i<m;i++)
  {
    long long x = q.top();
    q.pop();
    x/=2;
    q.push(x);
  }
  while(!q.empty())
  {
    sum+=q.top();
    q.pop();
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 1400
if __name__ == "__main__":
	N = int(input())
	S = list(str(input()))
	# print(S)

	al = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
	for i in range(0,len(S)):
		if al.index(S[i]) + N > 25:
			# print(al.index(S[i]))
			index = al.index(S[i])
			S[i] = al[index + N - 26]
		else:
			index = al.index(S[i])
			S[i] = al[index+N]
	print(''.join(map(str, S)))

Measured memory_bytes: 3188
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    int v[] = new int[n];
    int c[] = new int[n];

    for (int i = 0; i < n; i++) {
      v[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (v[i] > c[i]) {
        sum += v[i] - c[i];
      }
    }
    os.println(sum);
  }
}

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

const int mod = 1000000007;

int main(){
    int n;
    int k;
    cin>>n>>k;
    k--;
    vector<double>p(n);
    vector<double>rui(n+1);
    rui[0]=0;
    rep(i,n){
        cin>>p[i];
        rui[i+1]=rui[i]+(p[i]*(p[i]+1))/(2*p[i]);
        //cout<<rui[i+1]<<endl;
    }
    double sum=0.0;

    sum=rui[k+1]-rui[0];
    //rep(i,n+1)cout<<rui[i]<<endl;
    rep(i,n-k+1){
        if(sum<rui[i+k+1]-rui[i]){
            //cout<<sum<<endl;
            sum=rui[i+k+1]-rui[i];
        }
    }
    
    cout<<setprecision(11)<<sum<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define lg long long
bool J(lg a,lg b,lg c,lg d){
	if(b>d)return 0;
	if(a<b)return 0;
	if(c>=b)return 1;
	lg e=d%b;
	//cout<<"@@@"<<endl;
	if(a%b>c)return 0;
	if(e==0)return 1;
	lg f=a%b;
	//cout<<e<<' '<<b<<' '<<c<<endl;
	lg g=__gcd(e,b);return c>=b-g?1:0;
}
int main(){
	int T;
	cin>>T;
	while(T--){
		//cout<<"T"<<T<<endl;
		lg a,b,c,d;
		cin>>a>>b>>c>>d;
		puts(J(a,b,c,d)?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[200005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);

	int pos=n-1;
	int ct=0;
	ll ans=0;
	for(int i=n-2;i>=0;i--){
		ans+=a[pos];
		ct++;
		if(pos==n-1){
			pos--;
			ct=0;
		}else if(ct==2){
			pos--;
			ct=0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.ArrayList;
public class Main {

    public static void main(String[] args) {
        FastReader f = new FastReader();
        
     long n = f.nextLong();
     long q=(long)Math.sqrt(n);
     ArrayList<Long> a1 = new ArrayList<Long>();

     for(long i = 1 ;i <= q ; i++){
         if(n%i==0){
         a1.add(i);
        // long x =(long)(n/i);
         a1.add((long)(n/i));
         
         }
     }
     
        long [] arr = new long[a1.size()];
        for(int i= 0;i<arr.length;i++){
            arr[i]=a1.get(i);
        }
     Arrays.sort(arr);
     int mid=(int)arr.length/2;     
     
       System.out.println((arr[mid] + arr[mid-1])-2);
        
        
     
     
    }   
 }




class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        byte nextByte() 
        { 
            return Byte.parseByte(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    
}


Measured memory_bytes: 23636
#![allow(unused)]

use std::{cell, cmp, collections, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();
    let a = parse_vec::<i64>();

    let (mut left, mut right): (i64, i64) = (
        *a.iter().min().unwrap() - n as i64,
        *a.iter().max().unwrap() + n as i64,
    );

    loop {
        let l = (left * 2 + right) / 3;
        let r = (left + right * 2) / 3;

        if sadness(&a, l) < sadness(&a, r) {
            if right == r {
                break;
            }

            right = r;
        } else {
            if left == l {
                break;
            }

            left = l;
        }
    }

    let ans = vmin!(
        sadness(&a, left),
        sadness(&a, (left + right) / 2),
        sadness(&a, right)
    );

    println!("{}", ans);
}

fn sadness(a: &[i64], b: i64) -> i64 {
    a.iter()
        .enumerate()
        .map(|(i, a)| (a - (b + (i + 1) as i64)).abs())
        .sum()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}


Measured memory_bytes: 8444
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define N 1000001
using namespace std;

int main(){
    FAST;
    string s;cin>>s;
    int n=s.size()-1;
    if(s[n]=='s'){s.append("es");}
    else{s.pb('s');}
    cout<<s<<endl;
}


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

int main() {
    int N, M;
    cin>>N>>M;
    int sum = 0;
    vector<int> A(N);
    REP(i, 0, N){
        cin >> A[i];
        sum += A[i];
    }
    sort(A.rbegin(), A.rend());
    if(A[M-1] * M * 4 >= sum) cout << "Yes"<< endl;
    else cout << "No"<< endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

/**
 * TogglingCases
 */
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            String str = sc.nextLine();
            char list[] = str.toCharArray();
            for (char ch : list) {
                if (ch >= 'a' && ch <= 'z') {
                    String newstr = new String(Character.toChars(ch + 'A' - 'a'));
                    System.out.print(newstr);
                } else if (ch >= 'A' && ch <= 'Z') {
                    String newstr = new String(Character.toChars(ch + 'a' - 'A'));
                    System.out.print(newstr);
                } else {
                    System.out.print(ch);
                }
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 27012
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int N, K;
    cin >> N >> K;
    vector<tuple<ll, ll, bool>> sushi(N);
    for(int i = 0; i < N; i++){
        ll t, d;
        cin >> t >> d;
        get<0>(sushi[i]) = d;
        get<1>(sushi[i]) = t;
        get<2>(sushi[i]) = 0;
    }
    sort(sushi.begin(), sushi.end());
    reverse(sushi.begin(), sushi.end());
    
    ll OisisaKisoPoint = 0;
    set<int> Kind;
    for(int i = 0; i < K; i++){
        OisisaKisoPoint += get<0>(sushi[i]);
        if(Kind.count(get<1>(sushi[i])) == 0){
            get<2>(sushi[i]) = 1;
        }
        Kind.insert(get<1>(sushi[i]));
    }
    ll u = Kind.size();
    vector<ll> OtherMax;
    for(int i = K; i < N; i++){
        if(Kind.count(get<1>(sushi[i])) == 0){
            get<2>(sushi[i]) = 1;
            OtherMax.push_back(get<0>(sushi[i]));
        }
        Kind.insert(get<1>(sushi[i]));
    }
    
    ll ans = u * u + OisisaKisoPoint;
    int cnt = 0;
    for(int t = K - 1; t >= 0; t--){
        if(OtherMax.size() == cnt) break;
        if(get<2>(sushi[t]) == 1) continue;
        OisisaKisoPoint += OtherMax[cnt];
        OisisaKisoPoint -= get<0>(sushi[t]);
        u++;
        ans = max(ans, u * u + OisisaKisoPoint);
        cnt++;
    }
    cout << ans << endl;
}


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


int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    rep(i, n){
        cin >> blue.at(i);
    }
    int m;
    cin >> m;
    vector<string> red(m);
    rep(i, m){
        cin >> red.at(i);
    }
    int ans = 0;
    auto calc = [&](string s){
        int buf = 0;
        for (string t: blue){
            if (t == s) buf++;
        }
        for (string t: red){
            if (t == s) buf--;
        }
        return buf;
    };

    for (string t: blue){
        ans = max(ans, calc(t));
    }

    cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 1000000007;
// const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
// const ll LLINF = 1LL << 50;
const double PI = acos(-1);
const double EPS = 0.000000001;


int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

const int MAX_n = 100;
int n,t[MAX_n];

signed main(){

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

    int ans = 1;
    for(int i = 0;i < n;i++){
        if(ans>=t[i]){
            t[i]/=gcd(ans, t[i]);
            ans*=t[i];
        }else{
            t[i]/=gcd(t[i], ans);
            ans*=t[i];
        }
    }
    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
s = input()

d = defaultdict(int)

s1 = s[:n]
s2 = s[n:][::-1]

for i in range(2**n):
    left,right = [],[]
    for j in range(n):
        if(i >> j)&1:
            left.append(s1[j])
        else:
            right.append(s1[j])
    d[ ''.join(left) + '_' + ''.join(right) ] += 1

ans = 0
for i in range(2**n):
    left,right = [],[]
    for j in range(n):
        if(i >> j)&1:
            left.append(s2[j])
        else:
            right.append(s2[j])
    ans += d[ ''.join(left) + '_' + ''.join(right) ]

print(ans)


Measured memory_bytes: 233436
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int sum=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(k-x<=x) sum+=(k-x)*2;
    else sum+=x*2;
  }
  cout<<sum<<endl;
}

    

Measured memory_bytes: 256