akhauriyash/Code-Regression huggingface dataset:
#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>

using namespace std;

int main(void){
    long long int N,K;
    cin>>N>>K;
    N=N%K;
    if(N<=abs(N-K)){
        cout<<N<<endl;
    }else{
        cout<<abs(N-K)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * The Number of Area
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			System.out.println(((n * n + n) >> 1) + 1);
		}
	}
}

Measured memory_bytes: 16864
/*
    Vora Mahammadasim
*/

#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
#define ps(a) partial_sum(all(a),a.begin())
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int>m;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<'\n'<<"WA x "<<m["WA"]<<'\n'<<"TLE x "<<m["TLE"]<<'\n'<<"RE x "<<m["RE"]<<'\n';
}


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

int selectionSort(int a[], int n)
{
  int minj;
  int sw = 0;
  for (int i = 0; i < n; i++) {
    minj = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[minj])
	minj = j;
    }
    if (minj != i) {
      swap(a[minj], a[i]);
      sw++;
    }
  }
  return sw;
}

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

  sw = selectionSort(a, n);

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

  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int f[22][(1<<22)+1];
int a[22][22];
int lowbit(int x)
{
	return x&(-x);
}
int count1(int num)
{
	int ret=0;
	while(num)
	{	
		ret++;
		num-=lowbit(num);
	}
	return ret;
}
int main()
{
	int i,j,l,n;
	scanf("%d",&n);
	f[0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);	
		}	
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<(1<<n);j++)
		{
			if(count1(j)!=i)
				continue;
			for(l=0;l<=n-1;l++)
			{
				if((j&(1<<l))!=0&&a[i][n-l]==1)
					f[i][j]=(f[i-1][j^(1<<l)]+f[i][j])%(1000000000+7);
			}
		}
	}
	printf("%d",f[n][(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 178432
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    String ans = "";
    
    for(int i = 0;i<n;i++){
      ans = ans + s.substring(i,i+1) + t.substring(i,i+1);
    }
    
    System.out.println(ans);
    
    
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 100000000000

#define MAXN 1000001

using namespace std;

int dp[MAXN][2];

int main(){
  string s;cin>>s;
  reverse(s.begin(), s.end());
  s+='0';
  int n=s.size();

  rep(i, n+1)rep(j, 2)dp[i][j]=INF;
  dp[0][0]=0;
//  dp[0][1]=0;
  
  rep(i, n)rep(j, 2){
    int x = s[i]-'0'+j;
    rep(a, 10){
      int ni = i+1;
      int nj = 0;
      int b = a-x;
      if(b<0){
        nj=1;
        b+=10;
      }
      dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
    }
  }

  cout<<dp[n][0]<<endl;

  return 0;
}

Measured memory_bytes: 12116
#include<stdio.h>
int main(void)
{
	int i,j,a,b;
	int n=1;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		for(i=0;i<=9;i++)
		{
			for (j=0;j<=9;j++)
			{
				for (a=0;a<=9;a++)
				{
					for (b=0;b<=9;b++)
					{
						if (n-a-b-i-j==0)
						{
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string s; cin>>s;
  int limit=1<<(s.size()-1);
  int check;
  rep(i,limit)
  {
    ll sum=s[0]-'0';
    rep(j,s.size()-1)
    {
      if(1<<j&i)
      {
        sum+=s[j+1]-'0';
      }
      else 
      {
        sum-=s[j+1]-'0';
      }
    }
    if(sum==7)
    {
      check=i;
      break;
    }
  }
  char c[3];
  rep(i,s.size()-1)
  {
    if(1<<i&check) c[i]='+';
    else c[i]='-';
  }
  rep(i,3)
  {
    cout<<s[i]<<c[i];
  }
  cout<<s[3]<<"=7"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(15);
vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	string s;
	cin >> s;
	if((s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0') <= 2019){
		if((s[5]-'0')*10+(s[6]-'0') <= 4){
			if((s[8]-'0')*10+(s[9]-'0') <= 30){
				cout << "Heisei" << endl;
				return 0;
			}
		}
	}
	cout << "TBD" << endl;
}

Measured memory_bytes: 3620
'''
Created on Mar 22, 2013

@author: wukc
'''
from sys import stdin
import math

x,y=0,0
t=math.radians(90)
for l in stdin:
    r,d=map(int,l.split(","))
    if (r,d)==(0,0): break
    x+=r*math.cos(t)
    y+=r*math.sin(t)
    t+=math.radians(-d)    
    
print(int(x))
print(int(y))

Measured memory_bytes: 4440
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char S[200000+2];
int main(){
  int i;
  int res = 0;
  N = rd(S);
  for(i=(0);i<(N);i++){
    res += S[i] - '0';
  }
  if(res%9){
    wt_L("No");
    wt_L('\n');
  }
  else{
    wt_L("Yes");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200911-1

// --- original code ---
// int N;
// char S[2d5+2];
// {
//   int res = 0;
//   rd(S@N);
//   rep(i,N) res += S[i] - '0';
//   wt(if[res%9, "No", "Yes"]);
// }


Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll R;
    cin>>R;
    cout<<2*R*pi<<endl;
}



Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n;
int a[101];

int calc(){
	int ret = 0;
	rep(i, n - 1){
		rep(j, n - 1){
			if (a[j] > a[j + 1])++ret, std::swap(a[j], a[j + 1]);
		}
	}
	return ret;
}

int main(){
	std::cin >> n;
	rep(i, n)std::cin >> a[i];
	int ans = calc();
	std::cout << a[0];
	REP(i, 1, n)std::cout << " " << a[i];
	std::cout << std::endl;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, ans = 1; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) {
  	cin >> A[i];
  }
  vsort(A);
  if (N % 2) {
    if (A[0] != 0) {
    	cout << 0 << endl;
      	return 0;
    }
    for (ll i = 1; i < N - 1; i += 2) {
    	if (A[i] != i + 1 || A[i + 1] != i + 1) {
        	cout << 0 << endl;
          	return 0;
        }
    }
    rep(i, 0, (N - 1) / 2) {
    	ans *= 2;
      	ans = ans % MOD;
    }
  } else {
    for (ll i = 0; i < N - 1; i += 2) {
    	if (A[i] != i + 1 || A[i + 1] != i + 1) {
        	cout << 0 << endl;
          	return 0;
        }
    }
    rep(i, 0, N / 2) {
    	ans *= 2;
      	ans = ans % MOD;
    }
  }
  cout << ans % MOD << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  vector<ll> C(N+1); // The count of each A. C[0] is dummy.
  rep(i, N) {
    ++C[A[i]];
  }
  // For Debug
  // cout << "C[i]:" << endl;
  // for (ll i = 1; i <= N; ++i) {
  //   cout << C[i] << endl;
  // }
  vector<ll> D(N+1); // The count of each C.
  for (ll i = 1; i <= N; ++i) {
    ++D[C[i]];
  }
  // For Debug
  // cout << "D[i]:" << endl;
  // for (ll i = 1; i <= N; ++i) {
  //   cout << D[i] << endl;
  // }

  // Here, the count of k is represented as D[k].
  // We want to calculate the f(X) = sum min(C[j], X) / X
  // f(X) = (sum(k=1,X) kD[k] + X*sum(k=X+1,N) D[k])
  vector<ll> ckD(N+1);
  for (ll k = 1; k <= N; ++k) {
    ckD[k] = ckD[k-1] + k * D[k];
  }
  // For Debug
  // cout << "ckD[i]:" << endl;
  // for (ll i = 1; i <= N; ++i) {
  //   cout << ckD[i] << endl;
  // }
  vector<ll> cD(N+1);
  for (ll k = 1; k <= N; ++k) {
    cD[k] = cD[k-1] + D[k];
  }
  // For Debug
  // cout << "cD[i]:" << endl;
  // for (ll i = 1; i <= N; ++i) {
  //   cout << cD[i] << endl;
  // }

  // f(X) .. The maximam length of sequence when X sequences can be extracted.
  vector<ll> f(N+1);
  for (ll i = 1; i <= N; ++i) {
    f[i] = (ckD[i] + i*(cD[N] - cD[i])) / i;
  }
  // For Debug
  // cout << "f[i]:" << endl;
  // for (ll i = 1; i <= N; ++i) {
  //   cout << f[i] << endl;
  // }

  // Here, the maximum X where K <= f(X) is the answer of each K.

  reverse(all(f));
  f.resize(N); // f[N] is thrown away.
  // Now, f is increasing order.
  for (int i = 1; i <= N; ++i) {
    auto it = lower_bound(all(f), i);
    if (it != f.end()) {
      int j = it - f.begin(); // index
      cout << (N - j) << endl;
    } else { // not found
      cout << 0 << endl;
    }
  }
}


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

int main() {
 int N , score ;
  cin >> N ;
  score = 0 ;
  vector<int> A(N), B(N) , C(N) ;
  for (int i=0; i<N;i++){
    cin >> A.at(i) ;
  //  cout <<A.at(i) ;
  }
 for (int i=0; i<N;i++){
    cin >> B.at(i) ;
     //cout <<B.at(i) ;
  }
  for (int i=0; i<N;i++){
    cin >> C.at(i) ;
   // cout <<C.at(i) ;
  }
 for (int i=0;i<N;i++){
   score += B.at(A.at(i)-1);
   if (i<(N-1)){
    if (A.at(i+1)==(1+A.at(i)))
      score +=C.at(A.at(i)-1) ;
     }
 }
  cout << score ;
}

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

int main()
{
	long int l,r,d,i,ans=0;
	cin>>l>>r>>d;
	for(i=l;i<=r;i++)
	{
	    if(i%d==0)
	        ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
using namespace std;
#define RT3 1.7320508

void koch(int dim, double sx, double sy, double dx, double dy, int angle){
  if (dim==0){
    cout << dx << " " << dy << endl;
  }
  else {
    double x1, y1, x2, y2, x3, y3, xm, ym;
    x1 = sx + (dx-sx)/3; y1 = sy + (dy-sy)/3;
    x3 = sx + (dx-sx)/3*2; y3 = sy + (dy-sy)/3*2;
    // 正三角形の計算めんどいしたかだか6方向なのでハードコードする
    switch(angle){
      case 0: x2 = (sx+dx)/2; y2 = sy + (x1-sx)*RT3/2; break;
      case 1: x2 = sx; y2 = y3; break;
      case 2: x2 = dx; y2 = y1; break;
      case 3: x2 = (sx+dx)/2; y2 = sy + (x1-sx)*RT3/2; break;
      case 4: x2 = sx; y2 = y3; break;
      case 5: x2 = dx; y2 = y1; break;
    }
    koch(dim-1,sx,sy,x1,y1,angle);
    koch(dim-1,x1,y1,x2,y2,(angle+1)%6);
    koch(dim-1,x2,y2,x3,y3,(angle+5)%6);
    koch(dim-1,x3,y3,dx,dy,angle);
  }
}

int main(void){
  int n;
  cin >> n;
  cout << 0 << " " << 0 << endl;
  koch(n,0,0,100,0,0);
  return 0;
}


Measured memory_bytes: 3248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] word = line.split("");
        if(word[2].equals(word[3]) && word[4].equals(word[5])) {
            System.out.println("Yes");   
        }else {
            System.out.println("No");
        }
    }
}

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

typedef pair<int,int> ii;


vector<int> adj[100003];
int edges[100003][2];
map<ii, int> m;
int c[100003];
bool visited[100003];

int main() {
    string s;
    long long n;

    memset(visited, false, sizeof visited);
    memset(edges,0,sizeof edges);
    memset(c,0,sizeof c);
    cin >> n;

    int a, b;
    int maxCount = 0, maxIndex = 1;
    for(int i = 0; i<n-1; i++) {
        cin >> a >> b;

        adj[a].push_back(b);
        adj[b].push_back(a);
        edges[i][0] = a;
        edges[i][1] = b;
        c[a]++;
        c[b]++;
        if(c[a]>maxCount) {
            maxCount = c[a];
            maxIndex = a;
        }
        if(c[b]>maxCount) {
            maxCount = c[b];
            maxIndex = b;
        }
    }

    queue<ii> q;
    q.push(ii(maxIndex, -1));
    while(!q.empty()) {
        ii cur = q.front();
        q.pop();
        if(visited[cur.first])  continue;
        visited[cur.first] = true;
        int color = 1;
        for(int i = 0; i<adj[cur.first].size(); i++) {
            if(!visited[adj[cur.first][i]]) {
                if (color == cur.second) color++;

                m.insert(pair<ii,int>(ii(cur.first, adj[cur.first][i]), color++));
                m.insert(pair<ii,int>(ii(adj[cur.first][i], cur.first), color-1));
                q.push(ii(adj[cur.first][i], color-1));
            }
        }
    }

    cout << maxCount << endl;
    for(int i = 0; i < n-1; i++) {
        auto it = m.find(ii(edges[i][0],edges[i][1]));
        cout << it->second << endl;
    }
    return 0;
}

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

int main()
{
    long long n, m;
    cin >> n >> m;
    long long ans = 0;
    if (n == 1 or m == 1)
        ans = 1;
    else if (n % 2 == 1 and m % 2 == 1)
        ans = (n - 1) * m / 2 + (m + 1) / 2;
    else if (n % 2 == 1)
        ans = (n - 1) * m / 2 + m / 2;
    else if (m % 2 == 1)
        ans = (m - 1) * n / 2 + n / 2;
    else
        ans = n * m / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 3005;
const int MOD = 998244353;
 
int n, s;
int a[N], cache[N][N];
 
int dp(int idx, int s)
{
	if(s == 0)
		return (n - idx + 2);
	if(s < 0)
		return 0;
	if(idx > n)
		return 0;
	int &ans = cache[idx][s];
	if(ans != -1)
		return ans;
	ans = dp(idx + 1, s) + dp(idx + 1, s - a[idx]);
	ans %= MOD;
	return ans;
}
 
int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n >> s;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans += dp(i, s);
	ans %= MOD;
	cout << ans;
	return 0;
}

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

using namespace std;

int main(){
  
  string a;
  
  cin >> a;
  
  int len = a.length();
    
  string answer = "";
  
  for(int i = 0; i < len; i++){
    answer += "x";
  }
  
  cout << answer << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a, b, i;
  scanf("%d %d", &a, &b);
  if(b == 1){
    puts("0");
    return 0;
  }
  for(i = 0; a + (a - 1) * i < b; i++){} 
  printf("%d\n", i + 1);
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long int> v;
	long int sum = 0;
	
	for(int i = 0; i < N; ++i){
		int tmp;
		cin >> tmp;
		sum += tmp;
		v.push_back(sum);
	}
	
	long int ans = 10e9;
	for(int i = 0; i < N-1; ++i) {
		long int y = sum - v[i];
		ans = min(ans, abs(v[i]-y));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2420
#include<vector>
#include<iostream>
#include<string>

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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}

	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)    {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

void dej(char *str)
{
  int len=strlen(str);
  char a=str[len-1];
  str[len-1]=0;
  char ptr[112345]={};
  sprintf(ptr,"%c%s",a,str);
  sprintf(str,"%s",ptr);
}
void dec(char *str)
{
  sprintf(str,"%s%c",&str[1],str[0]);
}
void dee(char *str)
{
  int len=strlen(str);
  char top[112345]={};sprintf(top,"%s",str);top[len/2]=0;
  char mid[10]={};if(len%2)mid[0]=str[(len+1)/2-1];
  char bot[112345]={};sprintf(bot,"%s",&str[(len+1)/2]);
  sprintf(str,"%s%s%s",bot,mid,top);
}
void dea(char *str)
{
  int i;
  int len=strlen(str)-1;
  int n=(len+1)/2;
  char t;
  rep(i,n)
    {
      t=str[i];
      str[i]=str[len-i];
      str[len-i]=t;
    }
}
void dep(char *str)
{
  int i;
  int n=strlen(str);
  rep(i,n)
    if('0'<=str[i] && str[i]<='9')
      {
	if(str[i]=='0')
	  str[i]='9';
	else
	  str[i]--;
      }
}
void dem(char *str)
{
  int i;
  int n=strlen(str);
  rep(i,n)
    if('0'<=str[i] && str[i]<='9')
      {
	if(str[i]=='9')
	  str[i]='0';
	else
	  str[i]++;
      }
}

void decode(char *str,char type)
{
  switch(type)
    {
    case 'J':dej(str);break;
    case 'C':dec(str);break;
    case 'E':dee(str);break;
    case 'A':dea(str);break;
    case 'P':dep(str);break;
    case 'M':dem(str);break;
    }
}

signed main(void)
{
  char str[112345]={};
  char type[112345]={};
  int n;
  cin>>n;
  int i;
  int j,len;
  rep(i,n)
    {
      scanf("%s",type);
      scanf("%s",str);
      len=strlen(type);
      rep(j,len)
	decode(str,type[len-j-1]);
      printf("%s\n",str);
    } 
  return 0;
}

Measured memory_bytes: 3536
/// Bismillah Hir Rahmanir Rahim

/**
    Practice like Cristiano Ronaldo
        Play Like Leo Messi..
**/

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<int,int>	          mii;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%I64d %I64d", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e5 + 10;
const ll mod = 1e9 + 7;

int main()
{
    string s, s1;

    cin >> s >> s1;

    reverse( all( s ) );

    if( s == s1 ){
        deb("YES");
    }
    else {
        deb("NO");
    }

    return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int countM(int n, int m) {
    LL res = 0;
    for(;0 < n;n /= m) {
        res += (n/m)%m;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    int mn = 1e9;
    for(int i = 0;i <= N;i += 9) {
        int c9 = countM(i, 9);
        int c6 = countM(((N - i)/6)*6, 6);
        int s = c9 + c6 + (N - i - ((N - i)/6)*6);
        mn = min(s, mn);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	ll a, b, n;
	cin >> a >> b >> n;

	ll ans = (1LL<<62);
	for(ll i = 1; i <= n; i++) {
		for(ll j = 1; j <= n; j++) {
			if((b * i) % j == 0) {
				ll nA = (b * i) / j;
				ans = min( abs(a - nA), ans);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  string s; cin >> s;
  int size = s.length(), a = 0, b = 0;
  for (int i = 0; i < size; i++) {
    if (s[i] == 'S')
      a++;
    else {
      if (a>0)
        a--;
      else
        b++;
    }
  }
  cout << a+b << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>

#define REP(i,n)   for(int i=0;i<(n);++i)

int main(){
    int n,a,min=1234567899,d=0,cnt=0;
    scanf("%d%*d",&n);
    REP(i,n){
        //scanf("%d",&a);
        std::cin >> a;
        if(min>a){
            min = a;
        }else if(d==a-min){
            ++cnt;
        }else if(d<a-min){
            d = a - min;
            cnt=1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL)

typedef long long ll;

using namespace std;

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

	ll arr[n], ara[n], ans1 = 0, ans2 = 0, ans = LONG_LONG_MAX, l = -1000000000, r = 1000000000, m = 0;

	for(int i=0; i<n; i++)
		cin >> arr[i];

	while(l < r){
		for(int i=0; i<n; i++){
			ans1 += abs(arr[i] - (m+i+1));
			ans2 += abs(arr[i] - (m+1+i+1));
		}

		// cout << l << " " << r << " " << m << " " << ans << "**\n";

		if(ans1 < ans2){
			ans = min(ans, ans1);
			r = m;
		}
		else{
			ans = min(ans, ans2);
			l = m+1;	
		}

		m = l+(r-l)/2;
		ans1 = 0;
		ans2 = 0;
	}	

	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k,x;
  cin >> k >> x;
  int s = x-k+1;
  int f = s + k*2-1;
  for(int i=s; i<f; i++) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3596
read n
read -a a
read -a b
as=${a[0]}
bs=$((`echo ${b[@]} | tr ' ' '+'`))
m=$((as+bs))
for i in `seq $((n-1))`
do
    as=$((as+a[i]))
    bs=$((bs-b[i-1]))
    m=$((as+bs>m?as+bs:m))
done
echo $m


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


using namespace std;


using ll = long long;


int main(void) {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i <= N + 1; i++) {
        ll maximum, minimum;
        maximum = minimum = 0;
        maximum = i * (N + (N - (i - 1))) / 2;
        minimum = i * (0 + i - 1) / 2;
        ans = (ans + (maximum - minimum + 1)) % 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fori(i,a,b) for(int i=a,b_=b;i<=b_;++i)
#define ford(i,a,b) for(int i=a,b_=b;i>=b_;--i)
#define forv(i,a) for(auto &i:a)
#define ll long long
#define pb push_back
#define pp pop_back()
#define pii pair<ll,ll>
#define fi first
#define se second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ___ << "\n"
#define __ << " " <<
#define _ << " "
using namespace std;

const int N=1005, mod=1e9+7;
int m,n,a[N][N];
ll f[N][N];

int main()
{
	cin >> m >> n; char ch;
  	fori(i,1,m) fori(j,1,n)
    {
      cin >> ch; if(ch=='.') a[i][j]=1;
    }
  	fori(i,1,m) fori(j,1,n)
    {
        if(i==1 && j==1) f[i][j]=1;
        else if(a[i][j]==0) f[i][j]=0;
        else f[i][j]=(f[i-1][j]+f[i][j-1])%mod;
    }
    cout << f[m][n];
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 1e5 +10;
vector<int> es[MAX_N];
bool f = true;

bool check(int cur, int par) {
	int cnt = 0;
	if(par != -1 && es[cur].size() == 1) return false;
	for(auto& to : es[cur]) {
		if(to == par) continue;
		if(!check(to, cur)) cnt++;
	}
	if(cnt > 1) f = false;
	return cnt;
} 

int main(){
	int n;
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	f &= check(0, -1);
	cout << (f ? "Second":"First") << endl;
	return 0;
}

Measured memory_bytes: 5888
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

const int size = 12801;
int H, W, tmp;
int A[80][80];
bitset<size> dp[80];

int main() {
    fastio();
    cin >> H >> W;
    REP(i, H) REP(j, W) cin >> A[i][j];
    REP(i, H) REP(j, W) {
        cin >> tmp;
        A[i][j] = abs(A[i][j] - tmp);
    }
    dp[0].set(A[0][0]);
    FOR(i, 0, H - 1) FOR(j, 0, W - 1) {
        if(i > 0) {
            auto tmp = dp[j] << A[i][j];
            tmp |= dp[j] >> A[i][j];
            REP(k, A[i][j]) if(dp[j][k]) tmp.set(A[i][j]-k);
            dp[j] = tmp;
        }
        if(j > 0) {
            auto tmp = dp[j-1] << A[i][j];
            tmp |= dp[j-1] >> A[i][j];
            REP(k, A[i][j]) if(dp[j-1][k]) tmp.set(A[i][j]-k);
            dp[j] |= tmp;
        }
        // cerr << dp[j] << " ";
        // if(j == W-1) cerr << "\n";
    }
    for (int i = 0; i < size; i++) if(dp[W-1][i]) {
        cout << i << endl;
        return 0;
    }
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

struct edge{ int from, to, cost; };
int par[105];

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

int find(int x)
{
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	par[y] = x;
}


int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		vector<edge> e;
		REP(i, m)
		{
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			c = c/100 - 1;
			edge tmp = { a, b, c };
			e.push_back(tmp);
		}
		sort(e.begin(), e.end(), comp);

		REP(i, 105) par[i] = i;
		int cost = 0;
		REP(i, e.size())
		{
			if (find(e[i].from) != find(e[i].to))
			{
				cost += e[i].cost;
				unite(e[i].from, e[i].to);
			}
		}
		cout << cost << endl;
	}
	return 0;
}

Measured memory_bytes: 1392
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)

#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))

#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)

#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())

#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )

#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("out.txt","w",stdout)

/// DEBUG
#define deb             printf("OKA\n")
/// DEBUG ENDSk

using namespace std;

#define lim 200010
LL f[lim] , fact[lim] ,a[lim];

int main(){
       
       LL N;
       SL(N);
       FOR(i,1,N){
           
           SL(a[i]);
           f[a[i]]++;
       }
       LL ans = 0 , sum = 0;
       for( LL i = 1 ; i<lim  ; i++ ){
           fact[i] = (f[i]*(f[i]-1))/2;
           sum += fact[i]; 
       }

       for( LL i = 1 ; i<=N; i++ ){
           ans = (sum - ( f[ a[i] ] -1) );
           printf("%lld\n", ans);
       }
     

return 0;}

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

#define N 300005

int n,m,x,y,d[N],a[N],b[N],k;
vector<int>g[N];
int vis[N];

bool dfs(int u,int fa)
{
    int s=0;
    vis[u]=1,d[u]=d[fa]+1;
    for(auto v:g[u])
    {
        if(!vis[v])
            s^=dfs(v,u);
        else if(d[v]>d[u])
        {
            a[++k]=u,b[k]=v;
            s^=1;
        }
    }
    if(s)
        a[++k]=u,b[k]=fa;
    else
        a[++k]=fa,b[k]=u;
    return s^1;
}
int main()
{
   scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    if(!dfs(1,0))
        puts("-1");
    else
    {
        for(int i=1;i<=m;i++)
            printf("%d %d\n",a[i],b[i]);
    }
    return 0;
}


Measured memory_bytes: 20608
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

answer = [1 for _ in range(N)]

for a, b in AB:
    if H[a-1] <= H[b-1]:
        answer[a-1] = 0
    if H[b-1] <= H[a-1]:
        answer[b-1] = 0

print(answer.count(1))

Measured memory_bytes: 98764
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll dp[20010];

ll wt[1010],val[1010];

ll n,W;

void KnapSack(ll n,ll W,ll maxi)
{
    for(int i=0; i < n; i++)
        for(int j=wt[i]; j<W+maxi; j++)
            dp[j] = min(dp[j] , val[i] + dp[j-wt[i]]);
}


int main()
{
    IOS
    ll maxi=-1;
    for(int i=0;i<20010;i++)
    {
        dp[i]=1e12;
    }
    dp[0]=0;
    ll W,n;
    cin>>W>>n;
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
        maxi=max(maxi,wt[i]);
    }
    KnapSack(n,W,maxi);
    ll mini=LLONG_MAX;
    for(ll i=W;i<W+maxi;i++)
    {
        mini=min(mini,dp[i]);
    }
    cout<<mini<<"\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int next_perm(int *p, int n)
{
  int i, j, k, tmp;

  /* 上位桁のほうが下位桁よりも小さいところまで移動 */
  for(i = n - 1; i > 0 && p[i-1] >= p[i]; i--);

  /* pが最大(次の並べ替えがない) */
  if(i == 0) return 0;

  /* p[i-1]より値の大きい最も下位の桁をp[j]とする */
  for(j = n - 1; j > i && p[i-1] >= p[j]; j--);

  /* p[i-1]とp[j]とを交換 */
  tmp = p[i-1], p[i-1] = p[j], p[j] = tmp;

  /* p[i]から最下位までを逆順 */
  for(k = 0; k <= ((n-1)-i)/2; k++)
    tmp = p[i+k], p[i+k] = p[(n-1)-k], p[(n-1)-k] = tmp;

  return 1;
}

int main()
{
    int n,p[8],q[8],i,j,num[8],pp,qq;
    for (i = 1; i <= 8; i++)
    {
        num[i - 1] = i;
    }
    
    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&p[i]);
    }
    for (i = 0; i < n; i++)
    {
        scanf("%d",&q[i]);
    }
    
    j = 0;
    do {
        for (i = 0; i < n; i++)
        {
            if(p[i] != num[i])break;
        }
        if(i == n)pp = j;
        for (i = 0; i < n; i++)
        {
            if(q[i] != num[i])break;
        }
        if(i == n)qq = j;
        j++;
    }while (next_perm(num,n));

    printf("%d",abs(pp - qq));
}


Measured memory_bytes: 128
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)

h = Hash.new{0}

a.each do |rate|
  if rate/400 >= 8
    h[9] += 1
  else
    h[rate/400] += 1
  end
end

if h.has_key?(9)
  max_color = h.size - 1 + h[9]
  min_color = [h.size - 1, 1].max
else
  max_color = h.size
  min_color = h.size
end

p min_color
p max_color


Measured memory_bytes: 1788
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

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

int main()
{

    string s;
    getline(cin,s);
    if(s=="ABC")
    cout<<"ARC"<<endl;
    else
    cout<<"ABC"<<endl;
    return 0;
}


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

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

int main() {
  int N;
  for(;;) {
    cin>>N;
    if(!N) break;
    int n,d;
    int x[N],y[N];
    x[0] = 0,y[0] = 0;
    for(int i=0; i<N-1; ++i) {
      cin>>n>>d;
      x[i+1] = x[n]+dx[d];
      y[i+1] = y[n]+dy[d];
    }

    int minw, maxw, minh, maxh;
    minw = *min_element(x, x+N);
    minh = *min_element(y, y+N);
    maxw = *max_element(x, x+N);
    maxh = *max_element(y, y+N);
    cout<<maxw-minw+1<<" "<<maxh-minh+1<<endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct tokiomarine2020_b {
	std::string run(ll A, ll V, ll B, ll W, ll T) {
		ll dist = std::abs(A - B);
		ll v_diff = V - W;

		if(v_diff <= 0) {
			return "NO";
		}

		if(dist <= v_diff * T) {
			return "YES";
		}

		return "NO";
	}
};

int main(void) {
	tokiomarine2020_b solver;
	ll A, V, B, W, T;

	std::cin >> A >> V >> B >> W >> T;

	std::cout << solver.run(A, V, B, W, T) << std::endl;

	return 0;
}


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

int main()
{
  int X; std::cin >> X;
  int res{ 1 };
  for(int a = 1; a <= X; ++a)
    for(int b = 2; b <= X; ++b)
    {
      int i{ 1 };
      for(int p = b; p > 0; --p)
        i *= a;
      if(i <= X && i > 0)
        res = std::max(res, i);
      else
        break;
    }

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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	//ll n;
	cin>>n;
	cout<<n*n<<endl; 
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,Q,B[200010],C,D;
int A[200010];
std::string S;

#if 1
int main(){
	vector<int> v;
	int dim1,dim2,sum=0,p1=0,p2=0;
	cin>>N;
	REP(i,N){
		cin>>A[i];
		B[i]=A[i];
		sum+=A[i];
	}
	sort(A,A+N);
	dim1=A[N/2-1],dim2=A[N/2];
	REP(i,N){
		if(B[i]<=dim1){
			cout<<dim2<<endl;
		}
		else if(dim2<=B[i]){
			cout<<dim1<<endl;
		}
	}
	return 0;
}
#endif
#if 0
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
}
#endif

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

int main() {
  ll x;
  cin >> x;

  ll ans = 0;
  ll num = (x + 10) / 11;

  if (num * 6 + (num - 1) * 5 >= x) {
    ans = num * 2 - 1;
  } else {
    ans = num * 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <math.h>


int main(int argc, char const *argv[])
{
    int a;
    scanf("%d", &a);

    char str[11];
    scanf("%s", str);

    if(a < 3200){
        printf("red\n");
    }
    else{
        printf("%s\n", str);
    }
    
    return 0;
} 


Measured memory_bytes: 128