akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=501234;

int n,a[17][17],bt[17],flg[1<<17];
ll dp[1<<17],dp2[1<<17];
queue<int> q2;

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        bt[i]=1<<i-1;
        for(int j=1; j<=n; ++j)
            scanf("%d",&a[i][j]);
    }
    bt[n+1]=1<<n;
    for(int i=2,l=0,r=0; i<=n; ++i)
    {
        for(int j=1,tmp=0; j<i; ++j)
        {
            tmp=bt[i]|bt[j];
            dp[tmp]=a[j][i];
            flg[tmp]=1;
            q2.push(tmp);
        }
        while(!q2.empty())
        {
            int tmp=q2.front();
            q2.pop();
            for(int j=1,tmp2=0; j<i; ++j)
            {
                tmp2=tmp|bt[j];
                if(tmp2!=tmp && flg[tmp2]==0)
                {
                    dp[tmp2]=dp[tmp]+a[j][i];
                    flg[tmp2]=1;
                    q2.push(tmp2);
                }
            }
        }
    }
    for(int i=2; i<=n; ++i)
        for(int j=bt[i]+1; j<bt[i+1]; ++j)
            dp[j]+=dp[j^bt[i]];
    for(int i=3,j2=0; i<bt[n+1]; ++i)
    {
        int s=i;
        do{
            ll tmp3=dp[s]+dp2[s^i];
            if(dp2[i]<tmp3)
                dp2[i]=tmp3;
            s=i&(s-1);
        }while(s>0);
    }
    printf("%lld",dp2[(1<<n)-1]);
    return 0;
}


Measured memory_bytes: 1664
N, M = map(int, input().split())
ngs = [int(input()) for _ in range(M)]
mae = -10**9
for ng in ngs:
    if abs(ng - mae) == 1:
        print(0)
        exit()
    mae = ng
fib = [1, 1]
for i in range(N):
    fib.append(fib[-1]+fib[-2])
ans = 1
now = 0
for ng in ngs:
    l = ng - now - 1
    ans *= fib[l]
    ans %= (10**9+7)
    now = ng + 1
if now == N-1:
    print(ans)
    exit()
# print(fib)
l = N - now
ans *= fib[l]
ans %= (10**9+7)
print(ans)

Measured memory_bytes: 461992
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    if(N >= 65 && N <= 90){
        cout << 1 << endl;
    }
    else if(N >= 97 && N <= 122){
        cout << 2 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
    
}



Measured memory_bytes: 3088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AEoui
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskCATCoder solver = new TaskCATCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskCATCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] arr = in.next().toCharArray();
            long k = in.nextLong();

            for (char c : arr) {
                if (k == 1) {
                    out.println(c);
                    return;
                }

                if (c == '1') {
                    --k;
                } else {
                    out.println(c);
                    return;
                }
            }

            out.println(arr[arr.length - 1]);
        }

    }
}



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


public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        int sx = scanner.nextInt();
        int sy =scanner.nextInt();
        int tx = scanner.nextInt();
        int ty =scanner.nextInt();
   
        
        int y = ty- sy;
        int x = tx - sx;
        
        for(int i=0;i<y;i++)
         System.out.print("U");
        
        for(int i=0;i<x;i++)
        System.out.print("R");
        
         for(int i=0;i<y;i++)
         System.out.print("D");
        
        for(int i=0;i<=x;i++)
        System.out.print("L");
        
        for(int i=0;i<=y;i++)
         System.out.print("U");
        
        for(int i=0;i<=x;i++)
        System.out.print("R");
        
         System.out.print("D");
        
        
         System.out.print("R");
         
           for(int i=0;i<=y;i++)
         System.out.print("D");
         
          for(int i=0;i<=x;i++)
        System.out.print("L");
        
        
        System.out.print("U");
        
        
        
     }
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1), B(N + 1);
  for (int i = 0; i < N + 1; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];
  ll res = 0;
  for (int i = 0; i < N + 1; ++i) {
    int curr = min(A[i], B[i]);
    int next = 0;
    if (i < N) next = min(A[i + 1], B[i] - curr);
    res += curr + next;
    A[i + 1] -= next;
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int sum = 0;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	sum /= N;
	int a[3] = { sum,sum + 1,sum - 1 };
	int ans = LLINF;
	REP(j, 3) {
		int cnt = 0;
		REP(i, N) {
			cnt += (a[j] - A[i])*(a[j] - A[i]);
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}



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

int n, wt;
int dp[101][100001];
const int INF = 1000000001;

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

	dp[0][0] = 0;

	for(int j = 1; j < 100001; j++)
		dp[0][j] = INF;

	for(int i = 1; i <= n; i++){
		int w, v;
		cin >> w >> v;
		for(int j = 1; j < 100001; j++){
			if(j < v)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w);
		}
	}

	int vm = 0;
	for(int j = 1; j < 100001; j++){
		if(dp[n][j] <=wt)
			vm = j;
	}

	cout << vm << endl;
	return 0;
}

