akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  
  int x[n],y[n],a[n];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>a[i];
  }
  
  int x1=0,y1=0,x2=w,y2=h;
  for(int i=0;i<n;i++){
    if(a[i]==1){
      if(x1<=x[i]){
        x1=x[i];
      }
    }
    if(a[i]==2){
      if(x2>=x[i]){
        x2=x[i];
      }
    }
    if(a[i]==3){
      if(y1<=y[i]){
        y1=y[i];
      }
    }
    if(a[i]==4) {
      if(y2>=y[i]){
        y2=y[i];
      }
    }
  }
  if((x2-x1)*(y2-y1)>=0 and x2-x1>0 ){
    cout<<(x2-x1)*(y2-y1)<<endl;
  }else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef string str;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
 
 
int main() {
    IOS;
	
	int n;
	cin >> n;
	ll s = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		s+=x;
	}
	cout << s - n;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)
    cout<<"Yes";
else cout<<"No";
       return 0;
}

Measured memory_bytes: 3588
fn main() {
  let (a, b) = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let a: i64 = ws.next().unwrap().parse().unwrap();
    let b: i64 = ws.next().unwrap().parse().unwrap();
    (a, b)
  };

  if a < 6 {
    print!("{}", 0);
  } else if  6 <= a && a < 13 {
    print!("{}", b / 2);
  } else {
    print!("{}", b);
  }
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()
	fmt.Println("A"+string(s[8])+"C")
}


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

int main(){
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b})  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int P,Q,R;
  cin >> P >> Q >> R;

  int ans =min (P+Q, min(Q+R, R+P));
  cout << ans << endl;


  return 0;
    

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 2005
using namespace std;
int n,m,f[MN][MN],a[MN][MN],st[MN],id[MN],ans1;char ch[MN]; 
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
    	scanf("%s",ch+1);
    	for(int j=1;j<=m;j++)a[i][j]=(ch[j]=='.');
	}ans1=n;
	for(int i=1;i<=n;i++)for(int j=m;j>=2;j--)a[i][j]^=a[i][j-1];
    for(int i=2;i<=m;i++)f[1][i]=1;
    for(int i=2;i<=n;i++){
        memcpy(f[i],f[i-1],sizeof(f[i-1]));
        int top=0;
        for(int j=2;j<=m;j++){
            int tmp=j;
            if(a[i][j]==a[i-1][j])f[i][j]++;else f[i][j]=1;
            while(top&&(st[top]>f[i][j]))ans1=max(ans1,(j-id[top]+1)*st[top]),tmp=id[top],--top;
            st[++top]=f[i][j],id[top]=tmp;
        }
        while(top)ans1=max(ans1,(m-id[top]+2)*st[top]),top--;  
    }printf("%d\n",ans1);
}

Measured memory_bytes: 31616
N, T = map(int, input().split())
A = [int(x) for x in input().split()] + [0]
buy = A[0]
sale = A[0]
benefit = 0
cost = 0
for a in A[1:]:
  if a > sale:
    sale = a
  elif a < buy:
    b = sale - buy
    if b > benefit:
      benefit = b
      cost = 1
    elif b == benefit:
      cost += 1
    buy = a
    sale = a
print(cost)

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

using namespace std;

int main()
{
  long long int n, k, x, y;


  cin >> n >> k;
  x = n % k;
  y = abs(x - k);

  if (x < y) {
    cout << x;
  } else {
    cout << y;
  }
 
  cin >> k;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<bool> pay(n + 1, false);
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        pay[a] = true;
    }

    int left = 0;
    for (int i = x; 0 < i; i--)
    {
        if (pay[i])
        {
            left++;
        }
    }

    int right = 0;
    for (int i = x; i < n; i++)
    {
        if (pay[i])
        {
            right++;
        }
    }
    cout << (min(left, right)) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Text;
using System.Threading.Tasks;

