akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

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

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

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

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

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

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


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

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

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

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

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


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

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; ll k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,0,n){
        cin >> a[i];
        a[i]--;
    }
    vector<int> b(n,-1);
    vector<int> c(n,-1);
    b[0] = 0;
    ll m = 0;
    ll r = 0;
    queue<ll> que;
    que.push(0);
    while(!que.empty()){
        ll x = que.front();
        que.pop();
        b[x] = m;
        m++;
        if(b[a[x]]>=0){
            que.push(a[x]);
            while(!que.empty()){
                ll nx = que.front();
                que.pop();
                c[nx] = r;
                r++;
                if(c[a[nx]]>=0) break;
                que.push(a[nx]);
            }
            break;
        }
        que.push(a[x]);
    }
    if(k<=m){
        rep(i,0,n){
            if(b[i]==k){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
    k -= m;
    ll t = k%r;
    rep(i,0,n){
        if(c[i]==t){
            cout << i+1 << endl;
        }
    }
} 

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,k;
  int r,s,p;
  string t;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;

  vector<string> enemy(k);
  for(int i = 0; i < n; i++){
    enemy[i%k].push_back(t[i]);
  }
  bool flag = 0;
  long long ans = 0;
  for(int i = 0; i < k; i++){
    for(int j = 0; j < enemy.at(i).size(); j++){
      // cout << enemy[i][j] << ",";
      if(j != 0 && enemy[i][j] == enemy[i][j-1] && flag == 0){
        flag = 1;
        continue;
      }
      flag = 0;
      if(enemy[i][j] == 'r') ans += p;
      else if(enemy[i][j] == 's') ans += r;
      else if(enemy[i][j] == 'p') ans += s;
    }
    // cout << endl;
  }

  cout << ans << endl;

  // long long ans = 0;
  // for(int i = 0; i < n; i++){
  //   if(i >= k-1 && t[i - k] == t[i]) continue;
  //   if(t[i] == 'r') ans += p;
  //   else if(t[i] == 's') ans += r;
  //   else if(t[i] == 'p') ans += s;
  // }
  // cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6064
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

N, a, b = map(int, inp().split())
ans = N//(a+b) * a
rest = N%(a+b)
ans += min(a, rest)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
void solve(void)
{
	int a,b,c;
	char op;
	scanf("%d %c %d",&a,&op,&b);
	switch(op){
		case '+':
			c=a+b;
			break;
		case '-':
			c=a-b;
			break;
		default:
			break;
	}
	printf("%d\n",c);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
#include <complex>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const double EPS = 1e-8;
const double INF = 1e18;

struct P
{
	double x, y;
};

struct C
{
	P p;
	double r;
};

double distPP(const P& p1, const P& p2){
	return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
}

double distPC(const P& p, const C& c){
	return max(0.0, distPP(p, c.p) - c.r);
}

double distCC(const C& c1, const C& c2){
	return max(0.0, distPP(c1.p, c2.p)-(c1.r+c2.r));
}

struct Edge
{
	int to;
	double cost;
};

vector<Edge> es[1010];
double d[1010];

int main(){
	P s, t;
	cin>>s.x>>s.y>>t.x>>t.y;
	int n;
	cin>>n;
	vector<C> c(n);
	rep(i, n) cin>>c[i].p.x>>c[i].p.y>>c[i].r;
	es[n].pb({n+1, distPP(s, t)});
	es[n+1].pb({n, distPP(s, t)});
	rep(i, n){
		es[n].pb({i, distPC(s, c[i])});
		es[i].pb({n, distPC(s, c[i])});
		es[n+1].pb({i, distPC(t, c[i])});
		es[i].pb({n+1, distPC(t, c[i])});
		rep(j, n) if(j != i) es[i].pb({j, distCC(c[i], c[j])});
	}
	auto dijkstra = [&]{
		typedef pair<double, int> P;
		priority_queue<P, vector<P>, greater<P> > q;
		P p;
		q.push({0.0, n});
		rep(i, 1010) d[i] = INF;
		while(!q.empty()){
			p = q.top(); q.pop();
			int from = p.se;
			double c = p.fi;
			for(auto& e : es[from]){
				int to = e.to;
				double cost = c + e.cost;
				if(d[to] <= cost) continue;
				d[to] = cost;
				q.push({cost, to});
			}
		}
	};
	dijkstra();
	printf("%.15lf\n", d[n+1]);
}

Measured memory_bytes: 20592
package main

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

func main(){
    stdin := bufio.NewScanner(os.Stdin)
    stdin.Scan()
    tmp := strings.Split(stdin.Text(), " ")
    h, _ := strconv.ParseInt(tmp[0], 10, 32)
    w, _ := strconv.ParseInt(tmp[1], 10, 32)

    cells := make([][]int, h)
    for i := 0; i < int(h); i++ {
        cells[i] = make([]int, w)
    }

    stdin.Scan()
    n_, _ := strconv.ParseInt(stdin.Text(), 10, 32)
    n := int(n_)

    stdin.Scan()
    tmp = strings.Split(stdin.Text(), " ")

    colors := make([]int, n)
    for i := 0; i < int(n); i++ {
        n_, _ = strconv.ParseInt(tmp[i], 10, 32)
        colors[i] = int(n_)
    }
    color := 0
    count := colors[0]

    for i := 0; i < int(h); i++ {
        for j := 0; j < int(w); j++ {
            if count < 1 {
                color++
                count = colors[color]
            }
            if i % 2 == 0{
                cells[i][j] = color + 1
            }else{
                index := int(w) - j - 1
                cells[i][index] = color + 1
            }
            count--
        }
    }

    for i := 0; i < int(h); i++ {
        for j := 0; j < int(w); j++ {
            fmt.Print(cells[i][j])
            fmt.Print(" ")
        }
        fmt.Println()
    }
}


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

// #include<iostream>
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())


 using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;
int main(){
  // #ifndef ONLINE_JUDGE
  //     // for getting input from input.txt
  //     freopen("input.txt", "r", stdin);
  //     // for writing output to output.txt
  //     freopen("output.txt", "w", stdout);
  // #endif
  int n,k,p,t;
  cin >> n >> k;
  set<int> s;
  for0(i,k){
    cin >> p;
    for0(i,p){
      cin >> t;
      s.insert(t);
    }
  }
  cout << n-sz(s);
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    vector<int> dp(n,1e9);
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=max(0,i-k);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
def solve(string):
    n, k, q, *a = map(int, string.split())
    t, b = [0] * n, q - k
    for _a in a:
        t[_a - 1] += 1
    return "\n".join(["Yes" if _t > b else "No" for _t in t])


if __name__ == '__main__':
    n, m, q = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, q) + '\n'.join([input() for _ in range(q)])))