Measured memory_bytes: 39680
#include <iostream>

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

ll DP[10001][1000];
ll A[1000];
ll B[1000];
ll H, N;

int main(){
    cin >> H >> N;
    for(ll i=0;i<N;i++){
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    for(ll i=0;i<N;i++){
        DP[0][i] = 0LL;
    }
    for(ll h=1;h<=H;h++){
        for(ll i=0;i<N;i++){
            ll use = (h-A[i]>=0LL) ? DP[h-A[i]][i]+B[i] : B[i];
            ll notuse = (i>0LL) ? DP[h][i-1] : use;
            DP[h][i] = (use<notuse) ? use : notuse;
        }
    }
    cout << DP[H][N-1] << endl;
}


Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int n;
vector<vector<int>> graph(100);
vector<int> d(100, 0), f(100);
int t = 0;

void DFS(int u) {
    if (d[u] != 0) return;
    ++t;
    d[u] = t;
    for (int v : graph[u]) DFS(v);
    ++t;
    f[u] = t;
    return;
}

int main() {
    cin >> n;
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        rep(j, k) {
            int v;
            cin >> v;
            graph[u - 1].push_back(v - 1);
        }
    }
    
    rep(i, n) DFS(i);
    rep(i, n) cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int K;
    cin >> K;
    cout << 50 << endl;
    for(int i = 0; i < 50; i++) {
        if(i) cout << " ";
        if(K%50 > (i+1)%50) {
            cout << 49+(K/50+1)*50-(K-K/50-1);
        }
        else {
            cout << 49+K/50*50-(K-K/50);
        }
    }
    cout << endl;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
    bool cards[4][14];
    int n, rank;
    char suit;
    
    for(int s = 0; s < 4; s++)
        for(int r = 1; r <= 13; r++)
            cards[s][r] = 0;
            
    cin >> n;
    for(int i = 0; i < n; i++){
       cin >> suit >> rank;
       if(suit == 'S') cards[0][rank] = 1;
       if(suit == 'H') cards[1][rank] = 1;
       if(suit == 'C') cards[2][rank] = 1;
       if(suit == 'D') cards[3][rank] = 1;
       
    }
    
    for(int s = 0; s < 4; s++){
        for(int r = 1; r <= 13; r++){
        if(cards[s][r]) continue;
        if(s == 0 ) suit = 'S';
        if(s == 1 ) suit = 'H'; 
        if(s == 2 ) suit = 'C';
        if(s == 3 ) suit = 'D';
        cout << suit << " " << r << endl;
        }
    }
    return 0;
   
}



Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))



//*
//遅延セグ木ここから
//↓ここを変える
typedef struct sayouso{ll a,b;}sayouso;
typedef struct atai{ll a;}atai;
//↑ここを変える

typedef struct node{sayouso T;atai x;}node;
node *lsegN,*lseg;
ll lsegNUM,lsegk;

//↓ここから変える
sayouso sid={1,0};
atai aid={0};
atai xx(atai x,atai y){
	atai ret;
	ret.a=x.a+y.a;
	return ret;
}
atai Tx(sayouso T,atai x){
	atai ret;
	ret.a=T.a*x.a+T.b;
	return ret;
}
sayouso TT(sayouso S,sayouso T){
	sayouso ret;
	ret.a=S.a*T.a;
	ret.b=S.b+S.a*T.b;
	return ret;
}
sayouso fT(sayouso T,ll k){
	sayouso ret;
	ret.a=T.a;
	ret.b=T.b<<k;
	return ret;
}
//↑ここまで変える

