akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  int a[n],b[m],k=0,kk[2]={0,0};
  rep(i,n) {
    R a[i];
    k+=a[i];
  }
  rep(i,m) {
    R b[i];
    kk[i%2]+=b[i];
  }
  int ans=MAX;
  rep(t,2) {
    if(k!=kk[t]) continue;
    int p=!t,d=0;
    int c[n],cc[n],cnt=0;
    rep(i,n) cc[i]=a[i];
    rep(i,m) {
      REP(j,d,d+b[i]) c[j]=p;
      d+=b[i];
      p^=1;
    }
    rep(i,n) {
      int j=i;
      while(j<n && cc[j]!=c[i]) {
        cnt++;
        j++;
      }
      swap(cc[j],cc[i]);
    }
    ans=min(ans,cnt);
  }
  pr(ans);
}

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


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

using namespace std;
 
int main() {
    int a,b;
    string op = "";
    
    cin >> a >> op >> b;
    while(op != "?") {

        if(op == "+") {
            cout << a + b << endl;
        } else if(op == "-") {
            cout << a - b << endl;
        } else if(op == "*") {
            cout << a * b << endl;
        } else if(op == "/") {
            cout << a / b << endl;
        }
        
        cin >> a >> op >> b;
    }
}
    



Measured memory_bytes: 3164
N, M, Q = map(int, input().split())
T = [tuple(map(int, input().split())) for i in range(M)]
queries = [tuple(map(int, input().split())) for i in range(Q)]

plot = [[0] * (N + 1) for i in range(N + 1)]
accum = [[0] * (N + 1) for i in range(N + 1)]
for Li, Ri in T:
    plot[Li][Ri] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        accum[i][j] = accum[i][j - 1] + accum[i - 1][j] \
            - accum[i - 1][j - 1] + plot[i][j]

for pi, qi in queries:
    print(accum[qi][qi] - accum[pi - 1][qi])


Measured memory_bytes: 51504
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'

U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
R = np.zeros((H, W), dtype=int)

for h in range(H):
    U[h] = (U[h - 1] + 1) * S[h]
    D[-(h + 1)] = (D[-h] + 1) * S[-(h + 1)]

for w in range(W):
    L[:, w] = (L[:, w - 1] + 1) * S[:, w]
    R[:, -(w + 1)] = (R[:, -w] + 1) * S[:, -(w + 1)]

print(np.max(U + D + L + R) - 3)


Measured memory_bytes: 217536
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
double a[500];
double b[500];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  b[0] = a[0];
  rep(i, 1, n){
    b[i] = a[i];
    rep(j, i){
      double x = a[j] + a[i];
      double y = abs(a[j] - a[i]);
      double z = sqrt(x * x - y * y);
      chmax(b[i], b[j] + z);
    }
  }
  double res = 0.0;
  rep(i, n) chmax(res, b[i] + a[i]);
  cout << res << endl;
}

Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define mt make_tuple