Measured memory_bytes: 14552
#include <bits/stdc++.h>
  
using namespace std;
 
#define MAX 256
typedef pair<int, int> pii;
  
int n;
vector<string> e;
map<string, pii> mp;
  
int op_num(char c)
{
    switch (c) {
        case '+':
            return 0;
        case '-':
            return 1;
        case '*':
            return 2;
        case '/':
            return 3;
    }
    return -1;
}
  
int s2i(string &s)
{
    int res;
    stringstream ss(s);
    ss >> res;
    return res;
}

int calc(int a, int op, int b)
{    
    if (op == 0) {
        return (a + b) % 256;
    } else if (op == 1) {
        return (a - b + 256) % 256;
    } else if (op == 2) {
        return (a * b) % 256;
    } else {
        return (b == 0 ? MAX : (a / b) % 256);
    }
}

bool zero_division_checker()
{
    stack<vector<int>> st;
    for (int i = 0; i < n; i++) {
        if (isdigit(e[i][0])) {
            vector<int> v = {s2i(e[i])};
            st.push(v);
        } else {
            int op = op_num(e[i][0]);
            if (op >= 0) {
                vector<int> vb = st.top(); st.pop();
                vector<int> va = st.top(); st.pop();
                vector<int> v;
                for (int j = 0; j < (int)va.size(); j++) {
                    for (int k = 0; k < (int)vb.size(); k++) {
                        int res = calc(va[j], op, vb[k]);
                        if (res == MAX) {
                            return 0;
                        }
                        v.push_back(res);
                    }
                }
                sort(v.begin(), v.end());
                v.erase(unique(v.begin(), v.end()), v.end());
                st.push(v);
            } else {
                vector<int> v;
                pii p = mp[e[i]];
                for (int j = p.first; j <= p.second; j++) {
                    v.push_back(j);
                }
                st.push(v);                
            }
        }
    }
    return 1;
}
  