//要素数(2ベキ)でこれを呼ぶ
void lseguse(ll n){
	lsegN=(node*)calloc(2*n,sizeof(node));
	lsegNUM=n;
	lseg=lsegN+lsegNUM;
	lsegk=0;while(n/=2)lsegk++;
	rep(i,1,2*lsegNUM){
		lsegN[i].x=aid;
		lsegN[i].T=sid;
	}
}
//lseg[i].xに値を与えてから初期化
void lseginit(){
	for(ll i=lsegNUM-1;i>0;i--)lsegN[i].x=xx(lsegN[2*i].x,lsegN[2*i+1].x);
}
void lsegupdatesub(ll l,ll r,sayouso T,ll i,ll cl,ll cr,ll ck){
	if(l>=r)return;
	//disjointなとき
	if(cr<=l||r<=cl)return;
	//完全に含むとき
	if(l<=cl&&cr<=r){
		lsegN[i].T=TT(T,lsegN[i].T);
		return;
	}
	//どちらでもないとき
	//遅延伝播
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	//再帰的に更新
	ll cm=(cl+cr)/2;
	lsegupdatesub(l,r,T,2*i  ,cl,cm,ck-1);
	lsegupdatesub(l,r,T,2*i+1,cm,cr,ck-1);
	//自身のnodeを更新
	lsegN[i].x=xx(Tx(fT(lsegN[2*i].T,ck-1),lsegN[2*i].x),Tx(fT(lsegN[2*i+1].T,ck-1),lsegN[2*i+1].x));
	lsegN[i].T=sid;
}
void lsegupdate(ll l,ll r,sayouso T){lsegupdatesub(l,r,T,1,0,lsegNUM,lsegk);}
atai lsegcalcsub(ll l,ll r,ll i,ll cl,ll cr,ll ck){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return Tx(fT(lsegN[i].T,ck),lsegN[i].x);

	ll cm=(cl+cr)/2;
	//遅延伝播(変更はないので配るだけで良い)
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	lsegN[i].x=Tx(fT(lsegN[i].T,ck),lsegN[i].x);
	lsegN[i].T=sid;

	//左側だけ
	if(r<=cm)return lsegcalcsub(l,r,2*i  ,cl,cm,ck-1);
	//右側だけ
	if(cm<=l)return lsegcalcsub(l,r,2*i+1,cm,cr,ck-1);
	//両方
	return xx(lsegcalcsub(l,r,2*i,cl,cm,ck-1),lsegcalcsub(l,r,2*i+1,cm,cr,ck-1));
}
atai lsegcalc(ll l,ll r){return lsegcalcsub(l,r,1,0,lsegNUM,lsegk);}
//遅延セグ木ここまで
//*/


int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	lseguse(1<<17);
	while(q--){
		int t;
		scanf("%d",&t);
		if(t){
			int x;
			scanf("%d",&x);
			printf("%lld\n",lsegcalc(x,x+1).a);
		}
		else{
			int x,y,b;
			scanf("%d%d%d",&x,&y,&b);
			sayouso T={1,b};
			lsegupdate(x,y+1,T);
		}
	}
}


Measured memory_bytes: 8008
package main

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

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for {
		s := nextString()
		if s == "-" {
			break
		}
		m := nextInt()
		for i := 0; i < m; i++ {
			a := nextInt()
			s = s[a:] + s[:a]
		}
		fmt.Println(s)
	}
}



Measured memory_bytes: 1112
#include <stdio.h>

#define A 500000
#define B 2000000000

int L_s[A/2+2],R_s[A/2+2];
int count=0;

void meg(int in[],int z,int l,int m,int r){
  int s1,s2,i,j,k;

  s1=m-l;
  s2=r-m;
  
  for(i=0;i<s1;i++){
    L_s[i]=in[l+i];
  }
  for(i=0;i<s2;i++){
    R_s[i]=in[m+i];
  }

  L_s[s1]=R_s[s2]=B;
  i=j=0;
  for(k=l;k<r;k++){
    count++;
    if(L_s[i]<R_s[j]){
      in[k]=L_s[i++];
    }
    else {
      in[k]=R_s[j++];
    }
  }
}

