akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int d, g;
    cin >> d >> g;

    vector<pair<long long int,long long int>> v(d);
    REP(i,d){
        scanf("%lld %lld", &v[i].first, &v[i].second);
    }

    long long int tmp_score,tmp_result, result = linf,max_hanpa=0;

    for (long long int bit = (long long int)pow(2, d) - 1; bit >= 0;bit--){
        tmp_score = 0;
        tmp_result = 0;

        REP(i,d){
            if(bit&(long long int)pow(2,i)){
                tmp_score += (i+1) * 100 * v[i].first + v[i].second;
                tmp_result += v[i].first;
            }else{
                max_hanpa = i;
            }
        }
        if(tmp_score<g){
            if(g-tmp_score < v[max_hanpa].first*(max_hanpa+1)*100){
                tmp_result += (g - tmp_score+(max_hanpa+1)*100-1) / ((max_hanpa+1) * 100);
            }else{
                continue;
            }
        }

        result = min(result, tmp_result);
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  
  vector<string> mjrt(H);
  
  int i;
  for(i=0; i<H; i++) {
    cin >> mjrt.at(i);
  }
  
  for(i=0; i<W+2; i++){
  	cout << "#";
  }
  cout << endl;
  
  for(i=0; i<H; i++){
    cout << "#" << mjrt.at(i) << "#" << endl;
  }
  
  for(i=0; i<W+2; i++){
  	cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class Button {
public:
  char vowel;
  char consonant;

  Button(int num){
    conv[1] = 'a';
    conv[2] = 'k';
    conv[3] = 's';
    conv[4] = 't';
    conv[5] = 'n';
    conv[6] = 'h';
    conv[7] = 'm';
    conv[8] = 'y';
    conv[9] = 'r';
    conv[0] = 'w';
    
    //aiueo
    //'T','L','U','R','D';
    flick['T'] = 'a';
    flick['L'] = 'i';
    flick['U'] = 'u';
    flick['R'] = 'e';
    flick['D'] = 'o';

    vowel = conv[num];
  }
  void push(char dir){
    if(vowel == 'w' && dir == 'U'){
      cout << "nn";
    }
    else if(vowel == 'a'){
      cout << flick[dir];
    }
    else{
      cout << vowel <<flick[dir];
    }
  }
private:
  map<int,char> conv;
  char flick[256];
};

int main(){
  string str;
  while(cin >> str){
    for(int i=0;i<str.size();i+=2){
      int num = str[i] - '0';
      char dir = str[i+1];
      Button button(num);
      button.push(dir);
    }
    cout << "\n";
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e9+7;

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int m = max(x,y);
    ll ans=INF;
    for(int i=0;i<=m;i++){
        ll tans = i*2*c+max(x-i,0)*a+max(y-i,0)*b;
        ans = min(tans,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key)
{
	int i=0;
	A[n]=key;
	while(A[i] != key)
	{
		i++;
	}	
	return i != n;
}

int main()
{
	int i,n,A[10000+1],q,key,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&key);
		if(search(A,n,key))sum++;
	}
	printf("%d\n",sum);
	return 0;

}


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

int main()
{
	int r, d, x;; cin >> r >> d >> x;

	int x_next;
	int x_now = x;
	for (int  i = 1; i <= 10; i++) {
		x_next = r * x_now - d;
		cout << x_next << endl;
		x_now = x_next;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, M;
	while (scanf("%d%d", &N, &M) == 2 && (N != 0 || M != 0)) {
		int i;
		int asumikana = M / N;
		int igutiyuka = 0;
		for (i = 0; i < N; i++) {
			int A;
			if (scanf("%d", &A) != 1) return 0;
			igutiyuka += A >= asumikana ? asumikana : A;
		}
		printf("%d\n", igutiyuka);
	}
	return 0;
}



Measured memory_bytes: 2068
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL a, b, k;
	cin >> a >> b >> k;
	LL t = min(a, k);
	a -= t;
	b -= min(b, k - t);
	cout << a << " " << b << "\n";
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define UMLL unordered_map<ll,ll>
#define UMII unordered_map<int,int>
#define VI vector<int>
#define VL vector<ll>
#define S second
#define F first
#define PB push_back


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

    int n;
    string s;
    cin>>n>>s;
    if(n<3200)
        cout << "red";
    else
        cout << s;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

//根からの距離の偶奇が一致する時２点の距離は偶数になることを利用する
struct Edge{//一回で二つの整数を格納する　コンストラクタ？？
    ll to; ll cost;
    Edge(ll to,ll cost) : to(to), cost(cost){}
};

int N;
vector<Edge> G[101000];

int ans[101000];
bool visited[101000];

void dfs(int s,ll cost){
	if(visited[s]){
      return ;
    }

	visited[s]=true;

	if(cost % 2 == 0){
      ans[s]=0;
    }
	else{
      ans[s]=1;
    }
    

	for(auto p:G[s]){// struct Edgeで二つの整数を格納できるようにした場合のそれぞれの要素の特定方法
		dfs(p.to, cost + p.cost);
	}
}

int main(){
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back(Edge(v,w));
		G[v].push_back(Edge(u,w));
	}
	dfs(0,0);
	for(int i = 0; i < N; i++){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = (v[0] + v[1]) / pow(2.0, N - 1);
  for (int i = 2; i < N; i++) {
    ans += v[i] / pow(2.0, N - i);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
	io
	int n;
  	cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  int j=0;
  int ans=0,temp=0;
  while(j<n-1){
  	temp=0;
    while(v[j+1]<=v[j]&&j<n-1){
      j++;
      temp++;
     }
     j++;
    ans=max(ans,temp);
   }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX_E = 100100;
struct edge{
    int u,v,cost;
};

// Union-Find
// n要素で初期化
void init(int par[], int rank[], int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rank[i] = 0;
    }
}

// 木の根を求める
int find(int par[], int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par,par[x]);
    }
}

// xとyの属する集合を併合
void unite(int par[], int rank[], int x, int y){
    x = find(par,x);
    y = find(par,y);
    if(x == y) return;

    if(rank[x] < rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rank[x] == rank[y]) rank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int par[], int x, int y){
    return find(par,x) == find(par,y);
}

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

long long int kruscal(int V, int E, edge es[]){
    sort(es, es + E, comp); // edge.costが小さい順にソートする

    int par[V]; // 親
    int rank[V]; // 木の深さ
    init(par, rank, V); // Union-Findの初期化
    long long int res = 0;
    for(int i=0; i<E; i++){
        edge e = es[i];
        if(!same(par, e.u, e.v)){
            unite(par, rank, e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    int V; // 頂点数
    int E; // 辺数
    cin >> V >> E;
    edge es[MAX_E]; // 辺の大きさ

    rep(i, E){
        cin >> es[i].u >> es[i].v >> es[i].cost;
    }

    ll ans = kruscal(V, E, es);

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



Measured memory_bytes: 4356
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int x=0;
    int maxx=0;
    rep(i,0,n){
        if(s[i]=='I')x++;
        else x--;
        maxx=max(maxx,x);
    }
    cout<<maxx<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n = 3;
  vector<vector<int>> c(n, vector<int>(n));
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  bool res = true;
  for (int i = 1; i < n; i++){
    for (int j = 1; j < n; j++){
      if (c[0][0] + c[i][j] != c[i][0] + c[0][j]){
        res = false;
      }
    }
  }
  cout << (res ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, a[1000], t = -1, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);


  for (int i = 0; i < N; i++) {
    if (t != a[i]) {
      ans++;
      t = a[i];
    }
  }

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


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


using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>v(h+2,vector<char>(w+2,'#'));

    for(int i = 1;i <= h;i++){
        for(int j = 1;j <= w;j++){
            char c;
            cin >> c;
            v[i][j] = c;
        }
    }

    for(int i = 0;i < h+2;i++){
        for(int j = 0;j <w+2;j++)
            cout << v[i][j];
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 256
a = map(int, input().split())
paint_list = list(a)

if paint_list[0] == paint_list[1] == paint_list[2]:
    print(1)
elif paint_list[0] == paint_list[1] and paint_list[0] != paint_list[2]:
    print(2)
elif paint_list[0] == paint_list[2] and paint_list[0] != paint_list[1]:
    print(2)
elif paint_list[1] == paint_list[2] and paint_list[0] != paint_list[1]:
    print(2)
else:
    print(3)

Measured memory_bytes: 9200
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	string a, b, c;
	int d;
	cin >> a >> b;
	c = a + b;
	d = atoi(c.c_str());
	if (d == 100000)return 0;
	for (int i = 0; d >= i*i; i++) {
		if (d == pow(i, 2)) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	
	return(0);
}

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



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

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));


int main()
{
    int n;cin>>n;
    int res=n%10;
    if(res==2 ||res==4||res==5||res==7||res==9){
        cout<<"hon"<<endl;
    }else if (res==3)
    {
        cout<<"bon"<<endl;
    }else{
        cout<<"pon"<<endl;
    }
    

    return 0;

}




Measured memory_bytes: 3620
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	maxIndex := -1
	max := 0
	max2 := 0

	for i := 0; i < n; i++ {
		num := nextInt()

		if num > max {
			max2 = max
			maxIndex = i
			max = num
		} else if num > max2 {
			max2 = num
		}
	}

	for i := 0; i < n; i++ {
		if i == maxIndex {
			fmt.Println(max2)
		} else {
			fmt.Println(max)
		}
	}
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;
#define m 1000000007

const int mxn = 2e5 + 5;
ll add[mxn];
void takbir(){
    for(ll i = 1; i<=mxn; i++) add[i] = add[i-1] + i;
}

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

    takbir();
    int n, k; cin>>n>>k;
    
    ll ans = 0, maxsum = 0, minsum = 0;
    for(int i = k; i<=n+1; i++){
        minsum = add[i-1];
        maxsum = add[n]-add[n-i];
        minsum = (maxsum - minsum + 1)%m;
        ans = (ans + minsum)%m;
    }
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int N;
    cin >> N;

    cout << 3*pow(N,2) << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=a+b;
  int r=c+d;
  if(l<r){cout<<"Right";}
  else if(l==r){cout<<"Balanced";}
  else{cout<<"Left";}
}

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

int main() {

  string s, t;
  cin >> s >> t;

  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));

  dp[0][0] = 0;

  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j]+1;
      } else {
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
      }
    }
  }

  string answer = "";
  int i = s.size();
  int j = t.size();

  while (i && j) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      i--;
      j--;
      answer += s[i];
    }
  }

  reverse(answer.begin(), answer.end());
  cout << answer << endl;

}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

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

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