int main()
{
    int m;
    cin >> m;
    string name;
    int lb, ub;
    for (int i = 0; i < m; i++) {
        cin >> name >> lb >> ub;
        mp[name] = pii(lb, ub);
    }
    cin >> n;
    e.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> e[i];
    }
    cout << (zero_division_checker() ? "correct" : "error") << endl;
    return 0;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

string s;

int main() {
	cin >> s;
	
	int a = stoi(s.substr(0, 2));
	int b = stoi(s.substr(2, 2));
	
	bool ym = inII(b, 1, 12);
	bool my = inII(a, 1, 12);
	
	if(  ym &&   my) { cout << "AMBIGUOUS" << endl; }
	if(  ym && ! my) { cout << "YYMM" << endl; }
	if(! ym &&   my) { cout << "MMYY" << endl; }
	if(! ym && ! my) { cout << "NA" << endl; }
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, h[100000], dp[100000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i], dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j <= i + 2 && j < n; j++) dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
	cout << dp[n - 1] << "\n";
	return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

double calcAngle(double h, double m)
{
    // validate the input
    if (h <0 || m < 0 || h >12 || m > 60)
        assert(1 == 0);

    if (h == 12) h = 0;
    if (m == 60) m = 0;

    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;


    double angle = abs(hour_angle - minute_angle);

    angle = min(360 - angle, angle);

    return angle;
}
int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int a, b , h , w;
    cin >> a >> b >> h >> w;
    double angle = calcAngle(h,w);
    angle = (angle/180) * PI;

    double s = SQR(a) + SQR(b) - 2 * a * b * cos(angle);
    cout << fixed << setprecision(9) << sqrt(s) << '\n';


    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 4192
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long

using namespace std;

int main(void)
{
    int n,i,j;
    int a[100010],f[100010];
    while(scanf("%d",&n)==1)
    {
        memset(f,0,sizeof(f));
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            f[a[i]]++;
        }
        sort(a,a+n);
        int cnt = 0;
        int ans = 0;
        for(i=1;i<=100000;i++)
        {
            if(f[i] == 0)
                continue;
            if(f[i] % 2 == 0)
                cnt++;
            else
                ans++;
        }
        if(cnt % 2 == 1)
            cnt--;
        ans += cnt;
        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    if (k % 2 == 1) {
        cout << (n / k) * (n / k) * (n / k) << endl;
    } else {
        ll x = n / k;
        ll y = (n + k / 2) / k;

        cout << x * x * x + y * y * y << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define line                    cout << "\n===================\n"

const ll mod = 1e9 + 7;
const int nax = 3e5 + 5;
ll ara[nax];
ll n;

inline ll big_mod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1) res = (res * x) % m;
        x = (x * x) % m, p >>= 1;
    }
    return res;
}

ll solve() 
{
    ll total = 0; 
    for (ll i = 0; i < 64; i++)  { 
        ll zero = 0, one = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (ara[j] % 2 == 0){
                zero++;
            }
            else{
                one++; 
            }
            ara[j] /= 2; 
        } 
        ll sum = (one * zero) % mod * big_mod(2, i, mod);    
        total += sum;
        total %= mod;
    } 
    return total; 
} 

int main ()
{
    // freopen ("input.txt", "r", stdin);
    // freopen ("output.txt", "w", stdout);
    //fastRead;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> ara[i];
	}
    ll sum = solve();
    cout << sum << endl;
    return 0;
}	

Measured memory_bytes: 2560
N = int(input())
A = list(input().split())
locate = [int(A[i]) for i in range(N)]
locate.append(0)
locate.insert(0, 0)
ALL = sum([abs(locate[i+1]-locate[i]) for i in range(N+1)])

for i in range(1, N+1):
    left = locate[i] - locate[i-1]
    right = locate[i+1] - locate[i]
    if left*right < 0:
        print(ALL - 2 * min(abs(left), abs(right)))
    else:
        print(ALL)

Measured memory_bytes: 17880
#ABC056b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