namespace B_coins
{
    class Program
    {
        static void Main(string[] args)
        {
            int total = int.Parse(ReadLine());
            string input = ReadLine();
            string [] arrey = input.Split(' ');
            int[] n = new int[arrey.Length+1];
            for (int i = 0; i < total; i++) {
                n[i] = int.Parse(arrey[i]);
            }
            Array.Sort(n);
            Array.Reverse(n);
            int a = 0;
            int b = 0;
            for (int m = 0; m < total; m = m + 2) {
                a += n[m];
                b += n[m+1];
            }
            int result = a - b;
            WriteLine("{0}",result);
            ReadKey();
        }
    }
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int main()
{
	int n, m;
	cin>>n>>m;
	vector<ll> v(m), b(m-1);
	rep(i, 0, m)
		cin>>v[i];
	sort(all(v));
	rep(i, 0, m-1)
	{
		b[i] = abs(v[i+1] - v[i]);
	}
	sort(all(b), greater<ll>());
	ll ans = 0;
	for(ll x: b)
	{
		n--;
		if(n <= 0) ans += x;
	}	
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define A first
#define B second
#define db double
#define lowbit(p) (p&(-p))
using namespace std;
inline void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
map< pii,int >id;
#define M 100005
struct ed{
	int x,l,nx;
}e[M*12];
int nx[6*M],dis[6*M],n,m,ecnt=1;
bool mark[6*M];
int tot,r[2],Q[2][6*M];
inline void add(int x,int y,int l){
	e[ecnt]=(ed){y,l,nx[x]};
	nx[x]=ecnt++;
}
void bfs(int s,int t){
	int x,now=0,l,i;
	memset(dis,63,sizeof(dis));
	dis[s]=0;
	Q[now][++r[now]]=s;
	
	for (;r[now];now=!now){
		for (;r[now];){
			x=Q[now][r[now]--];
			if (mark[x])continue;
			mark[x]=1;
			if (x==t){
				printf("%d\n",dis[t]);
				return ;
			}
			for (i=nx[x];i;i=e[i].nx){
				if (dis[x]+e[i].l<dis[e[i].x]){
					dis[e[i].x]=dis[x]+e[i].l;
					Q[now^e[i].l][++r[now^e[i].l]]=e[i].x;
				}
			}
		}
	}
	printf("-1\n");
}
inline int cal(int x,int col){
	int &res=id[mp(x,col)];
	if (res)return res;
	res=++tot;
	add(x,res,1);
	add(res,x,0);
	return res; 
}
int main(){
	int Caseid;
// 	freopen("8.in","r",stdin);
//	read(Caseid);
	read(n); read(m);	
	int i,x,y,c;
	tot=n;
	for (i=1;i<=m;i++){
		read(x); read(y); read(c);
		x=cal(x,c);
		y=cal(y,c);
		add(x,y,0);
		add(y,x,0);
	}
	bfs(1,n);
	return 0;
}

Measured memory_bytes: 47488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

char M[11][1005];
ll cum[11][1005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> m >> k;

	for(i=1;i<=n;i++)
	{
		string s;
		cin >> s;
		for(j=1;j<=m;j++)
			M[i][j]=s[j-1];
	}

	for(j=1;j<=m;j++)
	{
		for(i=1;i<=n;i++)
		{
			cum[i][j]=cum[i-1][j];
			if(M[i][j]=='1')
				cum[i][j]++;
		}
	}

	ll ans=n+m-2;
	for(i=0;i<(1<<(n-1));i++)
	{
		ll ver=0,hori=0;
		vector<ll>hor;
		vector<ll>Cut;
		hor.pb(0),Cut.pb(0);
		for(j=0;j<n-1;j++)
		{
			if(i&(1<<j))
			{
				hori++;
				hor.pb(j+1);
				Cut.pb(0);
			}
		}
		hor.pb(n),Cut.pb(0);
		j=1;
		ll no=0;
		// if(i==1)
		// cout<<hor[2]<<" "<<hor[0]<<" "<<hor[1]<<endl;
		while(j<=m)
		{
			x=j;
			for(ll p=0;p<sz(hor);p++)
				Cut[p]=0;
			while(x<=m)
			{
				ll f=0;
				for(ll p=0;p<sz(hor)-1;p++)
				{
					ll w=cum[hor[p+1]][x]-cum[hor[p]][x];
					// cout<<"how"<<" "<<sz(Cut)<<" "<<p<<endl;
					// if(i==1)
					// 	cout<<w<<" "<<p<<" "<<x<<endl;
					if(Cut[p]+w<=k)
						Cut[p]+=w;
					else
						f=1;
				}
				// if(i==1)
				// cout<<Cut[0]<<" "<<Cut[1]<<endl;
				if(f)
					break;
				x++;
			}

			// if(i==1)
			// {
			// 	cout<<Cut[0]<<" "<<Cut[1]<<" "<<x<<" "<<i<<" "<<j<<endl;
			// }
			if(x>m)
				break;

			if(x!=j)
				ver++,j=x;
			else
			{
				no=1;
				break;
			}
		}
		if(!no)
			ans=min(ans,ver+hori);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
ll an[100010],am[100010];
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    int mn = 1e9+1;
    int ans = 0;
    REP(i,n) {
        if (v[i] < mn) ans++;
        mn = min(mn,v[i]);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 1e5 + 10;
const ll INF = 1e9;
const ll M = 1e9 + 7;
ll n;
ll d[N], dp[N][2];
vector <ll> adj[N];

void makeRooted() {
  fill (d , d + N , INF);
  queue <ii> q;
  q.push({1 , 0});
  while (q.size()) {
    ii cur = q.front(); q.pop();
    ll u = cur.fi, cd = cur.se;
    if (d[u] != INF) continue;
    d[u] = cd;
    for (ll v : adj[u]) {
      q.push({v , cd + 1});
    }
  }
  return;
}

ll add(ll a , ll b) {
  return ((a % M) + (b % M)) % M;
}

ll mul(ll a , ll b) {
  return ((a % M) * (b % M)) % M;
}

ll f(ll u , bool col) {
  ll &sol = dp[u][col];
  if (sol != -1) return sol;
  sol = 1;
  for (ll v : adj[u]) {
    if (d[v] < d[u]) continue;
    ll cur = 0;
    if (col) {
      cur = add(cur , f(v , !col));
    } else {
      cur = add(cur , add(f(v , !col) , f(v , col)));
    }
    sol = mul(sol , cur);
  }
  return sol;
}

int main() {
  in(n);
  for (ll i = 1, u, v ; i < n ; i++) {
    in(u); in(v);
    adj[u].pb(v);
    adj[v].pb(u);
  }
  makeRooted();
  memset (dp , -1 , sizeof dp);
  printf("%lld\n" , add(f(1 , 0) , f(1 , 1)));
  return 0;
}

void in(ll &x){
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 19824
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>



using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 


//#define inf 10000000
typedef struct { int x;int y; } P;
int h, w, n,co=0;
char ch[1000][1000];
int fl[1000][1000];
P ps[10];


int bfs(int t) {
	int nx, ny;
	//fori0(h)forj0(w) { fl[i][j] = inf; }
	memset(fl, -1, sizeof(fl));
	queue<P> que;
	que.push(ps[t]);
	fl[ps[t].x][ps[t].y] = 0;
	while (que.size()) {
		P p = que.front();
		//printf("(%d,%d)", p.x, p.y);
		que.pop();
		fori0(4){
			nx = p.x + dx[i];
			ny = p.y + dy[i];
			if (nxnycon&&ch[nx][ny] != 'X'&&fl[nx][ny] == -1) {
				fl[nx][ny] = fl[p.x][p.y] + 1;
				if (nx == ps[t + 1].x&&ny == ps[t + 1].y) { return fl[nx][ny]; }
				que.push({ nx,ny });

			}
		}

	}

}

int main() {
	cin >> h >> w >> n;
	fori0(h)forj0(w) {
		cin >> ch[i][j];
		if (ch[i][j] == 'S') { ps[0].x = i;ps[0].y = j; }
		if (('0' < ch[i][j]) && (ch[i][j] <= '9')) {
			ps[(int)(ch[i][j] - '0')].x = i; 
			ps[(int)(ch[i][j] - '0')].y = j;
			
		}
	}
	fori0(n) {
		co+=bfs(i);
	}
	
	printf("%d\n",co);
	//system("pause");
	return 0;
}



Measured memory_bytes: 8072
x, k, d = map(int, input().split())
x = abs(x)
ans = 0
if x >= k * d:
	ans = x - k * d
else:
	step = x // d
	x -= d * step
	k -= step
	if k % 2 == 0:
		ans = abs(x)
	else:
		ans = abs(x - d)
print(ans)


Measured memory_bytes: 9176
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine(tmp[0] % tmp[1] == 0 ? "0" : "1");
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String str = in.next();
		StringBuilder rev = new StringBuilder("");
		in.close();
		for (int i = str.length() - 1; i >= 0; i--) {
			rev.append(str.charAt(i));
		}
		System.out.println(rev.toString());
	}
}

Measured memory_bytes: 25960
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, M, ac=0, pe=0;

    cin >> N >> M;

    vector<int> p(M);
    vector<string> S(M);
    vector<bool> A(N, false);
    vector<int> pen(N, 0);

    rep(i, M) {
        cin >> p[i] >> S[i];
        if(A[p[i]]==false && S[i]=="WA") {
            pen[p[i]]++;
        } else if(A[p[i]]==false && S[i]=="AC") {
            ac++;
            pe += pen[p[i]];
            A[p[i]] = true;
        }
    }

    cout << ac << " " << pe << endl;

    return 0;
    
}

Measured memory_bytes: 6528
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0), b = sc.next().charAt(0);
        char ans = '>';
        if(a == b) ans = '=';
        else if(a < b) ans = '<';
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
import sys
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations
N,M,R=map(int,input().split())
r=list(map(lambda x: int(x)-1,input().split()))
l=tuple(permutations(range(R)))
C=[[10**8]*N for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    C[a-1][b-1]=c
    C[b-1][a-1]=c
for i in range(N):
    C[i][i]=0
for i in range(N):
    for j in range(N):
        for k in range(N):
            C[j][k] = min(C[j][k],C[j][i] + C[i][k])
a=10**8
for i in l:
    t=0
    for j in range(R-1):
        t+=C[r[i[j]]][r[i[j+1]]]
    if a>t:
        a=t
print(a)

Measured memory_bytes: 47724
#define bi
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<string>
#define MP make_pair
using namespace std;
typedef long long ll;
const ll maxn=2e5+10;
const ll mod=1e9+7;
vector<ll>road[maxn];
vector<ll>rail[maxn];
ll nogong[maxn];//gonglubianhao
ll num[maxn];
bool p[maxn];
bool q[maxn];
ll N,K,L;
ll fi,se;
map<ll,ll>use;
ll x;
void dfs(ll st,ll num)
{
    nogong[st]=num;
    ll len=road[st].size();
    for(ll i=0;i<len;i++)
    {
        if(nogong[road[st][i]]<0)
        {
            dfs(road[st][i],num);
        }
    }
}
void cc(ll st)
{
    p[st]=1;
    use[nogong[st]]++;
    ll len=rail[st].size();
    for(ll i=0;i<len;i++)
    {
        if(!p[rail[st][i]])
        {
            cc(rail[st][i]);
        }
    }
}
void kk(ll st)
{
    q[st]=1;
    num[st]+=use[nogong[st]];
    ll len=rail[st].size();
    for(ll i=0;i<len;i++)
    {
        if(!q[rail[st][i]])
        {
            kk(rail[st][i]);
        }
    }
}
int main()
{
#ifdef bibi
freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K>>L;
    memset(nogong,-1,sizeof(nogong));
    for(ll i=0;i<K;i++)
    {
        cin>>fi>>se;
        road[fi].push_back(se);
        road[se].push_back(fi);
    }
    for(ll i=0;i<L;i++)
    {
        cin>>fi>>se;
        rail[fi].push_back(se);
        rail[se].push_back(fi);
    }
    for(ll i=1;i<=N;i++)
    {
        if(nogong[i]<0)
        {
            dfs(i,++x);//wei gonglu liantong gonglu bianhao
        }
    }
    for(ll i=1;i<=N;i++)
    {
        if(!p[i])
        {
            use.clear();
            cc(i);//zhuang hui zhexie city de gonglu number
            kk(i);
        }
    }
    for(ll i=1;i<=N;i++)
    {
        cout<<num[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 23296
#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)

using namespace std;

const int N = 1e5;
const int NN = 2e5;
const int O = 1e5+1;

int n,a[N+10],temp[N+10];
LL cnt;

struct BI {
    LL a[NN + 10];

    int lowbit(int x) {
        return x&(-x);
    }

    void add(int x,int y) {
        while (x <= NN) {
            a[x] += y;
            x += lowbit(x);
        }
    }

    LL sum(int x) {
        LL now = 0;
        while (x > 0) {
            now += a[x];
            x -= lowbit(x);
        }
        return now;
    }

    LL get_sum(int l, int r) {
        if (l>r) return 0;
        return sum(r) - sum(l - 1);
    }

}b;


bool ok(int x){
    for (int i = 0;i <= NN;i++) b.a[i] = 0;
    for (int i = 1;i <= n;i++)
        if (a[i]>=x)
            temp[i]=1;
        else if (a[i]<x)
            temp[i]=-1;
    for (int i = 1;i <= n;i++) temp[i]+=temp[i-1];
    LL ju1 = 0;
    b.add(O,1);
    for (int i = 1;i <= n;i++){
        ju1+=b.get_sum(0,O+temp[i]);
        b.add(temp[i]+O,1);
    }
    //中位数大于等于x的区间的个数为ju1
    //x越大,ju1越小
    if (ju1>=(cnt+1)/2)
        return true;
    else
        return false;
}

int main()
{
    #ifdef LOCAL_DEFINE
        freopen("rush.txt","r",stdin);
    #endif // LOCAL_DEFINE
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    cnt = 1LL*n*(n-1)/2+n;
    int l= 1,r = 0,temp = -1;
    rep1(i,1,n) {
        cin >> a[i];
        r = max(r,a[i]);
    }
    while (l<=r){
        int mid = (l+r)>>1;
        if (ok(mid)){
            l = mid + 1;
            temp = mid;
        }else
            r = mid -1;
    }
    cout<<temp<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

struct UnionFind {
private:
    int N;
    vi parent;
    vi rank_;

    void init(int n) {
        N = n;
        parent.resize(0); parent.clear(); parent.resize(n);
        REP (i, N) parent[i] = i;
        rank_.resize(0); rank_.clear(); rank_.resize(n);
    }

public:
    UnionFind() { init(0); }
    UnionFind(int n) { init(n); }

    int root(int x) {
        return (parent[x] == x) ? x : parent[x] = root(parent[x]);
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank_[x] < rank_[y])
            parent[x] = y;
        else {
            parent[y] = x;
            if (rank_[x] == rank_[y]) rank_[x]++;
        }
    }
};

int N, M;
vii xy;

ll solve() {
    UnionFind uf(N);
    FORE (x, xy) {
        uf.merge(x.first, x.second);
    }

    set<int> s;
    REP (i, N) s.insert(uf.root(i));
    return s.size();
}

int main() {
    cin >> N >> M;
    REP (i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        xy.push_back(ii(x-1, y-1));
    }
    cout << solve() << endl;
}

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

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

	vector <int> v;
	int n;
	int res = 0;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		int t;
		cin >> t;
		v.push_back(t);
	}

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				vector <int> vec = {v[i],v[j],v[k]};
				sort(vec.begin(),vec.end());

				if(vec[0] + vec[1] > vec[2] && vec[0]!=vec[1] && vec[0]!=vec[2] && vec[1]!=vec[2])
				{
					res++;
				}
			}
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
  int n;
  int a[100001],b[100001];
  int i,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<100001;i++){
    b[i]=0;
  }
  ans=0;
  i=0;
  while(1){
    i=a[i]-1;
    ans++;
    if(i==1){
      printf("%d",ans);
      return 0;
    }
    if(b[i]==1){
      printf("%d",-1);
      return 0;
    }
    else{
      b[i]++;
    }
  }
}


Measured memory_bytes: 2472
n = int(input())

table = []
for _ in range(n):
    table.append([int(v) for v in input().split()])

dp = [0] * 3

for i in range(n):
    dp_n = [0] * 3

    a, b, c = table[i]

    a0 = dp[0]
    b0 = dp[1]
    c0 = dp[2]

    dp_n[0] = max(b0, c0) + a
    dp_n[1] = max(c0, a0) + b
    dp_n[2] = max(a0, b0) + c

    dp = dp_n

print(max(dp))


Measured memory_bytes: 24308
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
int ans, r, g, b;
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>();
	string str = next<string>();
	rep(i, 0, n)
		if (str[i] == 'R') r++;
		else if (str[i] == 'G') g++;
		else b++;
	ans = r*g*b;
	rep(i, 0, n)
		rep(l, 1, n)
		{
			int j = i+l, k = i+2*l;
			if (k >= n) continue;
			if (str[i]+str[j]+str[k] == 'R'+'G'+'B') ans--;
		}
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}
 
 
int main()
{
    hello;
    
    ll t; 
//    cin>>t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		ll ar[n+1],br[n+1];
		for(ll i=1;i<=n;i++) cin>>ar[i],br[i]=ar[i];
		for(ll i=n-1;i>=1;i--) ar[i]=(ar[i]+ar[i+1])%MOD;
		ll ans=0;
		for(ll i=1;i<n;i++){
			ans=(ans+br[i]*ar[i+1]%MOD)%MOD;
		}
		cout<<ans<<"\n";
	}
    
