akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }
    int m;
    cin >> m;
    vector<int> t(m);
    rep(i, m){
        cin >> t[i];
    }
    SORT(d);
    SORT(t);
    bool flag = true;
    int k = 0;
    rep(i, m){
        vector<int>::iterator it = lower_bound(d.begin() + k, d.end(), t[i]);
        if(it == d.end()){
            flag = false;
            break;
        }
        if(*it == t[i]){
            k = (it - d.begin()) + 1;
        }else{
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            double [] V = new double[N];

            for(int i=0; i<N; i++)
            {
                V[i] = int.Parse(line[i]);
            }
            Array.Sort(V);

            for(int i=0; i<N-1; i++)
            {
                V[i + 1] = (V[i] + V[i + 1]) / 2;
            }
            Console.WriteLine(V[N-1]);
        }
    }
}

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

int main(){
  char c;
  cin >> c;
  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    string s,t;
    cin>>s>>t;
    int ans=t.size();
    for(int i=0;i+t.size()-1<s.size();i++){
        int cnt=0;
        for(int j=0;j<t.size();j++){
            cnt+=s[i+j]!=t[j];
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[])
{
	int a,b,c;
	cin >> a >> b >> c;

	if((a+b == c) || (b+c == a) || (c+a == b)){
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

int N,K;
int V[50];

LL dp[50][50][101];
LL solve(int l, int r, int nokori){
	if(l > r) return 0;
	if(nokori == 0) return 0;
	if(nokori == -1) return LLONG_MIN/100;
	if(dp[l][r][nokori] != LLONG_MIN) return dp[l][r][nokori];
	LL ret = 0;
	ret = max(ret, V[l]+solve(l+1, r, nokori-1));
	ret = max(ret, solve(l+1, r, nokori-2));
	ret = max(ret, V[r]+solve(l, r-1, nokori-1));
	ret = max(ret, solve(l, r-1, nokori-2));
	return dp[l][r][nokori] = ret;
}

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> V[i];
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++)
			for(int k=0; k<=K; k++) dp[i][j][k] = LLONG_MIN;
	cout << solve(0,N-1,K) << endl;
	
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>H>>W;
    vector<string> G(H), r(H), b(H);
    rep(i,H){
        cin>>G[i];
        r[i] = b[i] = G[i];
    }
    rep(i,W) r[0][i] = b[H-1][i] = '#';
    reps(i,1,H - 1) rep(j,W){
        (j&1 ? r[i][j] : b[i][j]) = '#';
    }
    rep(i,H) cout<<r[i]<<endl;
    cout<<endl;
    rep(i,H) cout<<b[i]<<endl;
    
    /*
    cout<<endl;
    rep(i,H) rep(j,W){
        cout<<(r[i][j] == '#' && b[i][j] == '#' ? '#' : '.');
        if(j == W - 1) cout<<endl;
    }
    */
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

const int N = 3e3 + 5;
int n, m;
ll res;
bool grid[N][N][4];
bool visited[N][N];

struct seg {
    int L, R, x;
};

int main() {
    // freopen("in2.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    vector<seg> v(n); // vertical input
    vector<seg> h(m); // horizontal input
    unordered_set<int> V; // vertical set
    unordered_set<int> H; // horizontal set
    for (int i = 0; i < n; ++i) {
        cin >> v[i].L >> v[i].R >> v[i].x;
        H.insert(v[i].L);
        H.insert(v[i].R);
        V.insert(v[i].x);
    }
    for (int i = 0; i < m; ++i) {
        cin >> h[i].x >> h[i].L >> h[i].R;
        V.insert(h[i].L);
        V.insert(h[i].R);
        H.insert(h[i].x);
    }
    vector<int> vl(V.begin(), V.end());
    vector<int> hl(H.begin(), H.end());
    vl.push_back(INT_MIN);
    vl.push_back(INT_MAX);
    hl.push_back(INT_MIN);
    hl.push_back(INT_MAX);
    sort(vl.begin(), vl.end());
    sort(hl.begin(), hl.end());
    int r = hl.size() - 1; // max grid r
    int c = vl.size() - 1; // max grid c

    // split up / down
    for (auto s : h) {
        int L = s.L, R = s.R, x = s.x;
        int idx0 = lower_bound(vl.begin(), vl.end(), L) - vl.begin();
        int idx1 = lower_bound(vl.begin(), vl.end(), R) - vl.begin();
        int idx = lower_bound(hl.begin(), hl.end(), x) - hl.begin();
        for (int k = idx0; k < idx1; ++k) {
            grid[idx - 1][k][1] = grid[idx][k][3] = true;
        }
    }
    // split left / right
    for (auto s : v) {
        int L = s.L, R = s.R, x = s.x;
        int idx0 = lower_bound(hl.begin(), hl.end(), L) - hl.begin();
        int idx1 = lower_bound(hl.begin(), hl.end(), R) - hl.begin();
        int idx = lower_bound(vl.begin(), vl.end(), x) - vl.begin();
        for (int k = idx0; k < idx1; ++k) {
            grid[k][idx - 1][0] = grid[k][idx][2] = true;
        }
    }

    vector<iii> dxy = {{1,0,1}, {-1,0,3}, {0,1,0}, {0,-1,2}};
    queue<ii> que;
    int sx = lower_bound(hl.begin(), hl.end(), 0) - hl.begin() - 1;
    int sy = lower_bound(vl.begin(), vl.end(), 0) - vl.begin() - 1;
    que.push({sx, sy});
    visited[sx][sy] = true;
    bool ok = true;
    while (!que.empty()) {
        auto [x, y] = que.front(); que.pop();
        res += 1LL * (hl[x + 1] - hl[x]) * (vl[y + 1] - vl[y]);
        if (res)
        for (auto [dx, dy, dir] : dxy) {
            int nx = x + dx;
            int ny = y + dy;
            if (grid[x][y][dir]) {
                continue; // block
            }
            if (nx == 0 || ny == 0 || nx == r || ny == c) {
                ok = false;
                continue;
            }
            if (visited[nx][ny]) continue;
            visited[nx][ny] = true;
            que.push({ nx, ny });
        }
    }
    if (!ok)
        cout << "INF" << endl;
    else
        cout << res << endl;


    return 0;
}



Measured memory_bytes: 45436
#include<bits/stdc++.h>
using namespace std;
int main(){
int s;
cin>>s;
vector<int> v(1000000,0);
int count=1;
v.at(s-1)=1;
while(true){
  count++;
  if(s%2==0) s=s/2;
  else s=3*s+1;
  v.at(s-1)++;
  if(v.at(s-1)==2) break;
}
cout<<count<<endl;
}

Measured memory_bytes: 7192
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

	N := getInt()
	b := make([]int, 100001)
	for i := 0; i < N; i++ {
		a := getInt()
		if a-1 >= 0 {
			b[a-1]++
		}
		b[a]++
		if a+1 != N {
			b[a+1]++
		}
	}
	max := 0
	for i := 0; i < 100000; i++ {
		if max < b[i] {
			max = b[i]
		}
	}
	out(max)
}


Measured memory_bytes: 2048
import java.util.Scanner;

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

  }
  static int qtyCandy(int n){
    if(n == 0) {
      return 0;
    } else {
      return  n + qtyCandy(n - 1);
    }
  }
}