w, a, b = map(int, input().split())
if (a + w < b):
    print(b - (a + w))
elif (b + w < a):
    print(a - (b + w))
else:
    print(0)

Measured memory_bytes: 3060
import fractions
a,b,c,d = map(int,input().split())
cnt = 0
numc = b // c - (a - 1) // c
numd = b // d - (a - 1) // d
com = c * d // fractions.gcd(c,d)
numcd = b // com - (a - 1) // com
print(int(b - a + 1 - (numc + numd - numcd)))


Measured memory_bytes: 5048
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<bool, ll> pbl;

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl

int n;
struct node {
    int id;
    int x, y;
} point[maxn];

bool cmp1(node a, node b){
    return a.x < b.x;
}

bool cmp2(node a, node b){
    return a.y < b.y;
}

ll dist(node a, node b) {
    return min(abs(a.x - b.x), abs(a.y - b.y));
}

int father[maxn], rank_[maxn], sz[maxn];

void init() {
    for (int i = 1; i <= n; i++) {
        father[i] = i;
        rank_[i] = 0;
        sz[i] = 0;
    }
}

int find(int x) {
    return father[x] == x ? x : father[x] = find(father[x]);
}

void merge(int a, int b) {
    a = find(a);
    b = find(b);
    if (a != b) {
        if (rank_[a] > rank_[b]) {
            father[b] = a;
            sz[a] += sz[b];
            sz[b] = 0;
        }
        else {
            father[a] = b;
            sz[b] += sz[a];
            sz[a] = 0;
            if (rank_[a] == rank_[b]) rank_[b]++;
       }
    }
}

struct edge {
    int u, v;
    ll w;
} Edge[4 * maxn];

bool operator < (edge a, edge b) {
    return a.w < b.w;
}

