akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector< vector<P> > g(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, i - 1);
        g[b].emplace_back(a, i - 1);
    }

    int maxc = 0;
    for (int i = 0; i < n; i++) {
        maxc = max(maxc, (int)g[i].size());
    }

    vector<int> ans(n - 1, -1);
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int cur = q.front();
        q.pop();

        vector<int> v;
        for (P& e : g[cur]) {
            if (ans[e.second] == -1) continue;
            v.push_back(ans[e.second]);
        }
        sort(v.begin(), v.end());

        int col = 0, idx = 0;
        for (P& e : g[cur]) {
            if (ans[e.second] != -1) continue;
            while (idx < v.size()) {
                if (v[idx] == col) {
                    col++;
                    idx++;
                }
                else break;
            }
            ans[e.second] = col;
            col++;
            q.push(e.first);
        }
    }

    cout << maxc << "\n";
    for (int i = 0; i < n - 1; i++) {
        cout << ans[i] + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 7040
import sys
A,B,K = map(int,input().split())

if not ( 0 <= A <= 10**12 and 0 <= B <= 10**12 and 0 <= K <= 10**12 ): sys.exit()
if not ( isinstance(A,int) and isinstance(B,int) and isinstance(K,int) ): sys.exit()

if K >= A:
    if (K - A) >= B:
        B = 0
    elif (K - A) < B:
        B = B - (K - A)
    A = 0
elif K < A:
    A = A - K
print(A,B)

Measured memory_bytes: 9112
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

#define ll long long int
using namespace std;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int rgb[3][4005];
	int rgb_c[3] = {};
	bool flag[3] = {};


	int n;
	cin >> n;
	string str;
	cin >> str;
	ll count = 0;
	for (int i = n - 1; i >= 0; i--) {
		switch (str[i]) {
		case 'R':
			rgb_c[0] += 1;
			break;
		case 'G':
			rgb_c[1] += 1;
			break;
		case 'B':
			rgb_c[2] += 1;
			break;
		}
		rgb[0][i] = rgb_c[0];
		rgb[1][i] = rgb_c[1];
		rgb[2][i] = rgb_c[2];
	}
	


	for (int i = 0; i < n-2; i++) {
		for (int j = i+1; j < n-1; j++) {
			switch (str[i]) {
			case 'R':
				flag[0] = true;
				break;
			case 'G':
				flag[1] = true;
				break;
			case 'B':
				flag[2] = true;
				break;
			}
			switch (str[j]) {
			case 'R':
				flag[0] = true;
				break;
			case 'G':
				flag[1] = true;
				break;
			case 'B':
				flag[2] = true;
				break;
			}

			if (flag[0] && flag[1]) {
				count += rgb[2][j + 1];
				if (2*j-i<n &&str[2 * j + -i] == 'B')count--;
			}
			if (flag[1] && flag[2]) {
				count += rgb[0][j + 1];
				if (2 * j - i < n && str[2 * j + -i] == 'R')count--;
			}
			if (flag[2] && flag[0]) {
				count += rgb[1][j + 1];
				if (2 * j - i < n && str[2 * j + -i] == 'G')count--;
			}
			flag[0] = false;
			flag[1] = false;
			flag[2] = false;
		}
	}

	cout << count << endl;








	return 0;
}


Measured memory_bytes: 3660
N = gets.to_i
array = ("1".."#{N}").to_a.reject { |n| n[-1] == "0" }
cij = Array.new(9) { Array.new(9, 0) }
count = 0

array.each do |n|
    if n.to_i < 10
        cij[n.to_i - 1][n.to_i - 1] += 1
    else
        cij[n[0].to_i - 1][n[-1].to_i - 1] += 1
    end
end

9.times do |i|
    9.times do |j|
        count += cij[i][j] * cij[j][i]
    end
end

puts count

Measured memory_bytes: 17788
#include <stdio.h>