Measured memory_bytes: 21716
var n,num,max,sum:longint;
    i,j:longint;
    v:array[0..100000]of boolean;
    a:array[0..10000]of longint;
begin
  readln(n);
  max:=55555;
  for i:=2 to max do
  if not v[i] then
  begin
    inc(num);
    a[num]:=i;
    for j:=1 to max div i do
    v[i*j]:=true;
  end;
  for i:=1 to num do
  begin
    if a[i] mod 10=1 then
    begin
      write(a[i],' ');
      dec(n);
    end;
    if n=0 then exit;
  end;

end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<int>vec(N);
    vector<long long>vec1(1000000,0);
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
        if(vec.at(i)==0){
            vec1.at(vec.at(i))++;
            vec1.at(vec.at(i)+1)++; 
        }
        else{
        vec1.at(vec.at(i))++;
        vec1.at(vec.at(i)-1)++;
        vec1.at(vec.at(i)+1)++;  
        }  
    }
    sort(vec1.begin(),vec1.end());
    reverse(vec1.begin(),vec1.end());
    cout<<vec1.at(0)<<endl;
}

Measured memory_bytes: 11356
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let x = io.chars();
    io.writeln(x.iter().filter(|&x| x == &'1').count());
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


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

using namespace std;
int mas[200005],input[200005];
int main()
{
    int n,p,in,pans=0;
    cin>>n>>p;
    input[0]=p;
    mas[0]=0;
    for(int i=1; i<n; i++){
        cin>>input[i];
        in=input[i];
        int k=pans^in^p;
        mas[i]=k;
        pans=k;
        p=in;
    }
    int test=0;
    for(int i=1; i<n; i++){
        test^=mas[i];
    }
    pans=test^input[0];
    p=input[0];
    cout<<pans<<" ";
    for(int i=1; i<n; i++){
        in=input[i];
        int k=pans^in^p;
        cout<<k<<" ";
        pans=k;
        p=in;
    }
}


