akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a==b && b==c){
			System.out.println("No");
		}else if(a!=b && c!=b && a!=c){
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23892
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n, k; ll s;
	cin>>n>>k>>s;
	const ll MAX=1e9;
	if(s<MAX){
		for(int i=0; i<n; i++){
			if(i<k) cout<<s<<" ";
			else cout<<s+1<<" ";
		}
		cout<<endl;
		return 0;
	}else{
		for(int i=0; i<n; i++){
			if(i<k) cout<<s<<" ";
			else cout<<s-1<<" ";
		}
		cout<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int n, a, b, c;
vector<int> l;

int inf = 1e9;

int dfs(int v, int aa, int bb, int cc, const vector<int>& l)
{
    int ret = inf;
    if (v == n)
    {
        if (aa > 0 && bb > 0 && cc > 0)
        {
            return (abs(a - aa) + abs(b - bb) + abs(c - cc) - 30);
        }
        return ret;
    }
    for (int i = 0; i < 4; ++i)
    {
        if (i == 0)
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc, l));
        }
        else if (i == 1)
        {
            ret = min(ret, dfs(v + 1, aa + l[v], bb, cc, l) + 10);
        }
        else if (i == 2)
        {
            ret = min(ret, dfs(v + 1, aa, bb + l[v], cc, l) + 10);
        }
        else
        {
            ret = min(ret, dfs(v + 1, aa, bb, cc + l[v], l) + 10);
        }
    }
    
    return ret;
}

int main() {
    
    cin >> n >> a >> b >> c;
    
    l = vector<int>(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> l[i];
    }
    
    int ret = dfs(0, 0, 0, 0, l);
    
    cout << ret << endl;
    
    return 0;
}

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


#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000
#define NMAX                    100005




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll H ,  N , sum = 0 ;
    cin >> H >> N ;
    for(ll i = 1 ; i<=N ; i++){
        ll x ; cin >> x ;
        sum+=x ;
    }
    if(H <= sum)cout << "Yes" << endl ;
    else cout << "No" << endl ;

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        long A = long.Parse(input[0]) - 1;
        long B = long.Parse(input[1]);
        long C = long.Parse(input[2]);
        long D = long.Parse(input[3]);
        long x1 = A / C;
        long x2 = A / D;
        long x12 = A / Lcm(C, D);
        long xa = B - A;
        long y1 = B / C;
        long y2 = B / D;
        long y12 = B / Lcm(C, D);
        long xy = (y1 + y2 - y12) - (x1 + x2 - x12);
        long ans = xa - xy;
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 13140
//T1
#include <bits/stdc++.h>
using namespace std;
int n,ans=0;
int a[10000];
inline int read()
{
	int sum=0,flag=1;
	char c=getchar();
	for (;c<'0' || c>'9';c=getchar())
	 if (c=='-') flag=-1;
	for (;c>='0' && c<='9';c=getchar())
	 sum=(sum<<3)+(sum<<1)+c-48;
	return sum*flag;
}
inline void write(int x)
{
    if(x<0) 
	 {
	   putchar('-');
	   x=-x;
     }
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void start()
{
	return;
}
inline void init()
{
	n=read();
	for (int i=1;i<=2*n;i++)
	 a[i]=read();
	return;
}
inline void work()
{
	sort(a+1,a+2*n+1);
	for (int i=2;i<=2*n;i+=2)
	 ans+=min(a[i],a[i-1]);
	return;
}
inline void outo()
{
	printf("%d\n",ans);
	return;
}
int main()
{
	start();
	init();
	work();
	outo();
	return 0;
}

Measured memory_bytes: 256
p = 1
cnt = 1
h, w, k = map(int, input().split())
for i in range(h):
    s = input()
    if s.count("#") == 1:
        a = []
        for j in range(w):
            a.append(p)
        p += 1
        for _ in range(cnt):
            print(*a)
        cnt = 1
    elif s.count("#") == 0:
        cnt += 1
    else:
        a = []
        itigo = 0
        for j in range(w):
            if s[j] == "#" and itigo == True:
                p += 1
                a.append(p)
            elif s[j] == "#":
                itigo = True
                a.append(p)
            else:
                a.append(p)
        for _ in range(cnt):
            print(*a)
        cnt = 1
        p += 1
for i in range(cnt - 1):
    print(*a)


Measured memory_bytes: 3964
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0])
    const S = arg[1].split(" ").map(n=>parseInt(n));
    
    const set = new Set(S);
    
    console.log(set.size === N ? "YES" : "NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 44152
#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int N, M;
Graph G;
vector<int> us, vs;

bool rec(int v, int p, int target, long long &path) {
    if (v == target) {
        path = 0;
        return true;
    }
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (rec(e.first, v, target, path)) {
            path |= (1LL<<e.second);
            return true;
        }
    }
    return false;
}

