akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	map<double, int> n_t;
	int race = 3;
	int num;
	double t;
	vector<double> rank, all;
	while( race-- > 0 ){
		for( int i = 0; i < 8; i++ ){
			cin >> num >> t;
			n_t[t] = num;
			rank.push_back(t);
		}
		sort(rank.begin(), rank.end());
		vector<double>::iterator it = rank.begin();
		cout << n_t[*it] << ' ' << *it << endl;
		//rank.erace(it);
		it++;
		cout << n_t[*it] << ' ' << *it << endl;
		it++;
		for( ; it != rank.end(); it++ ){
			all.push_back(*it);
		}
		rank.clear();
	}
	sort(all.begin(), all.end());
	vector<double>::iterator it = all.begin();
	cout << n_t[*it] << ' ' << *it << endl;
	it++;
	cout << n_t[*it] << ' ' << *it << endl;

	return 0;
}

Measured memory_bytes: 1316
class Tree():
    def __init__(self, n, decrement=1):
        self.n = n
        self.edges = [[] for _ in range(n)]
        self.root = None
        self.size = [1]*n       # number of nodes in subtree
        self.decrement = decrement

    def add_edge(self, u, v):
        u, v = u-self.decrement, v-self.decrement
        self.edges[u].append(v)
        self.edges[v].append(u)

    def add_edges(self, edges):
        for u, v in edges:
            u, v = u-self.decrement, v-self.decrement
            self.edges[u].append(v)
            self.edges[v].append(u)

    def set_root(self, root):
        root -= self.decrement
        self.depth = [-1]*self.n
        self.root = root
        self.par = [-1]*self.n
        self.depth[root] = 0
        self.order = [root]
        next_set = [root]
        while next_set:
            p = next_set.pop()
            for q in self.edges[p]:
                if self.depth[q] != -1: continue
                self.par[q] = p
                self.depth[q] = self.depth[p]+1
                self.order.append(q)
                next_set.append(q)
        for p in self.order[::-1]:
            for q in self.edges[p]:
                if self.par[p] == q: continue
                self.size[p] += self.size[q]

    def rerooting(self, op, merge, id):
        # assert self.root is not None
        dp1 = [id] * self.n
        dp2 = [id] * self.n
        for p in self.order[::-1]:
            t = id
            for q in self.edges[p]:
                if self.par[p] == q: continue
                dp2[q] = t
                t = merge(t, op(dp1[q], p, q))
            t = id
            for q in self.edges[p][::-1]:
                if self.par[p] == q: continue
                dp2[q] = merge(t, dp2[q])
                t = merge(t, op(dp1[q], p, q))
            dp1[p] = t
        for q in self.order[1:]:
            pq = self.par[q]
            dp2[q] = op(merge(dp2[q], dp2[pq]), q, pq)
            dp1[q] = merge(dp1[q], dp2[q])
        return dp1

#########################################################################################################
import sys
input = sys.stdin.readline


# edges = make_tree(10,show=True)
# N = len(edges)+1

# example()

N = int(input())
T = Tree(N)
for _ in range(N-1):
    x, y = map(int, input().split())
    T.add_edge(x,y)
T.set_root(1)

##########################################################
def op(a, p, q):
    # define how the dp[q] is determined by children of q if setting (p, q) = (parent, child)
    # Cation: p, q are now defined by 0-indexed
    return a/(len(T.edges[q])-1) + 1 if a != 0 else 1

def merge(a, b):
    # define how the O(N) info. {r in ch(q)} in op({r in ch(q)}, p, q) の {r in ch(q)} is reduced to O(1) info.
    return a + b

# identity elem. of merge
id = 0
##########################################################

dp = T.rerooting(op, merge, id)
res = [""]*N
for i in range(N):
    res[i] = str(dp[i]/len(T.edges[i]))
print("\n".join(res))