Measured memory_bytes: 5064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b,c,d;
	cin >> a >> b >> c >>d;
	int mi = a+c;
	mi = min (mi,a+d);
	mi = min (mi, b+c);
	mi = min (mi, b+d);
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import collections
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10000000)

n = int(input())
g = [[]for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1
    v-=1
    g[u].append([v,w])
    g[v].append([u,w])
lis = [-1 for i in range(n)]
def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color)
lis[0]=0
dfs(0,-1,0)

for i in range(n):
    print(lis[i])


Measured memory_bytes: 167856
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define pi 3.14159265358979
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef vector<int>   vi;
typedef vector<pii>   vpii;
typedef vector<vi>    vvi;

const int MAX = 1000001; 
struct Query 
{ 
    int l, r, idx; 
}; 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
void option(int idx, int val, int shit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        shit[idx] += val; 
} 
int query(int idx, int shit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += shit[idx]; 
    return sum; 
} 

void solutionweringsolutiopnofqueries(int arr[], int n, Query solutiopnofqueries[], int q) 
{ 
    int shit[n+1]; 
    memset(shit, 0, sizeof(shit)); 

    int dovisit[MAX]; 
    memset(dovisit, -1, sizeof(dovisit)); 
    int solution[q]; 
    int mycounter = 0; 
    for (int i=0; i<n; i++) 
    { 
        if (dovisit[arr[i]] !=-1) 
            option (dovisit[arr[i]] + 1, -1, shit, n); 
        dovisit[arr[i]] = i; 
        option(i + 1, 1, shit, n); 
        while (mycounter < q && solutiopnofqueries[mycounter].r == i) 
        { 
            solution[solutiopnofqueries[mycounter].idx] = 
                    query(solutiopnofqueries[mycounter].r + 1, shit, n)- 
                    query(solutiopnofqueries[mycounter].l, shit, n); 
            mycounter++; 
        } 
    } 
    for (int i=0; i<q; i++) 
        cout << solution[i] << endl; 
} 

int main() 
{ 
       int n,q;
   cin>>n>>q;
   int a[n+5];
   for(int i=0;i<n;i++)
   cin>>a[i]; 
    Query solutiopnofqueries[q];
    for(int i=0;i<q;i++)
    {
        int u,v;
        cin>>u>>v;
        solutiopnofqueries[i].l = u-1; 
        solutiopnofqueries[i].r = v-1; 
        solutiopnofqueries[i].idx = i; 
    }
     q = sizeof(solutiopnofqueries)/sizeof(solutiopnofqueries[0]); 
    sort(solutiopnofqueries, solutiopnofqueries+q, cmp); 
    solutionweringsolutiopnofqueries(a, n, solutiopnofqueries, q); 
    return 0; 
} 


Measured memory_bytes: 19332
#include <stdio.h>

int A[2000001],B[2000001],C[10001];

int main(){
  
  int n,i,k=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }

  for(i=0;i<k+1;i++){
    C[i]==0;
  }

  for(i=0;i<n;i++){
    C[A[i]]++;
  }

  for(i=0;i<k+1;i++){
    C[i]=C[i]+C[i-1];
  }

  for(i=n-1;i>=0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n)printf(" ");
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 17420
n=int(input())
lists=list(map(int,input().split()))
cnt=0
from collections import Counter
d=dict(Counter(lists))
for value in d.values():
    cnt+=value*(value-1)//2

for i in range(n):
    x=lists[i]
    ans=0
    ans+=cnt
    now=d[x]
    ans-=now*(now-1)//2
    ans+=(now-1)*(now-2)//2
    print(ans)

Measured memory_bytes: 94156
import collections
n = int(input())
all_ma = []
for _ in range(n):
    tmp_li = list(input())
    tmp_c = collections.Counter(tmp_li)
    all_ma.append(tmp_c)
base = all_ma[0]
for target in all_ma:
    tmp_dic = {}
    for k,v in base.items():
        if k in target:
            tmp_dic[k] = min(v,target[k])
    base = tmp_dic
if len(base) == 0:
    print('')
else:
    ans_lis = []
    for k,v in base.items():
        ans_lis.append(k*v)
        ans_lis.sort()
    print(''.join(ans_lis))