    return 0;  
} 

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

template<typename T>
struct Parser {
	using itr = string::const_iterator;
	itr now;
	T ans;
	map<char, int> abcd;
	const struct ex {
		vector<char> abcd;
		ex() {
			abcd.resize(4);
			for(int i = 0; i < 4; ++i) {
				abcd[i] = (char)('a' + i);
			}
		}
	} ex;
	Parser(const string &s, map<char, T> &abcd) : abcd(abcd) {
		now = s.begin();
		ans = Hash(now);
	}
	T Hash(itr &now) {
		if(*now == '[') {
			next(now, '[');
			char op = *now;
			T ret;
			if(op == '+') {
				next(now, '+');
				T hash1 = Hash(now);
				T hash2 = Hash(now);
				ret = hash1 | hash2;
			}
			if(op == '*') {
				next(now, '*');
				T hash1 = Hash(now);
				T hash2 = Hash(now);
				ret = hash1 & hash2;
			}
			if(op == '^') {
				next(now, '^');
				T hash1 = Hash(now);
				T hash2 = Hash(now);
				ret = hash1 ^ hash2;
			}
			next(now, ']');
			return ret;
		} else {
			return Letter(now);
		}
	}
	T Letter(itr &now) {
		T ret = abcd[*now];
		next(now, ex.abcd);
		return ret;
	}
	void next(itr &now, const char expected) {
		vector<char> req = {expected};
		next(now, req);
	}
	void next(itr &now, const vector<char> &expected) {
		for(char c : expected) {
			if(*now == c) {
				now++;
				return;
			}
		}
		cerr << "now " << *now << "\n";
		for(char c : expected) cerr << c << "\n";
	}
};

