akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }
inline long long tonum(string s) {long long v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string tostr(T x) {ostringstream sout;sout<<x;return sout.str();}

string IN[32] = { "101", "000000", "000011", "10010001", "010001", "000001", 
    "100101", "10011010", "0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000", "0110", "00100",
    "10011001", "10011110", "00101", "111", "10011111", "1000", "00110", "00111", "10011100", "10011101", 
    "000010", "10010010", "10010011", "10010000"};


map<char,string> ma;
map<string,char> ma2;

string str;

int main() {
    for (int i = 0; i < 26; ++i) {
        string tmp = "";
        for (int j = 4; j >= 0; --j) {
            if (i & (1<<j)) tmp += "1";
            else tmp += "0";
        }
        ma[ 'A'+i ] = tmp;
    }
    ma[' '] = "11010"; ma['.'] = "11011"; ma[','] = "11100";ma['-'] = "11101"; ma[39] = "11110"; ma['?'] = "11111";
    ma2[IN[0]] = ' '; ma2[IN[1]] = 39; ma2[IN[2]] = ','; ma2[IN[3]] = '-'; ma2[IN[4]] = '.'; ma2[IN[5]] = '?';
    for (int i = 0; i < 26; ++i) {
        ma2[IN[i+6]] = 'A'+i;
    }
    
    while (getline(cin, str)) {
        string tmp = "";
        for (int i = 0; i < str.size(); ++i) tmp += ma[str[i]];
        string res = "";
        int t = 0;
        string sstr = "";
        for (t = 0; t < tmp.size(); ++t) {
            sstr += tmp[t];
            if (ma2.count(sstr)) {
                res += ma2[sstr];
                sstr = "";
            }
        }
        cout << res << endl;
    }
    return 0;
}


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

int main()
{
  int c=0;
  string s,t;
  cin>>s>>t;
  for(int i=0;i<3;i++)
  {
    if(s[i]==t[i])
      c++;
  }
  cout<<c;
  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>
#include <math.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<long long, long long>;


struct Node {
    Node * left;
    Node * right;

    ll value;
};

void update (Node * node, ll tl, ll tr, ll l, ll r, ll add) {
    if (l > r)
        return;
    if (l == tl && tr == r)
        node->value += add;
    else {
        ll tm = (tl + tr) >> 1;
        if (node->left == nullptr)
            node->left = new Node();

        if (node->right == nullptr)
            node->right = new Node();

        update(node->left, tl, tm, l, min(r, tm), add);
        update(node->right, tm + 1, tr, max(l, tm + 1), r, add);
    }
}

int get (Node * node, ll tl, ll tr, ll pos) {
    if (tl == tr)
        return node->value;
    int tm = (tl + tr) / 2;
    if (pos <= tm) {
        if (node->left == nullptr)
            node->left = new Node();

        return node->value + get(node->left, tl, tm, pos);
    } else {
        if (node->right == nullptr)
            node->right = new Node();

        return node->value + get(node->right, tm + 1, tr, pos);
    }
}

void solve() {

    int n;

    ll D;
    ll A;

    cin >> n >> D >> A;

    vector<pair<ll, ll>> vec;

    for (int i = 0 ; i < n; ++ i){

        ll x, h;
        cin >> x >> h;

        vec.push_back({x, h});
    }

    Node * top = new Node();

    sort(vec.begin(), vec.end());

    ll inf = 1e9 + 10;

    ll answr = 0;

    for (auto el : vec){

        ll h = el.second;

        h += get(top, 0, inf, el.first);

        if (h < 0)
            continue;

        ll cnt = h / A;

        if (h % A)
            cnt++;

        answr += cnt;

        update(top, 0, inf, el.first, min(inf, el.first + 2 * D), -A * cnt);
    }


    cout << answr;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

    solve();
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a[4];
	int tmp; cin >> tmp;
	for(int i = 0; i < 4; i++){
		a[i] = (tmp/(int)pow(10,3-i))%10;
	}

	for(int i = 0; i < 8; i++){
		int sum = a[0];
		for(int j = 0; j < 3; j++){
			if(i>>j&1){
				sum += a[j+1];
			}else{
				sum -= a[j+1];
			}
		}
		if(sum == 7){
			cout << a[0];
			for(int j = 0; j < 3; j++){
				if(i>>j&1){
					cout << "+";
				}else{
					cout << "-";
				}
				cout << a[j+1];
			}
			cout << "=7" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  char ch=gc();
  while(!isdigit(ch)) ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return ans;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
}
using namespace modular;
const int N=1e5+5;
int n,m,v,p,a[N],vl[N],sig,cnt[N],ps;
ll sum1[N],sum2[N];
inline int find(int x) { return lower_bound(vl+1,vl+sig+1,x)-vl; }
inline int getsum(int l,int r) { return l<=r?cnt[r]-cnt[l-1]:0; }
inline bool check(int id) {
  if(getsum(id+1,sig)+1<=p) return 1;
  int dt=vl[ps]-vl[id];
  if(dt>m) return 0;
  int lim=vl[id]+m,tim=cnt[id]+p-1;
  if(tim>=v) return 1;
  return (ll)m*(v-tim)<=sum2[id+1]+(ll)(getsum(id+1,ps-1)+cnt[ps]-cnt[ps-1]-(p-1-getsum(ps+1,sig)))*(lim-vl[ps]);
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),m=read(),v=read(),p=read();
  for(ri i=1;i<=n;++i) a[i]=read(),vl[i]=a[i];
  sort(vl+1,vl+n+1),sig=unique(vl+1,vl+n+1)-vl-1;
  for(ri i=1;i<=n;++i) ++cnt[find(a[i])];
  for(ri i=sig,ss=0;i;--i) {
    ss+=cnt[i];
    if(ss>=p) { ps=i;break; }
  }
  for(ri i=ps-1;i;--i) sum2[i]=sum2[i+1]+(ll)cnt[i]*(vl[ps]-vl[i]);
  for(ri i=1;i<=sig;++i) cnt[i]+=cnt[i-1];
  int res=0;
  for(ri i=1;i<=sig;++i) if(check(i)) res+=cnt[i]-cnt[i-1];
  cout<<res;
  return 0;
}

Measured memory_bytes: 2432
import java.util.*;
public class Main {
    public static void main(String[] args){
        int N, M;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        int t=1;
        for(int i=1;i<=M;i++){
            t = t * 2;
        }
        int sum = M*1900 + (N-M)*100;
        System.out.println(sum*t);

    }

}

Measured memory_bytes: 21716
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <cmath>
#include <stdlib.h> 
#include <stdio.h>
#include <iterator>
#include <chrono>
#include <iomanip>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <deque>
#include <stack>
#include <queue>
#include <fstream>
#include <limits>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <sstream>
#include <random>
#include <cassert>

using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

int get_rep(int a, vector <int> & rep) {
	while (rep[a] != a) a = rep[a];
	return a;
}

void join(int a, int b, vector <int> & size, vector<int> & rep) {
	a = get_rep(a, rep); b = get_rep(b, rep);
	if (a == b) return;
	if (size[a] > size[b]) swap(a, b); // join a to b
	rep[a] = b;
	size[b] += size[a];
}

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

	int n, q, a, b;
	cin >> n >> q;
	vector <int> size(n, 1), rep(n);
	for (int i = 0; i < n; i++) rep[i] = i;

	ffor(q) {
		cin >> a >> b;
		a--; b--;
		join(a, b, size, rep);
	}

	int maximum = 0;
	for (auto e : size) maximum = max(maximum, e);
	cout << maximum;
}
	




/*
C:\Users\User\Desktop\comp_programming\final_straw_after_this_im_switching_to_vs_code\final_straw_after_this_im_switching_to_vs_code.cpp
*/

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

int main(){
  int N;
  cin>>N;
  vector<int> C(N-1),S(N-1),F(N-1);
  for(int i=0;i<N-1;i++){
    cin>>C.at(i)>>S.at(i)>>F.at(i);
  }

  for(int i=0;i<N-1;i++){
    int t=0;
    t+=S.at(i)+C.at(i);
    for(int j=i+1;j<N-1;j++){
      if(t<S.at(j)){
        t=S.at(j);
      }else{
        t=((t-1)/F.at(j)+1)*F.at(j);
      }
      t+=C.at(j);
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<string>s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  int cnt=0,cntA=0,cntB=0,cntBA=0;
  for(int i=0;i<N;i++){
    int ni=s[i].size();
    if(s[i].back()=='A'&&s[i].front()=='B'){cntBA++;}
    else if(s[i].back()=='A'){cntA++;}
    else if(s[i].front()=='B'){cntB++;}
    for(int j=0;j<ni;j++){
      if(s[i].substr(j,2)=="AB"){cnt++;}
    }
  }
  if(cntA==0&&cntB==0&&cntBA>0){cout<<cnt+cntBA-1<<endl;}
  else{cout<<cnt+min(cntBA+cntA,cntBA+cntB)<<endl;}
  
  return 0;
}

Measured memory_bytes: 3712
list = Hash.new{|index,key|
  index[key] = []
}

while input = gets do
  break if input.chomp == ""
  input = input.split
  list[input[0]] << (input[1].to_i)
end

list.sort.each do |key,val|
  puts key
  puts val.sort.join(" ")
end

Measured memory_bytes: 6088
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
vector<vector<int>>G;
list<int>out;
vector<bool>V;
int N;

void dfs(int u) {
	V[u] = true;
	rep(i, 0, G[u].size()) {
		int v = G[u][i];
		if (!V[v])dfs(v);
	}
	out.push_back(u);
}

signed main() {
	int s, t, M;
	cin >> N >> M;
	V = vector<bool>(N, false); G = vector<vector<int>>(N, vector<int>());
	rep(i, 0, M) {
		cin >> s >> t;
		G[s].push_back(t);
	}
	rep(i, 0, N) {
		if (!V[i])dfs(i);
	}
	reverse(out.begin(), out.end());
	each(it, out)cout << *it << endl;
	return 0;
}

Measured memory_bytes: 3868
import queue

N, Q = map(int, input().split())

P = queue.Queue()
for _ in range(N):
    p = input().split()
    P.put([p[0], int(p[1])])

time = 0
while not P.empty():
    p = P.get()
    if p[1] <= Q:
        time += p[1]
        print(p[0], time)
    else:
        time += Q
        P.put([p[0], p[1] - Q])


Measured memory_bytes: 14400
#include <stdio.h>

int main(void){
    
    long int a,b,x;
    
    scanf("%ld %ld %ld",&x,&a,&b);
    
    if(a>=b)printf("delicious\n");
    if(a<b){
        if(b-a>x)printf("dangerous\n");
        else printf("safe\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

// An Item is something we manage in a priority queue.
type Item struct {
	value    int // The value of the item; arbitrary.
	priority int // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, value int, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

const (
	white int = iota
	gray
	black
)

type node struct {
	id     int
	parent int
	edge   []int
	weight []int
	color  int
}

type graph struct {
	nodes    []node
	distance []int
}

var infty = 1 << 32
var null = -1

func constructgraph() *graph {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	g := &graph{make([]node, n), make([]int, n)}

	for i := 0; i < n; i++ {
		id := nextInt(sc)
		edges := nextInt(sc)
		n := node{}
		n.id = id
		n.edge = make([]int, edges)
		n.weight = make([]int, edges)
		n.color = white
		for j := 0; j < edges; j++ {
			to := nextInt(sc)
			w := nextInt(sc)
			n.edge[j] = to
			n.weight[j] = w
		}
		g.nodes[id] = n
	}
	return g
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func (g *graph) preparedijkstra(s int) {
	for i := 0; i < len(g.nodes); i++ {
		g.nodes[i].color = white
		g.nodes[i].parent = null
		g.distance[i] = infty
	}
	g.distance[s] = 0
}

func (g *graph) dijkstra(s int) []int {
	g.preparedijkstra(s)

	pq := make(PriorityQueue, 1)
	pq[0] = &Item{s, 0, 0}
	heap.Init(&pq)

	for pq.Len() > 0 {
		min := heap.Pop(&pq).(*Item)

		u := min.value
		cost := -1 * min.priority
		if g.distance[u] < cost {
			continue
		}

		g.nodes[u].color = black

		for i, v := range g.nodes[u].edge {
			if g.nodes[v].color != black {
				if g.distance[v] > g.distance[u]+g.nodes[u].weight[i] {
					g.distance[v] = g.distance[u] + g.nodes[u].weight[i]
					g.nodes[v].parent = u
					g.nodes[v].color = gray
					item := &Item{value: v, priority: -g.distance[v]}
					heap.Push(&pq, item)
				}
			}
		}
	}
	return g.distance
}

func printShortestPath(d []int) {
	for i, v := range d {
		fmt.Printf("%d %d\n", i, v)
	}
}

func main() {
	g := constructgraph()
	d := g.dijkstra(0)
	printShortestPath(d)
}



Measured memory_bytes: 11036
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

time = [A,B,C,D,E]
if N%min(time)==0:
	print(5+N//min(time)-1)
else:
	if N>min(time):
		print(5+N//min(time))
	else:
		print(5)

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

using namespace std;
 
int main()
{
    int N;
 
    while (cin >> N, N != -1) {
        double x = 1, y = 0, r;
	for (int i = 0; i < N-1; i++) {
            r = atan2(y, x);
	    x -= sin(r);
	    y += cos(r);
	}
	printf("%.5f\n%.5f\n", x, y);
    }
    return 0;
}

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

#define FAST {ios::sync_with_stdio(false); cin.tie(NULL);}
#define pb push_back
#define fi first
#define se second
#define ll long long int
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007

vector<vector<int>> knap(4000,vector<int>(4000,0));
int n1,n2;
string s,t;
string ans = "";

void lcs(){

	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			if(s[i-1] == t[j-1]){
				knap[i][j] = 1 + knap[i-1][j-1];
			}
			else
				knap[i][j] = max(knap[i-1][j],knap[i][j-1]);
		}
	}
}

void traceBack(){

	int r = n1, c = n2;
	while(r != 0 && c != 0){
		if(s[r-1] == t[c-1]){
			ans.pb(s[r-1]);
			r--;c--;
		}
		else if(knap[r-1][c] > knap[r][c-1]){
			r--;
		}
		else
			c--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";
}

int main(){

    FAST
    
    cin>>s>>t;

    n1 = s.length();
    n2 = t.length();

    lcs();
    traceBack();
    
    return 0;
}


Measured memory_bytes: 66276
from collections import defaultdict


def main():
    N = int(input())
    d = defaultdict(lambda: 0)
    for _ in range(N):
        s = input()
        d[s] += 1
    M = int(input())
    for _ in range(M):
        s = input()
        d[s] -= 1
    print(max(list(d.values()) + [0]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if a-b >= 0 {
		fmt.Println("delicious")
	} else if a-b+x >= 0 {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 512
import sys
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
    a,b = map(int, input().split())
    s = a*b
    l = 2*a + 2*b
    print(s,l)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
using System;

namespace AOJ.ITP
{
    public class MinMaxSum
    {
        public static void Main()
        {
            int num_cnt = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');

            int min_val = int.MaxValue;
            int max_val = int.MinValue;
            long sum = 0;
            for (int i = 0; i < num_cnt; i++)
            {
                int val = int.Parse(input[i]);
                min_val = Math.Min(min_val, val);
                max_val = Math.Max(max_val, val);
                sum += val;
            }
            Console.WriteLine(string.Format("{0} {1} {2}", min_val, max_val, sum));
        }
    }
}

Measured memory_bytes: 19980
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>ko[100000];
int calc(int node)
{
	vector<int>v;
	for (int i = 0; i < ko[node].size(); i++)
	{
		int z = calc(ko[node][i]);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int maxi = 0;
	for (int i = 0; i < v.size(); i++)maxi = max(maxi, v[i] + i + 1);
	return maxi;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 1; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		ko[z].push_back(i);
	}
	printf("%d\n", calc(0));
}

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

int n, m, k;
int d[105] = {0};
int point[20] = {0};
int dp[1000000] = {0};
int memo[105][105] = {0};
queue<int> qu;

int solve();

int main() {
  cin >> n >> m >> k;
  for(int i = 0; i < n; ++i) d[i] = -1;
  for(int i = 0; i < m; ++i) {
    cin >> point[i];
    --point[i];
    d[point[i]] = i;
  }
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < k; ++j) {
      cin >> memo[i][j];
      --memo[i][j];
    }
  cout << solve() << endl;
}

int solve() {
  int now, nextn;
  qu.push((1 << m) - 1);
  dp[(1 << m) - 1] = 0;
  while(qu.size() > 0) {
    now = qu.front();
    qu.pop();
    for(int i = 0; i < k; ++i) {
      nextn = 0;
      for(int j = 0; j < m; ++j)
        if(((1 << j) & now) == (1 << j)) {
          int np = point[j];
          int x = memo[np][i], bit;
          if(d[x] == -1) continue;
          bit = (1 << d[x]);
          nextn |= bit;
        }
      if(nextn != (1 << m) - 1 && dp[nextn] == 0) {
        dp[nextn] = dp[now] + 1;
        qu.push(nextn);
      }
    }
  }
  return dp[0];
}


Measured memory_bytes: 3588
fn gcd(a: usize, b: usize) -> usize {
    if a == 0 || b == 0 {
        if a == 0 {
            return b;
        } else {
            return a;
        };
    }
    if a < b {
        return gcd(b % a, a);
    }
    gcd(a % b, b)
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let x: usize = sc.read();
    let mut xs: Vec<usize> = sc.vec(n);
    xs.push(x);
    xs.sort();
    let mut result = xs[1] - xs[0];
    for i in 1..xs.len() - 1 {
        let diff = xs[i + 1] - xs[i];
        result = gcd(result, diff);
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10620
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define per(i,a,b) for(int i = (a); i >= (b); i--)
#define mst(a,b) memset(a,b,sizeof(a));
#define clr(a) mst(a,0);
#define pb  push_back
#define mp  make_pair
#define first fi
#define second se
int dir[4][2] = {1,0,-1,0,0,1,0,-1};
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
ll _gcd(ll a,ll b){return b?_gcd(b,a%b):a;}
const double PI = acos(-1);
//head
const int maxn = 1e5 + 11;
int a[maxn],b[maxn],ans = 0;
int main(int argc, char const *argv[]){
	

	string str; cin >> str;
	if(str.length() == 2){ 
		cout << str << endl;
	}else{
		cout << str[2] << str[1] << str[0] << endl;
	}
	return 0;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	string s;
	while(cin>>s){
		bool f=0;
		rep(i,0,3){
			if(s[3*i]==s[3*i+1] && s[3*i]==s[3*i+2] && s[3*i]!='s'){
				o(s[3*i]); f=1; break;
			}
		}
		if(f) continue;
		rep(i,0,3){
			if(s[i]==s[i+3] && s[i]==s[i+6] && s[i]!='s'){
				o(s[i]); f=1; break;
			}
		}
		if(f) continue;
		if(s[0]==s[4] && s[0]==s[8] && s[0]!='s'){
			o(s[0]); f=1;
		}
		if(f) continue;
		if(s[2]==s[4] && s[2]==s[6] && s[2]!='s'){
			o(s[2]); f=1;
		}
		if(!f) o('d');
	}
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  ll N; cin>>N;
  ll res = 0;
  rep1(i,N){
    if(i%3!=0&&i%5!=0)res+=i;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int n;
    int cnt = 0;
    vector<int> a(n);
    set<int> as;
    cin >> n;
    rep(i, n) {
        int ai;
        cin >> ai;
        if(ai >= 3200) {
            ai = 3200;
            cnt += 1;
        }
        a[i] = ai / 400;
        as.insert(a[i]);
    }

    if(n == cnt) cout << 1 << " " << n << endl;
    else if(cnt == 0){
        cout << as.size() << " " << as.size() << endl;
    } else {
        cout << as.size() - 1 << " " << as.size() + cnt - 1 << endl;
    }
}

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

struct CARD {
  char mark;
  char num;
  int index;
};


void selectionSort(CARD* A, int N){
  int minj;

  for(int i = 0; i < N - 1; i++){
    minj = i;
    for(int j = i; j < N; j++){
      if(A[j].num < A[minj].num)
        minj = j;
    }

    if(minj != i){
      CARD tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
    }
  }

  return;
}

void bubbleSort(CARD* A, int N){

  bool flag = true;

  while(flag){
    flag = false;

    for(int i = N-1; i > 0; i--){
      if(A[i].num < A[i-1].num){
        CARD tmp = A[i];
        A[i] = A[i -1];
        A[i-1] = tmp;
        flag = true;
      }
    }
  }

  return;
}

void showA(CARD* A, int N){
  for(int i = 0; i < N; i++){
    if(i < N-1)
      std::cout << A[i].mark << A[i].num << ' ';
    else
      std::cout << A[i].mark << A[i].num << std::endl;
  }
    return;
}

void checkA(CARD* A, int N){
  bool flag = true;

  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      if(A[i].num == A[j].num && A[i].index > A[j].index)
        flag = false;
    }
  }

  if(flag)
    std::cout << "Stable" << std::endl;
  else
    std::cout << "Not stable" << std::endl;

  return;
}

int main(){
  int N;

  std::cin >> N;

  CARD* A = new CARD[N];
  CARD* B = new CARD[N];
  for(int i = 0; i < N; i++){
    std::cin >> A[i].mark >> A[i].num;
    A[i].index = i;
  }

    for(int i = 0; i < N; i++){
    B[i].mark = A[i].mark;
    B[i].num = A[i].num;
    B[i].index = A[i].index;
  }


  bubbleSort(A, N);
  showA(A, N);
  checkA(A, N);

  selectionSort(B, N);
  showA(B, N);
  checkA(B, N);

  return 0;
}

Measured memory_bytes: 3104
import sys
from collections import deque

n, *aaa = map(int, sys.stdin.buffer.read().split())
children = [set() for _ in range(n)]
parent = [0] * n
for i, a in enumerate(aaa, start=1):
    a -= 1
    children[a].add(i)
    parent[i] = a

depth = [0] * n
fixed_children = [0] * n
q = deque([i for i, c in enumerate(children) if len(c) == 0])
while q:
    i = q.popleft()
    if len(children[i]) > 0:
        ds = [depth[j] for j in children[i]]
        ds.sort(reverse=True)
        depth[i] = max(j + d for j, d in enumerate(ds)) + 1
    p = parent[i]
    fixed_children[p] += 1
    if fixed_children[p] == len(children[p]):
        q.append(p)
print(depth[0])


Measured memory_bytes: 51408
N = int(input())
P = list(map(int,input().split()))
import collections
c = collections.Counter(P)
t = 0
for j in c.values():
    t = t+j*(j-1)/2
for i in range(N):
    t1 = t -(c[P[i]]-1)
    print(int(t1))
    

Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int N;
	cin >> N;
	ll ans = 1;
	int od = 1;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		ans *= 3;
		if (tmp % 2 == 0) {
			od *= 2;
		}
		else {
			od *= 1;
		}
		
	}
	cout << ans - od << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;
    int N = n * 3;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)  cin >> a[i];
    ll S1 = 0, S2 = 0;
    priority_queue<int, vector<int>, greater<int>> Q1;
    for(int i = 0; i < n; ++i){
        S1 += a[i];
        Q1.push(a[i]);
    }
    multiset<int> st, st2;
    for(int i = n; i < N; ++i){
        S2 += a[i];
        st.insert(a[i]);
    }
    int c = n;
    while(c-- > 0){
        int val = *(st.rbegin());
        st.erase(st.find(val));
        S2 -= val;
        st2.insert(val);
    }
    ll ans = S1 - S2;
    for(int i = n; i < N - n; ++i){
        if(a[i] > Q1.top()){
            S1 -= Q1.top();
            Q1.pop();
            Q1.push(a[i]);
            S1 += a[i];
        }
        auto it = st.find(a[i]);
        if(it != st.end()){
            S2 -= a[i];
            st.erase(it);
            int val = *(st2.begin());
            S2 += val;
            st2.erase(st2.begin());
            st.insert(val);
        }
        else{
            st2.erase(st2.find(a[i]));
        }
        chmax(ans, S1 - S2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14148
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T = sorted(T)

count = []
ans = []
start = 0
for i in range(N):
    if abs(T[start] - T[i]) <= K and len(count) < C:
        count.append(T[i])
    else:
        ans.append(count)
        count = [T[i]]
        start = i
    
    if i == N-1:
        ans.append(count)

print(len(ans))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    Scd(n);

    int a,b,c;
    vector<int> x,y,h;

    int height[101][101] = {{}};

    Rep(i,n){
        Scd3(a,b,c);
        x.push_back(a);
        y.push_back(b);
        h.push_back(c);
        height[a][b] = c;
    }

    int leng = 0;
    Rep(i,101)
        Rep(j,101) height[i][j] = -1;

    Rep(i,101){
        Rep(j,101){
            int preh = -1;
            Rep(k,n){
                if( h[k] == 0 ) continue;
                if( preh == -1 ) preh = abs(i-x[k]) + abs(j-y[k] ) + h[k];
                if( preh != abs(i-x[k]) + abs(j-y[k] ) + h[k] ){
                    preh = -1;
                    break;
                }
            }
            Rep(k,n){
                if( h[k] != 0 ) continue;
                if( preh == -1 ) break;
                if( preh > abs(i-x[k]) + abs(j-y[k] ) + h[k] ){
                    preh = -1;
                    break;
                }
            }

            if(preh == -1 ) continue;

            printf ("%d %d %d", i,j,preh);

        }
    }



    return 0;
}



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

int main() {
  int c[9];
  fill_n(c, 9, 0);

  for (int i = 0; i < 9; i++) {
    cin >> c[i];
  }
  
  int a1 = 0;
  int b1 = c[0] - a1;
  int b2 = c[1] - a1;
  int b3 = c[2] - a1;
  int a2 = c[3] - b1;
  int a3 = c[6] - b1;

  if(c[0] != a1+b1 || c[1] != a1+b2 || c[2] != a1+b3 ||
      c[3] != a2+b1 || c[4] != a2+b2 || c[5] != a2+b3 || 
      c[6] != a3+b1 || c[7] != a3+b2 || c[8] != a3+b3){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

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

    long long n, k;
    cin >> n >> k;


    long long ans;

    if(k&1){
        ans = (n/k)*(n/k)*(n/k);
    }
    else{
        ans = (n/k)*(n/k)*(n/k);
        ans += ((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 256
n = gets.to_i
m=Array.new(n,0)
d=gets.split(' ').map(&:to_i)
total=d.inject(:+)

m[0]=total
for i in 1..(n-1)/2
  m[0]-=2*d[(i * 2) -1]
end

for i in 1..n-1
  m[i] = 2*d[i-1]-m[i-1]
end
puts m


Measured memory_bytes: 13060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;

class Program
{
    static void Main()
    {
        new Program().Solve();
    }

    void Solve()
    {
        double c = Math.PI / 180;

        var abhm = ReadLongArray();
        var a = abhm[0];
        var b = abhm[1];
        var h = (double)abhm[2];
        var m = abhm[3];

        h += m / 60d;

        var x1 = Math.Sin(c * h * 360 / 12) * a;
        var y1 = -Math.Cos(c * h * 360 / 12) * a;
        var x2 = Math.Sin(c * m * 360 / 60) * b;
        var y2 = -Math.Cos(c * m * 360 / 60) * b;

        Console.WriteLine(Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)));
    }

    #region Console.Read 関係
    long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    long ReadLong() => long.Parse(Console.ReadLine());
    #endregion
}

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

typedef struct LinkedList
{
  struct LinkedList *prev;
  int key;
  struct LinkedList *next;
} LinkedList;

LinkedList *first = NULL;
LinkedList *last = NULL;

void insert(int);
void deleteKey(int);
void deleteFirst();
void deleteLast();
void printLinkedList();

int main(void)
{
  int numOp, i, key;
  char command[12];
  scanf(" %d", &numOp);
  for (i = 0; i < numOp; i++)
    {
      scanf(" %s", command);
      if (!strcmp(command, "insert"))
	{
	  scanf(" %d", &key);
	  insert(key);
	}
      else if (!strcmp(command, "delete"))
	{
	  scanf(" %d", &key);
	  deleteKey(key);
	}
      else if (!strcmp(command, "deleteFirst"))
	deleteFirst();
      else
	deleteLast();
    }
  printLinkedList();
  return 0;  
}

void insert(int key)
{
  LinkedList *newNode = (LinkedList *) malloc(sizeof(LinkedList));
  newNode->key = key;
  if (first == NULL)
    {
      first = newNode;
      last = newNode;
      newNode->prev = NULL;
      newNode->next = NULL;
    }
  else
    {
      newNode->next = first;
      first->prev = newNode;
      first = newNode;
    }
  return;
}

void deleteKey(int key)
{
  LinkedList *current = first;
  while (current != NULL)
    {
      if (current->key == key)
	{
	  if (current == first)
	    deleteFirst();
	  else if (current == last)
	    deleteLast();
	  else
	    {
	      current->prev->next = current->next;
	      current->next->prev = current->prev;
	      free(current);
	    }
	  return;
	}
      current = current->next;
    }
  return;
}
	  
void deleteFirst()
{
  if (!first)
    return;
  if (first == last)
    {
      free(first);
      first = NULL;
      last = NULL;
    }
  else
    {
      LinkedList *holder = first->next;
      free(first);
      first = holder;
      first->prev = NULL;
    }
  return;
}

void deleteLast()
{
  if (!last)
    return;
  if (first == last)
    {
      free(last);
      first = NULL;
      last = NULL;
    }
  else
    {
      LinkedList *holder = last->prev;
      free(last);
      last = holder;
      last->next = NULL;
    }
  return;
}

void printLinkedList()
{
  LinkedList *current = first;
  while (current != NULL)
    {
      printf("%d", current->key);
      if (current == last)
	{
	  printf("\n");
	  break;
	}
      else
	printf(" ");
      current = current->next;
    }
}




Measured memory_bytes: 32952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _087
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());

            int count = 0;

            for(int i = 0; i <= A; ++i)
            {
                for(int j = 0;j <= B; ++j)
                {
                    for(int k = 0;k <= C; ++k)
                    {
                        if ((i * 500) + (j * 100) + (k * 50) == X)
                        {
                            count = count + 1;
                        }

                    }
                }
            }

            Console.WriteLine(count);
            Console.Read();

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL tmp_a;
    bool is_ok=true;
    LL ans=1;
    vector<LL> num_list(MAX, 0);
    cin >> n;
    for(LL i=0; i<n; i++){
        cin >> tmp_a;
        num_list[tmp_a]++;
    }

    LL start=(n-1)%2;
    for(LL i=start; i<n; i=i+2){
        if(i==0 && num_list[i]!=1){
            //cout << i << " test" << endl;
            is_ok=false;
        }else if(i!=0 && num_list[i]!=2){
            //cout << i << " test2" << endl;
            is_ok=false;
        }
    }

    if(is_ok==false){
        cout << 0 << endl;
    }else{
        for(LL i=start; i<n; i=i+2){
            ans=ans*num_list[i];
            ans=ans%MOD;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3788
n=gets.to_i
s=gets.chomp
t=gets.chomp
m=1000000007
if s[0]==t[0]
  a=3
  i=1
else
  a=6
  i=2
end
while i<n
  if s[i]==t[i]
    if s[i-1]==t[i-1]
      a=a*2%m
    end
    i+=1
  else
    if s[i-1]==t[i-1]
      a=a*2%m
    else
      a=a*3%m
    end
    i+=2
  end
end
puts a


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    vector<int> count(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        count[b]++;
    }
    queue<int> zero;
    for (int i = 0; i < n; i++) if (count[i] == 0)zero.push(i);
    vector<int> ret(n);
    while (!zero.empty()) {
        int f = zero.front();
        zero.pop();
        for (auto x:edge[f]) {
            ret[x] = f + 1;
            count[x]--;
            if (count[x] == 0)zero.push(x);
        }
        count[f]--;
    }
    for (int i = 0; i < n; i++) cout << ret[i] << endl;
    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

#define min(a, b) ((a) < (b)) ? (a) : (b)

int main () {
    int P, Q, R;
    scanf("%d", &P);
    scanf("%d", &Q);
    scanf("%d", &R);
    int ans = min(min((P + Q), (Q + R)), R + P);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
from itertools import accumulate
from operator import add, xor

def solve(N: int, A: "List[int]"):
    acc_add = [0] +list(accumulate(A, add))
    acc_xor = [0] +list(accumulate(A, xor))

    ret = 0
    j = 0
    for i, (ba, bx) in enumerate(zip(acc_add, acc_xor)):
        while j < N:
            if (acc_add[j+1] - ba) != (acc_xor[j+1] ^ bx):
                break
            j += 1
        ret += j - i
    print(ret)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45572
import numpy as np
N=int(input())
#AGCT
#0123
dp = np.zeros((N+1, 4, 4, 4))
dp[0][3][3][3]=1
mod=1000000007
for c in range(N):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        for a in range(4):
          if a==1 and i==2 and j==0:continue
          if a==2 and i==1 and j==0:continue
          if a==2 and i==0 and j==1:continue
          if a==2 and j==1 and k==0:continue
          if a==2 and i==1 and k==0:continue
          dp[c+1][a][i][j]+=dp[c][i][j][k]
          dp[c+1][a][i][j]%=mod
ans=0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans+=dp[N][i][j][k]
      ans%=mod
print(int(ans))

Measured memory_bytes: 12488
H, W = map(int, input().split())
a = [[c for c in input()] for _ in range(H)]

b = []
for i in range(len(a)):
    if "#" in a[i]:
        b.append(a[i])

c = [[] for _ in range(len(b))]
for j in range(W):
    if any(["#" == b[i][j] for i in range(len(b))]):
        for i in range(len(b)):
            c[i].append(b[i][j])

for line in c:
    print("".join(line))


Measured memory_bytes: 3188
import java.util.Scanner;

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

		String moto=sc.next();

		for(int i=0; i<moto.length(); i++) {
			if(moto.charAt(i)=='0') {
				a=a+"0";
			}
			else if(moto.charAt(i)=='1') {
				a=a+"1";
			}

			else if(moto.charAt(i)=='B') {
				if(a.length()>0) {
					a=a.substring(0,a.length()-1);
				}
				else {
					//
				}
			}
		}
		System.out.println(a);
	}
}

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

using namespace std;

int main(void) {
  string S; cin >> S;
  
  int bw = 0, wb = 0;

  for (int i = 0; i < S.size(); i++) {
    if ((i&1) == 0) {
      if (S[i] == '0') {
        wb++;
      } else {
        bw++;
      }
    } else {
      if (S[i] == '1') {
        wb++;
      } else {
        bw++;
      }
    }
  }

  cout << min(bw, wb) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iterator>
#include <functional>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define sz(a)  int((a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define CLR(a) memset((a), 0, sizeof(a))
#define INF (1 << 31) - 1
const int dh[8] = {-1, 1, 0, 0,1,1,-1,-1};
const int dw[8] = {0, 0, 1, -1,1,-1,1,-1};
typedef long long ll;
typedef pair<int, int> p;
typedef vector <int> VI;
typedef vector <string> VS;

vector <int> his;

int main(){

	ll n;
	cin >> n;

	ll ans = floor(sqrt(n * 2));
	if((ans + 1) * ans / 2 < n) ans++;
	
	cout << ans << endl;
	return 0;	
}


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: 2052
n, y = gets.strip.split.map(&:to_i)

k_10 = 10000
k_5 = 5000
k_1 = 1000

(0..n).each do |i|
  (0..n-i).each do |j|
    if k_10*i + k_5*j + k_1*(n-i-j) == y
      puts [i, j, n-i-j].join(' ')
      exit
    end
  end
end

puts '-1 -1 -1'


Measured memory_bytes: 1788
N, K = map(int, input().split())

a_list = list(map(int, input().split()))
mod = 10 ** 9 + 7

# def count_inversion(sequence):
#     count = 0
#     for i in range(1,len(sequence),1):
#         for j in range(i,len(sequence),1):
#             if sequence[i-1] > sequence[j]:
#                 count += 1
#     return count

ans = 0
pre = []
from bisect import *
for i in range(N):
    a = a_list[i]
    for j in range(i + 1, N):
        b = a_list[j]
        if a > b:
            ans += (K + 1) * K // 2
            ans %= mod
    idx = bisect_left(pre, a)
    ans += idx * ((K-1)*K//2)
    ans %= mod
    insort_left(pre, a)
print(ans)


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	int a[3];
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	sort(a, a+3);
	printf("%s\n", (a[0] == 5 && a[1] == 5 && a[2] == 7) ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256