Measured memory_bytes: 39664
#include <iostream>
using namespace std;
int main(){
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
 
    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){

            
            if(mask >> i & 1){
                
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i; //フラグがたっていないものの中で最大の問題番号
            }
        }
        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;//最大の問題でも点数に届かない場合は評価対象外とする。なぜならそれは最小にならないから
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int countFoods[m];
  for (int i = 0; i < m; i++) {
    countFoods[i] = 0;
  }

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

    for (int j = 0; j < k; j++) {
      int food;
      cin >> food;
      food -= 1;

      countFoods[food] += 1;
    }
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (countFoods[i] == n) {
      ans += 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        Integer[] a = sc.nextIntegerArray(n);
        Integer[] b = sc.nextIntegerArray(n);
        Integer[] c = sc.nextIntegerArray(n);
        
        Arrays.sort(c);
        Arrays.sort(a);
        
        long ans = 0;
        for(int i=0;i<n;i++){
        	long ub = n - upperBound(c,b[i]); //b[i]より大きいcの数
        	long lb = lowerBound(a,b[i]); //b[i]より小さいaの数
        	ans += ub*lb;
        }        
        
        System.out.println(ans);
    }

	//lowerBound
	static int lowerBound(Integer[] a, int key){
		int idx = Arrays.binarySearch(a, key, (x,y)->x.compareTo(y)>=0?1:-1);
		
		if(idx<0){
			idx = ~idx;
		}
		
		return idx;
	}
	//upperBound
	static int upperBound(Integer[] a, int key){
		
		int idx = Arrays.binarySearch(a, key, (x,y)->x.compareTo(y)>0?1:-1);
		
		if(idx<0){
			idx = ~idx;
		}
		
		return idx;
	}
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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


