akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;

#define MAX 100005
#define NIL -1
// 左子右兄弟表現
struct Node{
    int p,l,r;
};

Node T[MAX];
int D[MAX];
int DEG[MAX];
int H[MAX];

int S[MAX];
int maxi=0;

void setDepth(int i, int d){
    D[i]=d;
    if(maxi<d)maxi=d;
    if(T[i].l!=NIL)setDepth(T[i].l,d+1);
    if(T[i].r!=NIL)setDepth(T[i].r,d+1);
}

void setDegree(int i){
    DEG[i]= (T[i].l!=NIL)+(T[i].r!=NIL);
    if(DEG[i]==0)return;
    if(T[i].r!=NIL)setDegree(T[i].r);
    if(T[i].l!=NIL)setDegree(T[i].l);
}

void setHeight(int i){
    if(i==NIL)return;
    if(T[i].l==NIL && T[i].r==NIL){
        H[i]=0;
        return;
    }
    setHeight(T[i].r);
    setHeight(T[i].l);
    H[i]=max(H[T[i].r]+1, H[T[i].l]+1);
    
}

void setSibling(int i){
    // Sが初期値であれば続行
    if(S[i]!=-2)return;
    if(T[i].p==NIL)S[i]=NIL;
    // if(T[T[i].p].r!=NIL && T[T[i].p].l==i)S[i]=T[T[i].p].r;
    // if(T[T[i].p].l!=NIL && T[T[i].p].r==i)S[i]=T[T[i].p].l;
    if(T[T[i].p].l==i)S[i]=T[T[i].p].r;
    if(T[T[i].p].r==i)S[i]=T[T[i].p].l;
    setSibling(T[i].l);
    setSibling(T[i].r);
}

void printChildren(int u){
    vector<int> rel;

    if(T[u].l!=NIL){
        int x = T[u].l;
        while(x!=NIL){
            rel.push_back(x);
            x=T[x].r;
        }
    }
    cout << "node " << u<<":";
    cout << " parent = " << T[u].p << ", ";
    cout << "sibling = " << S[u] << ", ";
    cout << "degree = " << (T[u].l!=NIL)+(T[u].r!=NIL) << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    if(T[u].p==NIL){
        cout << "root";
    }else if(T[u].l==NIL && T[u].r==NIL)cout << "leaf";
    else{
        cout << "internal node";
    }
    // cout << " [";
    // rep(i,rel.size()){
    //     if(rel.size()>1){
    //         if(i==0){
    //             cout<<rel[i];
    //         }else cout << ", "<<rel[i];
    //     }else{
    //         cout << rel[i];
    //     }
        
    // }
    // cout << "]"<<endl;;
    cout << endl;
    return;
}