int main () {
    int n, l;
    while (cin >> n >> l, n + l) {
        vector<vector<pii>> v(l + 1);
        REP (i, 0, n) {
            char d;
            int p;
            cin >> d >> p;
            v[p].push_back({(d == 'R'), i + 1});
        }
        int cnt = n;
        int ans = -1;
        int tm = -1;
        REP (i, 0, l + 1) {
            if (cnt == 0) break;
            vector<vector<pii>> vv(l + 1);
            REP (j, 0, v.size()) {
                REP (k, 0, v[j].size()) {
                    if (v[j][k].first == 0) {
                        vv[j - 1].push_back(v[j][k]);
                    } else {
                        vv[j + 1].push_back(v[j][k]);
                    }
                }
            }
            REP (j, 0, vv.size()) {
                if (vv[j].size() >= 2) {
                    REP (k, 0, vv[j].size()) {
                        vv[j][k].first = 1 - vv[j][k].first;
                    }
                }
            }
            if (vv[vv.size() - 1].size() > 0) {
                ans = vv[vv.size() - 1][0].second;
                tm = i + 1;
                vv[vv.size() - 1].clear();
                cnt--;
            }
            if (vv[0].size() > 0) {
                ans = vv[0][0].second;
                tm = i + 1;
                vv[0].clear();
                cnt--;
            }
            v = vv;
        }
        cout << tm << ' ' << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<time.h>
#include<sstream>
#define MINN -1e8 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll INF=0x3f3f3f3f3f3f;
const int P=1e9+7;
const int MAXN=32000;
const double pi=3.1415926;
//const int MINN=-1e8;
const ll mod=1000000007;

//map<string,ll> m;
//map<ll,ll> m;

//set<ll> s;

//vector<ll> v;

//scanf("%lld",&t);
struct qwq
{
	int id;
	double num;
}st[105];
int n;
int main()
{
	double sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>st[i].num;
		st[i].id=i;
		sum+=st[i].num;
	}
	double dis=sum;
	int k;
	sum/=n;
	for(int i=0;i<n;i++)
	{
		if(fabs(st[i].num-sum)<dis)
		{
			dis=fabs(st[i].num-sum);
			k=st[i].id;
		}
	}
	cout<<k;
	return 0;
}
//ll n,m,t,a,x,ans,res;
//ll powmod(ll a,ll b)     //快速幂 
//{
//	ll tmp=a%mod;
//	ll ans=1;
//	while(b)
//	{
//		if(b&1)ans=ans*tmp%mod;
//		tmp=tmp*tmp%mod;
//		b>>=1;
//	}
//	return ans%mod;
//}


//bool is_prime(ll a)     //判断素数 
//{
//	if(a==2)return 1;
//	else if(a==1||a%2==0)return 0;
//	else
//	{
//		for(ll i=3;i*i<=a;++i)
//		{
//			if(a%i==0)return 0;
//		}
//	}
//	return 1;
//}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n;

int a[N];

bool check(int x)
{
	int64 s = a[x];
	for (int j = 1; j <= n; ++j)
		if (x != j)
		{
			if (s * 2 >= a[j]) s += a[j];
			else return 0;
		}
	return 1;
}

int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) gi(a[i]);
	sort(a + 1, a + n + 1);
	int x = 0;
	for (int i = 17; ~i; --i)
		if (x + (1 << i) <= n && !check(x + (1 << i))) x += 1 << i;
	printf("%d\n", n - x);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int INF = 1e9;