int main() {
  int n,m,ans=0,i,j,k;
  cin >> n >> m;
  vector<int> h(n+1);vector<int> a(m);vector<int> b(m);vector<int> peaks(n+1,0);
  for(i=1;i<n+1;i++)
    cin >> h.at(i);
  for(i=0;i<m;i++){
    cin >> a.at(i);
    cin >> b.at(i);
    if(h.at(a.at(i))<h.at(b.at(i))){
      peaks.at(a.at(i))--;
    }else if(h.at(a.at(i))>h.at(b.at(i))){
      peaks.at(b.at(i))--;
    }
    if(h.at(a.at(i))==h.at(b.at(i))){
      peaks.at(a.at(i))--;
      peaks.at(b.at(i))--;
    }
  }
  for(i=1;i<n+1;i++){
    //cout << peaks.at(i) << endl;
    if(peaks.at(i)==0)
      ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 4844
#include <stdio.h>
#include <limits.h>

int main( int argc , char** argv )
{
	long data_count;
	scanf( "%ld" , &data_count );

	long data_l;
	scanf( "%ld" , &data_l );
	long data_r;
	scanf( "%ld" , &data_r );

	long diff_current = data_r - data_l;
	long diff_max = diff_current;

	for( int i = 2 ; i < data_count ; i++ )
	{

		long data_current;
		scanf( "%ld" , &data_current );

		if( data_l < data_r )
		{
			if( data_r < data_current )
			{
				data_r = data_current;
			}
			else if( data_current < data_l )
			{
				data_l = data_r;
				data_r = data_current;
			}
		}
		else
		{
			data_l = data_r;
			data_r = data_current;
		}

		diff_current = data_r - data_l;
		if( diff_max < diff_current )
		{
			diff_max = diff_current;
		}

	}

	printf( "%ld\n" , diff_max );
	return 0;
}

Measured memory_bytes: 1024
package main

import (
  "fmt"
  "os"
  "io"
)

func solve(w io.Writer, r io.Reader) {
  var A, B, C int
  fmt.Fscan(r, &A, &B, &C)
  
  if A == B && B == C {
    fmt.Fprint(w, "Yes")
  } else {
    fmt.Fprint(w, "No")
  }
}

func main() {
  solve(os.Stdout, os.Stdin)
}

Measured memory_bytes: 512
n , p = map(int,input().split())
pf={}
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        pf[i]=pf.get(i,0)+1
        p//=i
if p>1:
    pf[p]=1

ans = 1

for k,v in pf.items():
    ans *= k**(v//n)
print(ans)

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

using namespace std;
typedef long long ll;

int N;
ll dp[100000][2];
ll ar[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> ar[i];
	dp[0][0] = ar[0], dp[0][1] = -ar[0];
	for (int i = 1; i < N; i++) {
		if (i != N - 1) {
			dp[i][0] = max(dp[i - 1][0] + ar[i], dp[i - 1][1] - ar[i]);
			dp[i][1] = max(dp[i - 1][0] - ar[i], dp[i - 1][1] + ar[i]);
		}
		else {
			dp[i][0] = dp[i - 1][0] + ar[i];
			dp[i][1] = dp[i - 1][1] - ar[i];//最後の数字の反転は一つ前に依存
		}
	}
	cout << max(dp[N - 1][0], dp[N - 1][1]) << endl;
	return 0;
}

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

int main(){
  int a, b, c, d, s;
  cin >> a >> b;
  s = 0;
  for(int i = 0; i < a; i++){
    cin >> c;
    if(c >= b){
      d = c - b;
    }
    else d = min(c, b - c);
    s += 2 * d;
  }
  cout << s << endl;
}

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

int main() {
  long long N;
  cin >> N;
  string S;
  cin >> S;
  long long sum = 0;
  long long r_num = 0;
  long long g_num = 0;
  long long b_num = 0;
  for (long long i = 0; i < N; i++) {
    if (S[i] == 'R') {
      r_num++;
    } else if (S[i] == 'G') {
      g_num++;
    } else {
      b_num++;
    }
  }
  sum = r_num * g_num * b_num;

  for (long long i = 0; i < N - 2; i++) {
    for (long long j = i + 1; j < N - 1; j++) {
      if (2 * j - i < N) {
        if (S.at(i) != S.at(j) && S.at(i) != S.at(2 * j - i) &&
            S.at(j) != S.at(2 * j - i)) {
          sum--;
        }
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int ll
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int n, q; cin >> n >> q;
	static int A[1000010] = {};
	auto cmp = [](pii a, pii b) {return a.first == b.first ? a.second > b.second : a.first < b.first; };
	priority_queue < pii, vector<pii>, decltype(cmp) > pq(cmp);
	rep(i, 0, q) {
		int a, v; cin >> a >> v;
		A[a] += v;
		pq.push(pii(A[a], a));
		pii t;
		while (true) {
			t = pq.top();
			if (t.first != A[t.second])	pq.pop();
			else break;
		}
		cout << t.second << " " << t.first << endl;
	}
	return 0;
}

Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    string ans;
    while(n){
        int r = n % (-2);
        if(r < 0) r += 2;
        n = (n - r) / (-2);
        if(r % 2 == 0) ans += "0";
        else ans += "1";
    }
    reverse(ALL(ans));
    if(ans == "") ans = "0";
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
	"strconv"
)

func sum(array []int) int {
	value := 0
	for i := 0; i < len(array); i++ {
		value += array[i]
	}
	return value
}

func isAcceptable(a []int, x, k int) bool {
	for i := 0; i < len(a); i++ {
		k1 := 0

		for j := 0; j < i; j++ {
			k1 += a[j]

			if k1 > k {
				return false
			}
		}

		k2 := 0

		for j := i; j < len(a); j++ {
			k2 += x - a[j]
		}

		if k1 == k2 {
			return true
		}
	}

	return false
}

func divide(n int) []int {
	limit := int(math.Sqrt(float64(n)))
	array := []int{}

	for i := 1; i <= limit; i++ {
		if n % i == 0 {
			array = append(array, i)
			array = append(array, n/i)
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(array)))
	return array
}

func answer(n, k int, array []int) int {
	total := sum(array)

	nums := divide(total)
	a2 := make([]int, len(array))

	for p := 0; p < len(nums); p++ {
		x := nums[p]

		for i := 0; i < len(array); i++ {
			a2[i] = array[i] % x
		}
		sort.Ints(a2)

		if isAcceptable(a2, x, k) {
			return x
		}
	}

	return 1;
}

func main() {
	var text string
	fmt.Scan(&text)
	n, _ := strconv.Atoi(text)
	fmt.Scan(&text)
	k, _ := strconv.Atoi(text)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&text)
		a[i], _ = strconv.Atoi(text)
	}

	fmt.Println(answer(n, k, a))
}


Measured memory_bytes: 640
fun main(args: Array<String>) {

    val code = readLine()!!.toCharArray()
    if (code[0] == code[1]) {
        println("Bad")
        return
    }
    if (code[1] == code[2]) {
        println("Bad")
        return
    }
    if (code[2] == code[3]) {
        println("Bad")
        return
    }
    println("Good")
}

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

int main(){
	int a,b,c, mn=100000; cin>> a >> b >> c;

	mn = min(b+a,mn);
	mn= min(b+c,mn);
	mn= min(a+c,mn);

	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N;
    cin >> N;

    string S;
    ll cnt = 0, cnt1 = 0, cnt2 = 0, ans = 0 ;

    rep(i, N) {
        cin >> S;
        if (S[0] == 'B' && S[S.size() - 1] == 'A') cnt++;
        else if (S[S.size() - 1] == 'A') cnt1++;
        else if (S[0] == 'B') cnt2++;

        rep(i, S.size() -1) {
            if (S[i] == 'A' && S[i + 1] == 'B') {
                ans++;
            }
        }
    }

    if (cnt1 + cnt2 > 0) ans += cnt + min(cnt1, cnt2);
    else ans += max(cnt - 1, cnt * 0);

    cout << max(ans, ans * 0);

    return 0;

}



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

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	vector< pair< ll , ll > > v(n);
	rep(i,0,n){
		ll a,b;
		cin >> a >> b;
		v[i] = make_pair(b,a);
	}
	vsort(v);

	ll sum = 0;
	rep(i,0,n){
		sum += v[i].sec;
		//cout << v[i].fir << " " << v[i].sec << " " <<  sum << endl;
		if( v[i].fir < sum ){
			No;
			ret 0;
		}
	}

	Yes;
	ret 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int d=0;
    for(int i=0;i<s.length();i++){
        if('+'==s[i]){
            d++;
        }else{
            d--;
        }
    }
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
int main(){
    int a,b,c;
    cin >> a;
    if(a == 1){
        cout << "Hello World" << endl;
    }else{
        cin >> b >> c;
            cout << b+c << endl;
    }

return 0;
    
}

Measured memory_bytes: 256
S = input()

ACGT = ['A', 'C', 'G', 'T']
cntList = []
cnt = 0
cntList.append(cnt)
for s in S:
    if s in ACGT:
        cnt += 1
        cntList.append(cnt)
    else:
        cnt = 0
print(max(cntList))


Measured memory_bytes: 9032
#include <iostream>
#include <algorithm>
using namespace std;
int n;
bool tbl[30][30];
int dx[200],dy[200];
int main(){
  dy['N'] = 1;
  dy['S'] = -1;
  dx['W'] = -1;
  dx['E'] = 1;
  
  while(cin>>n,n){
    for(int i=0;i<30;++i) for(int j=0;j<30;++j) tbl[i][j] = false;
    for(int i=0;i<n;++i){
      int x,y;
      cin >> x >> y;
      tbl[y][x]=true;
    }

    int m;cin>>m;
    int x=10,y=10;
    int cnt = 0;
    while(m--){
      int d;char c;
      cin >> c >> d;
      for(int i=0;i<d;++i){
	cnt+=tbl[y][x];
	tbl[y][x]=false;
	x +=dx[c];
	y +=dy[c];
      }
    }
    cnt+=tbl[y][x];
    if(cnt==n) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>/*The header <string> and
<string.h> does not contain the useful
function 'memset' and 'memcpy'.*/
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<utility>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstdio>
using namespace std;
int A[100100],sum;
vector<int> M,G,All;
bool mn,gtz,alz=true,z;
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		sum+=abs(A[i]);
		if(A[i]>0)
			gtz=true,
			G.push_back(A[i]);
		if(A[i]<0)
			mn=true,
			M.push_back(A[i]);
		if(A[i])
			alz=false;
		else
			z=true,
			All.push_back(A[i]);
	}
	if(alz)
	{
		cout<<0<<endl;
		while(--N)
			cout<<0<<" "<<0<<endl;
		return 0;
	}
	if(mn&&gtz)
	{
		cout<<sum<<endl;
		while(G.size()>1)
		{
			cout<<M[0]<<" "<<G[0]<<endl;
			M[0]-=G[0];
			G.erase(G.begin());
		}
		while(M.size())
		{
			cout<<G[0]<<" "<<M[0]<<endl;
			G[0]-=M[0];
			M.erase(M.begin());
		}
		M=G;
	}
	else
		if(mn)
		{
			sort(M.begin(),M.end());
			reverse(M.begin(),M.end());
			if(All.size())
			{
				cout<<sum<<endl;
				cout<<0<<" "<<M[0]<<endl;
				All.erase(All.begin());
				M[0]*=-1;
				while(All.size())
				{
					cout<<M[0]<<" "<<0<<endl;
					All.erase(All.begin());
				}
				while(M.size()>1)
				{
					cout<<M[0]<<" "<<M[1]<<endl;
					M[0]-=M[1];
					M.erase(M.begin()+1);
				}
				return 0;
			}
			if(M.size()==1)
			{
				cout<<sum<<endl;
				while(All.size()>1)
				{
					cout<<M[0]<<" "<<All[0]<<endl;
					All.erase(All.begin());
				}
				cout<<All[0]<<" "<<M[0]<<endl;
				return 0;
			}
			cout<<sum+M[0]*2<<endl;
			while(M.size()>1)
			{
				cout<<M[0]<<" "<<M[1]<<endl;
				M[0]-=M[1];
				M.erase(M.begin()+1);
			}
		}
		else
		{
			M=G;
			sort(M.begin(),M.end());
			if(All.size())
			{
				cout<<sum<<endl;
				cout<<0<<" "<<M[0]<<endl;
				All.erase(All.begin());
				M[0]*=-1;
				while(All.size())
				{
					cout<<M[0]<<" "<<0<<endl;
					All.erase(All.begin());
				}
				while(M.size()>2)
				{
					cout<<M[0]<<" "<<M[1]<<endl;
					M[0]-=M[1];
					M.erase(M.begin()+1);
				}
				cout<<M[1]<<" "<<M[0]<<endl;
				return 0;
			}
			if(M.size()==1)
			{
				cout<<sum<<endl;
				while(All.size())
				{
					cout<<M[0]<<" "<<All[0]<<endl;
					All.erase(All.begin());
				}
				return 0;
			}
			cout<<sum-M[0]*2<<endl;
			while(M.size()>2)
			{
				cout<<M[0]<<" "<<M[1]<<endl;
				M[0]-=M[1];
				M.erase(M.begin()+1);
			}
			cout<<M[1]<<" "<<M[0]<<endl;
			M[1]-=M[0];
			M.erase(M.begin());
		}
	while(All.size())
	{
		cout<<M[0]<<" "<<All[0]<<endl;
		All.erase(All.begin());
	}
	return 0;
}

Measured memory_bytes: 3064
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define ro return 0
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
    ios;
    ll x;
    cin >> x ;
    if(x == 7 or x == 5 or x == 3){
        cout <<"YES\n";
        ro;
    }
    else cout <<"NO\n";
    ro;
}


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

int ABS(int a){
	return a >= 0 ? a : -a;
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	else{
		return gcd(b, a % b);
	}
}

int main(){
	int N, X, x, i, g = 0;
	scanf("%d%d", &N, &X);
	for(i = 0; i < N; i++){
		scanf("%d", &x);
		g = gcd(g, ABS(x - X));
	}
	printf("%d\n", g);
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
tree = Struct.new(:parent, :depth, :type, :children)
node = Array.new(n) {tree.new}
n.times do
  ar = gets.split.map(&:to_i)
  node[ar[0]].children = ar[2..-1]
  node[ar[0]].parent = -1
  node[ar[0]].type = "leaf"
end

node.each_with_index do |nd, i|
  nd.children.each {|child| node[child].parent = i}
  nd.type = "internal node" unless nd.children.empty?
end

root_index = 0
node.each_with_index {|nd, i| root_index = i if nd.parent == -1}
node[root_index].type = "root"

search = ->(index, depth) {
  node[index].depth = depth
  children = node[index].children
  return if children.empty?
  children.each {|child| search.(child, depth + 1)}
}
search.(root_index, 0)

node.each_with_index do |nd, i|
  puts "node #{i}: parent = #{nd.parent}, depth = #{nd.depth}, #{nd.type}, #{nd.children.inspect}"
end


Measured memory_bytes: 35664
import Data.List
import System.Environment (getArgs)

-- http://tnomura9.exblog.jp/12332000/
factors :: Integer -> [Integer]
factors n = [x | x <- [1..n], n `mod` x == 0]

factorization :: Integer -> [Integer]
factorization 1 = []
factorization x = v : factorization (x `div` v)
  where v = (factors x) !! 1

primeList 2 = [2]
primeList n = (factorization n) ++ (primeList (n - 1))

answer 1 = 1
answer n = foldr f 1 $ map g $ groupBy (==) $ sort $ primeList n
  where f x p = (x * p) `rem` 1000000007
        g l = (fromIntegral 1) + (fromIntegral (length l))

main = do
  n <- readLn
  print $ answer (n :: Integer)


Measured memory_bytes: 1916
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		String[] apple = {"apple", "APPLE"};
		String[] peach = {"peach", "PEACH"};
		
		String input = scanner.nextLine();
		
		String output = "";
		for(int i=0; i<input.length(); i++)
		{	
			if(i <= input.length()-5)
			{
				if(input.substring(i, i+5).equals("apple"))
				{
					output += "peach";
					i += 4;
				}
				else if(input.substring(i, i+5).equals("peach"))
				{
					output += "apple";
					i += 4;
				}
				else
				{
					output += input.substring(i, i+1);
				}
			}
			else
			{
				output += input.substring(i, i+1);
			}
		}
		
		System.out.println(output);
	}
}

Measured memory_bytes: 26640
n, x = map(int, input().split())

pate, slice = [1], [1]
for _ in range(n + 1):
    pate.append(2 * pate[-1] + 1)
    slice.append(2 * slice[-1] + 3)

ans = 0
while n > 0:
    if x >= slice[n - 1] + 2:
        ans += pate[n - 1] + 1
        x -= slice[n - 1] + 2
    elif x < slice[n - 1] + 2:
        x -= 1
    n -= 1
print(ans + (x > 0))


Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    string s;cin>>s;
    int n=siz(s);
    if((s[0]==s.back())^(n%2)){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main(){
	
	int w,h,n;
	int nx,ny,gx,gy;
	int a=0;
	
	cin >> w >> h >> n ;
	cin >> nx >> ny ;
	
	for( int i=1 ; i<n ; i++ ){
		cin >> gx >> gy ;
		
		if( nx > gx && ny > gy || nx < gx && ny < gy ){
			if( abs( nx-gx ) >= abs( ny-gy ) ) a += abs( nx-gx ) ;
			else a += abs( ny-gy ) ;
		}else{
			a += abs( nx-gx ) + abs( ny-gy ) ;
		}
		
		nx = gx ;
		ny = gy ;
	}
	
	cout << a << endl ;
	
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    string s;
    cin >> s;
    ll cnt = 0;
    int w_count = 0;
    rep(i,s.length()){
        if(s[i] == 'W'){ 
            w_count++;
            //cout << i << " " << w_count << endl;
            cnt += (i+1-w_count);
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include <algorithm>
using namespace std;
using ll = long long;

typedef pair<ll,ll> P;
 


int main(void){
    int N;
    cin >>N;
    vector<pair<int,int>> D(N);
    for(int k=0;k<N;k++){
        int x,y;
        cin >>x>>y;
        pair<int,int> dice(x,y);
        D[k]=dice;
    }
    int pea=0;
    for(int m=0;m<N;m++){
        if(D[m].first==D[m].second){
            pea++;
        }else{
            pea=0;
        }
        if(pea==3){
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";
    return 0;
}

Measured memory_bytes: 3624
#coding:utf-8
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]


    n = II()

    for i in range(50001):
        if int(i*1.08) == n:
            print(i)
            exit()

    print(":(")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
# -*- coding: UTF-8 -*-
#Stable Sort
import copy

def bubble_sort(bubble_N,bubble_A):
    #バブルソート
    flag = 1
    bi = 0
    # Sort処理（自分メモ：flagが0になったらループを抜ける）
    while flag:
        flag = 0
        for bj in reversed(range(bi + 1, bubble_N)):
            if bubble_A[bj][1:2] < bubble_A[bj - 1][1:2]:
                tmp = bubble_A[bj - 1]
                bubble_A[bj - 1] = bubble_A[bj]
                bubble_A[bj] = tmp
            flag = 1
        bi += 1

def selection_sort(selection_N,selection_A):
    #選択ソート
    for si in range(selection_N):
        cnt_flg = 0
        minj = si
        for sj in range(si, selection_N):
            if selection_A[sj][1:2] < selection_A[minj][1:2]:
                minj = sj
                cnt_flg = 1
        tmp = selection_A[si]
        selection_A[si] = selection_A[minj]
        selection_A[minj] = tmp

#標準入力から
N = int(input()) #要素数
B_A = list(input().split()) #バブルソート対象（スペース区切り→配列に展開）
S_A = copy.deepcopy(B_A) #選択ソート対象（コピー）

bubble_sort(N,B_A) #バブルソート実施
selection_sort(N,S_A) #選択ソート実施
ans_bubble = ' '.join(map(str,B_A)) #配列を文字列に戻す
ans_selection = ' '.join(map(str,S_A)) #配列を文字列に戻す

#バブルソート結果の出力（常にStable）
print(ans_bubble)
print("Stable")

#選択ソート結果の出力（バブルソート結果と比較してStable判断）
print(ans_selection)
if ans_bubble == ans_selection:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 6348
L, R = map(int, input().split())
ans = []
check = False

for i in range(L, R+1):
    if i % 2019 == 0:
        print(0)
        check = True
        break
    else:
        ans.append(i % 2019)

if not check:
    ij = 2019
    for i in range(len(ans)-1):
        for j in range(i+1, len(ans)):
            temp = ans[i] * ans[j] % 2019
            if temp < ij:
                ij = temp
    print(ij)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

S = input()
T = input()

ans = 0

for i in range(3):
    if S[i] == T[i]:
        ans += 1

print(ans)

Measured memory_bytes: 77392