int main(){
    int n, v,l,r,parent;
    cin >> n;
    rep(i,n)T[i].p=T[i].r=T[i].l=NIL;
    rep(i,n){
        cin >> v >> l >> r;
        T[v].l=l;T[v].r=r;
        if(l!=NIL)T[l].p=v;
        if(r!=NIL)T[r].p=v;
    }

    rep(i,n)if(T[i].p==NIL)parent=i;
    rep(i,MAX)S[i]=-2;
    setDepth(parent,0);
    setDegree(parent);
    setSibling(parent);
    setHeight(parent);
    S[parent]=NIL;
    rep(i,n){
        printChildren(i);
    }
    return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>

int judge(char n){
  int j;
  if(n=='A') j=10;
  if(n=='B') j=11;
  if(n=='C') j=12;
  if(n=='D') j=13;
  if(n=='E') j=14;
  if(n=='F') j=15;
  return(j);
}

int main(void){
  char x[2],y[2];
  int a,b;
  scanf("%s%s",x,y);
  a=judge(x[0]);
  b=judge(y[0]);
  if(a<b) printf("<\n");
  if(a==b) printf("=\n");
  if(a>b) printf(">\n");
  return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;


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

    int a, b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	S := readBytes()
	var n,w,s,e bool
	for i := range S {
		switch S[i] {
		case 'N':
			n = true
		case 'W':
			w = true
		case 'S':
			s = true
		case 'E':
			e = true
		}
	}

	if ((n && s) || (!n && !s)) && ((e && w) || (!e && !w)) {
		println("Yes")
	} else {
		println("No")
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <algorithm>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 3000;
int id[1 + nmax], v[1 + nmax];
std::vector<int> g[1 + nmax];
int dp[1 + nmax];

bool compare(int x, int y) {
  return v[x] < v[y];
}

int main() {
  int n;
  std::cin >> n;
  for(int i = 1; i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i < n; i++) {
    int x, y;
    std::cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for(int i = 1;i <= n; i++)
    id[i] = i;
  std::sort(id + 1, id + n + 1,compare );
  for(int i = 1;i <= n; i++) {
    int node = id[i];
    for(int h = 0; h < g[node].size(); h++) {
      int to = g[node][h];
      if(v[to] < v[node])
        dp[node] |= !dp[to];
    }
  }
  for(int i = 1;i <= n; i++)
    if(dp[i] == 1)
      std::cout << i << " ";
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

int H, W;
int a[500][500];

signed main(){
    cin >> H >> W;
    REP(i, H){
        REP(j, W){
            cin >> a[i][j];
        }
    }
    vector<pint> right, down;
    REP(i, H){
        REP(j, W - 1){
            if(a[i][j] % 2 == 1){
                a[i][j]--;
                a[i][j + 1]++;
                right.push_back(pint(i + 1, j + 1));
            }
        }
    }
    REP(i, H - 1){
        if(a[i][W - 1] % 2 == 1){
            a[i][W - 1]--;
            a[i + 1][W - 1]++;
            down.push_back(pint(i + 1, W));
        }
    }
    int N = right.size() + down.size();
    PRINT(N);
    for(auto p : right){
        cout << p.first << " " <<  p.second << " " << p.first << " " << p.second + 1 << endl; 
    }
    for(auto p : down){
        cout << p.first << " " <<  p.second << " " << p.first + 1 << " " << p.second << endl; 
    }
    return 0;
}

Measured memory_bytes: 4212
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=0
b=[]
for i in range(k):
  s+=a[i]
b.append(s)
for i in range(k,n):
  s+=a[i]
  s-=a[i-k]
  b.append(s)
m=max(b)
print(m/2+0.5*k)

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

int findD (int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10; 
  }
  return sum;
} 
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int total = 0;
  for (int i = 0; i <= n; i++) {
    int sum = findD(i);
    if (sum >= a && sum <= b ) {
      total += i;
    } 
  }
  

  cout << total << endl;

}

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

 
int main(void) {
	
	int a,b,h,ans;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &h);
	
	ans = (a+b)*h/2;
	printf("%d\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	static int N;

	static int[][] h;

	static int[][] memo;

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

		N = sc.nextInt();

		h = new int[N][3];
		memo = new int[N][3];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 3; j++) {
				h[i][j] = sc.nextInt();
				memo[i][j] = -1;
			}
		}

		int ans = Math.max(dp(0, 0), Math.max(dp(0, 1), dp(0, 2)));

		System.out.println(ans);
		sc.close();
	}

	static int dp(int i, int x) {
		if(i >= N)
			return 0;
		if(memo[i][x] == -1) {
			int max = Integer.MIN_VALUE;
			for(int j = 0; j < 3; j++) {
				if(x != j) {
					int choice = dp(i + 1, j) + h[i][j];
					if(max < choice)
						max = choice;
				}
			}
			memo[i][x] = max;
		}
		return memo[i][x];
	}
}

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

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N = 100000;
int NN;
//エラトステネスの篩
bool is_prime[ 100000 + 1 ];
int prime[ 100000 + 2 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
          // if(i >= NN){
          //   cout << i << endl;
          //   return;
          // }
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int Q;
vector<int> L, R;


int main(){
  cin >>Q;
  L = vector<int>(Q);
  R = vector<int>(Q);

  for(int i = 0; i< Q; i++){
    cin >> L.at(i) >> R.at(i);
  }
  prime[1] = 0;
  prime[2] = 0;
  Eratosthenes(N);
  for(int i = 3; i<= N+1; i++){
    if(is_prime[i] && is_prime[(i+1)/2]){
      prime[i] = prime[i-1] + 1;
    }else{
      prime[i] = prime[i-1];
    }
    // prime[i] = prime[i-1] + is_prime[i];
  }

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

  ll ans = 0;

  for(int i = 0;i<Q ; i++){
    cout << prime[R.at(i)] - prime[L.at(i)-1] << endl;
  }

  // cout << ans << endl;

}


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

int main()
{
  ll a; double b;
  cin >> a >> b;
  ll bi = b*100 + 0.5; //double→intキャストの誤差回避
  cout << a*bi/100 << endl;
}

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

using namespace std;

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline int readChar() {
	int c = getChar();
	while (c <= 32)
		c = getChar();
	return c;
}

template <class T>
inline T readInt() {
	int s = 1, c = readChar();
	T x = 0;
	if (c == '-')
		s = -1, c = getChar();
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getChar();
	return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
	if (write_pos == buf_size)
		fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
	write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
	if (x < 0)
		writeChar('-'), x = -x;

	char s[24];
	int n = 0;
	while (x || !n)
		s[n++] = '0' + x % 10, x /= 10;
	while (n--)
		writeChar(s[n]);
	if (end)
		writeChar(end);
}

inline void writeWord( const char *s ) {
	while (*s)
		writeChar(*s++);
}

struct Flusher {
	~Flusher() {
		if (write_pos)
			fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
	}
} flusher;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << 0 << endl;
    string first;
    cin >> first;
    if (first == "Vacant") {
        return 0;
    }
    int l = 1;
    int r = n - 1;
    string s;
    while (true) {
        int m = (l + r) / 2;
        cout << m << endl;
        cin >> s;
        if (s == "Vacant") {
            return 0;
        }
        if ((s == first ? 1 : 0) ^ (m % 2)) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }
    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x, n;
    cin >> x >> n;
    vector<Int> p(n);
    vector<bool> a(101, false);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> p[i];
        a[p[i]] = true;
    }
    if (not a[x]) {
        print(x);
        return 0;
    }
    Int i = 1;
    while (true) {
        Int res = INF;
        if (x - i < 1) {
            res = min(res, x - i);
        }
        if (x + i > 100) {
            res = min(res, x + i);
        }
        if (not a[x - i]) {
            res = min(res, x - i);
        }
        if (not a[x + i]) {
            res = min(res, x + i);
        }
        if (res != INF) {
            print(res);
            return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int h, w, a, b;
  cin >> h >> w >> a >> b;

  bool refl = true;
  for (int i = 0; i < h; i++) {
    int p = 0, q = 1;
    if (!refl) swap(p, q);
    for (int j = 0; j < w; j++) {
      if (j < a) cout << p;
      else cout << q;
    }
    cout << endl;
    if (i == b-1) refl = !refl;
  }
}


Measured memory_bytes: 1280
def solve(k):
    if k == 1:
        print(1)
        print(1)
        return

    n = ((k - 1) // 4 + 1) * 2
    ans = [[0] * n for _ in [0] * n]
    dub = 2 * (k - n)
    for m in range(n * 2):
        l = m + 1 if m < dub else dub + (m - dub) // 2 + 1
        i = m % 2
        j = (m // 2 + m % 2) % n

        for _ in range(n // 2):
            ans[i][j] = l
            i = (i + 2) % n
            j = (j + 2) % n

    print(n)
    print('\n'.join(' '.join(map(str, row)) for row in ans))


k = int(input())
solve(k)


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector <int> h(n);
    h.push_back(1+1e9);
    for(int ih=0; ih<n; ih++){
        cin >> h[ih];
    }
    int count =0;
    int ans=0;
    for(int ijudge=0; ijudge<n; ijudge++){
        if(h[ijudge]>=h[ijudge+1]){
            ++count;
            
        }else{
            // cout << count<<endl;
            ans = max(ans,count);
            count=0;
        }
    }
    cout << ans<< endl;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL dp[100010][4];

void add(LL &a, LL b) {
	a = (a + b) % MOD;
}

//dp i番目までみたときの、状態jをそれまでに完成させた文字列で決めておく

//j=0 ""
//j=1 "A"
//j=2 "AB"
//j=3 "ABC"

int main() {
	string s; cin >> s;


	//dp初期化、場合の数を数える問題なので0で初期化
	for (int i = 0; i < 100010; i++) {
		for (int j = 0; j < 4; j++) {
			dp[i][j] = 0;
		}
	}

	//0番目までみて文字列が何も無い状態が一通り
	dp[0][0] = 1;

	for (int i = 0; i < s.size(); i++) {
		//siを使わない

		for (int j = 0; j < 4; j++) {
			//si=?でないなら、状態i,jの数はそのまま引き継ぐ
			if (s[i] != '?') {
				dp[i + 1][j] = dp[i][j];
			}
			//si=?ならA,B,C 3文字分違う文字列になるので、3倍してやる
			else {
				dp[i + 1][j] = dp[i][j]*3%MOD;
			}
		}


		//siを使って遷移する

		if (s[i] == '?') {
			//""→A

			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= MOD;

			//A→AB

			dp[i + 1][2] += dp[i][1];
			dp[i + 1][2] %= MOD;
			//AB→ABC

			dp[i + 1][3] += dp[i][2];
			dp[i + 1][3] %= MOD;
		}

		if (s[i] == 'A') {
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][1] %= MOD;
		}

		if (s[i] == 'B') {
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][2] %= MOD;
		}

		if (s[i] == 'C') {
			dp[i + 1][3] += dp[i][2];
			dp[i + 1][3] %= MOD;
		}
	}

	cout << dp[s.size()][3] << endl;
	return 0;
}

Measured memory_bytes: 3584
N, M = map(int, input().split())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
z = [0 for i in range(N)]

for i in range(N):
    x[i], y[i], z[i] = map(int, input().split())

res = 0
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            t = []
            for l in range(N):
                t.append(x[l] * i + y[l] * j + z[l] * k)
            t.sort()
            t.reverse()
            tsum = sum(t[0:M])

            if tsum > res:
                res = tsum

print(res)

Measured memory_bytes: 3188
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			int q = cin.Int();

			bool isReverse = false;
			var front = new List<char>();
			var back = new List<char>();

			for (int i = 0; i < q; i++) {
				int qq = cin.Int();
				if (qq == 1) {
					isReverse = !isReverse;
				} else {
					int f = cin.Int();
					char c = cin.Next()[0];
					if (f == 1) {
						if (isReverse == false) {
							front.Add(c);
						} else {
							back.Add(c);
						}
					} else {
						if (isReverse == false) {
							back.Add(c);
						} else {
							front.Add(c);
						}
					}
				}
			}

			string ans = "";
			if (isReverse == false) {
				front.Reverse();
				ans = new string(front.ToArray()) + s + new string(back.ToArray());
			} else {
				back.Reverse();
				ans = new string(back.ToArray()) + new string(s.Reverse().ToArray()) + new string(front.ToArray());
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 20540
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=924844033;
const int g=5;
int fpow(int x,int y)
{
	if(y==0)
		return 1;
	int ret=fpow(x,y>>1);
	ret=(long long)ret*ret%mod;
	if(y&1)
		ret=(long long)ret*x%mod;
	return ret;
}
int inv(int x)
{
	return fpow(x,mod-2);
}
struct edges
{
	int to,next;
}edge[404040];
int first[202020],now;
void adde(int x,int y)
{
	now++;
	edge[now].to=y;
	edge[now].next=first[x];
	first[x]=now;
}
int fac[202020],ifac[202020];
int cnt[202020];
int n,siz[202020];
int w1[606060],w2[606060];
int rev[606060],l;
int C(int n,int m)
{
	return (long long)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void dfs(int p,int fa)
{
	siz[p]=1;
	for(int e=first[p];e;e=edge[e].next)
		if(edge[e].to!=fa)
		{
			dfs(edge[e].to,p);
			siz[p]+=siz[edge[e].to];
		}
	if(p!=1)
	{
		cnt[siz[p]]++;
		cnt[n-siz[p]]++;
	}
}
void ntt(int *a,int *w,bool intt)
{
	for(int i=0;i<l;i++)
		if(i<rev[i])
			swap(a[i],a[rev[i]]);
	int t1,t2;
	for(int i=1;i<l;i<<=1)
		for(int j=0;j<l;j+=(i<<1))
			for(int k=0;k<i;k++)
			{
				t1=a[j+k];
				t2=(long long)a[i+j+k]*w[i+k]%mod;
				a[j+k]=(t1+t2)%mod;
				a[i+j+k]=(t1-t2+mod)%mod;
			}
	if(intt)
	{
		int h=inv(l);
		for(int i=0;i<l;i++)
			a[i]=(long long)a[i]*h%mod;
	}
}
int a[606060],b[606060];
void init()
{
	int half,w;
	l=1;
	while(l<=2*n)
		l<<=1;
	half=(l>>1);
	rev[0]=0;
	for(int i=1;i<l;i++)
		rev[i]=(rev[i>>1]>>1)|((i&1)?half:0);
	w=fpow(g,(mod-1)/l);
	w1[half]=1;
	for(int i=half+1;i<l;i++)
		w1[i]=(long long)w1[i-1]*w%mod;
	for(int i=half-1;i>=0;i--)
		w1[i]=w1[i<<1];
	w=fpow(inv(5),(mod-1)/l);
	w2[half]=1;
	for(int i=half+1;i<l;i++)
		w2[i]=(long long)w2[i-1]*w%mod;
	for(int i=half-1;i>=0;i--)
		w2[i]=w2[i<<1];
}
int main()
{
	int x,y;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		adde(x,y);
		adde(y,x);
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=(long long)fac[i-1]*i%mod;
	ifac[0]=ifac[1]=1;
	for(int i=2;i<=n;i++)
		ifac[i]=(long long)(mod-mod/i)*ifac[mod%i]%mod;
	for(int i=2;i<=n;i++)
		ifac[i]=(long long)ifac[i-1]*ifac[i]%mod;
	dfs(1,0);
	init();
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i=1;i<n;i++)
		a[i]=(long long)cnt[i]*fac[i]%mod;
	for(int i=0;i<=n;i++)
		b[i]=ifac[n-i];
	ntt(a,w1,0);
	ntt(b,w1,0);
	for(int i=0;i<l;i++)
		a[i]=(long long)a[i]*b[i]%mod;
	ntt(a,w2,true);
	long long ans;
	for(int i=1;i<=n;i++)
	{
		ans=((long long)C(n,i)*n-(long long)a[i+n]*ifac[i])%mod;
		(ans+=mod)%=mod;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 29056
#include<bits/stdc++.h>
using namespace std;
main(){
long long i,j,k,l,m,n;
while(cin>>l>>m>>n){
     k=m-l;
k++;
  if(n*2>=k){
    for(i=l;i<=m;i++)cout<<i<<endl;
  }
  else{
    for(i=l;i<l+n;i++) cout<<i<<endl;
    
    for(i=(m-n)+1;i<=m;i++)cout<<i<<endl;

  }
} return 0;

}

Measured memory_bytes: 256
import math

a = []
for i in range(10001):
    a.append(0)
for i in range(1,99):
    for j in range(1,99):
        if i*i + i*j + j*j > 10000:
            break
        for k in range(1,99):
            l = i*i + j*j + k*k + i*j + i*k + j*k
            if l > 10000:
                break
            a[l]+= 1
N = int(input())
for i in range(1,N+1):
    print(a[i])


Measured memory_bytes: 9448
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from heapq import heapify, heappush, heappop
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    total = 0
    L, R = [], []
    for _ in range(N):
        k, l, r = map(int, input().split())
        if l >= r:
            # kより前に入れたい
            L.append((k, l, r))
            total += l
        else:
            # kより後ろに入れたい
            R.append((N - k, r, l))
            total += r

    # Lにとって前から，Rにとって後ろから
    L.sort()
    R.sort()

    queue = []
    for i in range(len(L)):
        k, ai, bi = L[i]
        heappush(queue, ai - bi)
        # 前から入れていき，効果が薄いもの(ai - bi)は消す
        while len(queue) > k:
            value = heappop(queue)
            total -= value
            
    queue = []
    for i in range(len(R)):
        k, ai, bi = R[i]
        heappush(queue, ai - bi)
        # 後ろから入れていき，効果が薄いもの(ai - bi)は消す
        while len(queue) > k:
            value = heappop(queue)
            total -= value

    print(total)


if __name__ == '__main__':
    t = int(input())
    while t > 0:
        t -= 1
        main()

Measured memory_bytes: 115948
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int i;
  map<int,int> m;
  for(i=0;i<n;i++)
  {
    int x;
    cin>>x;
    m[x]=i+1;
    }
  map<int,int>::iterator itr;
  for(itr=m.begin();itr!=m.end();itr++)
    cout<<itr->second<<" ";
  cout<<endl;
}

Measured memory_bytes: 5504
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try {
			Scanner scanner = new Scanner(System.in);
			int x = scanner.nextInt();

			int i = 25 - x;

			System.out.print("Christmas");

			for (; i > 0; i--) {
				System.out.print(" Eve");
			}

			System.out.println();
			scanner.close();
		} catch (InputMismatchException e) {
			System.out.println("整数を入力してください。");
		}
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int head[100001],to[100001],nxt[100001],f[100001],degree[100001]={0},tot=0,n,m;
void addedge(int u,int v)
{
	tot++;
	nxt[tot]=head[u];
	to[tot]=v;
	head[u]=tot;
}
int dfs(int i)
{
	if(head[i]==0)
	{
		f[i]=0;
		return f[i];
	}
	if(f[i]>=0)
		return f[i];
	int k,v;
	for(k=head[i];k;k=nxt[k])
	{
		v=to[k];
		f[i]=max(f[i],dfs(v)+1);
	}
}
int main()
{
	int i,u,v,maxv=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		addedge(u,v);
		degree[v]++;
	}
	memset(f,0xff,sizeof(f));
	for(i=1;i<=n;i++)
		if(degree[i]==0)
			dfs(i);
	for(i=1;i<=n;i++)
		maxv=max(maxv,f[i]);
	printf("%d",maxv);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string n;
    cin >> n;
    if ( n[0] == n[2] ) cout << "Yes" << endl;
    else                cout << "No" << endl;
    return 0;
}


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

int main(){
  long long a, b, k;
  cin>>a >>b >>k;
  
  if(k<=a){
    cout<<a-k<<" "<<b<<endl;
  }else{
    if(k-a<=b){
      cout<<0<<" "<<a+b-k<<endl;
    }else{
      cout<<0<<" "<<0<<endl;
    }
  }
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int H, W, K;
    cin >> H >> W >> K;
    vector<Vi> mas(H, Vi(W));
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            mas[i][j] = s[j] - '0';
        }
    }

    vector<Vi> csum(H + 1, Vi(W + 1));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            csum[i + 1][j + 1] = csum[i][j + 1] + csum[i + 1][j] - csum[i][j] + mas[i][j];
        }
    }

    int ans = I_INF;
    for (int mask = 0; mask < (1 << (H - 1)); mask++) {
        int cnt = 0;
        int left = 0;
        bool ok = true;
        for (int w = 1; w <= W; w++) {
            int mx = 0;
            int tp = 0;
            int white;
            for (int h = 1; h <= H; h++) {
                if ((mask >> (h - 1)) & 1) {
                    white = csum[h][w] - csum[tp][w] - csum[h][left] + csum[tp][left];
                    mx = max(mx, white);
                    tp = h;
                }
            }
            white = csum[H][w] - csum[tp][w] - csum[H][left] + csum[tp][left];
            mx = max(mx, white);
            if (mx > K) {
                if (w - left == 1) {
                    ok = false;
                }
                else {
                    ++cnt;
                    left = w - 1;
                    --w;
                }
            }
            if (!ok) {
                break;
            }
        }
        if (ok) {
            ans = min(ans, cnt + __builtin_popcount(mask));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

int main()
{
    int N;
    cin >> N;
    cout << (N - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long int lli;
using namespace std;

void solve()
{
	int day,n;
	cin>>day>>n;
	lli sum=0;
	int arr[n+1];
	for(int i=0;i<n;++i) cin>>arr[i];
	for(int i=0;i<n;++i) sum+=arr[i];
	if (sum<=day){
		cout<<day-sum<<"\n";
	}else{
		cout<<"-1\n";
	}
	
}


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


 return 0;
 }


Measured memory_bytes: 3692
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p%i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL a, b;
	LL ans = 0;
	cin >> a >> b;
	LL sa = b - a;

	LL t1 = 1, t2 = 3;
	FOR(i, 3, 1000) {
		t1 = t2;
		t2 += i;
		if (t2 - t1 == sa) {
			O(t2 - b);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
   int k;cin>>k;
   string s="";
   while(k--)s+="ACL";
   cout<<s<<endl;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int cnt = 0;
    for (int i = 0; i < n; ) {
        int r = distance(a.begin(), upper_bound(a.begin() + i, a.end(), a[i]));
        if ((r - i) % 2 == 1) ++cnt;
        i = r;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if(n == 1) cout << "Hello World\n";
	else{
		int a,b;
		cin >> a >>b ;
		cout << a + b << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll A[100010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }

    sort(A, A+N, greater<int>());
    ll l1 = -1;
    ll l2 = -1;
    ll val_prev = A[0];
    rep(i,1,N){
        if(A[i] == val_prev && l1 == -1){
            l1 = A[i];
            val_prev = -1;
        }else if(A[i] == val_prev && l1 != -1 && l2 == -1){
            l2 = A[i];
            ll ans = l1 * l2;
            print(ans);
            return 0;
        }else{
            val_prev = A[i];
        }

    }
    print(0);

}


Measured memory_bytes: 1024
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
count = 0
button = 1
for i in range(n):
    button = a[button - 1]
    count += 1
    if button == 2:
        break
if button == 2:
    print(count)
else:
    print(-1)

Measured memory_bytes: 49752
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [x]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const sen = Math.floor(x / 500);
    const go = Math.floor((x - sen * 500) / 5);
    return `${sen * 1000 + go * 5}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=55;

int main()
{
    IO;
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c)cout<<"Yes\n";
    else cout<<"No\n";
    re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n];
	ll hi = 1e18, prod = 1;
	int flag = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i] == 0)
			flag = 1;
	}

	if(flag){
		cout<<"0\n";
		return 0;
	}
	
	for(int i=0;i<n;i++){
		if(a[i] <= hi/prod)
			prod *= a[i];
		else{
			prod = -1;
			break;
		}
	}

	if(prod > hi)
		prod = -1;
	cout<<prod<<endl;
}

Measured memory_bytes: 4436
# N = gets.chomp.to_i
a, b, c = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

# A <-> B
# A <-> C

tmp = a
a = b
b = tmp

tmp = a
a = c
c = tmp

print [a, b, c].join(" ") + "\n"


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
 
int code[256] = { 0 };
 
typedef struct _tree {
    int flag;
    struct _tree * (list[4]);
} TREE, *PTREE;
 
PTREE newTree(void) {
    PTREE tree = (PTREE)calloc(1, sizeof(TREE));
    return tree;
}
 
void insert(PTREE root, char *str) {
    int i = code[(int)*str];
    if (*str == '\0') {
        root->flag = 1;
        return;
    }
    if (root->list[i] == NULL) {
        root->list[i] = newTree();
    }
    insert(root->list[i], str + 1);
}
 
int find(PTREE root, char *str) {
    int i = code[(int)*str];
    if (*str == '\0') {
        return root->flag;
    }
    if (root->list[i] == NULL) {
        return 0;
    }
    return find(root->list[i], str + 1);
}
 
int main(void) {
    int i, n;
    char cmd[100], str[100];
    PTREE root = newTree();
    code['A'] = 0;
    code['C'] = 1;
    code['G'] = 2;
    code['T'] = 3;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; ++i) {
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i') {
            insert(root, str);
        } else if (find(root, str)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
     
    return 0;
}

Measured memory_bytes: 16900
import java.util.*;

public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
	
	int n = kbd.nextInt();       //データセット数
	while(n>0) {
	    solve();
	    n--;
	}
    }

    static void solve() {
	int y = kbd.nextInt();   //誕生年
	int m = kbd.nextInt();   //誕生月
	int d = kbd.nextInt();   //誕生日
	int answer;
	answer = calc(y, m, d);
	System.out.println(answer);
    }

    static int calc(int y, int m, int d) {
	int total = 0;  //ミレニアムまでの日数
	int three = 0;  //3の倍数の年数
	int notT = 0;   //3の倍数でない年数
	int D;          //誕生年1月1日から誕生日までの日数
	for(int i=y; i<1000; i++) {
	    if(i%3 == 0) three++;
	    else         notT++;
	}
	total = notT*195 + three*200;   //仮total(誕生年1月1日〜ミレニアム)
	D = days(y, m, d);
	total = total - D + 1;          //誕生日も含めた正式なtotal
	return total;
    }

    static int days(int y, int m, int d) {
	int D = 0;
	if(y%3 == 0)
	    for(int j=1; j<m; j++) D += 20;
	else {
	    for(int j=1; j<m; j++) {
		if(j%2 == 0) D += 19;
		else         D += 20;
	    }
	}
	D += d;
	return D;
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

//演算の定義
auto query = [](ll x, ll y) { return min(x, y); };
//単位元
const ll unit = INF;
struct SegTree
{
private:
  ll n;
  vector<ll> node;

public:
  SegTree(vector<ll> v)
  {
    node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); //最小値なので残りはINFで埋める
    n = 1LL << 64 - __builtin_clzll(v.size());
    for (ll i = 0; i < v.size(); i++)
      node[i + n - 1] = v[i]; //最下段から構築
    for (ll i = n - 2; i >= 0; i--)
      node[i] = query(node[2 * i + 1], node[2 * i + 2]);
  }

  void update(ll x, ll val)
  {
    x += (n - 1);  // 最下段index
    node[x] = val; //valを加算などするときは+=
    while (x > 0)
    {
      x = (x - 1) / 2;
      node[x] = query(node[2 * x + 1], node[2 * x + 2]);
    }
  }

  // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
  ll getmin(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
  {
    // 最初に呼び出されたときの対象区間は [0, n)
    if (r < 0)
      r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if (r <= a || b <= l)
      return unit;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if (a <= l && r <= b)
      return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return query(vl, vr);
  }
};

int main()
{
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
ll n , q ;
cin >> n >> q ;

vector<ll> t(n,(1LL<<31)-1);
SegTree s(t);
rep(i,q){
  ll a , b , c ;
  cin >> a >> b >> c ;
  if(a==0)s.update(b, c);
  else cout << s.getmin(b, c+1) << endl;
}
return 0;
}



Measured memory_bytes: 6588
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(void)
{
  int n, p[21];
  scanf("%d", &n);

  rep(i, n)
  {
    scanf("%d", &p[i]);
  }

  int count = 0;
  rep(i, n - 2)
  {
    if ((p[i + 1] - p[i]) * (p[i + 1] - p[i + 2]) < 0)
      count++;
  }
  printf("%d\n", count);
  return 0;
}


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

bool cmp(int a,int b){
        return a>b;
}


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

    //Insert code
    
    ll a,b;
    cin>>a>>b;
    if (b%a==0) cout<<a+b; else cout<<b-a;
    
    //End code


    cerr << "\nTime elapsed: " << 1000*clock() / CLOCKS_PER_SEC << "ms\n";
    
}

Measured memory_bytes: 256
#include<stdio.h>




int main()
{
  int a,b,k,flag;  

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&b);
  scanf("%d",&b);
  scanf("%d",&b);
  scanf("%d",&k);

  
  if(b-a>k)
    printf(":(\n");
  else
    printf("Yay!\n");
  return 0;
}



Measured memory_bytes: 128
#include<cstdio>

char s[111111];

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

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define INF 100000000000000
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  ll V, E, r;
  cin >> V >> E >> r;
  vector< vector< pair<ll,ll> > > edges(V);
  ll dist[V];
  for(ll i = 0; i < V; i++){
    dist[i] = INF;
  }
  for(ll i = 0; i < E; i++){
    ll s,t,d;
    cin >> s >> t >> d;
    edges[s].push_back(make_pair(t,d));
  }

  dist[r] = 0;

  for(ll i = 0; i < E; i++){
    for(ll k = 0; k < V; k++){
      if(dist[k] != INF){
	for(pair<ll,ll> edge: edges[k]){
	  if(dist[edge.first] > dist[k] + edge.second){
	    if(i == V - 1){
	      cout << "NEGATIVE CYCLE" << endl;
	      return 0;
	    }
	    dist[edge.first] = dist[k] + edge.second;
	  }
	}
      }
    }
  }
  for(ll i = 0; i < V; i++){
    if(dist[i] == INF)
      cout << "INF" << endl;
    else
      cout << dist[i] << endl;
  }
}

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

#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )

int main(void)
{
    int P, Q, R;
    cin >> P >> Q >> R;
    int A[3] = {P + Q, Q + R, R + P};
    sort(A, A + 3);
    cout << A[0] << endl;


    return 0;
}


Measured memory_bytes: 256
array = []

for i in range(2):
    val = [int(s) for s in input().split()]
    array.append(val)

A = array[1]
check = 0

for i in A:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            check += 1


if check > 0:
    print("DENIED")
else:
    print("APPROVED")



Measured memory_bytes: 2940
def cin():
    return input().split()
def qpow(a,b,p):
    if p == 1 or p == 0:
        return 0
    a = (a%p+p)%p
    ans = 1
    while b!=0:
        if (b&1) != 0:
            ans = (ans * a) % p
        b >>= 1
        a = a * a  % p
    return ans

def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1

n = int(input())
x = list(input())
x = x[::-1]
cnt = 0;l = len(x)
r1 = 0;r2 = 0
for i in x:
    if i == '1':
        cnt += 1
i = 0
while i < l:
    if x[i] == '1':
        r1 += qpow(2,i,cnt+1)
        r2 += qpow(2,i,cnt-1)
    i += 1
i = 0
a = []
while i < l:
    if x[i] == '0':
        t = f((r1+qpow(2,i,cnt+1))%(cnt+1))+ 1
    else:
        if cnt-1 !=  0:
            t = f((r2-qpow(2,i,cnt-1)+(cnt-1))%(cnt-1)) + 1
        else:
            t = 0
    i += 1
    a.append(t)
a = a[::-1]
for i in a:
    print(i)




Measured memory_bytes: 13788