akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,ans,a[100005];
int main()
{
    n=read();reg int i,j,k;
    for(i=1;i<=n;++i)a[i]=read();
    sort(a+1,a+1+n);
    for(i=1;i<n;++i)
        for(j=i+1;j<n;++j)
        {
            k=lower_bound(a+1,a+1+n,a[i]+a[j])-a;
            if(k>n)k=n;while(a[k]>=a[i]+a[j])k--;
            ans+=k-j;
        }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string S;
  cin >> S;
  for(int l = (S.length() - 1) / 2; l >= 0; l--){
    if(S.substr(0, l) == S.substr(l, l)){
      cout << 2 * l << endl;
      break;
    }
  }
  return 0;
}


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

typedef long long int ll;

int main()
{
	ll n;
	scanf("%lld",&n);
	ll arr[n],ans=0;
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&arr[i]);
		ans=ans^arr[i];
	}
	for(ll i=0;i<n;i++)
		printf("%lld ",ans^arr[i]);
	printf("\n");
}



Measured memory_bytes: 5272
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int X;
  sc.scan(X);

  if (X == 7 || X == 5 || X == 3) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
/* ex 5-4
   TakayukiY*/

#include<stdio.h>

int main(void){
    //10文字以下の入力なので11文字分確保、ポインターの定義
    char seqence[11],*ptr;
    //インデックスと最大の長さの定義
    int i=0,max=0;
    //文字列を格納
    scanf("%s",seqence);
    //ポインターを格納
    ptr=seqence;

    while(*ptr){
        //ACGTの文字が現れたとき、現在の連続数iに1を加える
        if(*ptr=='A'||*ptr=='C'||*ptr=='G'||*ptr=='T'){
            i++;
        }
        //ACGT以外の文字が現れたとき、連続数iが今までの最大を超えれば更新
        //連続数iを初期化
        else{
            if(max<i) max=i;
            i=0;
        }
        ptr++;
    }
    //最後の文字までACGTだった場合の更新
    if(max<i) max=i;

    printf("%d",max);

    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
int main() {
    std::cin >> N;
    if(N <= 999) {
        printf("ABC\n");
    } else {
        printf("ABD\n");
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}


ll a[100009];


int main() {
	
	ll N, M, an = 1;
	cin >> N >> M;
	rep(i, M) {
		an *= 2;
	}
	cout << (1900 * M + 100 * (N - M)) * an << endl;
}

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

string arr[20];
int h,w;
int bfs(int x, int y){
    queue<pair<pair<int,int>,int>> q;
    bool visited[h][w];
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            visited[i][j]=false;
        }
    }
    int dst;
    int row,col;
    int maxdist=0;
    q.push(make_pair(make_pair(x,y),0));
    while(!q.empty()){
        row =q.front().first.first;
        col = q.front().first.second;
        dst = q.front().second;
        q.pop();
        if(visited[row][col]){
            continue;
        }
        if(dst>maxdist){
            maxdist = dst;
        }
        if(!visited[row][col]){
            visited[row][col]=true;
        }
        if(row!=h-1){
            if(arr[row+1][col]=='.' && !visited[row+1][col]){
                q.push(make_pair(make_pair(row+1, col),dst+1));
            }
        }
        if(row!=0){
            if(arr[row-1][col]=='.' && !visited[row-1][col]){
                q.push(make_pair(make_pair(row-1, col),dst+1));
            }
        }
        if(col!=w-1){
            if(arr[row][col+1]=='.' && !visited[row][col+1]){
                q.push(make_pair(make_pair(row, col+1),dst+1));
            }
        }
        if(col!=0){
            if(arr[row][col-1]=='.' && !visited[row][col-1]){
                q.push(make_pair(make_pair(row, col-1),dst+1));
            }
        }
    }
    return maxdist;
}

int main()
{
    cin>>h>>w;
    for(int i=0;i<h;++i){
        cin>>arr[i];
    }
    int total = 0;
    int res;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(arr[i][j]=='.'){
                res = bfs(i,j);
                if(res>total){
                    total = res;
                }
            }
        }
    }
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>