void solve() {
	int h, w, k; cin >> h >> w >> k;
	int x, y, xx, yy; cin >> x >> y >> xx >> yy;
	x--; y--; xx--; yy--;
	vector<string> v(h);
	for (auto &i : v)cin >> i;
	vector<vector<bool> > visited(h, vector<bool> (w, 0));
	vector<vector<int> > distance(h, vector<int> (w, INF));
	queue<pair<int, int> > q;
	q.push({x, y});
	distance[x][y] = 0;
	visited[x][y] = 1;
	while (!q.empty()) {
		int curx = q.front().first, cury = q.front().second;
		q.pop();
		for (int cnt = 0, tempx = curx + 1; tempx < h && cnt < k; cnt++, tempx++) {
			if (v[tempx][cury] == '@')break;
			if (distance[tempx][cury] > distance[curx][cury])distance[tempx][cury] = distance[curx][cury] + 1;
			else break;
			if (!visited[tempx][cury])q.push({tempx, cury});
			visited[tempx][cury] = 1;
		}
		for (int cnt = 0, tempx = curx - 1; tempx >= 0 && cnt < k; cnt++, tempx--) {
			if (v[tempx][cury] == '@')break;
			if (distance[tempx][cury] > distance[curx][cury])distance[tempx][cury] = distance[curx][cury] + 1;
			else break;
			if (!visited[tempx][cury])q.push({tempx, cury});
			visited[tempx][cury] = 1;
		}
		for (int cnt = 0, tempy = cury + 1; tempy < w && cnt < k; cnt++, tempy++) {
			if (v[curx][tempy] == '@')break;
			if (distance[curx][tempy] > distance[curx][cury])distance[curx][tempy] = distance[curx][cury] + 1;
			else break;
			if (!visited[curx][tempy])q.push({curx, tempy});
			visited[curx][tempy] = 1;
		}
		for (int cnt = 0, tempy = cury - 1; tempy >= 0 && cnt < k; cnt++, tempy--) {
			if (v[curx][tempy] == '@')break;
			if (distance[curx][tempy] > distance[curx][cury])distance[curx][tempy] = distance[curx][cury] + 1;
			else break;
			if (!visited[curx][tempy])q.push({curx, tempy});
			visited[curx][tempy] = 1;
		}

	}

	if (distance[xx][yy] == INF)cout << -1 << endl;
	else cout << distance[xx][yy];

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    Int(m);
    vector<int> hoge(m);
    for (int i = 0; i < m; i++) {
        cin >> hoge[i];
    }
    
    sort(all(data));
    sort(all(hoge));

    int ptr = 0;
    rep(i, n) {
        if (ptr >= m) {
            break;
        }
        if (data[i] == hoge[ptr]) {
            ptr++;
        }
    }

    if (ptr == m) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 3456
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int h, w;
   char a[100][100];
   bool x[100] = {}, y[100] = {};
   cin >> h >> w;
   FOR(i, 0, h)
   FOR(j, 0, w)
   {
      cin >> a[i][j];
   }

   FOR(i, 0, h)
   FOR(j, 0, w)
   {
      if (a[i][j] == '#')
      {
         x[i] = true;
         y[j] = true;
      }
   }

   FOR(i, 0, h)
   {
      if (x[i])
      {
         FOR(j, 0, w)
         {
            if (y[j])
               cout << a[i][j];
         }
         cout << endl;
      }
   }
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC174
{
    class Program
    {

        //static bool Judge(long x, long y, int d)
        //{
        //    if (Math.Sqrt(x * x + y * y) <= d)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            long x = 0;
            //string str = Console.ReadLine();
            //string[] stra = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            for (int i = 0; i < a; i++)
            {
                x = (x * 10 + 7) % a;
                if (x == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 27468
import java.util.Scanner;

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

		int n = sc.nextInt();
		String s = sc.next();

		int l = s.length();

		if (l % 2 == 1) {
			System.out.println("No");
			return;

		}

		int mid = l /2;

		String sub = s.substring(0, mid);
		String after = s.substring(mid, l);


		if(sub.equals(after)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n;
      string s;
      cin >> n >> s;
      n--;
      while (n>0 && s!="Y") {
        cin >> s;
        n--;
      }
      if (s == "Y")
        cout << "Four" << endl;
      else
        cout << "Three" << endl;
    }

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

int main(){
    int n;
    long long int k;
    cin >> n >> k;

    int sum = 0;// <= 500 * 1e6
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i];
    }

    vector<int> div;
    for (int i=1; i*i<=sum; i++){
        if (sum % i == 0){
            div.push_back(i);

            int j = sum / i;// counterpart
            if (j != i) div.push_back(j);
        }
    }
    sort(div.begin(), div.end());
    reverse(div.begin(), div.end());
    //for(auto d : div) cout << d << " ";
    //cout << endl;

    for(auto d : div){
        int rem = 0;
        vector<int> b;
        for(int i=0; i<n; i++){
            if(a[i] % d != 0){
                b.push_back(a[i] % d);
                rem += a[i] % d;
            }
        }
        sort(b.begin(), b.end());

        int subtract = rem, add = 0;
        for(int i=b.size()-1; i>=0; i--){
            subtract -= b[i];
            add += (d - b[i]);
            //cout << subtract << " " << add << endl;
            if(subtract == add) break;
        }
        if(subtract <= k){
            cout << d << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
   string s, t, u;
   int a, b;
   cin >> s >> t >> a >> b >> u;
   if(s == u) a--;
   if(t == u) b--;
   cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main() {
    int A[3];
    int Alice = 0;
    int Bob   = 0;

    for(int i = 0; i < 3; i++) {
        cin >> A[i];
    }

    sort(A, A + 3, greater<int>());

    if (A[0] == (A[1] + A[2])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P X);
P dequeue(void);
int min(int a, int b) {return a < b ? a : b; }


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n+1;

  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name, elaps);
    }
  }
  
  return 0;
}

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  
  return x;
}

  



Measured memory_bytes: 11872
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

int main() {
  int A, B, X;

  cin >> A >> B >> X;

  for (int cat = 0; cat <= B; ++cat) {
    if (cat + A == X) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19228
n,m=map(int,input().split())

a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
    


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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int r = 0;
    int b = 0;
    rep(i, s.size()) {
        if(s[i] == 'R') r++;
        else b++;
    }
    if(r > b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const int MAXN = 1e5+5;

int a, b, c, n, m, k;
string s, s1, s2, t;

int32_t main() {
	int n;
	cin >> n;
	cin >> s >> t;
	for(int i = 0; i < n; i++)
		cout << s[i] << t[i];
	cout << endl;
}
		
			




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

typedef struct {
    int b, tx;
    int time;
} TOWER;

TOWER queue[400];

int head, tail;

void enq(TOWER t)
{
    queue[(tail++) % 400] = t;
}

void deq(TOWER *t)
{
    *t = queue[(head++) % 400];
}

int main(void)
{
    TOWER first, temp;
    int building[2][100];
    char v[2][100];
    int n;
    int i;
    char flag;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%d", &building[0][i]);
        }
        for (i = 0; i < n; i++){
            scanf("%d", &building[1][i]);
        }
        
        memset(v, 0, sizeof(v));
        
        head = tail = 0;
        first.b = 0;
        first.tx = 0;
        first.time = 0;
        while (building[0][first.tx] == 1){
            v[0][first.tx++] = 1;
        }
        if (first.tx != 0){
            first.tx--;
        }
        enq(first);
        
        first.b = 1;
        first.tx = 0;
        while (building[1][first.tx] == 1){
            v[1][first.tx++] = 1;
        }
        if (first.tx != 0){
            first.tx--;
        }
        enq(first);
        
        flag = 0;
        
        while (head != tail){
            deq(&temp);
            
            if (temp.tx == n - 1){
                printf("%d\n", temp.time);
                flag = 1;
                break;
            }
            
            for (i = 0; i <= 2; i++){
                first = temp;
                first.b ^= 1;
                if (first.tx + i < n && !v[first.b][first.tx + i] && building[first.b][first.tx + i] == 0){
                    v[first.b][first.tx + i] = 1;
                    first.time++;
                    first.tx = temp.tx + i;
                    enq(first);
                }
                else if (first.tx + i < n && !v[first.b][first.tx + i] && building[first.b][first.tx + i] == 1){
                    first.time++;
                    first.tx = temp.tx + i;
                    while (building[first.b][first.tx] == 1 && first.tx < n && !v[first.b][first.tx]){
                        v[first.b][first.tx++] = 1;
                    }
                    if (first.tx != temp.tx){
                        first.tx--;
                    }
                    enq(first);
                }
                else if (first.tx + i < n && !v[first.b][first.tx + i] && building[first.b][first.tx + i] == 2){
                    first.tx = temp.tx + i;
                    first.time++;
                    while (building[first.b][first.tx] == 2 && first.tx < n && !v[first.b][first.tx]){
                        v[first.b][first.tx--] = 1;
                    }
                    if (building[first.b][first.tx] != 2){
                        enq(first);
                    }
                }
            }
        }
        if (!flag){
            printf("NA\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
string a;
  cin>>a;
  int x;
  if(a=="SUN") x=7;
  if(a=="MON") x=6;
  if(a=="TUE") x=5;
  if(a=="WED") x=4;
  if(a=="THU") x=3;
  if(a=="FRI") x=2;
  if(a=="SAT") x=1;
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    vi w(n);
    int sum=0;
    rep(i,n){
        cin >> w[i];
        sum += w[i];
    }
    int s1 = w[0];
    int s2 = sum - w[0];
    int mn = abs(s2 - s1);
    rep1(i,n-1){
        s1 += w[i];
        s2 -= w[i];
        mn = min(mn,abs(s2-s1));
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
?#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p,l,r,R,L;};
struct Node T[MAX]; 

void print(int u){
  
  int i = T[u].p, depth = 0, height, j = T[u].R, sibling = NIL, degree = 0;

  while(i!=NIL){
    i = T[i].p;
    depth++;
  }

  height = Height(u,0);  


  if(T[u].L == NIL && T[u].r != NIL){
    sibling = T[u].r;
  }else if(T[u].L != NIL && T[u].r == NIL){
    sibling = T[u].L;
  }

  if(T[u].l == NIL && T[u].R == NIL){
    degree = 0;
  }else if(T[u].l==NIL || T[u].R==NIL){
    degree = 1;
  }else if(T[u].l!=NIL && T[u].R!=NIL){
    degree = 2;
  }

  if(depth==0){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n",u,T[u].p,sibling,degree,depth,height);
  }else if(T[u].l == NIL && T[u].R == NIL){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", u, T[u].p, sibling, degree, depth, height);
  }else{
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",u,T[u].p,sibling,degree,depth,height);
  }
}

int Height(int a, int count){
  
  int x,y;

  x=y=count;
  if(T[a].l!=NIL){
    x = Height(T[a].l, count+1);
  }

  if(T[a].R!=NIL){
    y = Height(T[a].R, count+1);
  }
 
  if(x < y ){
    x = y;
  }

  return x;  
} 

main(){
  int i,j,d,v,c,l,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = T[i].L = T[i].R = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&d,&c);

      T[v].l = d;
      T[c].L = d;
      T[v].R = c;
      T[d].r = c;
      T[d].p = v;
      T[c].p = v;
    
    }

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SIZE = 1e5 * 2 + 10, INF = 1e9;

vector<ll> vec;
ll sz[SIZE], hv[SIZE];

int main()
{
    fastInp;

    ll n, l;
    cin >> n >> l;
    vec.resize(n);
    for (int i = 0; i < n; i++) cin >> vec[i];

    ll good = -1;
    for (int i = 0; i < vec.size() - 1; i++) {
        if (vec[i] + vec[i + 1] >= l) {
            good = i;
        }
    }

    if (good == -1) {
        cout << "Impossible";
        return 0;
    }

    cout << "Possible\n";
    vector<ll> ans;
    for (int i = 0; i < good; i++) {
        cout << i + 1 << "\n";
    }
    for (int i = n - 2; i > good; i--) {
        cout << i + 1 << "\n";
    }
    
    cout << good + 1;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

typedef unsigned long long ull;
//typedef long double ld;
int main()
{
   ull n;
cin >> n;
ull sum=1;
bool b=false;
for (ull i = 0; i < n; i++)
{
    ull a;
    cin >> a;
    if (a==0)
    {sum=0; b=false; break;}
    if(sum>1000000000000000000/a) b=true;
        sum*=a;
}
if(b)
cout<<-1<<endl;
else cout<<sum<<endl;
return 0;


}


Measured memory_bytes: 3624
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));

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

	int a,b,c;
	cin>>a>>b>>c;
	cout<<a*b/2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [0]*9
for a in A:
    k = 0
    while a>=400*k:
        k+=1
        if k>8:break
    B[k-1]+=1
a = B[8]
B = [1 for b in B[:8] if b>0]
print(max(1,sum(B)),sum(B)+a)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	float a;
	vector<float> m;
	while(cin >> a)
	{
		m.push_back(a);
	}
	cout << *max_element(m.begin(),m.end()) - *min_element(m.begin(),m.end())<< endl;
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    char a[100000];
    scanf("%s",a);
    int l=strlen(a),c=0;
    for(int i=1;i<l;i++)
    {
        if(a[i]==a[i-1]&&a[i]=='0')
        {
            a[i]='1';
            c++;
        }
        if(a[i]==a[i-1]&&a[i]=='1')
        {
            a[i]='0';
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+10;
const int mod=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    if(x)
    {
        cout<<0<<'\n';
    }
    else
        cout<<1<<'\n';



}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int stones[n+1],memo[n+1]; 
    for(int i = 1 ; i <= n ; i++) {
        cin >> stones[i];
        memo[i] = 1e9+5;  
    }

    memo[0] = 0;
    memo[1] = 0;
    for(int i =1; i<= n;i++){
        for(int j = 1; j <= k ; j++){
            if (i-j > 0){
                memo[i] = min(memo[i], abs(stones[i]-stones[i-j]) + memo[i-j]);
            }

        }
    }
    cout << memo[n] <<   endl;
    
    return 0;

}


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

struct activity{
    int a,b,c;
};
ll solve(vector<activity> v,int n){
    int dp[n+1][3];
    dp[1][0]=v[1].a;
    dp[1][1]=v[1].b;
    dp[1][2]=v[1].c;
    for(int i=2;i<=n;i++){
        dp[i][0]=v[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i].c+max(dp[i-1][0],dp[i-1][1]);
    }


    return max(dp[n][0],max(dp[n][1],dp[n][2]));

}



int main(){
    int n;
    cin>>n;
    vector<activity> v(n+1);
    for(int i=1;i<=n;i++){

        cin>>v[i].a>>v[i].b>>v[i].c;
    }
    cout<<solve(v,n)<<endl;

    return 0;
}


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

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

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


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

  vector<int> dp(N+1);
  fill(dp.begin(), dp.end(), 0);
  dp[0] = 1;
  dp[1] = 1;

  for (int i=2; i<=N; i++) {
    dp[i] = dp[i-2] + dp[i-1];
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 3076
import Data.List

main::IO()
main=do
    n <- readLn::IO Int
    let n' = fact n
        px = (genPrime . floor . sqrt . fromIntegral)n'
        qx = if px == [] then [[1]] else group $ primeFactorize n' px  []
        rx = if n == 1 then [1] else map (\xs -> length xs + 1) qx
        in print $ mod (product' rx) 1000000007


product'::[Int]->Integer
product' xs = foldr1(*) $ map (\x->fromIntegral x)xs  

primeFactorize::Integer->[Integer]->[Integer]->[Integer]
primeFactorize n' (p:px) xs
    |n'  == 1 = xs
    |n' `mod` p /= 0 = if px  == [] then n':xs else primeFactorize n' px xs
    |otherwise = primeFactorize (n' `div` p) (p:px) (p:xs)

fact::Int->Integer
fact k 
    |k == 1 = 1
    |otherwise = foldr1(*)[1..(fromIntegral k)] 

genPrime::Integer->[Integer]
genPrime n
    | n < 2 = []
    | n == 2 = [2]
    | otherwise = sieve [2..n] n
    where
        sieve :: [Integer] -> Integer -> [Integer]
        sieve [] _ = []
        sieve (x:xs) n
            | x^2 > n = x:xs
            | otherwise = x : sieve [a | a <- xs, a `mod` x > 0] n




Measured memory_bytes: 1148