Measured memory_bytes: 116552
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define x first
#define y second
const int N = 1e6+7;
vector<pii> qup,qdw;//qup : q > 0;qdw : q < 0
char s[N];
int main()
{
	int n;scanf("%d",&n);
    int tot = 0;
    for(int i = 1;i <= n;++i)
    {
    	scanf("%s",s);
    	int len = strlen(s);
    	int cur = 0;
    	int p = N;
    	for(int j = 0;j < len;++j)
    	{
    		if(s[j] == '(')	++cur;
    		else --cur;
    		p = min(p,cur);
    	}
    	if(p == 0 && cur == 0)	continue;
    	if(cur > 0)	qup.push_back({-p,cur - p});
    	else 		qdw.push_back({cur - p,-p});
    	tot += cur;
    }
    if(tot != 0)
    {
    	puts("No");
    	return 0;
    }
    //qup : p from big to small
    sort(qup.begin(),qup.end());//reverse(qup.begin(),qup.end());
    sort(qdw.begin(),qdw.end());
	bool ok = 1;
	int sum = 0;
	// for(int i = 0;i < qup.size();++i)
		// cout << qup[i].x << " " << qup[i].y << " ";
	// cout << endl;
	// for(int i = 0;i < qdw.size();++i)
		// cout << qdw[i].x << " " << qdw[i].y << " ";
	// cout << endl;
	for(int i = 0;i < qup.size();++i)
	{
		if(qup[i].x - sum > 0)
		{
			ok = 0;
			break;
		}
		sum += qup[i].y - qup[i].x;
	}
	sum = 0;
	for(int i = 0;i < qdw.size();++i)
	{
		if(qdw[i].x - sum > 0)
		{
			ok = 0;
			break;
		}
		sum += qdw[i].y - qdw[i].x;
	}
	if(!ok)	puts("No");
	else puts("Yes");
    return 0;
}