int main(void){
  int n,t,s;
  //0からsまでのs区間とsからtまでのt-s区間
  scanf("%d%d%d",&n,&t,&s);
  int i=0;
  int yade[3000][2]={{0}};//0に効果、1に時間
  for(i=0;i<n;i++){
    scanf("%d%d",&(yade[i][0]),&(yade[i][1]));
  }
  int dps[2][3005];//i行目で店iまで。
  int dpf[2][3005];//逆順で
  memset(dps,-1,sizeof(dps));
  memset(dpf,-1,sizeof(dpf));
  
  int mems[3005]={0};
  int memf[3005]={0};
  int j=0;
  int ma=0;
  int mb=0;
  dps[0][0]=0;
  dpf[0][0]=0;
  for(i=1;i<n+1;i++){
    for(j=0;j<s+1;j++){
      dps[i%2][j]=dps[(i+1)%2][j];
      if(j-yade[i-1][1]>=0 && dps[(i+1)%2][j-yade[i-1][1]]!=-1){
	 if(dps[i%2][j]<dps[(i+1)%2][j-yade[i-1][1]]+yade[i-1][0]){
	   dps[i%2][j]=dps[(i+1)%2][j-yade[i-1][1]]+yade[i-1][0];
	 }
      }
      ma=(ma<dps[i%2][j])?dps[i%2][j]:ma;
    }
    for(j=0;j<t-s+1;j++){
      dpf[i%2][j]=dpf[(i+1)%2][j];
      if(j-yade[n-i][1]>=0 && dpf[(i+1)%2][j-yade[n-i][1]]!=-1){
	if(dpf[i%2][j]<dpf[(i+1)%2][j-yade[n-i][1]]+yade[n-i][0]){
	  dpf[i%2][j]=dpf[(i+1)%2][j-yade[n-i][1]]+yade[n-i][0];
	}
      }
      mb=(mb<dpf[i%2][j])?dpf[i%2][j]:mb;
    }
    mems[i]=ma;
    ma=0;
    memf[i-1]=mb;
    mb=0;
  }
  mems[0]=0;
  memf[n]=0;
  int ans=0;

  for(i=0;i<n+1;i++){
    ans=(mems[i]+memf[n-i-1]>ans)?(mems[i]+memf[n-i-1]):ans;
    //printf("%d\x0020%d\n",mems[i],memf[n-i-1]);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1128
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0); 
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int s,w;
     cin>>s>>w;
     if(s<=w) cout<<"unsafe"<<endl;
     else cout<<"safe"<<endl;

     return 0;

}
///Alhamdulillah

Measured memory_bytes: 3652
#######################################
import numpy as np
#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i+1)

print(sum(ret[1:]))
print(" ".join(list(map(str, ret2[::-1]))))

Measured memory_bytes: 36928
import sys
input = sys.stdin.readline
 
#a,b,c = list(map(int,input().split()))
 
a = list(input().rstrip())

ans = 0

for dig in a:
  ans += int(dig)
  
#print(ans)
  
if ans % 9 ==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 77424
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;cin>>n>>a>>b;
  if(a>b){
    cout << '0'<<endl;
  }else{
    if(n==1){
      if(a==b){
        cout<< '1'<<endl;
      }else{
        cout << '0'<<endl;
      }
    }else{
      cout << (b-a)*(n-2)+1<<endl;
    }
  }
}
  

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

int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(n+1, -1);
    for (int i = 0; i < m; i++) {
        int tmp;
        std::cin >> tmp;
        a[tmp] = 0;
    }

    a[0] = 1;
    if (a[1] != 0) a[1] = 1;

    for (int i = 2; i <= n; i++) {
        if (a[i] != 0) {
            a[i] = 0;
            a[i] += a[i - 1];
            a[i] += a[i - 2];
            a[i] %= 1000000007;
        }
    }

    std::cout << a[n] << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[110][5],dp2[110][5];