int main() {
    //freopen(".in", "r", stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &point[i].x, &point[i].y), point[i].id = i;
    init();
    int cnt = 0;
    sort(point + 1, point + 1 + n, cmp1);
    for (int i = 1; i < n; i++) {
        Edge[++cnt] = (edge){point[i].id, point[i + 1].id, dist(point[i], point[i + 1])};
    }
    sort(point + 1, point + 1 + n, cmp2);
    for (int i = 1; i < n; i++) {
        Edge[++cnt] = (edge){point[i].id, point[i + 1].id, dist(point[i], point[i + 1])};
    }
    sort(Edge + 1, Edge + 1 + cnt);
    ll ans = 0;
    for (int i = 1; i <= cnt; i++) {
        int u = Edge[i].u;
        int v = Edge[i].v;
        ll w = Edge[i].w;
        if (find(u) != find(v)) {
            merge(u, v);
            ans += w;
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 6784
#include<iostream>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
    cs
    int n,m,x,t=0;
    cin>>n>>m;
    while(m--){
        cin>>x;t+=x;
    }
    if(t>n) cout<<-1;
    else cout<<n-t;
}

Measured memory_bytes: 3624
package main

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

// https://atcoder.jp/contests/abc106/tasks/abc106_b

func main() {

	n := IntStdin()

	var result int

	for i := 1; i <= n; i++ {
		var cnt int
		if i%2 == 1 {
			for j := 1; j <= n; j++ {

				if i%j == 0 {
					cnt++
				}
			}
		}
		if cnt == 8 {
			result++
		}
	}

	fmt.Println(result)
}

// StrStdin 1行の文字列を入力
// Example:
// -----------------
// hogehoge
// -----------------
func StrStdin() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}

// IntStdin 1つの符号付き整数値(64bit)入力
// Exapmle:
// ------------------
// 1000000007
// ------------------
func IntStdin() int {
	stringInput := StrStdin()
	num, _ := strconv.ParseInt(strings.TrimSpace(stringInput), 10, 64)
	return int(num)
}

// UintStdin 1つの符号なし整数値(64bit)入力
// Exapmle:
// ------------------
// 1000000007
// ------------------
func UintStdin() uint {
	stringInput := StrStdin()
	num, _ := strconv.ParseUint(strings.TrimSpace(stringInput), 10, 64)
	return uint(num)
}

// Float64Stdin 1つの符号付き浮動小数点数(64bit)の入力
// Exapmle:
// ------------------
// 33.4
// ------------------
func Float64Stdin() float64 {
	stringInput := StrStdin()
	num, _ := strconv.ParseFloat(strings.TrimSpace(stringInput), 64)
	return num
}

// SplitWithoutEmpty 空白や空文字だけの値を除去したSplit
func SplitWithoutEmpty(stringTargeted string, delim string) []string {
	stringSplited := strings.Split(stringTargeted, delim)
	strs := []string{}

	for _, str := range stringSplited {
		if str != "" {
			strs = append(strs, str)
		}
	}
	return strs
}

// SliceStrsStdin 空白区切りで複数の文字列を1行で入力
// Example:
// --------------------
// hoge fuga hage
// --------------------
func SliceStrsStdin(delim string) []string {
	stringInput := StrStdin()
	return SplitWithoutEmpty(stringInput, delim)
}

// SliceInt64Stdin 空白区切りで複数の符号付き整数値(64bit)を1行で入力
// Example:
// --------------------
// 45 -100 23
// --------------------
func SliceInt64Stdin() []int64 {
	stringSplited := SliceStrsStdin(" ")

	int64Slice := []int64{}

	for ni := range stringSplited {
		num, _ := strconv.ParseInt(stringSplited[ni], 10, 64)
		int64Slice = append(int64Slice, num)
	}

	return int64Slice
}

// SliceUint64Stdin 空白区切りで複数の符号なし整数値(64bit)を1行で入力
// Example:
// --------------------
// 43 7 21
// --------------------
func SliceUint64Stdin() []uint64 {
	stringSplited := SliceStrsStdin(" ")

	uint64Slice := []uint64{}

	for ni := range stringSplited {
		num, _ := strconv.ParseUint(stringSplited[ni], 10, 64)
		uint64Slice = append(uint64Slice, num)
	}

	return uint64Slice
}

// SliceFloat64Stdin 空白区切りで複数の符号付き浮動小数点数(64bit)を入力
// Example:
// --------------------
// 45.0 -62.1 11.7
// --------------------
func SliceFloat64Stdin() []float64 {
	stringSplited := SliceStrsStdin(" ")

	float64Slice := []float64{}

	for ni := range stringSplited {
		num, _ := strconv.ParseFloat(stringSplited[ni], 64)
		float64Slice = append(float64Slice, num)
	}

	return float64Slice
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

class UnionFind {
public:
    vector<LL> parent;
    vector<LL> member;

    UnionFind(LL N) {
        parent.resize(N);
        REP(i, N) {
            parent[i] = i;
        }
        member.resize(N);
        fill(ALL(member), 1);
    }

    int root(LL x) {
        if(x == parent[x]) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    bool same(LL x, LL y) {
        return root(x) == root(y);
    }

    LL size(LL x) {
        return member[root(x)];
    }

    void unite(LL x, LL y) {
        if(root(x) == root(y)) {
            return;
        }
        member[root(y)] += member[root(x)];
        parent[root(x)] = root(y);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> p(N + 1);
    FOR(i, 1, N + 1) {
        cin >> p[i];
    }
    UnionFind uf(N + 1);
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    vector<set<int>> vs(N + 1);
    vector<vector<int>> vo(N + 1);
    FOR(i, 1, N + 1) {
        int x = uf.root(i);
        vs[x].insert(p[i]);
        vo[x].push_back(i);
    }
    int res = 0;
    FOR(i, 1, N + 1) {
        for(auto j : vo[i]) {
            if(vs[i].find(j) != vs[i].end()) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 17024
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(A)
B = set(B[1::2])
C = [i%2==1 and a not in B for i, a in enumerate(A)]
print(sum(C))


Measured memory_bytes: 10844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

int n,a[N];
map<ll,ll>M;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(M.count(i-x)) res+=M[i-x];
		M[x+i]++;
	}
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 16004
/*
AUTHOR: Naman
*/
#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define pb push_back
#define Fo(i,k,n) for(ll i=k;i<=n;i+=1)
#define deb(x) cout << #x << "=" << x << endl
#define in(a,n) Fo( i,0,n-1)cin>>a[i]
#define out(a,n) Fo( i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=1e6+1;
const ll M=1e9+7;

ll Gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return Gcd(b % a, a); 
} 



int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	Fo(_,1,t)
	{
	   //cout<<"Case #"<<_<<": ";
	   ll n;
	   cin>>n;
	   ll ar[n];
	   in(ar,n);
	   ll gcd=0;
	   Fo(i,0,n-1)gcd=Gcd(gcd,ar[i]);
	   map<ll,ll> sm_fac;
	  Fo(i,2,N)sm_fac[i]=i;
	 
	   for(ll i=2;i*i<=N;i++)
	   {
	       if(sm_fac[i]!=i)continue;
	       
	       for(ll j=i*i;j<=N;j+=i)
	       {
	           if(sm_fac[j]==j)sm_fac[j]=i;
	       }
	       
	   }
	   
	  map<ll,ll> vis;
	   
	   Fo(i,0,n-1)
	   {
	       ll cur=ar[i];
	       while(cur!=1)
	       {  
	           ll fac=1;
	           fac=sm_fac[cur];
	           // deb(fac);
	           if(vis.find(fac)!=vis.end())
	           {
	               if(gcd==1)cout<<"setwise coprime";
	               else cout<<"not coprime";
	               return 0;
	               
	           }
	           vis[fac]=1;
	           while(fac&&cur%fac==0)cur/=fac;
	          
	           
	       }    
	   
	   }
	   
	   cout<<"pairwise coprime";
	   


	   cout<<endl;
	   
	}
	
    
}

Measured memory_bytes: 73908
MAXN = 1000001
spf = [i for i in range(MAXN)] 
hash1 = [0 for i in range(MAXN)] 

def sieve(): 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, MAXN): 
		if i * i > MAXN: 
			break
		if (spf[i] == i): 
			for j in range(i * i, MAXN, i): 
				if (spf[j] == j): 
					spf[j] = i 

def getFactorization(x): 

	while (x != 1): 
		temp = spf[x] 
		if (x % temp == 0): 

			hash1[spf[x]] += 1
			x = x // spf[x] 

		while (x % temp == 0): 
			x = x // temp 

def hasValidNum(arr, n): 

	sieve() 

	for i in range(n): 
		getFactorization(arr[i]) 

	for i in hash1:
		if(i>1):
			return False
	return True

def gcd(a,b): 
    if (b == 0): 
         return a 
    return gcd(b, a%b) 

n=int(input())
arr=list(map(int,input().split()))
if (hasValidNum(arr, n)): 
	print("pairwise coprime") 
else: 
	g=arr[0]
	for i in range(1,n):
		g=gcd(g,arr[i])
	if(g==1):
		print("setwise coprime") 
	else:
		print("not coprime")

Measured memory_bytes: 210228
s = input()
ans = 'AC'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            ans = 'WA'
    if i == 1 or i == len(s)-1:
        if s[i] not in ascii_lowercase:
            ans = 'WA'
if s[2:-1].count('C') != 1:
    ans = 'WA'
print(ans)

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

using namespace std;

using ll = long long;

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll f[300050], fi[300050];

ll comb(int x, int y) {
    return f[x] * fi[y] % MOD * fi[x - y] % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a, b, K;
    cin >> n >> a >> b >> K;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[n] = modpow(f[n], MOD - 2);
    for (int i = n; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }

    ll ans = 0;
    for (ll i = 0; i <= n; i++) {
        if ((K - a * i) % b != 0) continue;
        ll j = (K - a * i) / b;
        if (j < 0 || j > n) continue;
        (ans += comb(n, i) * comb(n, j) % MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int l = 0, r = s.size() - 1, cnt = 0;
    while (l < r) {
        if (s[l] != s[r]) cnt++;
        l++; r--;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		a := readInt()
		m[a] = true
	}

	if n == len(m) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define mp make_pair
#define ll long long
using namespace std;

int main() {
  
   int n;
   cin>>n;
   int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }  
    int c=0;
    for(int i=1;i<n-1;i++){
        if((a[i]<a[i+1]&&a[i]>a[i-1])||(a[i]>a[i+1]&&a[i]<a[i-1])){
            c++;
        }
    }
    cout<<c;
}

Measured memory_bytes: 256
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#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 INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

int gcd(int a, int b) {
  int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

int gcd3(int a, int b, int c) { return gcd(gcd(a, b), c); }

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

  int K;
  cin >> K;
  int ans = 0;

  REPS(i, K) {
    REPS(j, K) {
      REPS(k, K) { ans += gcd3(i, j, k); }
    }
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
typedef long long int l;
using namespace std;


int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int arr[n],sorgu[q];
    for(int i=0;i<q;i++)
        cin>>sorgu[i];
    for(int i=0;i<n;i++)
        arr[i]=k-q;
    for(int i=0;i<q;i++){
     	arr[sorgu[i]-1]++;
    }
    for(int i=0;i<n;i++){
        if(arr[i]<=0)
					 cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
    }        
    
    return 0;
}

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

int main(){
  int n,m,t,l,i,j,**A;
  scanf("%d",&n);
  A=(int **)malloc(sizeof(int *)*n);
  for(i=0;i<n;i++){
    A[i]=(int *)malloc(sizeof(int)*n);
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&t,&m);
    for(j=0;j<m;j++){
      scanf("%d",&l);
      A[t-1][l-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==n-1){
	if(A[i][j]!=1){
	  printf("0");
	}else printf("%d",A[i][j]);
      }else{
	if(A[i][j]!=1){
	  printf("0 ");
	}else printf("%d ",A[i][j]);
      }
    }
    printf("\n");
  }
  free(A);
  return 0;
}



Measured memory_bytes: 2148
#include<iostream>
#include<set>
#include<cassert>
#include<cmath>
#include<vector>
#include<algorithm>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
 
using namespace std;
 
typedef pair<int,int> ii;
set<string> used;
int cnt = 0;
ii raint[4];
 
void dfs(int cur,int st,string perm)
{
  if(cur >= 8)
    {
      if(used.find(perm) != used.end())return;
      used.insert(perm);
      rep(i,16)if(perm[i] == 'x')return;
    cnt++;
      return;
    }
 
  REP(i,st,16)
    {
      int x = i%4;
      int y = i/4;
      rep(j,4)
    {
      int nx = x + raint[j].first;
      int ny = y + raint[j].second;
      if(!(0 <= nx && nx < 4 && 0 <= ny && ny < 4))continue;
      if(perm[nx+ny*4] != 'x')continue;
      string nperm = perm;
      nperm[x+y*4] = nperm[nx+ny*4] = (char)('0'+cur);
      dfs(cur+1,i+1,nperm);
    }
    }
 
}
 
int main()
{
  while(cin >> raint[0].first,raint[0].first <= 4)
    {
      used.clear();
      cin >> raint[0].second;
      REP(i,1,4)cin >> raint[i].first >> raint[i].second;
      cnt = 0;
      string perm = string(16,'x');
 
      dfs(0,0,perm);
 
      cout << cnt << endl;
    }
}

Measured memory_bytes: 6992
from operator import itemgetter
n = int(input())
tasks = [list(map(int, input().split() )) for _ in range(n)]
tasks.sort(key = itemgetter(1))
# 締切時刻をkeyとしてソート

t = 0
for i in range(n):
	t += tasks[i][0]
	if t > tasks[i][1]:
		print("No")
		exit()

print("Yes")


Measured memory_bytes: 53732
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

struct S{
    int num;
    int p,y;
    int ans;
};

bool compare1(S s1, S s2 ){
    if(s1.p==s2.p)return s1.y<s2.y;
    else return s1.p<s2.p;
}

bool compare2(S s1,S s2){
    return s1.num<s2.num;
}

int main (){ 
    int n,m;
    cin>>n>>m;
    vector<S> v(m);
    rep(i,0,m){
        cin>>v[i].p>>v[i].y;
        v[i].num=i;
    }
    sort(v.begin(),v.end(),compare1);

    int ct=1;
    rep(i,0,m){
        while(i+1<m&&v[i].p==v[i+1].p){
            v[i].ans=ct;
            ct++;
            i++;
        }
        v[i].ans=ct;
        ct=1;
    }

    sort(v.begin(),v.end(),compare2);
    rep(i,0,m){
        printf("%06d%06d\n",v[i].p,v[i].ans);
    }

    return 0;
    
}


/*
1
CH3(1)CH2(1)CH2(1)CH2
*/


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n,m;
    cin2(n,m);
    string a[n];
    ncin1(n,a);
    string b[m];
    ncin1(m,b);

    REPE(i,0,n-m) {
        REPE(j,0,n-m) {
            // i,j を top-left とする位置から一致しているか？
            bool is_ok = true;
            REP(k,0,m) {
                REP(l,0,m) {
                    if (a[i+k][j+l] != b[k][l])
                        is_ok = false;
                }
            }
            if (is_ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N, M, Q = [int(_) for _ in input().split()]
Query = []
for _ in range(M):
    Query += [[int(_) for _ in input().split()] + [0, _]]
for _ in range(Q):
    p, q = [int(_) for _ in input().split()]
    Query += [[p, q + 1, 1, _]]
Query.sort(key=lambda xs: 2 * xs[1] - xs[2])
ans = [0] * Q


class SegmentTree():
    def __init__(self, array, m, e, size):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        m : func
            binary operation of the monoid
        e : 
            identity element of the monoid
        size : int
            limit for array size
        """
        self.m = m
        self.e = e
        self.size = size
        self.n = n = len(array)
        self.dat = dat = [e] * n + array + [e] * (2 * size - 2 * n)
        self.build()

    def build(self):
        dat, n, m = self.dat, self.n, self.m
        for i in range(n - 1, 0, -1):
            dat[i] = m(dat[i << 1], dat[i << 1 | 1])

    def modify(self, p, v):
        """
        set value at position p (0-indexed)
        """
        m, n, dat = self.m, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            dat[p >> 1] = m(dat[p], dat[p ^ 1])
            p >>= 1

    def query(self, l, r):
        """
        result on interval [l, r) (0-indexed)
        """
        m, e, n, dat = self.m, self.e, self.n, self.dat
        res = e
        l += n
        r += n
        while l < r:
            if l & 1:
                res = m(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = m(res, dat[r])
            l >>= 1
            r >>= 1
        return res


e = 0
size = N + 2
ST = SegmentTree([0] * (N + 2), m=lambda x, y: x + y, e=e, size=size)
for l, r, t, i in Query:
    if t:
        ans[i] = ST.query(l, r)
    else:
        ST.modify(l, ST.query(l, l + 1) + 1)
print(*ans, sep='\n')


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

int main() {
	//a 500 b 100 c 50 x kotae
	int a,b,c,x;
	cin >> a >> b >> c >> x;
	int kai = 0;
	for(int i = 0;i <= a;i++)
	{
		int a500 = 500 * i;
		if(a500 == x)
		{
			kai++;
			continue;
		}
		for(int j = 0;j <= b;j++)
		{
			int b100 = 100 * j;
			if(a500 + b100 == x)
			{
				kai++;
				continue;
			}
			for(int k = 0;k <= c;k++)
			{
				int c50 = 50 * k;
				if(a500 + b100 + c50 == x)
				{
					kai++;
					continue;
				}
			}
		}
	}
    cout << kai << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//float con[31][31][101][101]={};
int main(){
    int A,B,C,D,E,F;
    float M = 0;
    int ws=0, s=0;
    cin >> A >> B >> C >> D >> E >> F;
     
    rep(i,31){
        rep(j,31){
            rep(k,101){
                rep(l,101){
                    if(100*A*i+100*B*j+C*k+D*l <=F && 0 < 100*A*i+100*B*j+C*k+D*l){
                        //cout << M << endl;
                        if( (C*k+D*l)*(E+100) <= E*(100*A*i+100*B*j+C*k+D*l) ){
                            if(float(M*(100*A*i+100*B*j+C*k+D*l)) <= float((C*k+D*l)*100)){
                                M = float((C*k+D*l)*100/float(100*A*i+100*B*j+C*k+D*l));
                                ws = 100*A*i+100*B*j+C*k+D*l;
                                s = C*k+D*l;
                            }
                        }
                        //M = max(M, float((C*k+D*l)*100/(100*A*i+100*B*j+C*k+D*l)));
                    }
                    //cout << M;
                }
            }
        }
    }
    //cout<<M<<endl;
    cout << ws << " "<< s << endl;
}


Measured memory_bytes: 256
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
function main()
  n=parse(Int,readline())
  c=chomp(readline())
  allr=count(isequal('R'),c)
  leftw=count(isequal('W'),c[1:allr])
  println(leftw)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 158744