int main() {
	string s;
	while(cin >> s and s != ".") {
		map<char, int> abcd;
		map<int, int> cnt;
		int p; cin >> p;
		int hash;
		for(int i = 0; i < 10000; ++i) {
			int tmp = i;
			for(char c = 'd'; c >= 'a'; --c) {
				abcd[c] = tmp % 10;
				tmp /= 10;
			}
			Parser<int> parse(s, abcd);
			cnt[parse.ans]++;
			if(i == p) hash = parse.ans;
		}
		cout << hash << " " << cnt[hash] << "\n";
	}
	return 0;
}


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

const int INF = 1000000000;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(26, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

int main(){
    //input
    string S;
    cin >> S;

    //calc
    vector<vector<int> > next = calcNext(S);
    int n=S.length();
    vector<int> dp(n+1,INF);
    dp[n]=1;
    int i,j;
    for(i=n-1; i>=0; i--){
        for(j=0; j<26; j++){
            if(next[i][j]>=n){
                dp[i]=1;
            }else{
                dp[i]=min(dp[i],dp[next[i][j]+1]+1);
            }
        }
    }

    //output
    int now=0;
    while(dp[now]>1){
        for(i=0; i<26; i++){
            if(dp[now]==dp[next[now][i]+1]+1){
                cout << (char)('a'+i);
                now = next[now][i]+1;
                break;
            }
        }
    }
    for(i=0; i<26; i++){
        if(next[now][i]>=n){
            cout << (char)('a'+i) << endl;
            break;
        }
    }
    
    system("pause");
    return 0;
}

Measured memory_bytes: 30856
import copy
import time
import sys
input = sys.stdin.buffer.readline

t1 = time.time()
 
def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res
    
D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]
 