signed main(){
  string N;
  int K;
  cin>>N>>K;
  dp2[0][0]=1;
  for(int i=0;i<N.size();i++){
    for(int j=0;j<=K;j++){
      dp[i+1][j]=dp[i][j]+(N[i]!='0'?dp2[i][j]:0);
      dp2[i+1][j]=(N[i]=='0'?dp2[i][j]:0);
    }
    for(int j=0;j<K;j++){
      dp[i+1][j+1]+=dp[i][j]*9+dp2[i][j]*max(N[i]-'1',0);
      dp2[i+1][j+1]+=(N[i]!='0'?dp2[i][j]:0);
    }
  }
  cout<<dp[N.size()][K]+dp2[N.size()][K]<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
int a, b ;
string s;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> s;
    int n = (int)s.size();
    if(n != a + b + 1)return 0 * printf("No\n");
    bool da = true;
    if(s[a] != '-'){
        da = false;
    }
    for(int i = 0; i < n; i ++){
        if(i == a)continue;
        if(s[i] >= '0' && s[i] <= '9'){
            
        }
        else{
            da = false;
        }
    }
    if(da)puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int main()
{
	int k,s,l;
	int ans=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++){
			l=s-i-j;
			if(l>=0&&l<=k)ans++;
		}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    vector<string> grid(100,"");
    for(int i = 0; i < 100; i++)
    {
        for(int j = 0; j < 100; j++)
        {
            if (j<=49) {
                grid[i] += "#";
            }
            else
            {
                grid[i] += ".";
            }
        }
    }
    a--;
    b--;
    int co=0;
    while(a>0){
        grid[(co/25)*2].replace(2*(co%25),1,".");
        co++;
        a--;
    }
    co=0;
    while(b>0){
        grid[(co/25)*2].replace(2*(co%25)+51,1,"#");
        co++;
        b--;
    }

    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 100; i++)
    {
        cout << grid[i] << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int a, b, t, res=0, tot=0, i, j, k, l;
    cin>>a>>b>>t;
    res=t/a;
    tot=res*b;
    cout<<tot<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  unordered_map<int, int> map;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    for (int i = -1; i <= 1; ++i) {
      if(map.find(a + i) == map.end())
        map[a + i] = 0;
      ++map[a + i];
    }
  }
  // Gets max value.
  auto it = max_element(map.begin(), map.end(),
      [] (const auto& left, const auto& right) {
        return left.second < right.second;
      });
  cout << it->second << endl;
}


Measured memory_bytes: 4260
/*
A2740
title:Rooted Tree for Misawa-san
@kankichi573
*/
#include <stdio.h>
#include <string.h>
char input_tree[2][100000];
char ans[100000];
char *ap;
char zeros[1]="\0";

typedef struct  {
  char *sptr;
  int  len;
} mystr_;

void display(mystr_ *str)
{
  int i;
  for(i=0;i<str->len;i++)
    printf("%c",str->sptr[i]);
#ifdef DEBUG
  printf("{%d}",str->len);
#endif
  printf("\n");
}

void analyze_tree(mystr_ *in,mystr_ *left,mystr_ *right,int *val)
{
  char *p;
  int lv,i;

  left->sptr = p = in->sptr;

  for(i=0,lv=0;i<in->len;i++)
    {
      if(p[i]=='[')
	{
	if(lv==0)
	  {
	    left->len=i;
	    *val = atoi(p+i+1);
	  }
	
	
	  lv++;
	}
      else if(p[i]==']')
	{
	  if(lv==1)
	    {
	      right->sptr=&p[i+1];
	      right->len =in->len-i-1;
	    }
	  lv--;
	}
      else if(p[i]=='(')
	lv++;
      else if(p[i]==')')
	lv--;
    }
}

int is_empty_tree(mystr_ *in)
{
  if(in->len==2)
    return(1);
  else
    return(0);
}

void remove_paren(mystr_ *in)
{
  in->len  -= 2;
  in->sptr ++;
}