long long solve() {
    vector<long long> paths(M, 0);
    for (int i = 0; i < M; ++i) rec(us[i], -1, vs[i], paths[i]);
    long long res = 0;
    for (long long bit = 0; bit < (1<<M); ++bit) {
        long long val = 0;
        for (int i = 0; i < M; ++i) if (bit & (1LL<<i)) val |= paths[i];
        long long remnum = N-1 - __builtin_popcountl(val);
        if (__builtin_popcountl(bit) % 2 == 0) res += 1LL<<remnum;
        else res -= 1LL<<remnum;
    }
    return res;
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int x, y; cin >> x >> y; --x, --y;
        G[x].emplace_back(y, i);
        G[y].emplace_back(x, i);
    }
    cin >> M;
    us.resize(M), vs.resize(M);
    for (int i = 0; i < M; ++i) {
        cin >> us[i] >> vs[i];
        --us[i], --vs[i];
    }
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n; cin >> n;
    lint a[n], b[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int ans = 0;
    rrep(i, 30){
        rep(j, n) a[j] %= (1LL<<(i+1)), b[j] %= (1LL<<(i+1));
        sort(b, b+n);
        rep(j, n){
            if(a[j] <= (1LL<<i)){
                auto l = lower_bound(b, b+n, (1LL<<i) - a[j]);
                auto r = lower_bound(b, b+n, (1LL<<(i+1)) - a[j]);
                ans ^= ((r-l)%2) << i;
            }
            else{
                auto r = lower_bound(b, b+n, (1LL<<(i+1)) - a[j]);
                auto l = lower_bound(b, b+n, (1LL<<(i+1)) + (1LL<<i) - a[j]);
                ans ^= ((r-b) + ((b+n)-l))%2 << i;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int H = sc.nextInt();
	        int W = sc.nextInt();
	        int M = sc.nextInt();
	        long[] m = new long[M];
	        int[][] h = new int[H][2];
	        int[][] w = new int[W][2];
	        int ans=0;
	        for(int i=0;i<H;i++)h[i][1]=i;
	        for(int i=0;i<W;i++)w[i][1]=i;
	        for(int i=0;i<M;i++) {
	        	int x =sc.nextInt()-1;
	        	int y =sc.nextInt()-1;
	        	
	        	m[i]=1000000*x+y;
	        	h[x][0]++;
	        	w[y][0]++;
	        }
	        Arrays.sort(h, (b, c) -> Integer.compare(b[0], c[0]));
	        Arrays.sort(w, (b, c) -> Integer.compare(b[0], c[0]));
	        Arrays.sort(m);
	        for(int i=H-1;i>=0&&h[i][0]>=h[H-1][0]-1;i--) {
	        	for(int j=W-1;j>=0&&w[j][0]+h[i][0]>=w[W-1][0]+h[H-1][0]-1;j--) {
	        		long t=1000000*h[i][1]+w[j][1];
	        		int right = M-1;
	        		int left = 0;
	        		int n =0;
	        		while(right>=left) {
	        			int mid = (right+left)/2;
	        			if(m[mid]==t) {
	        				n++;
	        				break;
	        			}
	        			else if(m[mid]>t)right=mid-1;
	        			else left=mid+1;
	        		}
	        		
	        		ans=Math.max(ans, h[i][0]+w[j][0]-n);
	        		
	        	}
	        	if(ans==w[W-1][0]+h[H-1][0])break;
	        }
	        System.out.println(ans);
		 }
		 
	}

Measured memory_bytes: 83720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説AC
int n,q;
vector<int>G[201010];

void dfs(int v,int p,vector<long long> &a){
  if(p!=-1)a[v]+=a[p];
  rep(i,G[v].size()){
    int e=G[v][i];
    if(e==p)continue;
    dfs(e,v,a);
  }
}

int main(){
  cin>>n>>q;
  rep(i,n-1){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  vector<long long>a(n,0);
  rep(i,q){
    int x,y;
    cin>>x>>y;
    x--;
    a[x]+=y;
  }
  dfs(0,-1,a);
  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 25172
#include <stdio.h>
int main(void){
    int a=0;
    scanf("%d",&a);
    int b=a/1000;
    int c=(a%1000)/100;
    int d=(a%100)/10;
    int e=a%10;
    
    
    if((b==c&&c==d)||(c==d&&d==e))
    {
        printf("Yes");
    }
    else
        printf("No");
    
    
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();++i){
		if(s.at(i)!=t.at(i))++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main(int argc,char** argv)
{

	int a, b, k;
	cin >> a >> b >> k;
	if( k*2-1 >= (b-a) ){
		for(int i = a; i <= b; i++){
			cout << i << endl;
		}
	}
	else{
		for(int i = 0; i < k; i++){
			cout << a+i <<endl;

		}
		for(int i = k-1; 0 <= i; i--){
			cout << b-i <<endl;
		}
	}

	return 0;

}


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

int main(){
    int n,k;cin>>n>>k;
    int ans=0;
    vector<int> A(n,1);
    for(int i=0;i<k;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int a;cin>>a;
            a--;
            A[a]=0;
        }
    }
    for(int i=0;i<n;i++){
        ans+=A[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<int> l;
    rep(i, n){
        int x;
        cin >> x;
        l.push_back(x);
    }
    sort(l.begin(), l.end());
    int cnt=0;
    rep(i, n-2){
        rep2(j, i+1, n-1){
            rep2(k, j+1, n){
                // cout << i << j << k << endl;
                if(l[i]+l[j]<=l[k]){
                    break;
                }
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		boolean flag = true;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)flag = false;
		}
		if(flag) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	}

}


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

int main() {
    int64_t N;
    cin >> N;

    int64_t sum = 0;

    for (int64_t i = 1; i < N+1; i++) {
        if(i%3 != 0 && i%5 != 0) {
            sum = sum + i;
        }
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int n,m;
bool c[8000000];
main()
{
	while(cin>>m>>n,n)
	{
		for(int i=2;i<8e6;i++)c[i]=0;
		for(int i=m;;i++)
		{
			if(c[i])continue;
			if(n)
			{
				n--;
				for(int j=1;j*i<8e6;j++)c[i*j]=1;
			}
			else
			{
				cout<<i<<endl;
				break;
			}
		}
	}
}



Measured memory_bytes: 10892
# 各桁について3通りある
# (0,0) (1,0) (0,1)
# 3 ** 桁数すればよいのだが、たとえば100以下の数で101は選べないので、
# 桁DPで処理
# ・未満でない->未満でない : 1のときは2通り(1,0) (0,1)
# ・未満でない->未満でない : 0の時は1通り(0,0)
# ・未満でない->未満である : 1の時は1通り(0,0)
# ・未満でない->未満である : 0の時は0通り（未満にできない）
# ・未満である : 1でも0でも3通り(1,0)(0,1)(0,0)

# dp[i][smaller] = 場合の数

import sys
readline = sys.stdin.readline

L = readline().rstrip()
keta = len(L)
DIV = 10 ** 9 + 7

dp = [[0] * 2 for i in range(keta)]
dp[0][0] = 2 # 最初の桁は必ず1なので2通り
dp[0][1] = 1 # 未満になるタイミングで選べるのは1通り

for i in range(1, keta):
  x = L[i] # その桁の数
  if x == "1":
    dp[i][0] += dp[i - 1][0] * 2
    dp[i][1] += dp[i - 1][0] * 1
    dp[i][0] %= DIV
    dp[i][1] %= DIV
  else:
    dp[i][0] += dp[i - 1][0] * 1
    dp[i][0] %= DIV
  dp[i][1] += dp[i - 1][1] * 3
  dp[i][1] %= DIV

print((dp[keta - 1][0] + dp[keta - 1][1] ) % DIV)

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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;


signed main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int c = 1;
	int x = 1;
	for(int i = 1;i<n;i++){
        if(s[i] == s[i-1]){
            continue;
        }
        c++;
	}
	cout << c;
}


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

namespace ConsoleApp2
{
    class Program
    {

        public static void Main(String[] args)
        {
            var diceSeed = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var none = int.Parse(Console.ReadLine());
            for (var i = 0; i < none; i++)
            {
                var RollDest = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                var dice = new Dice(diceSeed[0], diceSeed[1], diceSeed[2], diceSeed[3], diceSeed[4], diceSeed[5]);

                dice.Vertical(RollDest[0], RollDest[1]);

                Console.WriteLine(dice.right);
            }

           // var n = Console.ReadLine();

        }

    }
    class Dice
    {
        public int top, front, right, left, back, bottom;

        public Dice(int dice0, int dice1, int dice2, int dice3, int dice4, int dice5)
        {
            top = dice0;
            front = dice1;
            right = dice2;
            left = dice3;
            back = dice4;
            bottom = dice5;

        }


        public void Vertical(int target, int target2)
        {
            List<int> lst = new List<int> { top, front, back, bottom };
            if (!lst.Contains(target))
            {
                RollE();
            }

            var isNotTop = true;

            while (isNotTop)
            {
                RollS();
                if (top == target)
                {
                    isNotTop = false;
                }
            }

            isNotTop = true;

            while (isNotTop)
            {
                RollE();
                if (front == target2)
                {
                    isNotTop = false;
                }
            }

        }

        public void RollS()
        {

            int pastFront = front;
            int pastTop = top;
            int pastBack = back;
            int pastBottom = bottom;

            top = pastBack;
            front = pastTop;
            back = pastBottom;
            bottom = pastFront;

        }

        public void RollE()
        {
            int pastFront = front;
            int pastRight = right;
            int pastLeft = left;
            int pastBack = back;

            front = pastLeft;
            right = pastFront;
            left = pastBack;
            back = pastRight;
        }

    }

    //public void Roll(String RollDest)
    //{

    //  RollDest.ToList().ForEach(x => Roll(x));
    //}

}




Measured memory_bytes: 18236
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat DFS(int R, int par, vector< vector< pair<int, cat> > > &G, int goal) {
	if(goal == R) return 0;
	ALL_THE(G[R], it) if(par != it->ff) {
		cat c = DFS(it->ff, R, G, goal);
		if(c == -1) continue;
		c = max(c, it->ss);
		return c;
	}
	return -1;
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cat X;
	cin >> N >> M >> X;
	if(N <= 2) {
		cout << "0\n";
		return 0;
	}
	vector< vector< pair<int, cat> > > G(N);
	vector< pair<cat, pair<int, int> > > E(M);
	for(int i = 0; i < M; i++) {
		int u, v;
		cat w;
		cin >> u >> v >> w;
		G[--u].push_back(make_pair(--v, w));
		G[v].push_back(make_pair(u, w));
		E[i].ff = w;
		E[i].ss = make_pair(u, v);
	}

	vector< vector< pair<int, cat> > > Gt(N);
	sort(begin(E), end(E));
	vector< vector<int> > comp(N);
	vector<int> inC(N);
	for(int i = 0; i < N; i++) {
		comp[i].push_back(i);
		inC[i] = i;
	}
	vector<bool> inT(M, 0);
	cat cost0 = 0;
	for(int i = 0; i < M; i++) {
		if(inC[E[i].ss.ff] == inC[E[i].ss.ss]) continue;
		int x = inC[E[i].ss.ff], y = inC[E[i].ss.ss];
		inT[i] = 1;
		cost0 += E[i].ff;
		Gt[E[i].ss.ff].push_back(make_pair(E[i].ss.ss, E[i].ff));
		Gt[E[i].ss.ss].push_back(make_pair(E[i].ss.ff, E[i].ff));
		if(comp[x].size() < comp[y].size()) swap(x, y);
		ALL_THE(comp[y], it) {
			inC[*it] = x;
			comp[x].push_back(*it);
		}
	}
	if(X < cost0) {
		cout << "0\n";
		return 0;
	}

	cat ans = 0, mod = 1000000007;
	vector<cat> pw2(M+1, 1);
	for(int i = 0; i < M; i++) pw2[i+1] = (2*pw2[i])%mod;
	if(cost0 == X) ans = pw2[M-(N-1)] * (pw2[N-1] - 2) % mod;
	int szT = N-1;
	vector<cat> cost(M, cost0);
	for(int i = 0; i < M; i++) if(!inT[i]) {
		cat mincost = DFS(E[i].ss.ff, E[i].ss.ff, Gt, E[i].ss.ss);
		cost[i] = cost0-mincost+E[i].ff;
		if(cost[i] < X) inT[i] = 1, szT++;
	}
	int m = M-szT;
	for(int i = 0; i < M; i++) if(!inT[i] && cost[i] == X) {
		m--;
		ans = (ans + pw2[m+1]) % mod;
	}

	ans %= mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
   int a, b;
   cin >> a >> b;
   if((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
   else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
S = str(input())
S_list = list(S)

if S_list[K-1] == 'A':
     S_list[K-1] = 'a'

if S_list[K-1] == 'B':
     S_list[K-1] = 'b'

if S_list[K-1] == 'C':
     S_list[K-1] = 'c'

S_changed = "".join(S_list)

print(S_changed)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  int X;
  cin >>N>>X;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
int D=0;
  int count=1;
  rep(i,N) {
if(D+vec.at(i)<=X) {
D=D+vec.at(i);
  count++;
} 
    else if (D+vec.at(i)>X) {
      break;
    }
  }
 
  cout << min(count,N+1)<< endl;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int di[21][21], n, m, s, e, i, j, mi, a, b, c, d, p, in, ha;

int dic(int start, int goal) {
  int min, mi = start, cost[200], f[21] = {0};
  for(i = 0; i < 200; i++) cost[i] = 100000000;
  cost[mi] = 0;//テ」ツつケテ」ツつソテ」ツδシテ」ツδ暗」ツつ津ッツシツ静」ツ?ァテ・ツ按敕ヲツ慊淌・ツ個?

  for(i = 0; i < n; i++) {
    f[mi] = 1;
    for(j = 1; j <= n; j++) {
      if(f[j]) continue;
      if(cost[j] > cost[mi] + di[mi][j]) cost[j] = cost[mi] + di[mi][j];
    }
    
    min = 200000000;
    for(j = 1; j <= n; j++) {
      if(f[j]) continue;
      if(min > cost[j]) min = cost[mi = j];
    }
  }
  return cost[goal];
}


int main(){
 
  for(i = 0; i < 20; i++) {
    for(j = 0; j < 20; j++) di[i][j] = 100000000;
  }
  
  scanf("%d%d", &n, &m);
  while(m--) {
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    di[a][b] = c;
    di[b][a] = d;
  }
  scanf("%d,%d,%d,%d", &s, &p, &in, &ha);
  cout << in - dic(s, p) - dic(p, s) - ha << endl; 
  return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define F first
#define S second
#define ll long long
const int MOD = 1e9 + 7;
const float epsilon = 0.0005f;
const float PI = 3.1415926535897932384626433f;
 
vector<pair<int,int>> dire{{0,1},{0,-1},{1,0},{-1,0}};
 
// std::cout << std::fixed;
// std::cout << std::setprecision(9);

void solve(){
    string s, t;
    cin >> s >> t;
    int ns = s.size(), nt = t.size(),ans = INT_MAX;
    for (int i = 0; i < ns - nt + 1;i++){
        int c = 0;
        for (int j = 0; j < nt;j++){
            if(s[i+j] != t[j]){
                c++;
            }
        }
        ans = min(ans, c);
    }
    cout << ans << "\n";
}
    
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // int t;cin>>t;
    // for(int i = 0;i<t;++i){
    //     solve();
    // }
    solve();
    return(0);
}

Measured memory_bytes: 3640
import java.util.*;

class C {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int T = sc.nextInt();
        for (int i = 0; i < T; i++) {
            final int N = sc.nextInt();
            final int D = sc.nextInt();
            if(N % 2 == 1)
                System.out.println(D + (N - 1) * 127);
            else
                System.out.println((D ^ 127) + (N - 1) * 127);
        }
    }
}

public class Main {
    public static void main(String... args) {
        C.main();
    }
}

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

using namespace std;

string s;
int ct[26];
long long ans = 1;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        ans += i - ct[s[i] - 'a'];
        ct[s[i] - 'a']++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
import sys

# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
# import heapq
import bisect


# def input():
#     return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = sorted(list(map(int, input().split())))
    mod = 10 ** 9 + 7

    if N == K:
        ans = 1
        for i in range(N):
            ans *= A[i]
            ans %= mod
        print(ans % mod)



    elif K % 2 == 0:
        ans = 1
        j = 0
        i = N - 1
        for _ in range(K // 2):
            if A[j] * A[j + 1] > A[i] * A[i - 1]:
                ans *= A[j] * A[j + 1]
                ans %= mod
                j += 2
            else:
                ans *= A[i] * A[i - 1]
                ans %= mod
                i -= 2
        print(ans % mod)

    elif A[-1] < 0:
        ans = 1
        for i in range(K):
            ans *= A[-(i + 1)]
            ans %= mod
        print(ans % mod)
    else:
        ans = A[-1]
        j = 0
        i = N - 2
        for _ in range(K // 2):
            if A[j] * A[j + 1] > A[i] * A[i - 1]:
                ans *= A[j] * A[j + 1]
                ans %= mod
                j += 2
            else:
                ans *= A[i] * A[i - 1]
                ans %= mod
                i -= 2
        print(ans % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106268
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????

NEXT = 2
DATA = 1
PREV = 0
from collections import deque
def dll_processor(operations):
    
    front = None
    end = None
    dll = deque([])
    for o in operations:
        if o[0] == "insert":
            dll.appendleft(o[1])
            #front, end = insert(front, end, o[1])
        elif o[0] == "delete":
            if o[1] in dll:
                dll.remove(o[1])
            #front, end = delete(front, end, o[1])
        elif o[0] == "deleteFirst":
            dll.popleft()
            #front, end = delete_first(front, end)
        elif o[0] == "deleteLast":
            dll.pop()
            #front, end = delete_last(front, end)
        #print(get_list(front))
        
    return dll

def get_list(front):
    if not front:
        return []
    
    l = []
    target = front
    while True:
        l.append(target[DATA])
        if not target[NEXT]:
            break
        target = target[NEXT]
    return l

def insert(front, end, target):
    node = [None, target, None]
    if front:
        front[PREV] = node
        node[NEXT] = front
        return node, end
    else:
        return node, node
    
def delete(front, end,target):

    delete_node = front
    while not delete_node[DATA] == target:
        delete_node = delete_node[NEXT]
        if delete_node == None:
            return front, end

    if delete_node[PREV] == None:
        delete_node[NEXT][PREV] = None
        return delete_node[NEXT], end
    elif delete_node[NEXT] == None:
        delete_node[PREV][NEXT] = None
        return front, delete_node[PREV]
    else:
        delete_node[NEXT][PREV] = delete_node[PREV]
        delete_node[PREV][NEXT] = delete_node[NEXT]
        return front, end
    
def delete_last(front, end):
    
    if not end[PREV]:
        return None, None
    else:
        end[PREV][NEXT] = None
        return front, end[PREV]
    
def delete_first(front, end):
    
    if not front[NEXT]:
        return None, None
    else:
        front[NEXT][PREV] = None
        return front[NEXT], end

def main():
    n_list = int(input())
    target_list = [input().split() for i in range(n_list)]
    print(*dll_processor(target_list))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 557264
def main():
    class segtree():
        def __init__(self,basesize):#self,モノイド,元の配列
            #ini：上限（下限）,base：元の配列,monoid：モノイド,tree：セグ木,depth：treeの深さ,
            #basesize：baseの要素数,treesize：treeの要素数,num：treesize-basesize
            
            # 初期値（上限とか下限）を決定
            self.ini=10**9+1
            #セグ木の要素数（num）および深さ（depth）を計算
            self.basesize=basesize
            self.num,self.depth=1,1
            while self.num<self.basesize:
                self.num*=2
                self.depth+=1
            self.num-=1
            #関数（モノイド、今回はmin）を設定
            self.monoid=min
            #セグ木を構築
            self.treesize=self.num+self.basesize
            self.tree=[self.ini]*self.treesize
    
        #半開区間[lower,upper)について更新の準備をする関数（テスト中、minやmaxのときのみ）
        def range_update_pre(self,lower,upper,new_value):
            q=[[0,1]]  #インデックス、階層
            while q:
                i,f=q.pop()
                #popしたインデックスと階層から、求める下限と上限を算出する
                #幅
                width=pow(2,self.depth-f)
                #下限と中央と上限
                kagen=(i-pow(2,f-1)+1)*width
                chuo=kagen+width//2
                jogen=kagen+width
                k=2*i+1
                if lower<=kagen and jogen<=upper:
                    self.tree[i]=self.monoid(new_value,self.tree[i])
                    continue
                if k<self.treesize:
                    if lower<=kagen and chuo<=upper:self.tree[k]=self.monoid(new_value,self.tree[k])
                    elif lower<=chuo:q.append([k,f+1])
                if k+1<self.treesize:
                    if lower<=chuo and jogen<=upper:self.tree[k+1]=self.monoid(new_value,self.tree[k+1])
                    elif chuo<=upper:q.append([k+1,f+1])

        #更新
        def range_update(self):
            for i in range(1,self.treesize):
                self.tree[i]=self.monoid(self.tree[i],self.tree[(i-1)//2])
    from sys import stdin
    input=stdin.readline
    import bisect

    n,q=map(int,input().split())
    stx=[list(map(int,input().split())) for _ in [0]*n]
    d=[int(input()) for _ in [0]*q]
    stx=[[s-x,t-x-1,x] for s,t,x in stx]
    stx=[[bisect.bisect_left(d,s),bisect.bisect_right(d,t),x] for s,t,x in stx]
    seg=segtree(q)
    for s,t,x in stx:
        if s<t:
            seg.range_update_pre(s,t,x)
    seg.range_update()
    ans=[i for i in seg.tree[seg.treesize-seg.basesize:]]
    for i in ans:
        if i==10**9+1:
            print(-1)
        else:
            print(i)
main()

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

int main(){
	int N;
	cin >> N;
	int x[N], y[N], h[N], Cx, Cy, H;
	int num;
	for(int i=0; i<N; i++){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i]!=0){
			num = i;
		}
	}
	int flag2;
	for(Cx=0; Cx<101; Cx++){
		for(Cy=0; Cy<101; Cy++){
			flag2 = 0;
			H = h[num] + abs(x[num]-Cx) + abs(y[num]-Cy);
			for(int i=0; i<N; i++){
				if(max((H-(abs(x[i]-Cx)+abs(y[i]-Cy))),0)!=h[i]){
					flag2 = 1;
					break;
				}
			}
			if(!flag2) break;
		}
		if(!flag2) break;
	}
	cout << Cx << " " << Cy << " " << H << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 

    class Program
    {
        static void Main(string[] args)
        {

            int[] xyz = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 2; i++)
                {
                    if (xyz[i] > xyz[i + 1])
                    {
                        int tmp = xyz[i];
                        xyz[i] = xyz[i + 1];
                        xyz[i + 1] = tmp;
                    }
                }
            }

            Console.WriteLine("{0} {1} {2}",xyz[0],xyz[1],xyz[2]);
        }
        
    }
}

Measured memory_bytes: 9624
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;

const int maxn=100010;
int n,k;
vector<int> g[maxn];

void read(int& x){
	x=0; char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
}
int dep[maxn], ans, fa[maxn];
void dfs(int x){
	dep[x]=1;
	for(int i=0;i<g[x].size();i++){
		int v=g[x][i];
		dfs(v);
		dep[x]=max(dep[x], dep[v]+1);
	}
	if(fa[x]!=1 && dep[x]==k) dep[x]=0, ans++;
}

int main(){

	read(n), read(k);
	for(int i=1;i<=n;i++){
		read(fa[i]);
		if(i!=1) g[fa[i]].push_back(i);
	}
	if(fa[1]!=1) ans++; fa[1]=1;
	dfs(1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 11264
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "";
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='0')
                ans+="0";
            if(s.charAt(i)=='1')
                ans+="1";
            if(s.charAt(i)=='B'){
                if(ans.length()>0)
                    ans = ans.substring(0,ans.length()-1); //要素の最初からansに格納されている要素数-1までの要素を抜き出してansへ(末尾の削除)
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
import numpy as np
(n,m,x)=map(int,input().split())

a=list()
for i in range(n):
    line=list(map(int,input().split()))
    a.append(line)

a=np.array(a)
result=np.array([[0]*(m+1)])
for i in range(n):
    l=list()
    for j in range(len(result)):
        l.append(a[i]+result[j])
        l.append(result[j])
    result=np.array(l)

c=list()
h=[x]*m
for line in result:
    if np.all(line[1:]>=h):
        c.append(line[0])
if len(c)==0:
    print(-1)
else:
    print(min(c))

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

int keta(int N) {
  int keta = 0;
  while (N > 0) {
    keta++;
    N /= 10;
  }
  return keta;
}

int main()
{
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (keta(i)%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int s[14],h[14],c[14],d[14],i,su,num;
  char jo;

  for(i=0;i<14;i++) s[i]=1;
  for(i=0;i<14;i++) h[i]=1;
  for(i=0;i<14;i++) c[i]=1;
  for(i=0;i<14;i++) d[i]=1;
  scanf("%d",&su);

  for(i=0;i<su;i++){
    scanf("%c",&jo);
    scanf("%c %d",&jo,&num);
    if(jo=='S') s[num] = 0;
    else if(jo=='H') h[num] = 0;
    else if(jo=='C') c[num] = 0;
    else if(jo=='D') d[num] = 0;
  }
  for(i=1;i<14;i++) if(s[i]==1) printf("S %d\n",i);
  for(i=1;i<14;i++) if(h[i]==1) printf("H %d\n",i);
  for(i=1;i<14;i++) if(c[i]==1) printf("C %d\n",i);
  for(i=1;i<14;i++) if(d[i]==1) printf("D %d\n",i);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> dp(n, (int)1e9); 
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);
  for (int i = 2; i < n; i++){
    for (int j = 0; j <= k; j++)
      if (i - j >= 0)
        dp[i] = min(dp[i], (dp[i-j] + abs(a[i] - a[i - j])));
  }
  cout << dp[n-1] << '\n';

  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX = 100100;
int d, n, m, a;
int S[MAX];


int main() {
    while (cin >> d) {
        if (d == 0) break;
        
        cin >> n >> m;
        memset(S, 0, sizeof(S));
        for (int i = 1; i < n; ++i) cin >> S[i];
        S[n] = d;
        sort(S, S+n+1);
        
        long long res = 0;
        for (int i = 0; i < m; ++i) {
            cin >> a;
            int it = upper_bound(S, S+n, a) - S;
            int tmp = min( abs(a - S[it]), abs(a - S[it-1]) );
            res += tmp;
        }
        
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1572
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);
  printf("%zu\n", std::set<int>(a.begin(), a.end()).size());
}



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

int main() {
	int h,w,d,i,j,ans;
	cin >> h >> w >> d;
	vector<int> a(h*w);
	vector<pair<int,int>> p(h*w);
	vector<int> dis(h*w,0);
	for(i=0; i<h*w; i++){
		cin >> a[i];
		a[i]--;
	}
	
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			p[a[i*w+j]]={i,j};
		}
	}
	/*
	for(i=0; i<h*w; i++){
		cout << p[i].first << ' ' << p[i].second << endl;
	}
	*/
	for(i=d; i<h*w; i++){
		dis[i]=dis[i-d]+abs(p[i].first-p[i-d].first)+abs(p[i].second-p[i-d].second);
	}
	
	int q,query,l,r;
	cin >> query;
	for(q=0; q<query; q++){
		cin >> l >> r;
		l--; r--;
		cout << dis[r]-dis[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}

int main()
{
    int n;
    cin >> n;
    vector<int> coins = {25, 10, 5, 1}; 
    int ans=0, tmp;
    FOR(i, 0, coins.size()){
        ans += n / coins[i];
        n %= coins[i];
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char> > vec(h,vector<char>(w));
    rep(i,h)rep(j,w)cin >> vec.at(i).at(j);
    rep(i,w+2)cout << '#';
    cout << endl;
    rep(i,h){
        cout << '#';
        rep(j,w)cout << vec.at(i).at(j);
        cout << '#' << endl;
    }
    rep(i,w+2)cout << '#';
    cout << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int n, m;
    cin >> n >> m;
    int p[m];
    string s[m];
    rep(i, m) {
        cin >> p[i] >> s[i];
        p[i]--;
    }
    int c[n];
    fill(c, c + n, 0);
    int pena[n];
    fill(pena, pena + n, 0);
    int ans = 0;
    int num = 0;

    rep(i, m){
        if (c[p[i]] == 0){
            if (s[i] == "WA"){
                pena[p[i]]++;
            }else{
                c[p[i]]++;
            }
        }
    }
    // rep(i, n){
    //     cout << pena[i] << endl;
    // }
    rep(i, n) {
        if (c[i] > 0){
            ans++;
            num += pena[i];
        }
    }
    cout << ans << " " << num << endl;
}

Measured memory_bytes: 6912
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(map(int, input().split()))
import bisect
ans = 0
 
for i in B:
    iA = bisect.bisect_left(A, i)
    iB = bisect.bisect_right(C, i)
    ans += (iA)*(N-iB)
print(ans)

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b) {return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b) {return a = (a < b ? a : b);}

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) break;
		vector<int> v(m);
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			chmax(v[a - 1], b);
		}
		cout << accumulate(all(v), 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  int ans = -1;

  if (M == 0) { // M=0ならば、指定なしなのでその桁の最小値
    if (N == 1) {
      cout << 0;
    }
    else {
      cout << pow(10 ,N-1);
    }
    return 0;
  }

  int s, c;
  int d[3];
  for (int i = 0; i < 3; i++) {
    d[i] = -1; //cがとりえない値を入れる
  }
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (s > N) { // 桁数オーバーをチェック
      cout << ans;
      return 0;
    }

    if (d[s - 1] != -1 && d[s - 1] != c) { //既に入っている情報をチェック
      cout << ans;
      return 0;
    }

    if (N != 1 && s == 1 && c == 0) { //先頭ゼロをチェック
      cout << ans;
      return 0;
    }

    d[s - 1] = c;
  }

  for (int i = 0; i < 3; i++) {
    if (d[i] == -1) {
      d[i] = 0;
    }
  }
 
  if (N == 3 ) {
    if (d[0] == 0) {
      d[0] = 1;
    }
    ans = d[0] * 100 + d[1] * 10 + d[2];
  }
  if (N == 2 ){
    if (d[0] == 0) {
      d[0] = 1;
    }
    ans = d[0] * 10 + d[1];
  }
  if (N == 1) {
    ans = d[0];
  }



  cout << ans;
  return 0;

}


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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 100005;

std::vector<int> g[MAXN];
int vis[MAXN], dp[MAXN];

void dfs (int u) {

	vis[u] = true;
	
	for (int v : g[u]) {
		if (!vis[v]) dfs (v);
		dp[u] = max (dp[u], 1 + dp[v]);
	}
}

int main () {

	int n, m;
	scanf("%d %d", &n, &m);

	while (m--) {
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
	}

	int ans = 0;

	for (int i = 1; i <= n; ++i) {
		if (!vis[i]) {
			dfs (i);
			ans = max (ans, dp[i]);
		}
	}
	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 8576
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, M, cnt = 0, tmp, ans = 0;
	cin >> N >>  M;
	vector<int> K(N);
	//vector<vector<long long>> A = vector<vector<long long>>(N);
	map<int, int> mp;
	for (int i = 1; i <= M; i++) {
		mp[i] = 0;
	}
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> tmp;
			//A[i].push_back(tmp);
			mp[tmp]++;
		}
	}

	for (int i = 1; i <= M ; i++) {
		if (mp[i] == N) ans++;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int even[] = new int[100005];
		int odd[] = new int[100005];

		for (int i = 0; i < n; i++) {
			int v = Integer.parseInt(str[i]);
			if (i % 2 == 0)
				even[v]++;
			else
				odd[v]++;
		}

		int maxE = 0;
		int maxO = 0;
		int maxEE = 0;
		int maxOO = 0;

		int maxEI = 0;
		int maxOI = 0;

		for (int i = 0; i < 100005; i++) {
			if (maxE < even[i]) {
				maxE = even[i];
				maxEI = i;
			}
			if (maxO < odd[i]) {
				maxO = odd[i];
				maxOI = i;
			}
		}

		if (maxEI == maxOI) {
			for (int i = 0; i < 100005; i++) {
				if (maxEE < even[i] && i != maxEI) {
					maxEE = even[i];
				}
				if (maxOO < odd[i] && i != maxOI) {
					maxOO = odd[i];
				}
			}
			int ans = Math.min(n - maxE - maxOO, n - maxEE - maxO);
			System.out.println(ans);
		} else
			System.out.println(n - maxE - maxO);

	}
}


Measured memory_bytes: 45784