int main(){
	int a[101],i,n,j=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	for(i=0;i<n;i++){
		if(a[i]==a[i+1]){
			a[i+1]=0;
			j=j+1;
		}
	}
	printf("%d\n",j);
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int d,g;
cin>>d>>g;
vector<pair<int,int>> p_c;
rep(i,d){
    int p,c;
    cin>>p>>c;
    p_c.pb(mp(p,c));
}
int n=pow(2,d);
int total;
int cnt;
int min_cnt=10000;
vector<int> idx;
rep(i,n){
    total=0;
    cnt=0;
    idx.clear();
    rep(j,d){
        if(i&(1<<j)){
            total+=p_c[j].first*(j+1)*100+p_c[j].second;
            cnt+=p_c[j].first;
        }
        else{
            idx.pb(j);
        }
    }
    if(g-total>0){
        //残ったインデックスの中で最大のものを中途半端に解く
        sort(idx.begin(),idx.end(),greater<int>());
        rep(k,p_c[idx[0]].first-1){
                total+=(idx[0]+1)*100;
                cnt++;
                if(g-total<=0){
                    break;
                }
            }
    }
    if(g-total<=0) min_cnt=min(min_cnt,cnt);
    
    // }
}
cout<<min_cnt<<endl;

//system("pause");
return 0;
}

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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 25164
#include <bits/stdc++.h>
using namespace std;
#define N 100000
int main() {
	int n;
	long long int k;
	cin>>n>>k;
	long long int hoge[N]={};
	int a,b;
	for(int i=0;i<n;i++){
		
		cin>>a>>b;
		hoge[a-1]+=b;
	}
 	for(int i=0;i<N;i++){
 		k=k-hoge[i];
 		if(k<=0){
 			cout<<i+1<<endl;
 			break;
 		}
 	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int a[5]={0},i,j,tmp=0;
  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<5;i++){
    for(j=i+1;j<5;j++){
      if(a[i]<a[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }
  for(i=0;i<5;i++){
    if(i==4){
      printf("%d\n",a[i]);
    }
    else{
      printf("%d ",a[i]);
    }
  }
  return 0;
}
  

Measured memory_bytes: 596
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

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

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=300300;
int frqx[N], frqy[N];
set<int>s[N];
bool vis[N];

int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0 ; i<k ; i++){
        int x,y;
        scanf("%d%d",&x,&y);
        frqx[x]++;
        frqy[y]++;
        s[y].insert(x);
    }

    int mx=0;
    for(int i=0 ; i<N ; i++)
        mx=max(mx, frqx[i]);

    set<int>smx;
    for(int i=0 ; i<N ; i++){
        if(frqx[i] == mx)
            smx.insert(i);
    }

    int res=mx, ans=0;
    mx=0;
    for(int i=0 ; i<N ; i++){
        int cnt=0;
        for(auto x:s[i]){
            if(smx.count(x)){
                if(vis[x]) continue;
                vis[x]=1;
                cnt++;
            }
        }

        for(auto x:s[i])
            vis[x]=0;

        int f=0;
        if(cnt == smx.size())
            f=1;

        ans=max(ans, res+frqy[i]-f);
    }

    printf("%d\n",ans);

}


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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> B, W;
    int cnt = 1;
    for(int i = 1; i < n; i++){
        if(s[i - 1] == s[i]){
            cnt++;
            if(i == n - 1){
                if(s[i - 1] == '0'){
                    B.push_back(cnt);
                }else{
                    W.push_back(cnt);
                }
            }
        }else{
            if(s[i - 1] == '0'){
                B.push_back(cnt);
            }else{
                W.push_back(cnt);
            }
            cnt = 1;
        }
    }
    if(cnt == 1){
        if(s[n - 1] == '0'){
            B.push_back(cnt);
        }else{
            W.push_back(cnt);
        }
    }

    if(B.size() <= k){
        cout << n << endl;
        return 0;
    }

    int ans = 0;
    vector<int> Ba, Wa;
    Ba.push_back(0);
    Wa.push_back(0);
    for(int i = 0; i < B.size(); i++){
        Ba.push_back(Ba[Ba.size() - 1] + B[i]);
    }
    for(int i = 0; i < W.size(); i++){
        Wa.push_back(Wa[Wa.size() - 1] + W[i]);
        ans = max(ans, W[i]);
    }

    if(Ba.size() > Wa.size()){
        for(int i = k; i < Ba.size(); i++){
            if(i == Ba.size() - 1){
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[(int)Wa.size() - 1] - Wa[(int)Wa.size() - 1 - k]);  
            }else if(i == k){
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[i] - Wa[0]);
            }else{
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[min(i, (int)Wa.size() - 1)] - Wa[max(0, i - k - 1)]);            
            }
        }
    }else if(Ba.size() < Wa.size()){
        for(int i = k; i < Ba.size(); i++){
            if(i == Ba.size() - 1){
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[max(i + 1, (int)Ba.size() - 1)] - Wa[i - k]);  
            }else if(i == k){
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[max(i, min(i + 1, (int)Wa.size() - 1))] - Wa[0]);   
            }else{
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[min(i + 1, (int)Wa.size() - 1)] - Wa[max(0, i - k)]);            
            }
        }
    }else{
        for(int i = k; i < Ba.size(); i++){
            // cout << ans << endl;
            if(i == Ba.size() - 1){
                if(s[n - 1] == '0') ans = max(ans, Ba[i] - Ba[i - k] + Wa[i] - Wa[max(0, i - k)]);
                else ans = max(ans, Ba[i] - Ba[i - k] + Wa[i] - Wa[max(0, i - k - 1)]);
            }else if(i == k){
                if(s[0] == '0'){
                    ans = max(ans, Ba[i] - Ba[i - k] + Wa[i] - Wa[0]);
                }else{
                    ans = max(ans, Ba[i] - Ba[i - k] + Wa[max(i, min(i + 1, (int)Wa.size() - 1))] - Wa[0]);   
                }
            }else{
                ans = max(ans, Ba[i] - Ba[i - k] + Wa[min(i + 1, (int)Wa.size() - 1)] - Wa[max(0, i - k)]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  for (int i = 0; i < K; i++) {
    if (A < B && B < C)
      break;
    else if (A >= B) {
      B *= 2;
      continue;
    }
    else if (B >= C) {
      C *= 2;
      continue;
    }
  }
  if (A < B && B < C) 
      cout << "Yes" << endl;
  if (A >= B || B >= C)
    cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

class UnionFind{
  public:
    //親の番号を格納．親の場合は-(その集合のサイズ)
    vector<int> Parent;
    //親との距離
    vector<int> Distance;
    //作るときはParentの値をすべて-1にする
    UnionFind(int N){
      Parent = vector<int>(N,-1);
      Distance = vector<int>(N,0);
    }

    //親を求める
    int find(int x){
      if(Parent[x] < 0) return x;
      //親の紐づけを変更
      //int p = Parent[x];
      //int fp = find(Parent[x]);
      //int d = Distance[p];
      if(Parent[x] != find(Parent[x])) Distance[x] += Distance[Parent[x]]; 
      return Parent[x] = find(Parent[x]);
    }

    //xの属する集合のサイズを取ってくる
    int size(int x){
      return -Parent[find(x)];
    }

    //2点間の距離を計算
    //xからみてy
    int getDistance(int x,int y){
      find(x);
      find(y);
      return  Distance[y] - Distance[x];
    }

    //xとyの属する集合を併合
    //併合できたらtrue，すでに併合していたらfalse 
    bool unite(int x, int y, int d){
      //xとyを直接つけない，親同士をつける
      d += Distance[x] - Distance[y];
      x = find(x);
      y = find(y);
      if(x==y) return false;

      //大きいほうに小さいほうをくっつける
      if(size(x) < size(y)){
        swap(x,y);
        d *= -1;
      }

      //xのサイズを更新
      Parent[x] += Parent[y];
      Parent[y] = x;
      Distance[y] = d;
      return true;
    }

    //xとyが同じ集合に属するか
    bool same(int x, int y){
      return find(x) == find(y);
    }
};
int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  UnionFind uni =  UnionFind(N);
  bool isExist = true;
  rep(i,M){
    int L,R,D;cin >> L >> R >> D;
    L--;R--;
    if(uni.same(L,R)){ 
      if(uni.getDistance(L,R) != D){
        isExist = false;
        break;
      }
    } else uni.unite(L,R,D);
  }
  YesNo(isExist);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

int main() {
  int s[4];
  string tar;
  cin >> tar;

  REP(i,4) {
    s[i] = tar[i] - '0';
  }

  for (int i = 0; i < 8; ++i) {
    int sum = s[0];
    string ope;
    bool flag[3];
    REP(loop,3) flag[loop] = false;

    int bin = i, count = 0;
    while (bin > 0) {

      if (bin % 2) {
        flag[count] = true;
      }

      bin /= 2;
      count++;

    }

    for (int j = 0; j < 3; ++j) {
      if (flag[j]) {
        sum += s[j+1];
        ope += '+';
      } else {
        sum -= s[j+1];
        ope += '-';
      }
    }

    if (sum == 7) {
      printf("%d%c%d%c%d%c%d=7\n", s[0], ope[0], s[1], ope[1], s[2], ope[2], s[3]);
      return 0;
    }
  }
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

d, n = rm()
if n != 100:
    print((n - (n-1)//99)*100**d)
else:
    print(101 * 100**d)



Measured memory_bytes: 27228
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int count=700;
  char c;
  r(i,3){
    cin >> c;
    if(c=='o')count+=100;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
s = list(str(input()))
count_0 = s.count("a")
count_1 = s.count("b")
count_2 = s.count("c")
max_c = max(count_0, count_1, count_2)
if abs(max_c - count_0) < 2 and abs(max_c - count_1) < 2 and abs(max_c - count_2) < 2:
    print("YES")
else:
    print("NO")

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

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

    int a[20];
    int b[20];
    int c[20];
    for (int i = 0; i < n; ++i) 
        cin >> a[i];
    for (int i = 0; i < n; ++i) 
        cin >> b[i];
    for (int i = 0; i < n - 1; ++i) 
        cin >> c[i];

    int score = 0;
    for (int i = 0; i < n - 1; ++i) {
        score += b[a[i] - 1];
        if (a[i + 1] == a[i] + 1) {
            score += c[a[i] - 1];
        }
        // cout << score << endl;
    }
    score += b[a[n - 1] - 1];

    cout << score << endl;
}

#include <string>
void _141() {
    string s;
    cin >> s;
    bool judge = true;
    for (int i = 0; i < s.size(); ++i) {
        if ((i + 1) % 2 == 0 && s[i] == 'R') {
            judge = false;
            break;
        } else if ((i + 1) % 2 == 1 && s[i] == 'L') {
            judge = false;
            break;
        }
    }

    if (judge) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void _142() {
    int n, k;
    cin >> n >> k;
    int count = 0;
    int h;
    for (int i = 0; i < n; ++i) {
        cin >> h;
        if (h >= k)
            count++;
    }
    cout << count << endl;
}

void _143() {
    int n;
    cin >> n;
    int d[50];
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    int value = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            value += d[i] * d[j];
        }
    }
    cout << value << endl;
}

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

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

void _145() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    if (s.size() %2 ==1) {
        cout << "No" << endl;
        return;
    }

    string first = s.substr(0, s.size() / 2);
    string second = s.substr(s.size() / 2, s.size());
    if (first == second)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    _145();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============BIT============================
const ll MAX_N = pow(10, 5) * 5 + 1;
ll n;
vector<ll> bit(MAX_N + 1, 0);

ll sum(ll i) {
  if (i < 0) {
    return 0;
  }
  i += 1;
  ll s = 0;
  while (i > 0) {
    s += bit.at(i);
    i -= i & -i;
  }
  return s;
}

void add(ll i, ll x) {
  i += 1;
  while (i <= n) {
    bit.at(i) += x;
    i += i & -i;
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, Q;
  cin >> N >> Q;
  n = N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    add(i, a);
  }
  for (ll i = 0; i < Q; ++i) {
    ll q, p, x;
    cin >> q >> p >> x;
    if (q == 0) {
      add(p, x);
    }
    else {
      ll ans = sum(x - 1);
      ans -= sum(p - 1);
      cout << ans << "\n";
    }
  }
}


Measured memory_bytes: 8228
import java.util.*;

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

      int w = sc.nextInt();
      int h = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      int r = sc.nextInt();

      int left = x - r;
      int right = x + r;
      int top = y + r;
      int bottom = y - r;

      if (left < 0 || left > w || right < 0 || right > w || top < 0 || top > h || bottom < 0 || bottom > h) {
        System.out.println("No");
      } else {
        System.out.println("Yes");
      }

      sc.close();
  }
}


Measured memory_bytes: 26288
#include <stdio.h>

#define NUM 1000000007

long long power_(long long m, long long n){
    //printf("%lld %lld\n", m, n);
    if(n == 1){
        return m % NUM;
    }
    return (n % 2 == 0) ? power_((m * m) % NUM, n / 2) : power_((m * m) % NUM, n / 2) * m % NUM;
}

int main(){
    long long M, N;
    scanf("%lld %lld", &M, &N);

    printf("%lld\n", power_(M, N));
}



Measured memory_bytes: 2752
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if (r < 1200) {
            System.out.println("ABC");
            return;
        }
        if (r < 2800) {
            System.out.println("ARC");
            return;
        }
        System.out.println("AGC");
    }

}


Measured memory_bytes: 23252
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)

	scanner.Scan()

	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()

	K, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	digit := 0
	for true {
		if(N / K > 0) {
			digit++
			N /= K
		} else {
			fmt.Println(digit + 1)
			break
		}
	}
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

struct Cake
{
	ll y = 0;
	ll x = 0;
	ll value = 0;
};

int main(void)
{
	ll h, w, k; cin >> h >> w >> k;

	vector<vector<char>> sv;
	sv.resize(h);
	each(i, s, sv)
	{
		s.resize(w);
		each(i, e, s)
			cin >> e;
	}

	vector<vector<ll>> ans;
	ans.resize(h);
	each(i, e, ans)
		e.resize(w);

	ll n = 0;
	vector<vector<Cake>> cake;
	cake.resize(h);
	each(y, s, sv)
	{
		rep(x, 0, size(s))
		{
			if (s[x] == '#')
				cake[y].push_back({y, x, ++n});
		}
	}

	each(y, s, sv)
	{
		if (size(cake[y]) == 0)
			continue;

		rep(j, 0, cake[y][0].x)
			ans[y][j] = cake[y][0].value;
		rep(i, 1, size(cake[y]))
		{
			rep(j, cake[y][i - 1].x, cake[y][i].x)
				ans[y][j] = cake[y][i-1].value;
		}
		rep(j, cake[y].back().x, size(s))
			ans[y][j] = cake[y].back().value;
	}

	rep(i, 0, size(ans))
	{
		each(y, s, ans)
		{
			each(x, e, s)
			{
				if (y == size(ans) - 1)
					continue;
				e = (e == 0) ? ans[y + 1][x] : e;
			}
		}
		each(y, s, ans)
		{
			each(x, e, s)
			{
				if (y == 0)
					continue;
				e = (e == 0) ? ans[y - 1][x] : e;
			}
		}
	}

	each(i, s, ans)
	{
		each(j, e, s)
			cout << e << ' ';
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4992
clr=["black","blue","lime","aqua","red","fuchsia","yellow","white"]
hex=["000000","0000ff","00ff00","00ffff","ff0000","ff00ff","ffff00","ffffff"]
def L(s1,s2):
	return ((int(s1[:2],16)-int(s2[:2],16))**2+(int(s1[2:4],16)-int(s2[2:4],16))**2+(int(s1[4:],16)-int(s2[4:],16))**2)**0.5

def nn(s):
	mn=mni=99999
	for i in range(8):
		if mn>L(hex[i],s):
			mn=L(hex[i],s);mni=i
	return mni

while 1:
	rgb=raw_input()
	if rgb=="0":break
	print clr[nn(rgb[1:])]

Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
typedef tuple<ll, int, int, int> t;
int main() {
  auto compare = [](t a,t b) {
    return get<0>(a)<get<0>(b);
  };
  priority_queue<t, vector<t>, decltype(compare)> q(compare);
  int x, y, z, K, e, f, g;
  cin >> x >> y >> z >> K;
  vector<ll> a(x), b(y), c(z);
  set<int> s;
  rep(i,x)
    cin >> a[i];
  rep(i,y)
    cin >> b[i];
  rep(i,z)
    cin >> c[i];
  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());
  sort(c.begin(), c.end(), greater<ll>());
  q.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
  while (K--) {
    t p = q.top();
    q.pop();
    cout << get<0>(p) << endl;
    e = get<1>(p);
    f = get<2>(p);
    g = get<3>(p);
    if (e < x - 1 && !s.count((e + 1) * y * z + f * z + g)) {
      q.push(make_tuple(a[e + 1] + b[f] + c[g], e + 1, f, g));
      s.insert((e + 1) * y * z + f * z + g);
    }
    if (f < y - 1 && !s.count(e * y * z + (f + 1) * z + g)) {
      q.push(make_tuple(a[e] + b[f + 1] + c[g], e, f + 1, g));
      s.insert(e * y * z + (f + 1) * z + g);
    }
    if (g < z - 1 && !s.count(e * y * z + f * z + g + 1)) {
      q.push(make_tuple(a[e] + b[f] + c[g + 1], e, f, g + 1));
      s.insert(e * y * z + f * z + g + 1);
    }
  }
  return 0;
}


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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)
#define sz(s) ((int) (s).size())

const int N = 100005;

int a, b, m;
int aa[N], bb[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    cin >> a >> b >> m;
    int mna = 1e9;
    int mnb = 1e9;
    for (int i = 1; i <= a; i++) {
        cin >> aa[i];
        mna = min(mna, aa[i]);
    }
    for (int i = 1; i <= b; i++) {
        cin >> bb[i];
        mnb = min(mnb, bb[i]);
    }
    int ans = mna + mnb;
    for (int i = 1; i <= m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, aa[x] + bb[y] - c);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

class DisjollSet {
public:
    DisjollSet(ll n) {
        rank.resize(n);
        parent.resize(n);
        sizes.resize(n);
        for (ll i=0; i<n; i++) rank[i] = 0, parent[i] = i, sizes[i] = 1;
    }

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

    void unite(ll x, ll y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        else if (rank[x] == rank[y]) rank[x]++;
        parent[y] = x;
        sizes.at(x) += sizes.at(y);
    }

    long long size(ll x) {
      return sizes.at(root(x));
    }

private:
    vector<ll> rank;
    vector<ll> parent;
    vector<long long> sizes;

    ll root(ll x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }

        return parent[x];
    }
};


int main() {
  int n,m; in(n),in(m);
  vector<int> A(n+1);
  loop(i,1,n+1) in(A[i]);
  DisjollSet ds(n+1);
  loop(i,0,m) {
    int x, y; in(x),in(y);
    ds.unite(x, y);
  }
  
  int ans = 0;
  loop(i,1,n+1) {
    ans += i == A[i] or ds.same(i, A[i]);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 5900
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
using namespace std;

int main(){
   int n; cin >> n;
   string s; cin >> s;
   int now=1;
   int ans=0;
   while(now<n){
        int tmp=0;
        rep(i,n-now){
            if(tmp>=now){
               ans=max(ans,tmp);
               tmp=0;
               continue;
            }
            if(s[i]==s[i+now]) tmp++;
            else{
               ans=max(ans,tmp);
               tmp=0;
            }
        }
        ans=max(ans,tmp);
        now++;
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

#define nil -1
#define max 25
struct node{int p, l, r;};
node t[25];
int h[25], d[25];

void preparse(int u){
    if(u == nil) return;
    cout << " " << u;
    preparse(t[u].l);
    preparse(t[u].r);
}

void inparse(int u){
    if(u == nil) return;
    inparse(t[u].l);
    cout << " " << u;
    inparse(t[u].r);
}

void postparse(int u){
    if(u == nil) return;
    postparse(t[u].l);
    postparse(t[u].r);
    cout << " " << u;
}

int main(){
    int n, v, l, r, root = 0;
    cin >> n;
    rep(i, n) t[i].p = nil;
    rep(i, n){
        cin >> v >> l >> r;
        t[v].l = l;
        t[v].r = r;
        if(l != nil) t[l].p = v;
        if(r != nil) t[r].p = v;
    }
    rep(i, n) if(t[i].p == nil) root = i;
    cout << "Preorder" << endl;
    preparse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inparse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postparse(root);
    cout << endl;
}


Measured memory_bytes: 3112
n = int(input())
a = [[0,0,0]] + [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  time = a[i+1][0] - a[i][0]
  dist = abs(a[i+1][1] - a[i][1]) + abs(a[i+1][2] - a[i][2])
  if time < dist or time % 2 != dist % 2 :
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 28068
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(){
    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    COMinit();
    ll ans=0;
    rep2(j,c1,c2+1){
        ans+=COM(r2+j+1,j+1);
        ans%=MOD;
        ans-=COM(r1-1+j+1,j+1);
        ans+=MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
     

    solve(); 


    return 0;
}


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

int main(){
  ll n,k;cin >> n >> k;
  ll r,s,p;cin >> s >> p >> r;
  map<char,ll> m;
  m['s'] = s;
  m['p'] = p;
  m['r'] = r;
  string t;cin >> t;
  vector<bool> b(n);

  ll ans = 0;
  rep(i,n){
    if( i-k >= 0 ){
      if( t.at(i-k) == t.at(i) && b.at(i-k) ){
        continue;
      }
    }
    ans += m[t.at(i)];
    b.at(i) = true;
  }
  

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        b%a==0?cout<<a+b<<endl:cout<<b-a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
s = list(input())
K = int(input())

alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if (26 - alphabet.index(s[i])) <= K and (s[i] != "a"):
        K -= (26 - alphabet.index(s[i]))
        s[i] = "a"
        
    if K <= 0:
        break
        
if K > 0:
    K = K % 26
  
    idx = alphabet.index(s[-1])+K
    s[-1] = alphabet[idx%26]
    
print("".join(s))

Measured memory_bytes: 4152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>

#define INF 2000000000
#define MOD 1000000007

using namespace std;

int n;
int arr[1000000];
int cnt[1000000];
int all;
long long sum = 0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum -= arr[i];
	}
	if (n == 1) {
		cout << "YES" << endl;
		return 0;
	}
	bool isGood = true;
	for (int i = 0; i < n; i++) {
		if (arr[i] >= arr[(i + 1) % n]) {
			cnt[(i + 1) % n] = (arr[i] - arr[(i + 1) % n] + n - 2) / (n - 1);
			all += cnt[(i + 1) % n];
			sum += 1LL * cnt[(i + 1) % n] * (1LL + n) * n / 2;
		}
	}
	if (sum != 0) {
		cout << "NO" << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (arr[i] != arr[(i + 1) % n] - all +
			cnt[(i + 1) % n] + (n - 1) * cnt[(i + 1) % n]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
#
import math
import sys

from collections import deque

h,w = map(int, input().split())

ch,cw = map(int, input().split())
dh,dw = map(int, input().split())

maze =["#"*(w+4) for i in range(2)] + ["##"+input()+"##" for i in range(h)] + ["#"*(w+4) for i in range(2)]
temp = [[-1]*(w+4) for i in range(h+4)]

#print(maze)

q = deque([(ch+1,cw+1)])
temp[ch+1][cw+1]=0

opt = [(0,1),(0,-1),(1,0),(-1,0)]

while q:
    y,x = q.popleft()
#    print(y,x)
    # aruki
    for i in opt:
        ty,tx = y+i[0], x+i[1]
        if maze[ty][tx]=='#':
            continue
        if (temp[ty][tx] == -1 or temp[ty][tx] > temp[y][x]):
            temp[ty][tx] = temp[y][x] # ikeru
            q.appendleft((ty,tx)) # new ikeru basho tuika
    # warp
    for i in range(-2,3):
        for j in range(-2,3):
            ty,tx = y+i, x+j
            if maze[ty][tx] == "#":
                continue
            if temp[ty][tx] == -1 or temp[ty][tx] > temp[y][x]+1:
                temp[ty][tx] =  temp[y][x]+1
                q.append((ty,tx))  # 
#    print(q)


print(temp[dh+1][dw+1])



Measured memory_bytes: 91756
#include <iostream>
int main(void) {
  long long int W, H, x, y;
  std::cin >> W >> H >> x >> y;
  std::cout << W * H / 2.0 << ' ' << (((x * 2 == W) && (y * 2 == H)) ? 1 : 0);
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Control.Monad.State

data Event = HIT | HOMERUN | OUT deriving (Show, Read, Eq)

type EventList = [Event]
type Base = Int
type Outs = Int
type GameCount = (Base, Outs)
type Score = Int
type Scores = [Int]
type GameState = (GameCount, Scores)

addScore :: State GameState Scores
addScore = do
  ((base, outs), score) <- get
  let (now:past) = score
      newScore = (now + 1):past
  put ((base - 1, outs), newScore)
  return newScore

newGame :: State GameState Scores
newGame = do
  ((base, outs), score) <- get
  let newScore = (0:score)
  put ((0, 0), newScore)
  return newScore

hit :: State GameState Scores
hit = do
  ((base, outs), score) <- get
  put ((base + 1, outs), score)
  return score

homerun :: State GameState Scores
homerun = do
  ((base, outs), score) <- get
  let (now:past) = score
      newScore = (now + base + 1):past
  put ((0, outs), newScore)
  return newScore

out :: State GameState Scores
out = do
  ((base, outs), score) <- get
  put ((base, outs + 1), score)
  return score

simulate :: EventList -> State GameState Scores
simulate [] = do
  (_, score) <- get
  return score
simulate (x:xs) = do
  ((base, outs), score) <- get
  case (base, outs, x) of
    (base, outs, x) | outs == 3 -> do
                      newGame
                      simulate (x:xs)
                    | base == 4 -> do
                      addScore
                      simulate (x:xs)
                    | x == HIT -> do
                      hit
                      simulate xs
                    | x == HOMERUN -> do
                      homerun
                      simulate xs
                    | x == OUT -> do
                      out
                      simulate xs

main = do
  getLine
  contents <- map (read :: String -> Event) . lines <$> getContents
  putStr $ unlines $ map show $ reverse $ evalState (simulate contents) ((0, 0), [0])

Measured memory_bytes: 4120
#include<iostream>
using namespace std;
int main()
{
  int n,k,h[100010],cnt=0;
  cin>>n>>k;
  for(int i=0; i<n; i++)
  {
    cin>>h[i];
    if(h[i]>=k) cnt++;
  }
  cout<<cnt<<endl;
}

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, count = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] != i+1) {
            count++;
        }
    }
    if(count <= 2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0; 
}

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

#define ll long long
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 main()
{
    ll N,K;
    cin >> N >> K;

    vector<ll> H(N);
    rep(i,N) cin >> H[i];

    sort(all(H),greater<ll>());

    rep(i,min(N,K)) H[i] = 0;

    ll ans = 0;
    rep(i,N)
    {
        ans += H[i];
    }
    cout << ans << endl;


}


Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    FOR(i, 0, n) {
        cin >> a[i] >> b[i];
    }
    vector<int> c(m), d(m);
    FOR(i, 0, m) {
        cin >> c[i] >> d[i];
    }

    FOR(i, 0, n) {
        int minidx = 0;
        int minx = 500000000;
        FOR(j, 0, m) {
            int t = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (t < minx) {
                minx = t;
                minidx = j;
            }
        }
        cout << minidx + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    cout << N * N << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long LL;;

LL bit[65];

int main() {
    int a, b, s;
    scanf("%d %d", &a, &b);
    s = a * b;
    if(s % 2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}

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

ll N, x;
vector<ll> a(100010);
int main(void){
    cin >> N >> x;
    for(int i = 0; i < N; i++) cin >> a[i];
    
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        if(a.at(i) + a.at(i+1) <= x) continue;
        if(a.at(i) <= x){
            ans += (a.at(i) + a.at(i+1) - x);
            a.at(i+1) = x - a.at(i);
        }else{
            ans += (a.at(i) + a.at(i+1) - x);
            a.at(i) = x;
            a.at(i+1) = 0;
        }
    }
    cout << ans << endl;
}

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

void dfs(char *s, size_t i, size_t n, char max)
{
    if (i == n)
    {
        printf("%s\n", s);
    }
    else
    {
        for (char c = 'a'; c <= max; c++)
        {
            s[i] = c;
            dfs(s, i + 1, n, ((c == max) ? max + 1 : max));
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    char *s = malloc(sizeof(char) * (n + 1));
    for (int i = 0; i < n; i++)
        s[i] = 'a';
    s[n] = '\0';
    dfs(s, 0, n, 'a');
    return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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


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

  long n;
  cin >> n;

  vector<long> a(n);
  fillLong(a, n);

  bool isKi = false;
  bool hasZero = false;
  long cnt = 0;
  long m = INF * 1000;
  rep(i, n) {
    if(a[i] == 0) hasZero = true;
    if(a[i] < 0) isKi = !isKi;
    cnt += abs(a[i]);
    m = min(m, abs(a[i]));
  }

  if (isKi && !hasZero) {
    cnt -= m*2;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

ll c=0;
ll N=200001;
vi vis(N,0);
vvi adj(N);
void dfs(ll u)
{
    vis[u]=1;
    c++;
    for(auto v:adj[u])if(!vis[v])dfs(v);
}

int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans=INT_MIN;
    rep(i,0,m)
    {
        ll u,v;
        cin>>u>>v;
        if(u>v)swap(u,v);
        adj[u].pb(v);
        adj[v].pb(u);
        }
        for(int i=1;i<n+1;i++)
        {
            if(!vis[i])
            {
                c=0;
                dfs(i);
                ans=max(ans,c);

            }

        }
    cout<<ans;


}


Measured memory_bytes: 21896
#include<stdio.h>
#define N 100000

typedef struct Card{
  char mark;
  int num;
  int index;
}Card;

int Partition( Card A[], int p, int r ){
  int x, i, j;
  Card c;
  x = A[r].num;
  i = p - 1;
  for( j = p; j < r; j++ ){
    if( A[j].num <= x){
      i++;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;

  return i+1;
}

void QuickSort( Card A[], int p, int r ){
  int q;
  if( p < r ){
    q = Partition( A, p, r );
    QuickSort( A, p, q-1 );
    QuickSort( A, q+1, r );
  }
}

int isStable( Card A[], int n ){
  int i;
  for( i = 1; i < n; i++ ){
    if( A[i-1].num == A[i].num ){
      if( A[i-1].index > A[i].index ){
	return 0;
      }
    }
  }
    return 1;
}

main(){
  int n, i;
  Card A[N];

  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf(" %c %d", &A[i].mark, &A[i].num);
    A[i].index = i;
  }

  QuickSort( A, 0, n-1 );

  if( isStable(A, n) == 1 ){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  for( i = 0; i < n; i++ ){
    printf("%c %d\n", A[i].mark, A[i].num);
  }
    return 0;
}

Measured memory_bytes: 1780
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN = 1e5;

char s[MAXN + 5],ans[MAXN + 5];
LL a[MAXN + 5],b[MAXN + 5];
bool q = 0;
LL sum = 0,k = 0;

int main(){
	memset(s,0,sizeof(s));
	cin >> s+1;
	cin >> k;
	int len = strlen(s+1);
	for(int i = 1;i <= len;i++){
		a[i] = (LL)s[i];
	}
	for(int i = 1;i <= len;i++){
		if(k ==0)break;
		if(a[i] == 97)continue;
		else{
			if(a[i]+k >122){
				k =k - (122 - a[i]+1);
				a[i] = 97;	
			}
		}
	}
	if(k > 0){
		if(k > 26)k %=26;
		a[len] += k;
		if(a[len] > 122){
			a[len] = 97 + a[len] - 122 - 1;
		}
	}
	for(int i = 1;i <= len;i++){
		cout << (char)a[i];
	}
	cout << endl;
}

Measured memory_bytes: 1280
code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
from libc.stdio cimport getchar, printf
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef int n = read(), i
cdef dsu *u = new dsu(n)
for i in range(read()): u.merge(read() - 1, read() - 1)
printf('%lu\n', u.groups().size() - 1)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 15428