void meg_sort(int in[],int z,int left,int right){
  if(left+1<right){
    int m=(left+right)/2;
    meg_sort(in,z,left,m);
    meg_sort(in,z,m,right);
    meg(in,z,left,m,right);
  }
}

int main()
{
  int in[A],i,g;

  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&in[i]);
  }
  meg_sort(in,g,0,g);

  for(i=0;i<g;i++){
    if(i>0) printf(" ");
    printf("%d",in[i]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}
  



Measured memory_bytes: 5608
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let mut xs = vec![true; 112345];
    xs[0] = false;
    xs[1] = false;
    for i in 2..1000 {
        for k in 2.. {
            if i*k >= 112345 { break; }
            xs[i*k] = false;
        }
    }
    let n = read_i64();
    let mut res = vec![];
    for i in 0..55555 {
        if res.len() == n as usize { break; }
        if i % 5 == 1 && xs[i] {
            res.push(i);
        }
    }
    print!("{}", res[0]);
    for i in 1..n {
        print!(" {}", res[i as usize]);
    }
    println!("");
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
l,r = map(int,input().split())
ans = 99999999999999
if r-l >= 2019:
    ans = 0

l %= 2019
r %= 2019

for i in range(l,r+1):
    for m in range(i+1,r+1):
        ans = min(ans,(i*m)%2019)
        
print(ans)

Measured memory_bytes: 3060
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func loadints(n int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = loadint()
	}
	return xs
}

func main() {
	n := loadint()
	m := loadint()
	as := loadints(n)
	ms := make(map[int]int)
	t := 0
	ms[t]++
	for _, a := range as {
		t = (t + a) % m
		ms[t]++
	}
	result := 0
	for _, r := range ms {
		result += r * (r - 1) / 2
	}
	fmt.Println(result)
}


Measured memory_bytes: 8192
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int a[100005];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	sort(a, a + n);
	vector<PII> ans(n - 1);
	FOR(i, 1, n - 1) {
		if (a[i] < 0) {
			ans[i - 1] = MP(a[n - 1], a[i]);
			a[n - 1] -= a[i];
		}
		else {
			ans[i - 1] = MP(a[0], a[i]);
			a[0] -= a[i];
		}
	}
	ans[n - 2] = MP(a[n - 1], a[0]);
	a[n - 1] -= a[0];
	printf("%d\n", a[n - 1]);
	REP(i, n - 1) {
		printf("%d %d\n", ans[i].first, ans[i].second);
	}

	return 0;
}

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

int main(){
    int N,M; cin >> N >> M;
    int A[N+1];
    int B[N+1];
    rep(i,N+1){
        A[i]=0;
        B[i]=0;
    }
    int AC=0;
    int WA=0;
    
    rep(i,M){
        int a; cin >> a;
        string b; cin >> b;
        
        if(b=="AC" && A[a]==0){
            A[a]=1;
            AC++;
            WA+=B[a];
        }
        if(b=="WA" && A[a]==0){
            B[a]++;
        }
    }
    cout << AC << " " << WA << endl;
}

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