void add_tree(mystr_ *in1,mystr_ *in2,mystr_ *out)
{
  mystr_ stree[2][2],sstree[2];
  int v[2],val,le,i;

  analyze_tree(in1,&stree[0][0],&stree[0][1],&v[0]);
  analyze_tree(in2,&stree[1][0],&stree[1][1],&v[1]);
  val = v[0]+v[1];

  if(is_empty_tree(&stree[0][0]) || is_empty_tree(&stree[1][0]))
    {
      sstree[0].sptr=zeros;
      sstree[0].len =0;
    }
  else
    {
      remove_paren(&stree[0][0]);
      remove_paren(&stree[1][0]);
      add_tree(&stree[0][0],&stree[1][0],&sstree[0]);
    }
  if(is_empty_tree(&stree[0][1]) || is_empty_tree(&stree[1][1]))
    {
      sstree[1].sptr=zeros;
      sstree[1].len =0;
    }
  else
    {
      remove_paren(&stree[0][1]);
      remove_paren(&stree[1][1]);
      add_tree(&stree[0][1],&stree[1][1],&sstree[1]);
    }

  out->sptr=ap;

  sprintf(ap,"(%.*s)[%d](%.*s)",sstree[0].len,sstree[0].sptr,val,
	  sstree[1].len,sstree[1].sptr);

  while(*ap)
    ap++;
  out->len=ap - out->sptr;

}

int main()
{
  char *l,*r;
  int llen,rlen,val;
  mystr_ tree[3],ltree,rtree;
  
  scanf("%s",&(input_tree[0][0]));
  tree[0].sptr=&(input_tree[0][0]);
  tree[0].len =strlen(&(input_tree[0][0]));
  scanf("%s",&(input_tree[1][0]));
  tree[1].sptr=&(input_tree[1][0]);
  tree[1].len =strlen(&(input_tree[1][0]));
  ap=&ans[0];

  add_tree(&tree[0],&tree[1],&tree[2]);
  display(&tree[2]);

  return(0);
}