Measured memory_bytes: 10912
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n, k;
    cin >> n >> k;
    
    int temp = k;
    int keta = 0;
    while (n > 0) {
        keta++;
        n /= k;
    }

    cout << keta << endl;
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	map<int,int>m1,m2;
	rep(i,n){
		m1[in[i]-i]++;
		m2[-in[i]-i]++;
	}
	int out=0;
	for(auto it=m1.begin();it!=m1.end();it++){
		out+=m2[it->first]*it->second;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 39004
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
B[N]=A[N]
for i in range(N-1,-1,-1):
    B[i]=B[i+1]+A[i]

C=[0]*(N+1)
C[0]=1
for i in range(1,N+1):
    C[i]=2*(C[i-1]-A[i-1])

check=[min(B[i],C[i]) for i in range(N+1)]
for i in range(N+1):
    if check[i]<A[i]:
        print(-1)
        exit()
print(sum(check))

Measured memory_bytes: 707840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl

int main(void){
    ll n,m;
    cin>>n>>m;
    if(n==1 && m==1)cout<<1<<endl;
    else if(n==1 || m==1)cout<<(n==1 ? m-2 : n-2)<<endl;
    else cout<<n*m-2*(n+m)+4<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    int n, x;
 
    while (cin >> n >> x, n | x){
        int cnt = 0;
 
        for (int i = 1; i <= n; i++){
            for (int j = i + 1; j <= n; j++){
                for (int k = j + 1; k <= n; k++){
                    if (i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 100010;
bool pr[N] = {0};
int ans[N] = {0};
void initialize()
{
    pr[0] = 1;
    pr[1] = 1;
    int i,j;
    for(i=2;i<N;i++)
    {
        if(pr[i])
            continue;
        for(j=i*2;j<N;j+=i)
            pr[j] = 1;
    }
    ans[1] = 0;
    for(i=3;i<N;i+=2)
    {
        if(pr[i]==0 && pr[(i+1)/2]==0)
            ans[i] = ans[i-2]+1;
        else
            ans[i] = ans[i-2];
    }
}
int main()
{
    initialize();
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",ans[r]-ans[l-2]);
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000001];
struct cmp1
{
    int x;
    cmp1(int x):x(x) {}
    bool operator < (const cmp1 &a) const
    {
        return x > a.x;
    }
};
struct cmp2
{
    int x;
    cmp2(int x):x(x) {}
    bool operator < (const cmp2 &a) const
    {
        return x < a.x;
    }
};
ll dpf[1000001] , dpe[1000001];
int main()
{
    int n;
    cin>>n;
    for(int i = 1 ; i <= 3 * n ; i++)
    {
        cin>>a[i];
    }
    priority_queue<cmp1> st;
    memset(dpf , 0 , sizeof(dpf));
    memset(dpe , 0 , sizeof(dpe));
    for(int i = 1 ; i <= n ; i++)
    {
        st.push(cmp1(a[i]));
        dpf[n] += (ll)a[i];
    }
    for(int i = n + 1 ; i <= 2 * n ; i++)
    {
        int gg = st.top().x;
        if(gg < a[i])
        {
            st.pop();
            st.push(cmp1(a[i]));
            dpf[i] = dpf[i - 1] - (ll)gg + (ll)a[i];
        }
        else dpf[i] = dpf[i - 1];
    }
    priority_queue<cmp2> ed;
    for(int i = 2 * n + 1 ; i <= 3 * n ; i++)
    {
        ed.push(cmp2(a[i]));
        dpe[2 * n + 1] += (ll)a[i];
    }
    for(int i = 2 * n ; i >= n ; i--)
    {
        int gg = ed.top().x;
        if(gg > a[i])
        {
            ed.pop();
            ed.push(cmp2(a[i]));
            dpe[i] = dpe[i + 1] - (ll)gg + (ll)a[i];
        }
        else dpe[i] = dpe[i + 1];
    }
    ll ans =LONG_LONG_MIN;
    for(int i = n ; i <= 2 * n ; i++)
    {
        ans = max(ans , dpf[i] - dpe[i + 1]);
    }
    cout<<ans;
}


Measured memory_bytes: 19832
h = {}
['a', 'b', 'c'].each do |s|
  h[s] = gets.chomp.reverse
end
p = 'a'
while true
  c = h[p]
  if c.empty?
    puts(p.upcase)
    break
  end
  p = c[c.size - 1]
  c.chop!
end


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

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


void solve()
{
    string str;
    cin>>str;

    vector<string> items;

    string current;

    for(int i=0;i<str.size();i++){

        current.push_back(str[i]);

        if(items.size()==0){
            items.push_back(current);
            current.clear();
        }
        else{
            string last=items.back();
            if(last!=current){
                items.push_back(current);
                current.clear();
            }
        }
    }

    cout<<items.size()<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

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


Measured memory_bytes: 11016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

template< typename flow_t >
struct FordFulkerson{
  struct edge {
    int to;
    flow_t cap;
    int rev;
  };

  vector<vector<edge>> graph;
  vector<int> used;
  const flow_t INF;

  FordFulkerson(int V):graph(V),used(V),INF(numeric_limits<flow_t>::max()) {}

  void add_edge(int from,int to,flow_t cap){
    graph[from].push_back((edge){to,cap,(int)graph[to].size()});
    graph[to].push_back((edge){from,0,(int)graph[from].size()-1});
  }

  flow_t dfs(int now,int t,flow_t f){
    if(now==t) return f;
    used[now]=true;
    for(int i=0;i<graph[now].size();i++){
      edge &e=graph[now][i];
      if(!used[e.to]&&e.cap>0){
        flow_t d=dfs(e.to,t,min(f,e.cap));
        if(d>0){
          e.cap-=d;
          graph[e.to][e.rev].cap+=d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s,int t){
    flow_t flow=0;
    for(;;){
      for(int i=0;i<graph.size();i++) used[i]=0;

      flow_t f=dfs(s,t,INF);
      if(f>0) flow+=f;
      else return flow;
    }
  }
};


int N;
vector<ll> A;

const ll INF=1e18;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];

  int s=0,t=N+1;
  FordFulkerson<ll> mff(N+2);
  ll ans=0;
  for(int i=0;i<N;i++){
      if(A[i]>0){
          ans+=A[i];
          mff.add_edge(s,i+1,A[i]);
          mff.add_edge(i+1,t,0);
      }else{
          mff.add_edge(s,i+1,0);
          mff.add_edge(i+1,t,abs(A[i]));
      }
  }

  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
          if(i==j) continue;
          if((j+1)%(i+1)==0) mff.add_edge(j+1,i+1,INF);
      }
  }

  ans-=mff.max_flow(s,t);
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CAntiDivision {
public:

void solve(std::istream& cin, std::ostream& cout) {
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll CD = C * D / __gcd(C, D);
    cout << (B - A + 1 - ((B/C - (A-1)/C) + (B/D - (A-1)/D) - ((B/CD - (A-1)/CD))) );
//    cout << (ll)(B - A + 1 - ((floor(B*1./C) - ceil(A*1./C) + 1)+(floor(B*1./D) - ceil(A*1./D) + 1)-(floor(B*1./(C*D/__gcd(C,D))) - ceil(A*1./(C*D/__gcd(C,D))) + 1)));

}
};


#undef int
int main() {
	CAntiDivision solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c = readInts()
dic = defaultdict(int)
m = a
while True:
    #print(a)
    if a%b == c:
        print('YES')
        exit()
    if dic[a%b] != 0:
        print('NO')
        exit()
    else:
        dic[a%b] = 1
    a += m


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

bool MAP[21][21]; //(0, 0) ~ (20, 20) ????????§???????????¨?????????21*21??????
                  //?????????????????????true??????????????????false??¨??????

int main(){

  int n, x, y;

  while(std::cin >> n){

    if(n == 0) break;

    for(int i=0; i<21; i++){
      for(int j=0; j<21; j++){
        //MAP????????????
        MAP[i][j] = false;
      }
    }


    for(int i=0; i<n; i++){
      std::cin >> x >> y;
      MAP[x][y] = true;
    }

    int m;
    int robot_x = 10, robot_y = 10; //???????????????????????????
    int num_of_get = 0; //??\?????§?????????????????°

    std::cin >> m;

    for(int i=0; i<m; i++){

      char direction;
      int distance;

      std::cin >> direction >> distance;

      for(int j=0; j<distance; j++){
        //??????:1?????????????§??????????????????¨?????????????????????????????????
        //     ????????£??????num_of_get??????????????????????????????????????????(true -> false)
        switch(direction){
          case 'E':
            robot_x++;
            break;

          case 'W':
            robot_x--;
            break;

          case 'N':
            robot_y++;
            break;

          case 'S':
            robot_y--;
            break;
        }

        if(MAP[robot_x][robot_y] == true){
          num_of_get++;
          MAP[robot_x][robot_y] = false;
        }

      }

    }

    if(num_of_get == n){
      std::cout << "Yes" << std::endl;
    }else{
      std::cout << "No" << std::endl;
    }

  }

  return 0;

}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            String S = sc.next();

            String T = "";
            for (int i = 0; i < S.length(); i++) {
                T += "x";
            }

            System.out.println(T);
        }
    }

}


Measured memory_bytes: 21716
from itertools import *

N = int(input())
An = map(int, input().split())

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    if a < 0:
        num_negs += 1
        a *= -1
        pass
    total += a
    minim = min(minim, a)
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass


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

int main(){
  int k;
  cin >> k;
  vector<int> pos, neg;

  rep(i,k) {
    int a;
    cin >> a;
    if (a < 0) neg.emplace_back(a);
    else pos.emplace_back(a);
  }

  sort(neg.begin(), neg.end());
  sort(pos.begin(), pos.end(), greater<int>());

  int n = neg.size(), m = pos.size();

  if (m == 0) {
    int res = neg[n-1];
    for (int i = 0; i < n-1; i++) {
      res -= neg[i];
    }
    cout << res << endl;
    for (int i = 0; i < n-1; i++) {
      cout << neg[n-1] << " " << neg[i] << endl;
      neg[n-1] -= neg[i];
    }
    return 0;
  }
  if (n == 0) {
    int res = pos[m-1];
    for (int i = m-2; i > 0; i--) {
      res -= pos[i];
    }
    res = pos[0] - res;
    cout << res << endl;
    for (int i = m-2; i > 0; i--) {
      cout << pos[m-1] << " " << pos[i] << endl;
      pos[m-1] -= pos[i];
    }
    cout << pos[0] << " " << pos[m-1] << endl;
    return 0;
  }

  int mx = pos[0], mi = neg[0];
  for (int i = 1; i < n; i++) {
    mx -= neg[i];
  }
  for (int i = 1; i < m; i++) {
    mi -= pos[i];
  }
  int res = mx - mi;
  cout << res << endl;
  for (int i = 1; i < n; i++) {
    cout << pos[0] << " " << neg[i] << endl;
    pos[0] -= neg[i];
  }
  for (int i = 1; i < m; i++) {
    cout << neg[0] << " " << pos[i] << endl;
    neg[0] -= pos[i];
  }
  cout << pos[0] << " " << neg[0] << endl;
  return 0;
} 

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

// flag?????¨????????????????????????
int bubbleSort(int A[], int N) {
  int sw =- 0;
  bool flag = 1;
  for ( int i = 0; flag; i++ ) {
    flag = 0;
    for ( int j = N - 1; j >= i + 1; j-- ) {
      if ( A[j] < A[j - 1] ) {
        // ??£??\????´????????????????
        swap(A[j], A[j - 1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> A[i];

  sw = bubbleSort(A, N);

  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}

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

int main(){
  	int n,k,a[100],memo;
  	cin >> n >> k;
  
  	rep(i,0,n) cin >> a[i];
  
  	rep(i,0,n){
      memo += min(a[i]*2,abs(k-a[i])*2);
    }
  	
  	cout << memo << endl;
  
  	return 0;
}

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

int main()
{
    int n,c=0;
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5]){
    cout<<"Yes";
   }else
   cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char* argv[]) {
  using std::cin;
  using std::cout;

  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << (a + b);
  } else {
    cout << (b - a);
  }
  return 0;
}


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

#define int long long

int32_t main(){
	int n ;
	cin >> n ;
	pair<int,int> a[n] ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i].first ;
		a[i].second = i ;
	}
	sort(a,a+n) ;
	int mn = a[0].second ;
	int ans = 1 ;
	for(int i = 1 ; i < n ; i++){
			ans += (a[i].second < mn) ;
			mn = min(mn,a[i].second) ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h1,s1,h2,s2;
  cin>>h1>>s1>>h2>>s2;

  while(h2>0 && h1>0){
     h2-=s1;
     if(h2<=0){
       cout<<"Yes"<<endl;
       return 0;
     }
     h1-=s2;   
     if(h1<=0){
       cout<<"No"<<endl;
       return 0;
     }

  }
  
  

  
     
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	vc<pi> all;
	for(int i=0,x,y;i<m;i++)
	{
		cin>>x>>y;
		x--,y--;
		all.emplace_back(x,y);
	}
	reverse(all.begin(),all.end());
	vi ok(n,1);
	vc<vi> state(n);
	for(int i=0;i<n;i++)
	{
		vi vis(n);
		vis[i]=1;
		for(auto &e:all)
		{
			int x=e.first,y=e.second;
			if(vis[x]&&vis[y])
			{
				ok[i]=0;
				break;
			}
			else if(vis[x]||vis[y]) vis[x]=vis[y]=1;
		}
		state[i]=vis;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(!ok[i]) continue;
		for(int j=0;j<i;j++)
		{
			if(!ok[j]) continue;
			bool suc=1;
			for(int k=0;k<n;k++)
			{
				if(state[i][k]&&state[j][k]) suc=0;
			}
			ans+=suc;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 4540
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

#define inc(...)      \
  char __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
  ini(X);
  out(8 - (X - 400) / 200);
}


Measured memory_bytes: 3648
#ベクトルの次元数n
n = int(input())

#ベクトルx
x = list(map(int,input().split()))

#ベクトルy
y = list(map(int,input().split()))


#p==1
Dxy = 0
for i in range(n):
    Dxy += abs(x[i]-y[i])
print(Dxy)

#p==2
Dxy = 0
s1 = 0
for i in range(n):
    s1 += (x[i]-y[i])**2
Dxy = s1**(1/2)
print(Dxy)

#p==3
Dxy = 0
s1 = 0
for i in range(n):
    s1 += abs(x[i]-y[i])**3
Dxy = s1**(1/3)
print(Dxy)

#p==infinity
Dxy = 0
s1 = 0
for i in range(n):
    if Dxy < abs(x[i]-y[i]):
        Dxy = abs(x[i]-y[i])
print(Dxy)



Measured memory_bytes: 5636
program dividing_a_string
  implicit none
  character(200000) :: s
  integer :: n, i, f(0:200000) = 0
  read(*,*) s
  n = len_trim(s)
  f(1) = 1
  if (n > 1) then
    if (s(1:1) == s(2:2)) then
      f(2) = 1
    else
      f(2) = 2
    end if
  end if
  do i = 3, n
    if (s(i:i) == s(i-1:i-1)) then
      f(i) = f(i-3)+2
    else
      f(i) = f(i-1)+1
    end if
  end do
  write(*,'(i0)') f(n)
end program dividing_a_string

Measured memory_bytes: 1932
;; D - Prediction and Restriction

(defun main ()
  (let ((N (read)) ; じゃんけん回数
        (K (read)) ; 同じ手を出してはいけない周期
        (RSP (loop repeat 3 collect (read))) ; 各手の得点
        (seq (read-line))) ; 筐体が出す手の列
    (princ (solve N K RSP seq))
    (fresh-line)))

(defun solve (N K RSP seq)
  (let ((score (make-hash-table)))
    (loop for s in RSP
          for c in '(#\s #\p #\r) ; 相手=チョキ,パー,グー
          do (setf (gethash c score) s))
    (loop for i below N
          for c = (char seq i)
          if (and (>= i K) (eql c (char seq (- i K))))
            do (setf (char seq i) #\-) ; 次回は勝てる手を出してよい
          else
            sum (gethash c score))))

(main)


Measured memory_bytes: 14436
function main(input){
  const K = parseInt(input.split('\n')[0]);
  const S = input.split('\n')[1];
  if (S.length <= K) {
  	console.log(S);
  }else{
    console.log(S.substr(0,K)+"...");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29632
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int Q;
int SUM[100010];

int prime[100010];
bool is_prime[100010];

int sieve(int n)
{
	int p = 0;
	rep(i, 0, n + 1)is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	rep(i, 2, n + 1)
	{
		if (is_prime[i])
		{
			prime[p++] = i;
			for (int j = i + i; j <= n; j += i)is_prime[j] = false;
		}
	}
	return p;
}

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

	sieve(100005);

	rep(i, 3, 100005)
	{
		if (is_prime[i] && is_prime[(i + 1) / 2])
		{
			SUM[i]++;
		}
		SUM[i] += SUM[i - 1];
	}

	cin >> Q;
	int l, r;
	rep(i, 0, Q)
	{
		cin >> l >> r;
		cout << SUM[r] - SUM[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
from collections import deque
H,W,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1
Pond = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp = list(temp)
  Pond.append(temp)
#print(Pond)
Q = deque([])
Q.append((sx,sy))
reach = [[INF]*W for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
while Q:
  nx,ny = Q.popleft()
  for i in range(4):
    tx,ty = nx,ny
    step = K
    while step > 0:
      tx += dxdy[i][0]
      ty += dxdy[i][1]
      #print(i,tx,ty)
      if 0>tx or tx>=H or 0>ty or ty>=W or Pond[tx][ty] == "@": #or reach[tx][ty] != INF:
        #print(i,tx,ty,reach[2][0])
        break #範囲外やハスがあった、到達済みの場合には終了
      #print(i,tx,ty)
      if reach[nx][ny] + 1 > reach[tx][ty]: #もし現時点よりもステップが大きい場合はだめ。
        #同じ場合は向き的に得している場合もあるので残す。
        break
      if reach[nx][ny] + 1 == reach[tx][ty]:
        #同じときはQに加える必要はないが、そのまま先に進んだら得の場合があるのでContinue
        step -=1
        continue
      reach[tx][ty] = reach[nx][ny] + 1
      Q.append((tx,ty))
      step -=1

#print(reach)
ans = reach[gx][gy]
if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 142088
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> b(n + 1); rep(i, n)cin >> b[i + 1];
	vector<int> res(n);
	for (int i = n - 1; i >= 0; --i)
	{
		bool ok = false;
		for (int j = b.size() - 1; j > 0; --j)
		{
			if (j == b[j])
			{
				res[i] = j;
				b.erase(b.begin() + j);
				ok = true;
				break;
			}
		}
		if (!ok)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, n)cout << res[i] << endl;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    A, B, C = [int(item) for item in input().split()]
    K = int(input())
    is_flag = False
    for i in range(K+1):
        for j in range(K+1):
            if i+j <= K:
                if A*2**i < B*2**j < C*2**(K-(i+j)):
                    is_flag = True
    
    print('Yes') if is_flag else print('No')


if __name__ == "__main__":
    resolve()


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

#define INF (1000000000+1)

typedef struct {
	char a;
	int v;
} card;

vector<card> L;
vector<card> R;

void merge( vector<card> &A, int left, int mid, int right )
{
	int n1 = mid - left;
	int n2 = right - mid;
	for( int i = 0; i < n1; i++ ) {
		L[i] = A[left + i];
	}
	for( int i = 0; i < n2; i++ ) {
		R[i] = A[mid + i];
	}
	L[n1].v = INF;
	R[n2].v = INF;
	int i = 0;
	int j = 0;
	for( int k = left; k < right; k++ ) {
		if( L[i].v <= R[j].v ) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

void msort( vector<card> &A, int left, int right )
{
	if( right - left <= 1 ) return;
	int mid = ( right + left ) / 2;
	msort( A, left, mid );
	msort( A, mid, right );
	merge( A, left, mid, right );
}

int partition( vector<card> &A, int p, int r )
{
	card x = A[r];
	int i = p - 1;
	for( int j = p; j < r; j++ ) {
		if( A[j].v <= x.v ) {
			i++;
			swap( A[i], A[j] );
		}
	}
	swap( A[i + 1], A[r] );
	return i + 1;
}

void quick( vector<card> &A, int p, int r )
{
	if( p >= r ) return;
	int q = partition( A, p, r );
	quick( A, p, q - 1 );
	quick( A, q + 1, r );
}

int main()
{
	int n;
	cin >> n;
	vector<card> A( n );
	vector<card> B( n );
	L = vector<card>( n / 2 + 2 );
	R = vector<card>( n / 2 + 2 );
	for( int i = 0; i < n; i++ ) {
		cin >> A[i].a >> A[i].v;
		B[i] = A[i];
	}

	quick( A, 0, n - 1 );
	msort( B, 0, n );
	int s = 0;
	for( int i = 0; i < n; i++ ) {
		if( A[i].a != B[i].a ) {
			s = 1;
			break;
		}
	}
	string ans = "Stable";
	if( s ) ans = "Not stable";
	cout << ans << endl;
	for( int i = 0; i < n; i++ ) {
		cout << A[i].a << " " << A[i].v << endl;
	}
}



Measured memory_bytes: 5644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;



int main(){
    int N;
    cin >> N;
    ll a[N];
    ll sum = 0;
    for(int i =0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }

    ll x = 0;
    ll result = 100000000000000;

    for(int i=0; i<N-1; i++){
        x += a[i];
        ll y = sum - x;
        if(result > abs(x-y)){
            result = abs(x-y);
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1792
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],n;
bool solve(){
	fp(i,1,n)if(a[i]&1){
		if(a[i]==1)return 0;
		--a[i];break;
	}
	R int d=0;
	fp(i,1,n)d=__gcd(d,a[i]);
	fp(i,1,n)a[i]/=d;
	R int t=0,sz=0;
	fp(i,1,n)t^=(a[i]&1^1),sz+=(a[i]&1);
	if(t||sz!=1)return t^1;
	return solve()^1;
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	R int t=0,sz=0;
	fp(i,1,n)t^=(a[i]&1^1),sz+=(a[i]&1);
	if(t||sz!=1)return puts(t?"First":"Second"),0;
	puts(solve()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll v;cin>>v;vec.push_back(v);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
ll inv(ll a)
{
    ll p=mod2;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll ncr(ll n,ll m)
{
    ll p=mod2;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

ll countDigit(ll n)
{   
    return floor(log10(n) + 1); 
}  
ll a_pow_b(ll a,ll b)
{
    ll p=1000000007;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}
ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}
bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
}
ll ncr123(ll n, ll k){
    if (k == 1) {
        return n;
    }
    if (k == 2) {
        return n * (n - 1) / 2;
    }
    if (k == 3) {
        return n * (n - 1) * (n - 2) / 6;
    }
}
bool com(const pi &a,const pi &b)   //acc to second element sort for vec of pi
{ 
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}



void solve(){

    ll n;
    cin>>n;
    vec a,v1,v2;
    inpvec(a,n);

    loop(i,0,n){
        v1.pb(a[i]+i);
        v2.pb(-a[i]+i);
    }

    ll ans1=0,ans2=0;
    map<ll,ll> m1,m2;
    loop(i,0,n){
        m1[v1[i]]++;
        m2[v2[i]]++;
    }

    loop(i,0,n){
        if(m1[v2[i]]>0){
            ans1+=m1[v2[i]];
        }
    }
    loop(i,0,n){
        if(m2[v1[i]]>0){
            ans2+=m2[v1[i]];
        }
    }

    cout<<max(ans1,ans2);
    return ;
}
 
 
int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> c(H, vector<int>(W));
    vector<int> h(H,0);
    vector<int> w(W,0);
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        string tmp;
        cin >> tmp;
        for (int j = 0; j < W; j++)
        {
            if(tmp[j]=='.')c[i][j]=0;
            else {
                c[i][j] = 1;
                h[i]++;
                w[j]++;
                cnt++;
            }
        }
    }
        for(int bit=0; bit<(1<<(H+W)); bit++){
            int f = 0;
            vector<int> x;
            vector<int> y;
            for (int i = 0; i < H; i++)
            {
                if(bit & (1<<i)){
                    f += h[i];
                    x.push_back(i);
                }
            }
            for (int i = 0; i < W; i++)
            {
                if(bit & (1<<(i+H))){
                    f += w[i];
                    y.push_back(i);
                }
            }
            for (int i = 0; i < x.size(); i++)
            {
                for (int j = 0; j < y.size(); j++)
                {
                    int a = x[i];
                    int b = y[j];
                    if(c[a][b])f--;
                }
            }
            if(cnt-f==K)ans++;
        }
   cout << ans << endl;
}

Measured memory_bytes: 3628
import sys


def input():
    return sys.stdin.readline().strip()


N = int(input())
B = list(map(int, input().split()))
hand = []


def check(B, cnt):
    n = len(B)
    for i in range(n):
        if B[n - i - 1] == (n - i):
            hand.append(B[n - i - 1])
            B = B[: n - i - 1] + B[n - i :]
            break
    if len(B) != n and len(B) > 0:
        return B
    else:
        return False


cnt = 1
while B:
    B = check(B, cnt)
    # print(B)

if len(hand) < N:
    print(-1)
    sys.exit()
answer = hand[::-1]
for i in range(N):
    if answer[i] > i + 1:
        print(-1)
        sys.exit()
print(*answer, sep="\n")


Measured memory_bytes: 3064
n = int(input())
ls = list(map(int, input().split()))
if n < 3:
    print(0)
    exit()
def checkValidity(a, b, c):  
    # check condition  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True  
r = 0
for i in range(n):
    for j in range(i+1, n):
        if ls[i] != ls[j]:
            for k in range(j+1, n):
                if ls[j] != ls[k] and ls[k] != ls[i]:
                    if checkValidity(ls[i],ls[j],ls[k]):
                        r += 1

print(r)

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

using LL = long long;
const LL MOD = 1e9+7;

LL solve() {
  LL N, M;
  cin >> N >> M;

  if(N > M) swap(N, M);

  vector<LL> f = {1};
  while(f.size() <= M) f.emplace_back(f.back() * f.size() % MOD);

  auto d = M-N;
  if(1<d) return 0;
  if(d==1) return f[N] * f[M] % MOD;
  return f[N] * f[M] * 2 % MOD;
}

int main() {
  cout << solve() << endl;
}


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

int main() {
  int s;
  cin >> s;
  int aa,bb;
  aa = (s /1000)*10  + (s/100 % 10);
  bb = (s % 10) + (s/10 % 10)*10;
  int flagam = 0;
  int flagbm = 0;
  if( aa >= 1 && aa <= 12 ){
    flagam = 1;
  }
  if( bb >= 1 && bb <= 12 ){
    flagbm = 1;
  }
  if( flagam == 1){
    if( flagbm == 1){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout << "MMYY" << endl;
    }
  }
  else{
    if( flagbm == 1 ){
      cout << "YYMM" << endl;
    }
    else{
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
    int n, k, x, y;
    std::cin >> n >> k >> x >> y;
    if (n <= k)
    {
        std::cout << n * x << std::endl;
    }
    else
    {
        std::cout << (k * x + (n - k) * y) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;
const int Mod = 998244353, Inv2 = (Mod + 1) / 2;
const int MN = 1000005, MP = 78499;

bool ip[MN];
int p[MP], pc;
LL f[MN];
inline void Sieve(int N) {
	f[1] = 1;
	for (int i = 2; i <= N; ++i) {
		if (!ip[i]) p[++pc] = i, f[i] = (LL)i * (1 - i);
		for (int j = 1, k; j <= pc; ++j) {
			if ((k = p[j] * i) > N) break;
			ip[k] = 1;
			if (i % p[j]) f[k] = f[i] * f[p[j]];
			else { f[k] = f[i] * p[j]; break; }
		}
	}
}

int N, C[MN], Ans;

int main() {
	Sieve(1000000);
	scanf("%d", &N);
	for (int i = 1, x; i <= N; ++i) scanf("%d", &x), ++C[x];
	for (int i = 1; i <= 1000000; ++i) {
		int S = 0;
		for (int j = 1, k = i; k <= 1000000; ++j, k += i)
			S = (S + (LL)j * C[k]) % Mod;
		S = (LL)S * S % Mod;
		Ans = (Ans + (f[i] % Mod) * S - (LL)C[i] * i) % Mod;
	}
	printf("%lld\n", (LL)(Ans + Mod) * Inv2 % Mod);
	return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF (ll)(1e18)
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;

vii V[26];

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s;

	rep(i , s.size()) {
		int v = s[i] - 'a';
		V[v].pb(i);
	}

	for(int i = 0;i < 26;i++) {
		if (V[i].size() == 0)
			continue;
		int prev = V[i][0];
		int curr;
		for(int j = 1;j < V[i].size();j++) {
			curr = V[i][j];
			if (curr <= prev + 2) {
				cout << prev + 1 << ' ' << curr + 1 << '\n';
				return 0;
			}
			prev = curr;
		}
	}

	cout << "-1 -1\n";

	return 0;
}

Measured memory_bytes: 1104