T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx
    
p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = copy.deepcopy(T2)
    p = p2
else:
    p = p1
i = 0
next = 1
while time.time()-t1 < 1.9:
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1
for t in T:
    print(t)

Measured memory_bytes: 76400
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long multiple = 1;
		while(H > 0) {
			H = H / 2;
			multiple *= 2;
		}
		System.out.println(multiple - 1);
 
	
	}
}

Measured memory_bytes: 35860
import sys
# sys.stdin  = open("input.txt")
n=int(input())
pref=[0]
mod=10**9
mod+=7
a=[int(o) for o in input().split()]
ans=0
for i in a:
    pref.append(pref[-1]+i)
    ans+=((i*pref[-2])%mod)
    ans%=mod

# print(pref)
print(ans%mod)

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

int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int x;
    cin >> x;
    int f = findSumOfDigits(x);
    if (x % f == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main(void){
    string S;
    cin >> S;
    if(S <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;


llong isSeq(llong val){

  llong res = 0;
  int len = 0, tmp = val;
  int p = 1;

  if(val < 10) return val;

  while(tmp > 0){
    tmp /= 10;
    len++;
    p *= 10;
  }
  p /= 10;

  int last = -1;
  for(int i = 0; i < len; ++i){
    int v = (val  % (p * 10)) / p;
    
    if(last == -1 || v == last + 1){
      res = res * 10 + v;
    }else{
      return -1;
    }
    last = v;
    p /= 10;
  }

  return res;
}



int main(){

  int n;
  scanf("%d", &n);
  
  vector<llong> v(n);
  REP(i,n){
    scanf("%lld", &v[i]);
  }

  llong ans = -1;

  llong tmp = 0;
  REP(i,n){
    for(int j = i+1; j < n; ++j){
      tmp = v[i] * v[j];
      llong hoge = isSeq(tmp);
      if(hoge != -1){
        ans = max(ans, hoge);
      }
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}




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

long gcd(long x, long y)
{
	return (y == 0 ? x : gcd(y, x % y));
}

int main(void)
{
	long a, b, ans;
	cin >> a >> b;
	cout << gcd(a, b) << endl;

	return 0;
}

Measured memory_bytes: 1164
# Queue キュー
class Queue():
    def __init__(self, size):
        self.size = size
        self.Q = [None for i in range(size)]
        self.top = 0
        self.btm = 0
    
    def enqueue(self, x):
        self.Q[self.btm] = x;
        self.btm += 1;
        if self.btm >= self.size:
            self.btm = 0
    
    def dequeue(self):
        ret = self.Q[self.top]
        self.Q[self.top] = None
        self.top += 1
        if self.top >= self.size:
            self.top = 0
        return ret
    
    def __repr__(self):
        list(self.Q)
    
class Process():
    def __init__(self, name, time):
        self.name = name
        self.time = time
    
    def getname(self):
        return self.name
    
    def proceed(self, q):
        if q <= self.time:
            self.time -= q
            return q;
        elif q > self.time:
            ret = self.time
            self.time = 0
            return ret
    
    def isFinished(self):
        return self.time == 0
    
    def __repr__(self):
        return self.name + " " + str(self.time)

n, q = (int(i) for i in input().split())
Q = Queue(n)
for i in range(0,n):
    data = input().split()   
    name = data[0]
    time = int(data[1])
    Q.enqueue(Process(name, time))
timeelapsed = 0
while True:
    p = Q.dequeue()
    if p == None:
        break
    timeelapsed += p.proceed(q)
    if p.isFinished():
        print(p.getname(), timeelapsed)
    else:
        Q.enqueue(p)



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

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

  int N;
  string S;
  cin >> N >> S;

  for (int i = 0; i < S.size(); ++i) {
    S.at(i) += N;
    if ('Z' < S.at(i)) {
      S.at(i) -= ('Z' - 'A' + 1);
    }
    cout << S.at(i);
  }
  cout << endl;
  return 0;
}


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

const int maxn=100000+10;
int a[maxn];

int main() {
	int n;
	cin >> n;
	
	for (int i=1;i<=n;i++) cin >> a[i];
	sort(a+1,a+n+1);
	
	int first=0,second=0;
	for (int i=1;i<=n;i+=2) {
		if (a[i]==a[i+1]) {
			second =first;
			first=a[i];
		}
		else i--;
	}
	cout << (long long)first*second << endl;
	return 0;
} 

Measured memory_bytes: 640
S = input()
A = []
down = [] # index
Asum = 0

for i, line in enumerate(S):
    if line == "\\":  # "\"
        down.append(i)
    elif line == "/" and down:
        j = down.pop()
        temp = i - j
        Asum += temp
        while A and A[-1][0] > j:
            temp += A.pop()[1]
        A.append([j, temp])

print(Asum)
print(len(A), *[S for i, S in A])


Measured memory_bytes: 6512
# include <iostream>
# include <string.h>

using namespace std;
const int mod = 1e9 + 7;
const int M = 1e5 + 5;

char s[M];
int f[M], nxt[M][2];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	bool ab_flag = true;
	for (int i = 2; i <= n; ++ i) if (s[i] == s[i - 1]) ab_flag = false;
	if(ab_flag) {
		puts("1");
		return 0;
	}
	f[n + 1] = 1; nxt[n + 1][0] = nxt[n + 1][1] = nxt[n + 2][0] = nxt[n + 2][1] = n + 2;
	int sum = 0;
	for (int i = n; i >= 1; -- i) {
		sum = (sum + (s[i] == 'a' ? 1 : 2)) % 3;
		if (s[i] == 'a') {
			// a mod 3 = 1
			nxt[i][0] = i + 1;
		} else if (s[i + 1] == 'b') {
			// bb mod 3 = 1
			nxt[i][0] = i + 2;
		} else {
			// ba mod 3 = 0
			nxt[i][0] = nxt[i + 2][0];
		}
		if (s[i] == 'b') {
			// b mod 3 = 2;
			nxt[i][1] = i + 1;
		} else if (s[i + 1] == 'a') {
			// aa mod 3 = 2
			nxt[i][1] =  i + 2;
		} else {
			// ab mod 3 = 0
			nxt[i][1] = nxt[i + 2][1];
		}
		f[i] = f[nxt[i][0]] + f[nxt[i][1]];
		if (f[i] >= mod) f[i] -= mod;
		if (sum == 0) {
			f[i] ++;
			if (f[i] >= mod) f[i] -= mod;
		}
	}
	int ans = f[1];
	if (sum == 0) {
		ans --;
		if (ans < 0) ans += mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5012
module S = Set.Make(struct type t = int let compare = (-) end)
let c x = if x mod 2 = 0 then x / 2 else 3 * x + 1
let rec solve i m x =
  if S.mem x m then i
  else solve (i+1) (S.add x m) (c x)
let _ = Scanf.scanf "%d" (solve 1 S.empty) |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<stdio.h>
 
int main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  a=a+b-c-d;
  if(a>0)printf("Left");
  else if(a==0)printf("Balanced");
  else printf("Right");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    unordered_map<string,ll> mp;
    string S[N];
    REP(i,N){
        cin >> S[i];
        sort ALL(S[i]);
        mp[S[i]]++;
    }
    ll ans = 0;
  	for(auto p:mp){
      	ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;
}

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

int main()
{
  string s;
  cin>>s;
  int ans=0;
  int i;
  for(i=0;i<s.length();i++)
  {
if(i%2==0)
{
if(s.at(i)=='p')ans--;
}
    else
    {
if(s.at(i)=='g')ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool flag=false;
  for (int i=0;i<N;i++){
    string x;
    cin >> x;
    if (x=="Y"){
      flag = true;
      break;
    }
  }
  if (flag){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	char a,b;//h h nara h .h d nara d //
	cin>>a>>b;
	if(a=='H'){
		cout<<b<<endl;
	  }
	  else{
		  if(b=='D'){
			  cout<<'H'<<endl;
			}
			else{
				cout<<'D'<<endl;
			  }
		}

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int n, m, l;
    cin >> n >> m >> l;

    int A[n][m];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> A[i][j];

    int B[m][l];
    for (int i = 0; i < m; i++)
        for (int j = 0; j < l; j++)
            cin >> B[i][j];

    for (int i = 0; i < n; i++){
        for (int j = 0; j < l; j++){
            long value = 0;
            for (int k = 0; k < m; k++)
                value += A[i][k] * B[k][j];
            cout << value;
            if (j != l - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3160
t1,n1=(int(x) for x in input().split())
t2,n2=(int(x) for x in input().split())
t3,n3=(int(x) for x in input().split())
t4,n4=(int(x) for x in input().split())
t5,n5=(int(x) for x in input().split())
t6,n6=(int(x) for x in input().split())
t7,n7=(int(x) for x in input().split())

print(t1-n1)
print(t2-n2)
print(t3-n3)
print(t4-n4)
print(t5-n5)
print(t6-n6)
print(t7-n7)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;





int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;cin>>n;
	ll ans=0;
	ll b;cin>>b;
	FOR(i,0,n-1){
		ll k;cin>>k;
		if(b==k){
			ans++;
			b=-1;
		}else{
			b=k;
		}
	}
	cout<<ans<<endl;
}

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


int main() {
  int N,K;cin>>N>>K;
  cout << (N-1+K-2)/(K-1) << endl;
}
 

Measured memory_bytes: 3568
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String a="ARC";
    if(s.equals(a))
    {
      System.out.println("ABC");
    }
    else
    {
      System.out.println("ARC");
    }
  }
}

Measured memory_bytes: 35616
#include<stdio.h>
int main(){
  char strA[10],strB[10],strC[10];
  scanf("%10s %10s %10s",strA,strB,strC);
  int i,j;
  for (i=0;strA[i] != '\0';i++);
  if(strA[i-1]==strB[0]){
    for (i = 0;strB[i] != '\0';i++);
    if(strB[i-1]==strC[0]){
      printf("YES");
    }else{
      printf("NO");
    }
  }else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
import collections
# N = int(input())
# L = [int(x) for x in input().split()]
# L = [[int(x) for x in input().split()] for _ in range(N)]
# N, M = map(int, input().split())
S = input()

c = collections.Counter(S)

print("Yes" if len(c.values()) == 2 else "No")


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if (a!=b && a!=c && b!=c){
        cout<<3<<endl;
    }
    else if (a==b && b==c){
        cout<<1<<endl;
    }
    else{
        cout<<2<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
string A="AKIHABARA";
string B;
int flag=0;
void dfs(int k1,string k2){
	if (k1==A.length()){
		if (k2==B) flag=1; return;
	}
	dfs(k1+1,k2+A[k1]);
	if (A[k1]=='A') dfs(k1+1,k2);
}
int main(){
	cin>>B;
	dfs(0,"");
	if (flag) cout<<"YES"<<endl; else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int X,D;
    cin >>X;
    D=X%7;
    if(D==0){
        cout <<"thu"<<endl;
    }
    else if(D==1){
        cout <<"fri"<<endl;
    }
    else if(D==2){
        cout <<"sat"<<endl;
    }
    else if(D==3){
        cout <<"sun"<<endl;
    }
    else if(D==4){
        cout <<"mon"<<endl;
    }
    else if(D==5){
        cout <<"tue"<<endl;
    }
    else if(D==6){
        cout <<"wed"<<endl;
    }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll index=0;
    ll num=a[0];
    ll ans=n;
    for(ll i=1;i<n;i++){
        if(num+a[i]==(num^a[i])){
            num+=a[i];
            ans+=i-index;
        }
        else if(i>index){
            num-=a[index];
            index++;
            i--;
        }
    }
    cout << ans<<endl;
    return 0;
}





Measured memory_bytes: 1792
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007
const int INF = 1e9 + 5;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n;
    scanf("%d", &n);
    vector<int> dp(3,0);

    for(int i1 = 0; i1 < n; i1++) 
    {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; i++) 
            scanf("%d", &c[i]);

        for(int i = 0; i < 3; i++)   //Parent Possibility
        {
            for(int j = 0; j < 3; j++)   // Current Child Possibility
            {
                if(i != j && (new_dp[j] < dp[i] + c[j])) 
                    new_dp[j] =  dp[i] + c[j];
            }
        }
        dp = new_dp;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));

    return 0;
}


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

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

	vector<int> v;
	for(int i=0;i<n;i++){
		int x;
		cin >> x;

		if(i>0)
			v.push_back(v[v.size()-1] + x);
		else
			v.push_back(x);
	}

	int ans = 10000001;
	for(int i=0;i<n;i++){
		ans = min(ans, max(v[i], v[v.size()-1] - v[i]) - min(v[i], v[v.size()-1] - v[i]));
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256