const int MA = 100001;
unordered_set<int> vis[MA];
vector<pii> G[MA];
int P[2*MA], Q[2*MA], C[2*MA];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        cin >> P[i] >> Q[i] >> C[i];
        G[P[i]].push_back({C[i], Q[i]});
        G[Q[i]].push_back({C[i], P[i]});
    }
    rep(i, N + 1)sort(all(G[i]));

    // dis, pos, line
    deque<tuple<int,int,int> > deq;
    deq.push_back(mt(0,1, 0));
    auto f = [&](int v, int l) {
        return vis[v].count(l);
    };

    while(!deq.empty()) {
        int d, v, line;
        tie(d, v, line) = deq.front();
        deq.pop_front();
        auto p = mp(v, line);
        if(f(v, line))continue;
        vis[v].insert(line);

        if(v == N) {
            cout << d << endl;
            return 0;
        }
        if(line > 0 && !f(v, 0))deq.push_front(mt(d, v, 0));
        
        if(line == 0) {
            each(e, G[v]) {
                int to, nline;
                tie(nline, to) = e;
                if(!f(to, nline))deq.push_back(mt(d + 1, to, nline));
            }
        } else {
            for(auto it = lower_bound(all(G[v]), mp(line, 0)); it != G[v].end() && it->first == line; ++it) {
                int to = it->second;
                if(!f(to, line))deq.push_front(mt(d, to, line));
            }
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 32000
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main() {
	int N;
	cin >> N;

	cout << N*N*N << endl;
}

Measured memory_bytes: 256
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

int main(){
	int n=6;
	LL a[7]={},mn=1LL*mod*mod;
	FOR(i,0,n){
		cin>>a[i];
		if(i!=0)mn=min(mn,a[i]);
	}
	cerr<<mn<<endl;
	LL ans=5;
	ans+=(a[0]+mn-1)/mn-1;
	cout<<ans;

  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
program-id. kyopuro.

data division.
working-storage section.
01 in-str pic x(12).
01 a pic 9(5).
01 b pic 9(5).
01 res pic 999.
01 t pic 9(5).
01 view-res pic zz9.

procedure division.
main.
    accept in-str.
    unstring in-str 
    delimited by all SPACE
    into
        a
        b.
    move 0 to res.
    
    compute t = b - a + 1.
    
    perform t times
        if (a(1 : 1) = a(5 : 1)) and (a(2 : 1) = a(4 : 1))
        then
            add 1 to res
        end-if
        add 1 to a
    end-perform.
    
    move res to view-res.
    display view-res.
    end run.

Measured memory_bytes: 636
x,k,d = list(map(int,input().split()))
#偶数回前後に移動したら0
#偶数回一方向に移動したら2D

if x >= 0:
  capa_iter = x // d
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(x - capa_iter*d)
    else:
      print(min([abs(x - capa_iter*d-d),x - capa_iter*d+d]))
    exit()

  ans =x-d*k
  print(ans)

if x < 0:
  capa_iter = abs(-x // d)
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(abs(x + capa_iter*d))
    else:
      print(min([abs(x + capa_iter*d+d),abs(x + capa_iter*d -  d)]))
    exit()

  ans =abs(x+d*k)
  print(ans)

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

int main(){
    bool card[4][13] = {};
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        char x;
        int num;
        cin >> x >> num;
        if(x == 'S'){
            card[0][num-1] = true;
        }else if (x == 'H'){
            card[1][num-1] = true;
        }else if (x == 'C'){
            card[2][num-1] = true;
        }else if (x == 'D'){
            card[3][num-1] = true;
        }
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(i == 0 && card[i][j] == 0){
                cout << "S" << " " << j+1 << endl;
            }else if (i == 1 && card[i][j] == 0){
                cout << "H" << " " << j+1 << endl;
            }else if (i == 2 && card[i][j] == 0){
                cout << "C" << " " << j+1 << endl;
            }else if (i == 3 && card[i][j] == 0){
                cout << "D" << " " << j+1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<ll> b(n-1);
    
    rep(i, n-1){
        cin >> b[i];
    }
    
    ll result = 0;
    result += b[n-2];
    
    repR(i, n-3){
        result += min(b[i], b[i+1]);
        
        //cout << result << endl;
    }
    
    result += b[0];
    
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    return (a == 0 ? b : gcd(b % a, a));
}

int main() {
    ios::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;

    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
long long kai(int n){
	if(n==0) return 1;
	long long ans;
	ans=n*kai(n-1)%1000000007;
	return ans;
}
int main(){
	int n;
	cin>>n;
	cout<<kai(n)<<endl;
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n,m;
int main()
{
	cin>>n>>m;
	ll res=(max(0ll,n-2))*max(0ll,(m-2));
	if(n==1&&m>2)
		res+=m-2;
	if(m==1&&n>2)
		res+=n-2;
	if(n==1&&m==1)
		res++;
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include"string"
#include"math.h"
using namespace std;

int N;
string S,s;
int main(){
	cin>>N;
	if(N==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=1;i<=N;i++){
		if(N/i<i){
			cout<<(i-1)*(i-1)<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// original: ei1333-san
// https://ei1333.github.io/luzhiled/snippets/string/z-algorithm.html
template <typename T>
vector<int> ZAlgorithm(const T &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j         = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

int main() {
    int n;
    cin >> n;
    vl a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    vi xx(3 * n);
    for (int i = 0; i < 2 * n; ++i) {
        xx[i + n] = a[i % n] ^ a[(i + 1) % n];
    }
    for (int i = 0; i < n; ++i) {
        xx[i] = b[i] ^ b[(i + 1) % n];
    }
    vi pos = ZAlgorithm(xx);
    for (int i = n; i < 2 * n; ++i) {
        if (pos[i] >= n) {
            int x = a[i - n] ^ b[0];
            cout << i - n << " " << x << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++ i)
#define per(i,a,b) for(int i = (a); i >= (b); -- i)
#define pb push_back
#define VI vector<int>
#define VVI vector<VI>
#define Pii pair<int,int>
#define Pll pair<ll,ll>
#define Pli pair<ll,int>
#define fi first
#define se second
#define Ppi pair<Pii,int>
#define VII vector<Pii>

using namespace std;

typedef long long ll;
typedef int (*funI_I) (int);
typedef int (*funI_II) (int, int);

constexpr int N = 4000100;

int n, a[N];
ll R, A, A2;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    rep(i, 1, n) cin >>a[i], A2 += a[i] * a[i], A += a[i];

    auto cal = [&](ll P) {
        return A2 - 2ll * P * A + P * P * n;
    };
    ll ans = 1e18;
    rep(P, 1, 100) {
        ans = min(ans, cal(P));
    }
    cout << ans << "\n";

}
// (a[i]-p)^2 = a[i]^2 - 2 * p * a[i] + p^2
// \sum_i=[1:n] = \sum a[i]^2 - \sum 2 * p * a[i] + \sum p^2

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

using Graph = vector<vector<int> >;
using Weight = vector<vector<int> >;
int color[MAX_N];

// 木上の探索
// v: 現在探索中の頂点、p: v の親 (v が根のときは -1)
void dfs(const Graph &G, const Weight &W, int v, int p) {
    for (int i=0; i<G[v].size(); i++) {
        if (G[v][i] == p) continue; // nv が親 p だったらダメ
        if (W[v][i]%2 == 0){
            color[G[v][i]] = color[v];
        }
        else{
            color[G[v][i]] = 1 - color[v];
        }
        dfs(G, W, G[v][i], v); // v は新たに nv の親になります
    }
}


int main(void){
    int n; cin >> n;

    Graph G(n);
    Weight W(n);
    for(int i=0; i<n; i++){
        color[i] = 0;
    }

    for(int i=0; i<n-1; i++){
        int u,v,w;
        cin >> u >> v >> w;
        G[u-1].push_back(v-1);
        W[u-1].push_back(w);

        G[v-1].push_back(u-1);
        W[v-1].push_back(w);
    }

    int root = G[0][0];
    dfs(G, W, root, -1);

    for(int i=0; i<n; i++){
        cout << color[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 14848
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt(),w=sc.nextInt();
		int[][] a=new int[h][w];
		for(int i=0;i<h;i++) {
			String buff=sc.next();
			for(int j=0;j<w;j++) {
				if(buff.substring(j,j+1).equals("#")) {
					a[i][j]=1;
				}else {
					a[i][j]=0;
				}
			}
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				boolean flag=false;
				if(a[i][j]==1) {
					if(i!=0&&a[i-1][j]==1)flag=true;
					if(j!=0&&a[i][j-1]==1)flag=true;
					if(i!=h-1&&a[i+1][j]==1)flag=true;
					if(j!=w-1&&a[i][j+1]==1)flag=true;
				}
				if(!flag&&a[i][j]==1) {
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		System.out.println("Yes");
	}
}



Measured memory_bytes: 22996
import sys,collections
N,E,r = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
sdw = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param
#sdw = [[src1 dist1 d1][src1 dist1 d1]...]# vect source1 -> distance1 distances
INF = float("inf")
ALL = set(range(N))#including sentinel
distances = collections.defaultdict(lambda:INF)
distances[r] = 0

for _ in range(N):
  modified = False
  for src,dst,weight in sdw:
    if distances[dst] > distances[src] + weight:
      distances[dst] = distances[src] + weight
      modified = True
  if modified == False:
    for i in range(N):
      if distances[i] == INF:
        print("INF")
      else:
        print(distances[i])
    exit()
print("NEGATIVE CYCLE")


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j;
    cin >> n;
    vector<pair<int, int>> v(n);
    double kyori = 0.000000;
    for(i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        v[i] = {x, y};
    }
    double mv_rate = 0.5;
    double max_dist = 0.0;
    double xsv = 0.0;
    double ysv = 0.0;
    double cx = 0.0;
    double cy = 0.0;
    double CONVRGV = 1.0e-9;
    int k = 0;
    bool cvgflg = false;
    while(cvgflg == false) {
        for(int x = 0; x < 100; x++) {
            max_dist = 0.0;
            for(i = 0; i < n; i++) {
                double dist = (v[i].first - cx) * (v[i].first - cx) + (v[i].second - cy) * (v[i].second - cy);
                dist = sqrt(dist);
                if(dist > max_dist) {
                    max_dist = dist;
                    k = i;
                }
            }
            cx += (v[k].first - xsv) * mv_rate;
            cy += (v[k].second - ysv) * mv_rate;
            if(sqrt((cx - xsv) * (cx - xsv) + (cy - ysv) * (cy - ysv)) <= CONVRGV) {
                cx = xsv;
                cy = ysv;
                cvgflg = true;
            }
            xsv = cx;
            ysv = cy;
        }
        mv_rate /= 2.0;
    }
    printf("%.12f\n", max_dist);
    return 0;
}

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

int main(){
  char X, Y;
  scanf("%c %c", &X, &Y);
  if(X>Y)
    printf(">\n");
  else if(X<Y)
    printf("<\n");
  else
    printf("=\n");
}


Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        if(a + b  > n + 1 || ((long)a) * b < (long) n) {
            System.out.println(-1);
            return;
        }
        int c = 0;
        for (int i = 1; i <= a; i++) {
            int num =  Math.min(n - c - (a - i), b);
            for (int j = 0; j < num; j++) {
                System.out.print(c + num - j + " ");
            }
            c += num;
        }
    }
}


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

long long n, a[50], ans;

bool cek(long long x, long long y, long long z){
	vector<long long>v;
	v.push_back(x);
	v.push_back(y);
	v.push_back(z);
	sort(v.begin(),v.end());
	if (v[1]==y) return 1;
	else return 0;
}

int main(){
	ans=0;
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=1;i<n-1;i++){
		if (cek(a[i-1],a[i],a[i+1])) ans++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <map>
using namespace std;


#define ARRAYMAX 2*100000
int person[ARRAYMAX];

#define DEBUG

map<int, int> mp;

int main()
{
    int i, j, k, m;

    
    long long X;
    cin >> X;

    long long n = 100;
    for (i = 1;;i++)
    {
        n = (long long)(n * 1.01);
        if (n >= X)
        {
            break;
        }
    }
     
    cout << i << endl;


    return 0;
}


Measured memory_bytes: 3628
s = int(input())

AM = [0] * 100010
AM[s] = 1
idx = 1
tmp = s
while True:
    if tmp%2 == 0:
       tmp //= 2 
    else:
        tmp = 3*tmp+1
    AM[tmp] += 1
    if AM[tmp] == 2:
        break
    idx += 1
    
print(idx+1)

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
    int sum=0;
    int n; cin >> n;
    vector<int> A(n),B(n);
    for (int i=0; i<n; i++){
        cin >> A[i];
        B[i]=A[i];
    }
    
    sort(A.begin(),A.end());
    for (int i=0; i<n; i++){
        if (A[i]!=B[i] && B[i]-A[i]>=2) sum+=1; 
    }
    if (sum!=0) cout <<"No";
    else cout <<"Yes";
    return 0;
}

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

using namespace std;

template<typename Data, typename T>
struct ReRooting {

    struct Node {
        int to, rev;
        Data data;
    };

    using F1 = function<T(T, T)>;
    using F2 = function<T(T, Data)>;

    vector<vector<Node> > g;
    vector<vector<T> > ldp, rdp;
    vector<int> lptr, rptr;
    const F1 f1;
    const F2 f2;
    const T ident;

    // ident: dp配列の初期値
    // f2: 子頂点のDP配列の値を処理する演算
    // f1: f2で処理された値をDP配列にマージする演算
    ReRooting(int n, const F1 &f1, const F2 &f2, const T &ident) :
            g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}

    void add_edge(int u, int v, const Data &d) {
        g[u].emplace_back((Node) {v, (int) g[v].size(), d});
        g[v].emplace_back((Node) {u, (int) g[u].size() - 1, d});
    }

    void add_edge_bi(int u, int v, const Data &d, const Data &e) {
        g[u].emplace_back((Node) {v, (int) g[v].size(), d});
        g[v].emplace_back((Node) {u, (int) g[u].size() - 1, e});
    }


    T dfs(int idx, int par) {
        while (lptr[idx] != par && lptr[idx] < g[idx].size()) {
            auto &e = g[idx][lptr[idx]];
            ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), e.data));
            ++lptr[idx];
        }
        while (rptr[idx] != par && rptr[idx] >= 0) {
            auto &e = g[idx][rptr[idx]];
            rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), e.data));
            --rptr[idx];
        }
        if (par < 0) return rdp[idx][0];
        return f1(ldp[idx][par], rdp[idx][par + 1]);
    }

    vector<T> solve() {
        for (int i = 0; i < g.size(); i++) {
            ldp[i].assign(g[i].size() + 1, ident);
            rdp[i].assign(g[i].size() + 1, ident);
            lptr[i] = 0;
            rptr[i] = (int) g[i].size() - 1;
        }
        vector<T> ret;
        for (int i = 0; i < g.size(); i++) {
            ret.push_back(dfs(i, -1));
        }
        return ret;
    }
};

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

    int n;
    cin >> n;

    auto f2 = [&](vector<int> a, int d) -> vector<int> {
        a[0] += d;
        a[1] = 0;
        return a;
    };
    auto f1 = [&](vector<int> a, const vector<int> b) -> vector<int> {
        for (int c : b) a.push_back(c);
        sort(a.rbegin(), a.rend());
        a.pop_back();
        a.pop_back();
        return a;
    };

    ReRooting<int, vector<int>> g(n, f1, f2, {0, 0});
    for (int i = 0; i < n - 1; i++) {
        int a, b, w;
        cin >> a >> b >> w;
        g.add_edge(a, b, w);
    }
    int ans = 0;
    for (auto &p : g.solve()) {
        ans = max(ans, p[0] + p[1]);
    }
    cout << ans << endl;
}



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

int main() {
  string n;
  cin >> n;
  
  int i;
  for(i = 0; i < 3; i++){
    if(n.at(i) == '1'){
      n.at(i) = '9';
    }
    else if(n.at(i) == '9'){
      n.at(i) = '1';
    }
  }
  
  cout << n << endl;
}


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

int main(){
	set<int> st;
	int a;
	rep(i,3){
		cin>>a;
		st.insert(a);
	}
	cout<<st.size()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
string saiki(vector<vector<char>> a,int n,int m,vector<int> c){
    if(c[0] == n-1 && c[1] == m-1){
        if(a[c[0]-1][c[1]] == '#' && a[c[0]][c[1]-1] == '#'){
            return "Impossible";
        }
        else{
        return "Possible";
        }
    }
    else{
        if(c[0] != 0 && c[1] != 0 && a[c[0]-1][c[1]] == '#' && a[c[0]][c[1]-1] == '#'){
            return "Impossible";
        }
        else{
        if(a[c[0] + 1][c[1]] == '#' && a[c[0]][c[1] + 1] != '#'){
            c[0]++;
            return saiki(a,n,m,c);
        }
        else if(a[c[0] + 1][c[1]] != '#' && a[c[0]][c[1] + 1] == '#'){
            c[1]++;
            return saiki(a,n,m,c);
        }
        else{
            return "Impossible";
        }
        }
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<char>> a;
    vector<char> b;
    for(int i = 0;i<=n;i++){
        for(int j = 0;j<=m;j++){
            b.push_back('r');
        }
        a.push_back(b);
    }
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            cin >> a[i][j];
        }
    }
    vector<int> c = {0,0};
    if(a[0][0] != '#'){
        cout << "Impossible";
    }
    else{
    string ans = saiki(a,n,m,c);
    cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
 
struct node { int t,next; }a[400010],a1[400010];
 
int fa[200010],son[200010],top[200010],dep[200010],dfn[200010],pid[200010],size[200010];
int head[200010],head1[200010],dep1[200010],f[200010],n,s1,s2,cl,ans,tot,tot1;
bool flag;
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }
 
inline void add1(int x,int y) { a1[++tot1].t=y;a1[tot1].next=head1[x];head1[x]=tot1; }
 
inline int lca(int x,int y)
{
    for (;top[x]!=top[y];x=fa[top[x]]) if (dep[top[x]]<dep[top[y]]) swap(x,y);
    if (dep[x]>dep[y]) swap(x,y);
    return x;
}
 
inline int get_dis(int x,int y) { return dep[x]+dep[y]-dep[lca(x,y)]*2; }
 
inline int up(int x,int y)
{
    for (;dep[x]-dep[top[x]]+1<=y;x=fa[top[x]]) y-=dep[x]-dep[top[x]]+1;
    return pid[dfn[x]-y];
}
 
inline int work(int x,int y)
{
    int hh=lca(x,y);
    if (hh!=x) return fa[x];
    return up(y,dep[y]-dep[x]-1);
}
 
inline void dfs1(int x)
{
    size[x]=1;
    for (int i=head[x];i;i=a[i].next)
    {
        int t=a[i].t;
        if (t==fa[x]) continue;
        dep[t]=dep[x]+1;
        fa[t]=x;dfs1(t);
        size[x]+=size[t];
        if (size[t]>size[son[x]]) son[x]=t;
    }
}
 
inline void dfs2(int x,int tp)
{
    dfn[x]=++cl;pid[cl]=x;top[x]=tp;
    if (son[x]) dfs2(son[x],tp);
    for (int i=head[x];i;i=a[i].next)
    {
        int t=a[i].t;
        if (t==fa[x]||t==son[x]) continue;
        dfs2(t,t);
    }
}
 
inline void dfs(int x,int y)
{
    for (int i=head1[x];i;i=a1[i].next)
    {
        int t=a1[i].t;
        if (t==y) continue;
        int hh=get_dis(x,t);
        if (hh>2&&x!=f[x]) { flag=true;return; }
        if (t==f[x]|x==f[x]) continue;
        f[t]=work(f[x],t);
        dep1[t]=dep1[x]+1;
        dfs(t,x);
        if (flag) return;
    }
    ans=max(ans,(get_dis(f[x],x)+dep1[x])<<1);
}
 
int main()
{
    n=rd();s1=rd();s2=rd();
    if (s1==s2) { puts("0");return 0; }
    tot=tot1=0;
    for (int i=1;i<n;i++) { int x=rd(),y=rd();add1(x,y);add1(y,x); }
    for (int i=1;i<n;i++) { int x=rd(),y=rd();add(x,y);add(y,x); }
    cl=0;dfs1(s2);dfs2(s2,s2);
    f[s1]=s2;ans=0;flag=false;dfs(s1,0);
    if (!flag) printf("%d\n",ans);
    else puts("-1");
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

// 3乗で通したお詫びにO(NlogN)で通します
// 参考 : https://twitter.com/SayakaAmemiya/status/1249515024541859842

template<int mod, int proot> struct NTT {
	int get_mod() { return mod; }
	int pow(int a, int b) {
	int res = 1;
		for (; b; b >>= 1) {
			if (b & 1) res = (int64_t) res * a % mod;
			a = (int64_t) a * a % mod;
		}
		return res;
	}
	int inv(int i) { return pow(i, mod - 2); }
	void ntt(std::vector<int> &a, bool inverse) {
		int n = a.size();
		assert((n & -n) == n);
		int h = pow(proot, (mod - 1) / n);
		if (inverse) h = inv(h);
		
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k > (i ^= k); k >>= 1);
			if (j < i) std::swap(a[i], a[j]);
		}
		for (int i = 1; i < n; i <<= 1) {
			int base = pow(h, n / i / 2);
			int w = 1;
			
			std::vector<int> ws(i);
			for (int j = 0; j < i; j++) ws[j] = w, w = (int64_t) w * base % mod;
			
			for (int j = 0; j < n; j += i << 1) {
				for (int k = 0; k < i; k++) {
					int u = a[k + j];
					int d = (int64_t) a[k + j + i] * ws[k] % mod;
					a[k + j] = u + d >= mod ? u + d - mod : u + d;
					a[k + j + i] = d > u ? u + mod - d : u - d;
				}
			}
		}
		if (inverse) {
			int ninv = inv(a.size());
			for (auto &i : a) i = (int64_t) i * ninv % mod;
		}
	}
};

int main() {
	int n = ri();
	std::vector<int> sum[3];
	for (auto &i : sum) i.resize(n + 1);
	std::vector<int> a(n);
	{
		std::string tmp;
		std::cin >> tmp;
		for (int i = 0; i < n; i++) {
			a[i] = tmp[i] == 'R' ? 0 : tmp[i] == 'G' ? 1 : 2;
			sum[a[i]][i + 1]++;
		}
	}
	for (int i = 0; i < 3; i++) for (int j = 0; j < n; j++) sum[i][j + 1] += sum[i][j];
	
	int64_t res = 0;
	// j - i != k - jを無視したの
	for (int j = 0; j < n; j++) {
		auto &r0 = sum[(a[j] + 1) % 3];
		auto &r1 = sum[(a[j] + 2) % 3];
		res += (int64_t) r0[j] * (r1[n] - r1[j + 1]);
		res += (int64_t) r1[j] * (r0[n] - r0[j + 1]);
	}
	// j - i == k - jで相異なるものを引く
	int n2 = 1;
	for (; n2 < n + n - 1; n2 <<= 1);
	NTT<998244353, 3> ntt;
	std::vector<int> count[3];
	for (auto &i : count) i.resize(n2);
	for (int i = 0; i < n; i++) count[a[i]][i]++;
	for (auto &i : count) ntt.ntt(i, false);
	
	std::vector<int> conved[3][3];
	for (int i = 0; i < 3; i++) {
		auto &cur = conved[i][(i + 1) % 3];
		cur.resize(n2);
		for (int j = 0; j < n2; j++) cur[j] = (int64_t) count[i][j] * count[(i + 1) % 3][j] % 998244353;
		ntt.ntt(cur, true);
	}
	for (int j = 0; j < n; j++) res -= conved[(a[j] + 1) % 3][(a[j] + 2) % 3][j + j];
	
	printf("%" PRId64 "\n", res);
	
	return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define ll long long
#define pii pair < ll , ll >
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;


int main(){
   ll x;
   cin >> x;
   int f = 0;
   for(int a = -118 ; a <= 119; a++){
        for(int b = a - 1; b >= -118; b--){
                if(x == (ll)pow(a,5) - (ll)pow((b),5)){
                cout << a<<" "<<b;
                f = 1;
                break;
                }
        }
        
        if(f)break;
   }


}

Measured memory_bytes: 4016
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <functional>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
	int n;
	cin >> n;
  if (n % 2) {
    cout << n/2 +1 << endl;
  } else {
    cout << n/2 << endl;
  }
  return 0;
}

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

int main()
{
    ll l, n;
    cin >> l >> n;
    ll lx[200002], rx[200002];
    for(int i = 0; i < n; i++){
        cin >> lx[i];
        rx[n - 1 - i] = l - lx[i];
    }
    ll ans = 0;
    
    ll sum = lx[0];
    for(int i = 1; i <= n / 2; i++){
        if(i * 2 == n) continue;
        sum = sum - rx[n - 1 - i] * 2 + rx[n - i * 2] * 2 + rx[n - i * 2 - 1] * 2 + lx[i - 1] + lx[i];
        ans = max(ans, sum);
    }
    for(int i = n / 2; i < n; i++){
        if(i * 2 < n) continue;
        if(i * 2 == n){
            sum = sum + rx[0] * 2 - lx[i * 2 - n] * 2 - rx[n - 1 - i] * 2 + lx[i - 1] + lx[i];
            ans = max(ans, sum);
            continue;
        }
        sum = sum - lx[i * 2 - n - 1] * 2 - lx[i * 2 - n] * 2 - rx[n - 1 - i] * 2 + lx[i - 1] + lx[i];
        ans = max(ans, sum);
    }
    
    sum = lx[0] * 2 + rx[n - 2];
    for(int i = 2; i <= n / 2; i++){
        sum = sum + lx[i - 1] * 2 + rx[n - i * 2 + 1] * 2 + rx[n - i * 2] * 2 - rx[n - i] - rx[n - 1 - i];
        ans = max(ans, sum);
    }
    for(int i = n / 2 + 1; i < n; i++){
        if(i * 2 == n + 1){
            sum = sum + rx[0] * 2 - lx[i * 2 - n - 1] * 2 + lx[i - 1] * 2 - rx[n - i] - rx[n - 1 - i];
            ans = max(ans, sum);
            continue;
        }
        sum = sum - lx[i * 2 - n - 2] * 2 - lx[i * 2 - n - 1] * 2 + lx[i - 1] * 2 - rx[n - i] - rx[n - 1 - i];
        ans = max(ans, sum);
    }
    
    sum = rx[0];
    ans = max(ans, sum);
    for(int i = 1; i <= n / 2; i++){
        if(i * 2 == n) continue;
        sum = sum - lx[n - 1 - i] * 2 + lx[n - i * 2] * 2 + lx[n - i * 2 - 1] * 2 + rx[i - 1] + rx[i];
        ans = max(ans, sum);
    }
    for(int i = n / 2; i < n; i++){
        if(i * 2 < n) continue;
        if(i * 2 == n){
            sum = sum + lx[0] * 2 - rx[i * 2 - n] * 2 - lx[n - 1 - i] * 2 + rx[i - 1] + rx[i];
            ans = max(ans, sum);
            continue;
        }
        sum = sum - rx[i * 2 - n - 1] * 2 - rx[i * 2 - n] * 2 - lx[n - 1 - i] * 2 + rx[i - 1] + rx[i];
        ans = max(ans, sum);
    }
    
    sum = rx[0] * 2 + lx[n - 2];
    for(int i = 2; i <= n / 2; i++){
        sum = sum + rx[i - 1] * 2 + lx[n - i * 2 + 1] * 2 + lx[n - i * 2] * 2 - lx[n - i] - lx[n - 1 - i];
        ans = max(ans, sum);
    }
    for(int i = n / 2 + 1; i < n; i++){
        if(i * 2 == n + 1){
            sum = sum + lx[0] * 2 - rx[i * 2 - n - 1] * 2 + rx[i - 1] * 2 - lx[n - i] - lx[n - 1 - i];
            ans = max(ans, sum);
            continue;
        }
        sum = sum - rx[i * 2 - n - 2] * 2 - rx[i * 2 - n - 1] * 2 + rx[i - 1] * 2 - lx[n - i] - lx[n - 1 - i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

int main(void){
  int n, m, id[114514][2];
  vector<pair<int, int>> cnt[114514];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int p, y;
    scanf("%d%d", &p, &y);
    cnt[p - 1].push_back({y, i});
  }
  for (int i = 0; i < n; i++) {
    sort(cnt[i].begin(), cnt[i].end());
    for (int j = 0; j < cnt[i].size(); j++) {
      id[cnt[i][j].second][0] = i + 1;
      id[cnt[i][j].second][1] = j + 1;
    }
  }
  for (int i = 0; i < m; i++)
    printf("%06d%06d\n", id[i][0], id[i][1]);
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int W, H;
ll ps[100000], qs[100000];

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

    std::cin >> W >> H;
    for(int i=0;i<W;++i){
        std::cin >> ps[i];
    }

    for(int j=0;j<H;++j){
        std::cin >> qs[j];
    }

    sort(ps, ps+W);
    sort(qs, qs+H);
    
    int cur_x = W + 1, cur_y = H + 1;
    ll res = 0;
    for(int i=0,j=0;i<W||j<H;){
        if(j == H || (i < W && ps[i] < qs[j])){
            res += ps[i] * cur_y;
            ++i;
            --cur_x;

            // std::cout << "choose1: " << ps[i] << std::endl;
        }else{
            res += qs[j] * cur_x;
            ++j;
            --cur_y;
            
            // std::cout << "choose2: " << qs[j] << std::endl;
        }
    }

    std::cout << res << std::endl;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
typedef long long lglg;
 
int N, T;
pair<int, int> dishes[3012];
int dp[3012][3012][2];
int search(int n, int t, int flag) {
    if (n == 0) return 0;
    if (t == 0) {
        if (flag == 0) return 0;
        return dishes[n-1].first;
    }
    if (dp[n][t][flag] != -1) return dp[n][t][flag];
    int val;
    int notinc = search(n-1, t, 0) + (flag ? dishes[n-1].first : 0);
    if (dishes[n-1].second > t) val = notinc;
    else val = max(notinc, dishes[n-1].first + search(n-1, t-dishes[n-1].second, flag));
    dp[n][t][flag] = val;
    return val;
}
 
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    for (int i=0; i<3012; ++i) dishes[i] = {4000, 4000};
    for (int i=0; i<3012; ++i) for (int j=0; j<3012; ++j) for (int k=0; k<2; ++k) dp[i][j][k] = -1;

    cin >> N >> T;
    for (int i=0; i<N; ++i) {
        int a, b; cin >> a >> b;
        dishes[i] = {b, a};
    }

    sort(dishes, dishes+3012);

    int val = search(N, T-1, 1);
    cout << val;
}

Measured memory_bytes: 71424
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main()
{
	//int h, w,   q, D, ax[90001], ay[90001], l[100000], r[100000];
	long long int  a, b, c, d, e, ans = 0;
	//string a, b, c;

	cin >> a >> b;
	
	//	cout << a[0]<<b[1]<<c[2] << endl;
	if (a==1)
	{
		if (b==1)
		{
			cout << 1 << endl;

		}
		else
		{
			cout << b-2 << endl;

		}
	}
	else if(b==1)
	{
			cout << a - 2 << endl;
	}
	else
	{
		cout << (a - 2)*(b - 2) << endl;
	}






	// 出力
	return 0;
}

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

int main() {
  long long N;
  long long M;
  cin >> N >> M;
  
  int A[M];

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

cout << N;
return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)    cin>>a[i];
    sort(a,a+n,greater<>());
    int alice=0,bob=0;
    rep(i,n){
        if(i%2==0)  alice+=a[i];
        else        bob+=a[i];
    }
    cout<<(alice-bob)<<endl;
    return 0;
}


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

int m[12][12];

void dfs(int r, int c) {
  m[r][c] = 2;
  if (r && m[r-1][c]==1) dfs(r-1, c);
  if (r<11 && m[r+1][c]==1) dfs(r+1, c);
  if (c && m[r][c-1]==1) dfs(r, c-1);
  if (c<11 && m[r][c+1]==1) dfs(r, c+1);
}

int main() {
  char buf[15];
  int c;

  while (1) {
    c = 0;
    for (int i=0; i<12; i++) {
      cin >> buf;
      for (int j=0; j<12; j++) {
        m[i][j] = buf[j] - '0';
      }
    }
    if (cin.eof()) break;

    for (int i=0; i<12; i++) {
      for (int j=0; j<12; j++) {
        if (m[i][j]==1) {
          dfs(i, j);
          ++c;
        }
      }
    }
    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define f first
#define s second
#define all(a) a.begin(),a.end()
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 2005
#define mod 1000000007
#define inf 1e17
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

int32_t main()
{
   // boost
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a,b;
        cin>>a>>b;
        if((a%n==0||b%n==0)||(a/n!=b/n))
        {
            cout<<"OK";        }
    else
    {
        cout<<"NG";
    }
    }
    


    

}

Measured memory_bytes: 3616
N = input()
A, B, C = [input() for _ in range(3)]
ans = 0
for a, b, c in zip(A, B, C):
    if a == b == c:
        continue
    elif a != b and b != c and c != a:
        ans += 2
    elif a == b or b == c or c == a:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    vector<long long> num(5);
    vector<long long> mm(5,0);
    long long N;
    long long time = 0;
    cin >> N;
    for(int i = 0 ; i < 5 ; i++){
        cin >> num[i];
    }
    long long min = *std::min_element(num.begin(), num.end());
    if (min >= N){cout << 5 << endl; return 0;}
    std::vector<long long>::iterator minIt = std::min_element(num.begin(), num.end());
    time += N / min;
    if (N % min > 0) time++;
    size_t minIndex = std::distance(num.begin(), minIt);
    // i = minIndex;
    time += 4;
    cout << time << endl;
}

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

int main(){
  ll n;
  std::map<ll, ll> m;
  std::vector<ll> ch;

  std::vector<ll> ls;
  std::cin >> n;

  rep(i,n){
    ll temp;
    std::cin >> temp;
    ch.push_back(temp);

    if(m[temp]==0)ls.push_back(temp);
    m[temp]++;
  }

  ll sum=0;
  rep(i,ls.size()){
    if(m[ls[i]]>=2)sum+=m[ls[i]]*(m[ls[i]]-1)/2;
  }
  
  for (ll num : ch) {
    ll ans=0;
    ans+=sum;

    if(m[num]>=2){
      ans-=m[num]*(m[num]-1)/2;
      ans+=(m[num]-1)*(m[num]-2)/2;
    }

    std::cout << ans << '\n';
  }




  return 0;
}


Measured memory_bytes: 12004
#include<stdio.h>
int main(void){
	int n,i,x;
	scanf("%d",&n);
	for(i=3;i<n+1;i++){
		if(i%3==0){
			printf(" %d",i);
		}
		else{
			x=i;
			while(1){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				else if(x==0){
					break;
				}
				x=x/10;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n=ip()
h=linp()
ans=1
for i in range (1,n):
    f=True
    for j in range(i):
        if h[i]<h[j]:f=False
    if f==True:ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main () {
  int N,K,X,Y;
  cin>>N;
  cin>>K;
  cin>>X;
  cin>>Y;
  int n=0;
  int i;
  for(i=1;i<=N;++i){
    n+=i>=K+1?Y:X;
  }
  cout << n;
}


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

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for (int i=0;i<m;i++){
        cin >> b.at(i);
    }
    vector<int> tmp;
    string ans = "No";
    for (int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            int cnt =0;
            for (int k=0;k<m;k++){
                for (int l=0;l<m;l++){
                    if(a[i+k].at(j+l)==b[k].at(l))
                        cnt++;
                }
            }
            if(cnt==m*m){
                ans = "Yes";
            }
        }
    }

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

Measured memory_bytes: 256