Measured memory_bytes: 672
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  
  int check=0;
  
  for(int i=0;i<(S.size()-1)/2+1;i++){
    if(S[i]==S[(S.size()-1)/2+1+i]){
      check++;
    }
  }
  if(check==(S.size()-1)/2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3608
#include<cstdio>//AT3960
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

const int N=200010;

int n,a[N];

long long ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	if(a[1]!=0){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(a[i+1]-a[i]>1){
			printf("-1\n");
			return 0;
		}
		if(a[i+1]-a[i]!=1){
			ans+=a[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
def ite(N, M):
    import itertools
    return itertools.combinations_with_replacement(range(M),N)
def check(li):
    for i in range(len(li)-1):
        if li[i] > li[i+1]:
            return False
    return True
    
def score(l1, l2):
    s = 0
    for (a, b, c, d) in l2:
      if l1[b-1] - l1[a-1] == c:
            s += d
    return s
        

N, M, Q = list(map(int, input().split(" ")))
li = []
for i in range(Q):
    li.append(list(map(int, input().split(" "))))

m_s = 0
for l2 in ite(N, M):
    s = score(l2, li)
    if m_s < s:
      m_s = s
            
print(m_s)

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int a[maxn];
void run_case()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        ans ^= a[i];
    }
    //cout << ans << "\n";
    for (int i = 1; i <= n; i++)
    {
        int res = ans ^ a[i];
        cout << res << " ";
    }
    cout << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4376
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ai = [(0, -1)] + [(a, i+1) for i, a in enumerate(A)]
    ai.sort()
    A = [a for a, i in ai]
    I = [i for a, i in ai]
    ans = [0] * (N+1)

    i = N
    same = 0
    q = []
    while i != 0:
        j = i
        while True:
            j -= 1
            if I[j] < I[i]:
                break
            heapq.heappush(q, A[j])
        d = A[i] - A[j]
        ans[I[i]] = d * (same+1)
        same += 1
        while q and q[0] >= A[j]:
            b = heapq.heappop(q)
            ans[I[i]] += b - A[j]
            same += 1
        i = j
    for r in ans[1:]:
        print(r)

def main():
    N = read_int()
    A = read_int_n()
    (slv(N, A))


if __name__ == '__main__':
    main()


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

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    vector<ll> nums(N);
    rrep(i,N-1) cin>>nums[i];
    
    
    ll low=2, hig=2;
    rep(i,N){
        ll a=nums[i];
        ll nxtlow = (ll)ceill(1.*low/a)*a;
        ll nxthig = (ll)(hig/a+1)*a-1;
        if(!(nxtlow>=low&&nxtlow<=hig)){
            cout1(-1);
            return 0;
        }else{
            low = nxtlow;
            hig = nxthig;
        }
    }
    cout2(low,hig)
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

struct edge { int to, cost, time, com; };

vector<edge> g[105];
int dp[1<<8], ticket[1<<8], fee[1<<8];
int d[105][30];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n, m, h, k;
    cin >> n >> m >> h >> k;
    if(!n) break;
    REP(i, 1<<k) dp[i] = ticket[i] = fee[i] = 0;
    REP(i, n) g[i].clear();
    REP(i, m) {
      int a, b, c, h, r;
      cin >> a >> b >> c >> h >> r;
      a--, b--;
      g[a].PB({b, c, h, r-1});
      g[b].PB({a, c, h, r-1});
    }
    int s, t;
    cin >> s >> t; s--, t--;
    int p;
    cin >> p;
    REP(i, p) {
      int l;
      cin >> l >> fee[i];
      REP(j, l) {
        int com;
        cin >> com; com--;
        ticket[i] |= 1<<com;
      }
      // cout << "ti:" << ticket[i] << endl;
    }

    REP(i, 1<<k) dp[i] = INF;
    dp[0] = 0;
    REP(i, 1<<k) REP(j, p) chmin(dp[i | ticket[j]], dp[i] + fee[j]);

    int ans = INF;
    REP(i, 1<<k) {
      // iの会社はただで使えるとする
      int ret = dp[i];
      // cout << i << " " << ret << endl;

      REP(j, 105) REP(l, 30) d[j][l] = INF;
      d[s][0] = 0;
      priority_queue<VI, VVI, greater<VI>> que;
      que.push({d[s][0], s, 0});

      while(que.size()) {
        VI v = que.top(); que.pop();
        if(v[1] == t) break;
        for(edge e: g[v[1]]) {
          int n_cost = d[v[1]][v[2]] + (i & 1 << e.com ? 0 : e.cost);
          // cout << i << " " << e.com << " " << n_cost << " " << d[v[1]][v[2]] << endl;
          if(v[2] + e.time <= h && d[e.to][v[2]+e.time] > n_cost) {
            d[e.to][v[2]+e.time] = n_cost;
            que.push({d[e.to][v[2]+e.time], e.to, v[2]+e.time});
          }
        }
      }

      int mi = INF;
      REP(j, h+1) chmin(mi, d[t][j]);
      chmin(ans, ret+mi);
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3440
while True:
    m, f, r = map(int, input().split())

    if m == f == r == -1:
        break

    if ((m == -1) or
        (f == -1)):
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5592
s=input()
i,b=0,0
while i<len(s):
	if (((s[i]=='R') & (i%2==1))|((s[i]=='L') & (i%2==0))):
		b=1
		break
	i+=1
if(b):
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3188
def resolve():

    s = input()
    n = len(s)

    ans = 0

    for i in range(2 ** (n - 1)):

        cnt = 0
        for j in range(n - 1):

            if (i >> j) & 1:
                ans += int(s[j-cnt:j+1])
                cnt = 0

            else:
                cnt += 1

        ans += int(s[n-cnt-1:n])

    print(ans)
    
resolve()

Measured memory_bytes: 39280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) *min_element(ALL((vec)))
#define MAX(vec) *max_element(ALL((vec)))
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define zero_pad(num) setfill('0') << std::right << setw(num)

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);
int sum_digit(int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

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

    int f_N = sum_digit(N);
    if (N%f_N == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') REP(i, vec.size()) vec.at(i) += num;
    else if (ch == '-') REP(i, vec.size()) vec.at(i) -= num;
    else if (ch == '*') REP(i, vec.size()) vec.at(i) *= num;
    else if (ch == '/') REP(i, vec.size()) vec.at(i) /= num;
    else if (ch == '%') REP(i, vec.size()) vec.at(i) %= num;
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int sum_digit(int num) {
    int sum = 0;
    while (num > 0) {
        sum += num%10;
        num /= 10;
    }

    return sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//懒人专用头文件
using namespace std;
string s;char c;
main()
{
	cin>>s;
	for(register int i=1;cin>>c/*一直输入*/;i+=2/**/)s.insert(i,&c/*记住，要取地址*/);
	cout<<s;/*输入文件里有回车，所以不用手动添加endl*/
}

Measured memory_bytes: 256
n = int(input())
list_a = list(map(int, input().split()))
list_b = [0]*n
for i in range(0,n):
    if n % 2 == 1:
        if i % 2 == 0:
            list_b[(n-1)//2 - i//2] = list_a[i]
        else:
            list_b[(n-1)//2 + (i+1)//2] = list_a[i]
    else:
        if i % 2 == 1:
            list_b[n//2 - (i+1)//2] = list_a[i]
        else:
            list_b[n//2 + i//2] = list_a[i]

for i in range(0,n):
    list_b[i] = str(list_b[i])
print(" ".join(list_b))


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

using namespace std;

int solve(){
  string g;
  int y, m ,d;

  cin >> g >> y >> m >> d;

  if(g == "#") return 0;
  
  if(y >= 32 || (y == 31 && m >= 5)){
    g = "?";
    y -= 30;
  }
  
  cout << g << " " << y << " " << m << " " << d << endl;
  return 1;
}

int main(){
  while(solve());
}



Measured memory_bytes: 3188
solve :: Int -> Int -> Int -> Bool
solve n m k
  | k `rem` n == 0 = True
  | k `rem` m == 0 = True
  | otherwise = elem k $ do
      a <- [1..n]
      f a <$> [1..m]
  where
    f a b = m * a + n * b - a * b * 2

main :: IO ()
main = do
    [n,m,k] <- map read . words <$> getLine :: IO [Int]
    putStrLn $ if solve n m k then "Yes" else "No"

Measured memory_bytes: 1020
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


        long n = Long.parseLong(br.readLine());
        StringBuilder sb = new StringBuilder();
        int position = 26;

        while (n > 0) {
            int letter = (int)((n - 1) % 26 + 1);
            sb.append((char)('a' + letter - 1));
            n -= letter;
            n /= 26;
        }

        bw.write(sb.reverse().toString());
        bw.newLine();

        bw.close();
        br.close();
    }
}


Measured memory_bytes: 32716
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a<10){
		cout<<a<<'\n';
	}else if(a>=10 && a<100){
		cout<<9<<'\n';
	}else if(a>=100 && a<1000){
		cout<<a-90<<'\n';
	}else if(a>=1000 && a<10000){
		cout<<909<<'\n';
	}else if(a>=10000 && a<100000){
		cout<<a-9090<<'\n';
	}else if(a==100000){
		cout<<90909<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        mut n: usize
    }

    let mut ans: Vec<char> = Vec::new();
    while 0 < n {
        n -= 1;
        let c = (n % 26) as u32;
        ans.push(std::char::from_u32(c + ('a' as u32)).unwrap());
        n /= 26;
    }

    ans.reverse();
    for c in ans {
        print!("{}", c);
    }
    println!();

}


Measured memory_bytes: 2196
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    while(true) {
      val h, w = scanner.nextInt
      if((h == 0) && (w == 0)) System.exit(0)
      println("#" * w)
      print(("#" + "." * (w - 2) + "#\n") * (h - 2))
      println("#" * w)
      println()
    }
  }
}


Measured memory_bytes: 45372
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll p=1e9+1;
ll d[mm];
map<ll,ll> name;
double pi=3.141592654;
int main()
{
	    double a,b,c,d,e,f,T;
		scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
		c=c*30+(d/60)*30;
		d=d*6;
		c=fabs(c-d);
		if(c>360-c) c=360-c;
		printf("%.11f\n",sqrt(a*a+b*b-2*b*a*cos(pi*c/180))); 
	
	
}

Measured memory_bytes: 4252
#include"bits/stdc++.h"
using namespace std;

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    vector<int> a(3), b(3);
    bool ok = false;
    for (int i = -100; i <= 100; i++) {
        a[0] = i;
        for (int j = 0; j < 3; j++) {
            b[j] = c[0][j] - a[0];
        }
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];

        bool flag = true;
        for (int j = 1; j < 3; j++) {
            for (int k = 1; k < 3; k++) {
                if (c[j][k] != a[j] + b[k]) {
                    flag = false;
                }
            }
        }
        if (flag) {
            ok = true;
            break;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>

char buf[102];
int cnt[27];

int main(){
  int H, W; scanf("%d%d", &H, &W);

  for(int i = 0; i < H; i++){
    scanf("%s", buf);
    for(int j = 0; j < W; j++) cnt[buf[j] - 'a' + 1]++;
  }

  int n4 = 0, n2 = 0, n1 = 0;

  if(H % 2 == 0 && W % 2 == 0){
    n4 = H * W / 4;
  }
  if(H % 2 == 0 && W % 2 == 1){
    n2 = H / 2; n4 = (W - 1) * H / 4;
  }
  if(H % 2 == 1 && W % 2 == 0){
    n2 = W / 2; n4 = (H - 1) * W / 4;
  }
  if(H % 2 == 1 && W % 2 == 1){
    n1 = 1; n2 = (H - 1) / 2 + (W - 1) / 2; n4 = (H - 1) * (W - 1) / 4;
  }

  for(int i = 1; i <= 26; i++){
    if(cnt[i] % 2 == 1){
      if(n1 == 0){ puts("No"); return 0; }
      cnt[i]--; n1--;
    }
  }

  if(n1 != 0){ puts("No"); return 0; }

  for(int i = 1; i <= 26; i++){
    if(cnt[i] % 4 == 2){
      if(n2 == 0){ puts("No"); return 0; }
      cnt[i] -= 2; n2--;
    }
  }

  for(int i = 1; i <= 26; i++){
    while(n2 > 1 && cnt[i] > 0){ cnt[i] -= 4; n2 -= 2; }
  }

  if(n2 != 0){ puts("No"); return 0; }

  for(int i = 1; i <= 26; i++){
    if(cnt[i] % 4 != 0){ puts("No"); return 0; }
  }

  puts("Yes");
  return 0;
}

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



int main(){
    string A , B;
    cin >> A >> B;

    if(A.size() > B.size()){
        cout << "GREATER" << endl;
        return 0;
    }else if(A.size() < B.size()){
        cout << "LESS" << endl;
        return 0;
    }



    for(int i = 0; i < A.size(); i++){
        if(A[i] > B[i]){
            cout << "GREATER" << endl;
            return 0;
        }else if(A[i] < B[i]){
            cout << "LESS" << endl;
            return 0;            
        }
    }
    cout << "EQUAL" << endl;
}


Measured memory_bytes: 384
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
//#define mp make_pair 
typedef long long ll;
#define int long long
#pragma GCC optimize("Ofast")

const int maxn = 2e5+10;
const int mod = 1e9+7;
const ll inf = 1e18+10;
//const int N = 2e6+10;

ll pw(ll a, ll b)
{
    if(b == 0) return 1;
    ll x = pw(a,b/2); x = (x*x) % mod;
    if(b & 1) x = (x*a) % mod;
    return x;
}

int n;
int a[maxn], d[maxn];

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

    cin>> n;
    int R = n-(n&1)+1;
    int X = 1;
    for(int i = 1; i <= n-1; i++)
    {
        d[i] = ++X;
        d[R-i] = X;
    }
    d[R] = ++X;

    vector<pair<int,int>> edge;
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++)
            if(d[i] != d[j])
                edge.push_back({i,j});
    
    cout<< edge.size() <<"\n";
    for(auto e : edge)
        cout<< e.F <<" "<< e.S <<"\n";
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=1
    for i in range(1,n):
        if l[i]==max(l[:i+1]):
            cnt+=1
    print(cnt)
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> A(N);
  std::unordered_map<int, int> m;
  long long sum = 0;
  rep(i, N)
  {
    cin >> A[i];
    sum += A[i];
    m[A[i]]++;
  }

  int Q;
  cin >> Q;
  rep(i, Q)
  {
    int B, C;
    cin >> B >> C;
    sum -= (long long)B * m[B];
    sum += (long long)C * m[B];
    cout << sum << endl;
    m[C] += m[B];
    m[B] = 0;
  }

  return 0;
}


Measured memory_bytes: 7440
c = input()

if c == "a" :
    print("vowel")
elif c == "e" :
    print("vowel")
elif c == "i" :
    print("vowel")
elif c == "o" :
    print("vowel")
elif c == "u" :
    print("vowel")
else : # 単純出力
    print("consonant")


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LI long int
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(void){
    string s,t; cin>>s>>t;
    int x[100001]={},y[100001]={};
    FOR(i,0,s.size()){
        x[i+1]=x[i]+(s[i]=='A'?1:2);
    }
    cout<<endl;
    FOR(i,0,t.size()){
        y[i+1]=y[i]+(t[i]=='A'?1:2);
    }
    int q; cin>>q;
    FOR(i,0,q){
        int a,b,c,d; cin>>a>>b>>c>>d;
        YES((x[b]-x[a-1]-y[d]+y[c-1]+300000000)%3==0);
    }
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

char s1[15], s2[15], s3[15];
int main()
{
	while(scanf("%s %s %s", s1, s2, s3) != EOF)
	{
		//printf("%s %s %s\n", s1, s2, s3);
		printf("%c%c%c\n", s1[0] - 32, s2[0] - 32, s3[0] - 32);
		memset(s1, 0, sizeof(s1));
		memset(s2, 0, sizeof(s2));
		memset(s3, 0, sizeof(s3));
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { cin >> b[i]; }
	
	if(a > b) { swap(a, b); }
	
	int ans = 0;
	until(a == b) { ans++; next_permutation(ALL(a)); }
	
	cout << ans << endl;
	
	return 0;
}


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

struct node{
    int key;
    node* right;
    node* left;
    node* parent;
};

node *root;

//??????x??\???????°????
node* treeMinimum(node* x){
    while (x->left!=NULL)
        x=x->left;
    return x;
}

//????????????????????¶?????¨x????????????????????????????????????????°????
node* treeSuccessor(node* x){
    if(x->right!=NULL)
        return treeMinimum(x->right);
   //node* y=x->parent;
   // while(y!=NULL&&x==y->right){
        //x=y;
       // y=y->parent;
    //}
    //return y;
}

void treeDelete(node* z){
    //????????????????±?
    node* y;
    //y????????????
    node* x;

    //????????????????????????
    if(z->left==NULL||z->right==NULL)
        y=z;
    else
        y=treeSuccessor(z);

    //??????y????????????x???y????????????????????????
    if(y->left!=NULL)
        x=y->left;
    else
        x=y->right;

    //???x?????¶?????????????????????y?????¶??????
    if(x!=NULL)
        x->parent=y->parent;
    if(y->parent==NULL)
        root=x;
    else if(y==y->parent->left)
        y->parent->left=x;
    else
        y->parent->right=x;
    if(y!=z)
        z->key=y->key;
    delete y;

}

//?????\
void insert(int k){
    node *y = NULL;
    node *x = root;
    node *z;

    z = new node;
    z->key=k;
    z->left=NULL;
    z->right=NULL;

    while(x!=NULL){
        y=x;
        if(z->key<x->key)
            x=x->left;
        else
            x=x->right;
    }

    z->parent=y;
    if(y==NULL)
        root=z;
    else{
        if(z->key<y->key)
            y->left=z;
        else
            y->right=z;
    }

}

//????´¢
node* find(node* u,int k){
    while(u!=NULL&&k!=u->key){
        if(k<u->key)
            u=u->left;
        else
            u=u->right;
    }
    return u;
}

void inorder(node* u){
    if(u==NULL)
        return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node* u){
    if(u==NULL)
        return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            node* t=find(root,x);
            if(t!=NULL)
                printf("yes\n");
            else
                printf("no\n");
        }
        else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com=="delete"){
            scanf("%d",&x);
            treeDelete(find(root,x));
        }
    }
}

Measured memory_bytes: 21912