int main(){
    char s[6];
    cin >> s;
    
    if(s[2]==s[3] and s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl; 
    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  cout << (c%gcd(a,b) ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
import sys
N = int(input())

if N == 1:
    print(0)
    sys.exit(0)

if N == 2:
    print(2)
    sys.exit(0)

# out = (N * (N - 1) * (10 ** (N - 2))) % ((10 ** 9) + 7)
out = ((10 ** N) - ((9 ** N) * 2 - (8 ** N))) % ((10 ** 9) + 7)
print(out)


Measured memory_bytes: 10952
let () = Scanf.scanf "%d %d %d %d %d %d %d" @@ fun ai ao at aj al as_ az ->
  Printf.printf "%d\n" @@ ao + max
    ((ai land (-2)) + (aj land (-2)) + (al land (-2)))
    ( if ai <= 0 || aj <= 0 || al <= 0
      then min_int
      else ((ai - 1) land (-2)) + ((aj - 1) land (-2)) + ((al - 1) land (-2)) + 3 )


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
fn main() {
    input!{
        n: u64,
    }
    println!("{}", if n / 10 == 9 || n % 10 == 9 {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#!/usr/bin/env python3

from copy import deepcopy

ABMAX = 400
HUGE = 10 ** 12

def main():
    n, ma, mb = map(int, input().split())
    sold = []
    for i in range(n):
        a, b, c = map(int, input().split())
        sold.append((a, b, c))
    mincost = dp(sold, n)
    print(find_mincost(mincost, ma, mb))

def find_mincost(mincost, ma, mb):
    res = HUGE
    for mult in range(1, ABMAX):
        if ma * mult > ABMAX:
            break
        if mb * mult > ABMAX:
            break
        res = min(res, mincost[ma * mult][mb * mult])
    return -1 if res == HUGE else res

def dp(sold, n):
    # mincost[a][b]: Minimum cost of achieving a, b
    mincost = [[HUGE for b in range(ABMAX + 1)] for a in range(ABMAX + 1)]
    mincost[0][0] = 0
    for a, b, c in sold:
        update(mincost, a, b, c)
    return mincost

def update(mincost, a, b, c):
    for ia in reversed(range(ABMAX + 1)):  # 配る
        for ib in reversed(range(ABMAX + 1)):
            na = ia + a
            nb = ib + b
            if na <= ABMAX and nb <= ABMAX:
                mincost[na][nb] = min(mincost[na][nb], mincost[ia][ib] + c)

main()


Measured memory_bytes: 42604
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

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

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  char X, Y;
  cin >> X >> Y;
  if(X < Y) cout << "<" << endl;
  else if(X > Y) cout << ">" << endl;
  else cout << "=" << endl;
}

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

int main() {
	ll n, m;
	cin >> n >> m;

	if (n == 1 && m == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (n == 1 && m >= 2) {
		cout << m - 2 << endl;
		return 0;

	}else if(n >= 2 && m == 1) {
		cout << n - 2 << endl;
		return 0;
	}
	ll ans = 0;
	ans = (n - 2) *(m - 2);

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

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

int main(){
    int j=0;
    string s;
    cin >> s;
    vector<char> str2(s.size());
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            str2.at(j)='0';
            j++;
        }
        else if(s[i]=='1'){
            str2.at(j)='1';
            j++;
        }
        else if(s[i]=='B'){
            if(j==0)continue;
            else j--;
        }
    }
    for(int i=0;i<j;i++){
        cout << str2.at(i);
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<usize>().unwrap();
    let a = stdin.lock().gets().split(' ').take(n)
        .map(|x| x.parse::<i64>().unwrap()).collect::<Vec<_>>();
    let mut acc = vec![0; n + 1];
    for i in 0..n {
        acc[i + 1] = acc[i] + a[i];
    }
    acc.sort();
    acc.push(std::i64::MAX);	// sentinel
    let mut prev = std::i64::MAX;
    let mut count = 0u64;
    let mut ans = 0;
    for x in acc {
        if x == prev {
            count += 1;
        } else {
            if count >= 2 {
                ans += count * (count - 1) / 2;
            }
            count = 1;
        }
        prev = x;
    }
    println!("{}", ans);
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 10492
#include <iostream>
#include <string>

using namespace std;

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

    if((s[0] == s[1]) && (s[1] == s[2]))    cout << "Yes";
    else if((s[3] == s[2]) && (s[1] == s[2]))    cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
typedef pair<int,int> P;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL h,w,n,c[10]={};
	P p[101010]={};
	map<P,int> mp;
	cin>>h>>w>>n;
	FOR(i,0,n){
		int a,b;
		cin>>a>>b;
		p[i]=make_pair(a,b);
		mp[p[i]]=1;
	}
	sort(p,p+n);
	FOR(i,0,n){
		P q=p[i];
		FORQ(j,q.ST-2,q.ST+0){
			FORQ(k,q.ND-2,q.ND+0){
				int cc=0;
				if(j<=0||k<=0||j>h-2||k>w-2)continue;
				FOR(jj,j,j+3){
					FOR(kk,k,k+3){
						if(mp[make_pair(jj,kk)]==1)cc++;
					}
				}
				//if(cc==2)cout<<i<<" "<<j<<" "<<k<<" q.ST"<<q.ST<<" "<<q.ND<<endl;
				c[cc]++;
			}
		}
	}
	int s=0;
	//FOR(i,0,10)cout<<c[i]<<endl;
	FOR(i,1,10){
		c[i]/=i;
		s+=c[i];
	}
	c[0]=(h-2)*(w-2)-s;
	FOR(i,0,10)cout<<c[i]<<endl;
    return 0;
}


Measured memory_bytes: 157312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
string s;
std::vector<pairint> v(x);
rep(i,x){
  v[i].first=0;
  v[i].second =0;
}
rep(i,y){
  std::cin >> z>>s;
  if(s=="WA"&&v[z-1].first==0){
    v[z-1].second++;
  }else if(s=="AC"&&v[z-1].first==0){
    v[z-1].first++;
    m++;
  }
}
rep(i,x){
  if(v[i].first>0)n+=v[i].second;
}
std::cout<<m<<" " << n << '\n';
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <utility>

struct point {
	int x, y;
	int id;
};

bool order_x(const point &a, const point &b) 
{
	return a.x < b.x;
}
bool order_y(const point &a, const point &b) 
{
	return a.y < b.y;
}

const int N = 1000;
int n, m;
point p[N * 4 + 1];
int x_next[N * 3 + 1];
int y_next[N * 3 + 1];
int x_size, y_size;
int pr[N * 2];
bool g[N * 3 + 1][N * 3 + 1][4];
bool u[N * 3 + 1][N * 3 + 1];

long long dfs(int x, int y) 
{
	std::stack<std::pair<int, int> > st;
	st.push(std::make_pair(x, y));
	u[x][y] = true;
	long long res = 0;
	while (!st.empty()) {
		x = st.top().first;
		y = st.top().second;
		res += (long long)x_next[x] * y_next[y];
		st.pop();
		if (g[x][y][0]) {
			if (x == x_size - 1) return -1;
			if (!u[x + 1][y]) {
				u[x + 1][y] = true;
				st.push(std::make_pair(x + 1, y));
			}
		}
		if (g[x][y][1]) {
			if (y == y_size - 1) return -1;
			if (!u[x][y + 1]) {
				u[x][y + 1] = true;
				st.push(std::make_pair(x, y + 1));
			}
		}
		if (g[x][y][2]) {
			if (!x) return -1;
			if (!u[x - 1][y]) {
				u[x - 1][y] = true;
				st.push(std::make_pair(x - 1, y));
			}
		}
		if (g[x][y][3]) {
			if (!y) return -1;
			if (!u[x][y - 1]) {
				u[x][y - 1] = true;
				st.push(std::make_pair(x, y - 1));
			}
		}
	}
	return res;
}

int main() 
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		p[i * 2].id = p[i * 2 + 1].id = i;
		p[i * 2].x = a;
		p[i * 2 + 1].x = b;
		p[i * 2].y = p[i * 2 + 1].y = c;
	}
	for (int i = n; i < n + m; ++i) {
		int d, e, f;
		scanf("%d%d%d", &d, &e, &f);
		p[i * 2].id = p[i * 2 + 1].id = i;
		p[i * 2].x = p[i * 2 + 1].x = d;
		p[i * 2].y = e;
		p[i * 2 + 1].y = f;
	}
	int p_amount = (n + m) * 2 + 1;
	p[p_amount - 1].id = -1;
	p[p_amount - 1].x = p[p_amount - 1].y = 0;
	std::sort(p, p + p_amount, order_x);
	int i, j;
	for (i = 0, j = 0; i < p_amount; ++j) {
		int val = p[i].x;
		do {
			p[i].x = j;
			++i;
		} while (i < p_amount && p[i].x == val);
		if (i < p_amount) x_next[j] = p[i].x - val;
	}
	x_size = j;
	std::sort(p, p + p_amount, order_y);
	for (i = 0, j = 0; i < p_amount; ++j) {
		int val = p[i].y;
		do {
			p[i].y = j;
			++i;
		} while (i < p_amount && p[i].y == val);
		if (i < p_amount) y_next[j] = p[i].y - val;
	}
	y_size = j;
	for (int i = 0; i < x_size; ++i) for (int j = 0; j < y_size; ++j) for (int k = 0; k < 4; ++k) g[i][j][k] = true;
	memset(pr, -1, (n + m) * sizeof(int));
	point z;
	for (int i = 0; i < p_amount; ++i) {
		if (p[i].id == -1) z = p[i];
		else if (pr[p[i].id] == -1) pr[p[i].id] = i;
		else {
			point s = p[pr[p[i].id]];
			point t = p[i];
			if (s.id < n) {
				if (s.x > t.x) std::swap(s, t);
				for (int i = s.x; i < t.x; ++i) {
					g[i][s.y][3] = false;
					if (s.y > 0) g[i][s.y - 1][1] = false;
				}
			}
			else {
				if (s.y > t.y) std::swap(s, t);
				for (int i = s.y; i < t.y; ++i) {
					g[s.x][i][2] = false;
					if (s.x > 0) g[s.x - 1][i][0] = false;
				}
			}
		}
	}
	long long r = dfs(z.x, z.y);
	if (r == -1) printf("INF\n");
	else printf("%lld\n", r);
	return 0;
}


Measured memory_bytes: 74624
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	cout<<a[n]-a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s,t;cin>>s>>t;
  for(int i = 0; s.size() > i; i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
			//fios;
	char ch;
	cin >> ch;
	if(ch >= 'A' && ch <= 'Z') puts("A");
	else puts("a");
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	ll H, W;
	cin >> H >> W;

	if (H == 1 || W == 1)
	{
		cout << 1 << "\n";
	}
	else if (H % 2 == 1 && W % 2 == 1)
	{
		cout << H * (W - 1) / 2 + (H + 1) / 2 << "\n";
	}
	else
	{
		cout << H * W / 2 << "\n";
	}
}


Measured memory_bytes: 256
if __name__ == '__main__':
    from collections import deque
    str = input()
    stack1,stack2 = deque([]),deque([])
    sum = 0

    for i in range(len(str)):
        if str[i] == '\\':
            stack1.append(i)
        elif str[i] == '/':
            if stack1 != deque([]):
                x = stack1.pop()
                stack2.append([x,i-x])

        while len(stack2) >= 2 and stack2[len(stack2) - 2][0] > stack2[len(stack2) - 1][0]:
            a = stack2.pop()
            b = stack2.pop()
            stack2.append([a[0],a[1]+b[1]])

    #全面積算出、出力
    for i in range(len(stack2)):
        sum += stack2[i][1]
    print(sum)
    if len(stack2) > 0:
        print(len(stack2),end = " ")
    else:
        print(len(stack2))
    for i in range(len(stack2)):
        if i == len(stack2) - 1:
            print(stack2[i][1])
        else:
            print(stack2[i][1],end = " ")



Measured memory_bytes: 6780
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val Q = sc.nextInt
    val LR = Array.fill(M)(sc.nextInt, sc.nextInt)
    val pq = Array.fill(Q)(sc.nextInt, sc.nextInt)

    val m = ArrayBuffer.fill(N + 1)(ArrayBuffer.fill(N + 1)(0))
    LR.foreach { case (l, r) =>
      m(l)(r) += 1
    }
//    m.foreach(a => println(a.mkString(",")))
    for (i <- 1 to N; j <- 1 to N) {
      m(i)(j) += m(i - 1)(j) + m(i)(j - 1) - m(i - 1)(j - 1)
    }
//    m.foreach(a => println(a.mkString(" ")))

    pq.map { case (p, q) =>
      m(q)(q) - m(p - 1)(q) - m(q)(p - 1) + m(p - 1)(p - 1)
    }.mkString("\n")
  }
}


Measured memory_bytes: 128556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;

int main(void){
    ll n; cin >> n;
    set<P>a;
    for(ll i=1;i<=n;i++){
        ll tmp; cin >> tmp;
        a.insert(P{tmp,i});
    }
    for(auto iter=a.begin();iter!=a.end();iter++){
        P p = *iter;
        cout << p.second;
        if(iter!=--a.end()) cout << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 7040
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	char s[100001];
	scanf("%s",s);
	int opponent_p=0;
	int i;
	for(i=0;i<strlen(s);i++){
		if(s[i]=='p'){
			opponent_p++;
		}
	}
	
	printf("%d\n",(strlen(s)/2)-opponent_p);
	
	return 0;
}

Measured memory_bytes: 256
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 4005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;

    int ans1=0,ans2=0;

    int r=0,b=0,g=0;

    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            ans1+=g*b;
            r++;
        }
        else if(s[i]=='B'){
            ans1+=r*g;
            b++;
        }
        else{
            ans1+=r*b;
            g++;
        }
    }

    for(int i=0;i<=n-3;i++){
        for(int j=i+2;j<n;j+=2){
            if(s[i]!=s[j] && s[i]!=s[(i+j)/2] && s[j]!=s[(i+j)/2]){
                ans2++;
            }
        }
    }
    
    cout<<ans1-ans2<<"\n";

    return;
}
// how r u bro

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
 int64_t a,b,c,d;
  cin>>a>>b>>c>>d;
  int64_t e=a*c,f=b*d,g=a*d,h=b*c,maximum,max1,max2;
  max1=max(e,f);
  max2=max(g,h);
  maximum=max(max1,max2);
  cout<<maximum;
}
  

Measured memory_bytes: 3600
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    char c;
    string s;
    for(int i=0;i<3;i++)
    {
        cin >> c;
        if(c=='1') s.push_back('9');
        else if(c=='9') s.push_back('1');
    }
    
    cout << s << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,m,fl[N],dp[N]; vector<ll> vc[N];
ll maxval(ll i,ll p){
	if(dp[i]!=-1){
		return dp[i];
	}
	ll mx=0;
	for(auto it:vc[i]){
		if(it!=p){
			mx=max(mx,maxval(it,i)+1);
		}
	}
	return dp[i]=mx;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>k>>l;
		vc[k].ps(l);
	}
	memset(dp,-1,sizeof(dp));
	ll mx=0;
	for(i=1;i<=n;i++){
		mx=max(mx,maxval(i,i));
	}
	cout<<mx;
	return 0;
}

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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll a,b,c,d;
        cin >> a >>b >>c >>d;
        
        ll count=0;
        bool ok=true;
        while(a>0)
        {
            if(c<=0)
            {
                ok=false;
                break;
            }
            if(count%2==0)
            {
                c-=b;
            }
            else
                a-=d;
            
            count++;
        }
        if(ok)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(){
    int w, a, b, _a, _b;

    cin >> w >> a >> b;
    _a = a + w;
    _b = b + w;

    if(_b < a){
        cout << a - _b << endl;
    }else if(b > _a){
        cout << b - _a << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}
int main() {
  int N, A, ans;
  cin >> N >> ans;
  while(--N) {
    cin >> A;
    ans = gcd(ans, A);
  }
  cout << ans;
  return 0;
}

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

int main(){
    set<int>se;
    int q,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>q;
        se.insert(q);
    }
    cout<<se.size()<<endl;
    return(0);
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	sort(S);
	if (S[0] == S[1] && S[2] == S[3]&&S[1]!=S[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int a,b,k;
	cin >> a >> b >>k;
	for(int i=a; i<=b; i++){
		if(i<a+k || b-k<i)cout << i << endl;
	}
	return 0;
}


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

using namespace std;
using u64 = std::uint_fast64_t;

template <typename T> T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

template <typename T> T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int div2cnt(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<u64> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] >>= 1;
  }
  int cnt = div2cnt(A[0]);
  for (int i = 0; i < N; i++) {
    if (cnt != div2cnt(A[i])) {
      cout << 0 << '\n';
      return 0;
    }
  }
  u64 l = A[0];
  for (int i = 1; i < N; i++) {
    l = lcm(l, A[i]);
  }
  cout << (M / l + 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{

    int a, b;

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

    if (a < b){
    printf("a < b\n");
    }
    else if (a > b){
    printf("a > b\n");
    }
    else{
    printf("a == b\n");
    }
    return 0;
}


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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;

bool v[200010];

int main(){
    ios_base::sync_with_stdio(false);
	int n;
    cin >> n;
    v[0] = true;
    int ans = 0;
    REP(i, 1, n){
        int a;
        cin >> a;
        if(v[a - 1]){
            v[a] = true;
            ans = max(ans, a);
        }
    }
    cout << (ans ? n - ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 512