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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;

struct edge{int to, cap, cost, rev;};

int n, m;
vector<vector<edge>> g;
vector<int> dist, prevv, preve;

void add_edge(int from, int to, int cap, int cost){
  g[from].push_back({to, cap, cost, int(g[to].size())});
  g[to].push_back({from, 0, -cost, int(g[from].size())-1});
}

int min_cost_flow(int s, int t, int f){
  int res = 0;
  while(f > 0){
    dist = vector<int>(n, INT_MAX);
    dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      for (int v = 0; v < n; v++) {
        if(dist[v] == INT_MAX) continue;
        for(int i = 0; i < int(g[v].size()); i++){
          auto &e = g[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }

    if(dist[t] == INT_MAX) return -1;

    int d = f;
    for (int v = t; v != s; v = prevv[v]) {
      d = min(d, g[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[t];
    for (int v = t; v != s; v = prevv[v]) {
      auto &e = g[prevv[v]][preve[v]];
      e.cap -= d;
      g[v][e.rev].cap += d;
    }
  }
  return res;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int f;
  cin >> n >> m >> f;
  g = vector<vector<edge>> (n);
  dist = vector<int>(n+100);
  prevv = vector<int>(n+109);
  preve = vector<int>(n+100);
  for (int i = 0; i < m; i++) {
    int from, to, c, d;
    cin >> from >> to >> c >> d;
    add_edge(from, to, c, d);
  }

  cout << min_cost_flow(0, n-1, f) << endl;
}



Measured memory_bytes: 3260
h,w = map(int, input().split())
l = [None]*h
for i in range(h):
    l[i] = list(input())

from collections import deque

def solve(x,y):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    start = [x, y]
    dist = [[10**3]*w for i in range(h)]
    dist[y][x] = 0
    Q = deque()
    Q.append(start)
    mx = 0

    while Q:
        p = Q.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < w and 0 <= ny < h:
                if l[ny][nx]=="." and dist[ny][nx]==10**3:
                    Q.append([nx, ny])
                    dist[ny][nx] = dist[p[1]][p[0]] + 1
                    if mx < dist[ny][nx]:
                        mx=dist[ny][nx]
    return mx

ans=0
for i in range(h):
    for j in range(w):
        if l[i][j]=="#":
            continue

        res=solve(j,i)
        if res > ans:
            ans=res

print(ans)

Measured memory_bytes: 3444
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int a, b, c;
LL k;

int main() {
scanf("%d %d %d %lld", &a, &b, &c, &k);
if (k % 2 == 1) printf("%d\n", b - a); else printf("%d\n", a - b);
return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();

        System.out.println(Z + " " + X + " " + Y);
    }

}

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

public class Main {

	void submit() {
		int n = nextInt();
		int[][] a = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = nextInt();
			}
		}
		
		int[][] b = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				if (i > 0) {
					b[i][j] = Math.max(b[i][j], b[i - 1][j]);
				}
				if (j > 0) {
					b[i][j] = Math.max(b[i][j], b[i][j - 1]);
				}
				b[i][j] += a[i][j];
			}
		}
		
		out.println(b[1][n - 1]);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21204
var
	N,i,s,a,b:Longint;
	X:Array[1..100]of Longint;
begin
	read(N);
	for i:=1 to N do begin
		read(X[i]);
		inc(s,X[i]);
	end;
	s:=s div N;
	for i:=1 to N do begin
		inc(a,(s-X[i])*(s-X[i]));
		inc(b,(s+1-X[i])*(s+1-X[i]));
	end;
	if a>b then a:=b;
	writeln(a);
end.


Measured memory_bytes: 128
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val n = readInt()

    val a = mutableListOf<Int>(0)
    val tmp = readListOfInt()
    a.addAll(tmp)
    a.add(0)

    var total = 0
    for(i in 1 until n+2) {
        total += Math.abs(a[i] - a[i-1])
    }
    
    for(i in 1 until n+1) {
        val plan = total + Math.abs(a[i+1] - a[i-1]) - (Math.abs(a[i] - a[i-1]) + Math.abs(a[i+1] - a[i]))
        println(plan)
    }
    
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 58336
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll mod = 1e9+7;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll res = 0;
	ll s = 0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ll x;
		cin>>x;
		res = (res + s*x)%mod;
		s = (s+x)%mod;
	}
	cout<<res<<"\n";
	return 0;
}

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

int main(){
    while(true){
        string S;
        cin >> S;
        
        if(S == "-") break;
        int n;
        cin >> n;
        
        for(int i = 0; i < n; i++){
            int a;
            cin >> a;
            string ssub = S.substr(0,a);
            S += ssub;
            S.erase(0,a);
        }
        cout << S << endl;
       
    }
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	int n, s[310] = {}, ans = 0;
	cin >> n;
	REP(i, n * 2) cin >> s[i];
	sort(s, s + (n * 2));
	for (int i = 0; i < (n * 2); i += 2) ans += s[i];
	cout << ans << endl;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
#define ll long long

int main(){
    std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
    int n,m,a,cnt=0,ans=0;
    cin>>n>>m;
    while(m--){
        cin>>a;
        cnt+=a;
    }
    if(cnt>n) cout<<"-1"<<endl;
    else{
        cout<<n-cnt<<endl;
    }
}

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

class MainClass
{
    public static void Main(string[] args)
    {
        
        int[] s = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
        int N = s[0];
        int W = s[1];
        int[] v = new int[N];
        int[] w = new int[N];

        for (int i = 0; i < N; i++)
        {
            int[] s1 = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

            v[i] = s1[0];
            w[i] = s1[1];
        }

        int[,] dp = new int[N + 1, W + 1];

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < W + 1; j++)
            {
                if (j >= w[i])
                {
                    dp[i + 1, j] = Math.Max(dp[i, j], dp[i, j - w[i]] + v[i]);
                }
                else
                {

                    dp[i + 1, j] = dp[i, j];
                }
            }
        }

        Console.WriteLine(dp[N, W]);

    }
}

Measured memory_bytes: 13556
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int x, a, b;
    cin>>x;
    for(int i = -1000; i < 1000; i++) {
        for(int j = -1000; j < 1000; j++){
            if(pow(i,5)-pow(j,5) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }    
}

Measured memory_bytes: 4100
#include<stdio.h>
int main(void)
{
    int n,a[100],i,j,g=0,b=0,s,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n-1;i++){
        for(j=i;j<n;j++){
            if(a[i]<a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    for(i=0;i<n;i++){
        if(i%2==0)
            g+=a[i];
        else 
            b+=a[i];
    }
    s=g-b;
    printf("%d\n",s);
    return 0;
}

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

ll dp[110][110000];
ll v[110];
ll w[110];

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

    int N,W;
    cin >> N >> W;
    for(int i=0;i<N;i++){
        cin >> w[i] >> v[i]; 
    }

    for (int j=1;j<W+1;j++){
        if (j < w[0]){
            dp[1][j] = 0;
        }else{
            dp[1][j] = v[0];
        }
    }

    for(int i=2;i<N+1;i++){
        for(int j=1;j<W+1;j++){
            if (j-w[i-1] >0){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }

    }

    cout << dp[N][W] << endl;
}



Measured memory_bytes: 87424
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int n;
	
	cin >> n;
	
	for (int x = 1; x <= 9; x++) {
		if (n % x != 0) continue;
		int y = n / x;
		if (y <= 9) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

ll n;
ll block[301];
ll dp[301][301];
ll f(ll under, ll top){
  if (dp[under][top] != -1) return dp[under][top];
  if (top-under <= 1) return 0;
  ll res = 0;
  if (abs(block[under] - block[top-1]) <= 1 && f(under+1, top-1) == top-under-2){
    res = top - under;
  }
  rep2(middle, under+1, top){
    res = max(res, f(under, middle) + f(middle, top) );
  }
  return dp[under][top] = res;
}

int main(){
  while(1){
    cin >> n;
    if (n == 0) break;
    rep(i, n) cin >> block[i];
    memset(dp, -1, sizeof(dp));
    cout << f(0, n) << endl;
  }
  
  return 0;
}


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

int64_t K, A, B;

int main(){
    cin >> K >> A >> B;

    int64_t ans = 0;
    if( A + 1 < B ){
        K -= A - 1;
        ans = A;
        int64_t coin = K / 2;
        ans += coin * B;
        ans -= coin * A;
        if( K % 2 == 1 )    ans++;
    } else {
        ans = K + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define ll long long int
using namespace std;
int main()
{
  int i,j,k,n;
  string s;
  cin>>n;
  cin>>s;
  j=s.length();
  if(n>=j)
  {
    cout<<s;
  }
  else{
    for(i=0;i<n;i++)
    {
      cout<<s[i];
    }
    cout<<"...";
  }
}

Measured memory_bytes: 3628
N = int(input())

t = [0]
x = [0]
y = [0]
for i in range(N):
    t1, x1, y1 = [int(j) for j in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)

count = 0
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dist > dt:
        break
    elif dt%2 != dist%2:
        break
    else:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11816
S = list(input())
N = len(S) + 1

left = [0] * N
right = [0] * N

#left --> right
for i in range(N - 1):
    if S[i] == '<':
        left[i + 1] = left[i] + 1

#right --> left
for i in range(N - 2, -1, -1):
    if S[i] == '>':
        right[i] = right[i + 1] + 1

# print (left)
# print (right)

ans = 0
for i in range(N):
    ans += max(left[i], right[i])

print (ans)

Measured memory_bytes: 31024
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

void solve() {
    ll n;
    cin >> n;
    bool good = (n%1000)%111==0 || (n/10)%111==0;
    print(good?"Yes":"No");
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3656
// inputに入力データ全体が入る
function Main(input) {
    var output;
    input = input.trim().split("\n")[0];
    var a = input.slice(0,2);
    var b = input.slice(2,4);
    a = parseInt(a,10);
    b = parseInt(b,10);

    if(a == 0 && b == 0){
        output = "NA";
    }
    else if((a == 0 && b > 12) || (a > 12 && b == 0)){
        output = "NA";
    }
    else if(a == 0 && b <= 12){
        output = "YYMM";
    }
    else if(b == 0 && a <= 12){
        output = "MMYY";
    }
    else if(a <= 12 && b <= 12){
        output = "AMBIGUOUS";
    }
    else if(a <= 12 && b > 12){
        output = "MMYY";
    }
    else if(a > 12 && b <= 12){
        output = "YYMM";
    }
    else{
        output = "NA";
    }
    console.log(output);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.Scanner;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() < 6)
            System.out.print("No");
        else{

            if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
                System.out.print("Yes");
            else 
                System.out.print("No");
        }
    }
}

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

struct Rectangle {
    int height;
    int pos;
};

int getLargestRectangle(int size, int buffer[]) {
    // 行ごとに計算する
    stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;

    for (int i = 0; i <= size; i++) {
        Rectangle rect;  // まだ拡張される可能性のある長方形
        rect.height = buffer[i]; // 長方形の高さ
        rect.pos = i; // 左端の位置
        // Sが空->rectを入れる
        // Sが空でない->(Sの上の高さ < rectの高さ)->Sにpush
        // Sが空でない->(Sの上の高さ > rectの高さ)->Sにpush
        if (S.empty()) {
            S.push(rect);
        } else {
            if (S.top().height < rect.height) { // stackの上にある長方形の方がbufferの長方形の高さよりも低い時
                S.push(rect);
            } else if (S.top().height > rect.height) {
                int target = i; // targetをiとする
                // 一番heightが高くなるpreのposをtargetとする
                while (!S.empty() && S.top().height >= rect.height) { // stackに貯まっていて，Sの上にあるものの高さよりrectの高さが高い
                    Rectangle pre = S.top(); // stackの上のものをpreとする
                    S.pop(); // stackの上のものを取り出す
                    int area = pre.height * (i - pre.pos); // preの高さ * (現在の位置 - preの位置)
                    maxv = max(maxv, area); // maxvとareaの最大値を比べて高い方をmaxvを入れる
                    target = pre.pos; // targetを左端とする
                }
                rect.pos = target; // 拡張される可能性のある長方形の左端をtargetとする
                S.push(rect);
            }
        }
    }
    return maxv;
}

int H, W;
int buffer[MAX][MAX]; // 入力のタイル
int T[MAX][MAX]; // 入力から作るタイル

int getLargestRectangle() {
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (buffer[i][j]) { // もしbufferに1が入っていれば
                T[i][j] = 0; // T[i][j]は0
            } else { // もしbufferに0が入っている時
                T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1; // iが0より大きい時， T[i][j] = 上の行の同じ列の値+1
            }
        }
    }

    int maxv = 0;
    for (int i = 0; i < H; i++) {
        maxv = max(maxv, getLargestRectangle(W, T[i]));
    }
    return maxv;
}

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

    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            scanf("%d", &buffer[i][j]); // i行j列目の要素をbufferに入れる
        }
    }
    cout << getLargestRectangle() << endl;
    return 0;
}


Measured memory_bytes: 18580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n ;i++){
			String input = br.readLine();
			
//			int pattern = 0;
			HashSet<String> set = new HashSet<String>();
			for(int j= 1; j < input.length() ; j++){
				String sub1 = input.substring(0, j);
				String sub2 = input.substring(j, input.length());
				String rev1 = new StringBuffer(sub1).reverse().toString();
				String rev2 = new StringBuffer(sub2).reverse().toString();
				
				
				set.add(sub1+sub2);
				set.add(sub1+rev2);
				set.add(rev1+sub2);
				set.add(rev1+rev2);
				set.add(sub2+sub1);
				set.add(sub2+rev1);
				set.add(rev2+sub1);
				set.add(rev2+rev1);
//				System.out.println("j = "+j+" patter "+set.size());
//				System.out.println(set.toString());
//				pattern += set.size();
			}
			
			System.out.println(set.size());
		}
	}

}

Measured memory_bytes: 58908
package main

import "fmt"

func main() {
	// Code for B - Foods Loved by Everyone
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	flag := make(map[int]int, M)
	var K, A int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &K)
		for j := 0; j < K; j++ {
			fmt.Scanf("%d", &A)
			flag[A]++
		}
	}

	var count int = 0
	for i := 1; i <= M; i++ {
		if flag[i] == N {
			count++
		}
	}
	fmt.Println(count)
}


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

int main() {
	
	int a,b,k;
	cin>>a>>b>>k;
	
	for(int i = a; i < min(a+k,b+1); i++)
	{
		cout<<i<<endl;
	}
	for(int i = max(a+k,b-(k-1)); i <= b; i++)
	{
		cout<<i<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3664
class Tree
	attr_accessor :parent, :root, :dep, :key
	def initialize(key)
		@parent = -1
		@root = []
		@dep = nil
		@key = key
	end

	def depth(ans,tree)
		@root.each do |obj|
			tree[obj].depth(ans+1,tree)
		end
		@dep = ans
	end

	def add(data)
		@root << data
	end
end




n = gets.to_i

tree = Hash.new
check = Array.new(n){true}
n.times do |i|
	tree[i] = Tree.new(i)
end

n.times do |i|
	data = gets.split.map(&:to_i)
	num = data.shift
	data.shift
	
	data.each do |obj|
		tree[num].add(obj)
		tree[obj].parent = tree[num]
		check[obj] = false
	end
end
r = check.index(true)
tree[r].depth(0,tree)
num = 0
n.times do |i|
	obj = tree[i]
	jd = nil
	if obj.parent ==-1
		jd = "root"
	elsif obj.root.empty?
		jd = "leaf"
	else 
		jd = "internal node"
	end
	if obj.parent != -1
		puts "node #{num}: parent = #{obj.parent.key}, depth = #{obj.dep}, #{jd}, [#{obj.root.join(", ")}]"
	else
		puts "node #{num}: parent = #{-1}, depth = #{obj.dep}, #{jd}, [#{obj.root.join(", ")}]"
	end
	num+=1
end

Measured memory_bytes: 36320
function main(lines) {
  const input = parseInt(lines, 10)
  const second = parseInt(input%60, 10)
  const minute = parseInt(input/60, 10)%60
  const hour = parseInt(input/(60*60), 10)
  
  console.log(hour + ':' + minute + ':' + second)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 15376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    ll ans = (ll) n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    string S; cin >> S;
    //ll H,W; cin >> H >> W;
  bool ans=false;
  for(int i=0;i<S.length();i++){
    for(int j=i;j<S.length();j++){
      string T=S;
      T.erase(T.begin()+i,T.begin()+j);
      if(T=="keyence")ans=true;
    }
  }
  
  if(ans)  cout << "YES" << endl;
  else cout << "NO";
}

/*



 */


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++,i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)

def main():
    h,w,n = LI()
    sc,sr = LI()
    s = S()
    t = S()
    ra = ri = 0
    ca = ci = 0
    for i in range(n-1,-1,-1):
        si = s[i]
        ti = t[i]

        if ti == 'L':
            if ra > 0:
                ra -= 1
        elif ti == 'R':
            if ri > 0:
                ri -= 1
        elif ti == 'U':
            if ca > 0:
                ca -= 1
        else:
            if ci > 0:
                ci -= 1

        if si == 'L':
            ri += 1
        elif si == 'R':
            ra += 1
        elif si == 'U':
            ci += 1
        else:
            ca += 1

        if ri + ra >= w:
            return 'NO'
        if ci + ca >= h:
            return 'NO'

        # print(ri,ra,'c',ci,ca,'s',sr,sc)

    if sr <= ri or sr + ra > w:
        return 'NO'
    if sc <= ci or sc + ca > h:
        return 'NO'

    return 'YES'


print(main())




Measured memory_bytes: 6228
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
double pi=3.14159265;

int main(){
    while(1){
        int H,W;
        cin >> H >> W;
        if(H==0 && W==0) return 0;
        rep(i,H){
            rep(j,W){
                if((i+j)%2==0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3060
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MODULO = 1_000_000_000 + 7;

	public void run() {
		Scanner sc = new Scanner(System.in);
		long K = sc.nextLong();
		long K_ = K;
		int N = 50;
		long[] a = new long[N];
		Arrays.fill(a, K / 50 + N - 1);
		K -= K / 50 * 50;
		while (K > 0) {
			Arrays.sort(a);
			a[0] += N;
			for (int i = 1; i < N; ++i) {
				--a[i];
			}
			Arrays.sort(a);
			--K;
		}
		System.out.println(N);
		for (int i = 0; i < N; ++i) {
			System.out.print(a[i] + (i == N - 1 ? "\n" : " "));
		}
	}

	long f(long[] a, long k) {
		int n = a.length;
		long s = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] + k <= n - 1) {
				continue;
			} else {
				long res = a[i] + k - (n - 1);
				s += (res + n) / (n + 1);
			}
		}
		return k - s;

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 22356
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = input()

k = 0

for i in range(len(n)):
    k += int(n[i])

if k % 9 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9296
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	int n,m;
	int p[10];
	int k[10];
	bool s[10][10];
	fill(s[0],s[10],false);
	ll ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>k[i];
		for(int j=0;j<k[i];j++)
		{
			int tmp;
			cin>>tmp;
			tmp--;
			s[i][tmp]=true;
		}
	}
	for(int i=0;i<m;i++)
		cin>>p[i];

	//bit
	for(int bit=0;bit<(1<<n);bit++)
	{
		bool sw[10];
		bool f=true;
		fill(sw,sw+10,false);
		for(int i=0;i<10;i++)
		{
			if((bit&(1<<i))>0)
				sw[i]=true;
		}

		for(int i=0;i<m;i++)
		{
			int cnt=0;
			for(int j=0;j<10;j++)
			{
				if(s[i][j] && sw[j])
					cnt++;
			}
			if((cnt&1)!=p[i])
				f=false;

		}
		if(f)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	long long n; cin >> n;
	if (n % 2 == 0) {
		long long ans = 0, m = n / 2;
		while (m > 0) {
			ans += m / 5;
			m /= 5;
		}
		cout << ans << endl;
	}
	else cout << 0 << endl;

	return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	ll N, W;
	cin >> N >> W;
	vi weight(N + 10), value(N + 10);
	rep(i, 0, N) {
		cin >> weight[i] >> value[i];
	}
	vvi dp(N + 10, vi(W + 10, 0));

	rep(i, 0, N) {
		rep(w, 0, W + 1) {
			if (w >= weight[i])
				chmax(dp[i + 1][w], dp[i][w - weight[i]] + value[i]);
			chmax(dp[i + 1][w], dp[i][w]);
		}
	}

	cout << dp[N][W] << endl;
}

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

	Main();
	return 0;
}


Measured memory_bytes: 90204
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a,b;
    cin >> a >> b;
    if((a+b)&1==1) pr("IMPOSSIBLE");
    else pr((a+b)/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  char c;
  int cost = 700;
  REP(i,3){
  	cin >> c;
    if(c == 'o') cost += 100;
  }
  cout << cost << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int change(int x)
{
	if(x==1)
	return 0;
	else
	return 1;
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(m==n)
    cout<<"Yes";
    else
    cout<<"No";
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int H,W;
    char A;
    int Sum=0;
    cin >> H >> W;
    REP(i,H){
        REP(j,W){
            cin >> A;
            if(A=='#'){
                Sum++;
            }
        }
    }
    if(Sum==H+W-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	LL A,B,C,K;
	cin >> A >> B >> C >> K;
	LL ans = 0;
	if(K % 2 == 0) ans = A-B;
	else ans = B-A;

	cout << ans<< endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

int main()
{
	int N;
	vector<int> A;
	int c = 0;
	int temp;
	int min;

	cin >> N;
	A.reserve(N);

	REP(i, N)
		cin >> A[i];

	REP(i, N) {
		min = i;
		for(int j = i + 1; j < N; ++j) {
			if(A[j] < A[min]) {
				min = j;
			}
		}

		if(min != i) {
			temp = A[min];
			A[min] = A[i];
			A[i] = temp;
			++c;
		}
	}

	REP(i, N) {
		cout << A[i];
		(i != N - 1)?
			cout << ' ' : cout << endl;
	}
	cout << c << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<int, ll> cnt;
    rep(i, N) {
        int a;
        cin >> a;
        cnt[a] += 1;
    }

    ll res = 0;
    for (auto p : cnt) {
        if (p.second >= p.first)
            res += p.second - p.first;
        else
            res += p.second;
    }

    cout << res << endl;
}

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

int main(){
	int N, a[110], t, X, Y, Z, A = 0, B = 0 ,C = 0;
	
	for(int i = 0; i < 110; i++) a[i] = 1;
	
	cin>>N;
	
	cin>>X;
	
	for(int i = 0; i < X; i++){
		cin>>t;
		a[t] *= 2;
	}
	
	cin>>Y;
	for(int i = 0; i < Y; i++){
		cin>>t;
		a[t] *= 3;
	}
	
	cin>>Z;
	for(int i = 0; i < Z; i++){
		cin>>t;
		a[t] *= 5;
	}
	
	
	for(int i = 1; i <= N; i++){
		if(a[i]%5 == 0)A++;
		if(a[i]%10 == 0) B++;
		if(a[i]%30 == 0) C++;
	}
	
	cout<<A - B + C<<endl;
	
	return 0;
}


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

int main(){
    
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0) cout<<"Zero"<<endl;
    else if(a>0) cout<<"Positive"<<endl;
    else if((b-a)%2==1) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(), a.end());
    
    mint ans = 0;
    rep(i,n){
        ans += (c(i,k-1) - c(n-i-1,k-1))*a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 19236
def gcd(a, b):
    if(a < b):
        a, b = b, a
    if(b == 0):
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b

N = int(input())
A = list(map(int, input().split()))
l = 1
for a in A:
    l = lcm(l, a)
ans = 0
mod = 10**9+7
l %= mod
for a in A:
    ans += (l * pow(a, mod-2, mod))%mod
    ans %= mod
print(ans)


Measured memory_bytes: 4084
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = []
j = 1
for i in range(n):
    B.append(j)
    j = A[j-1]
    
visited = [-1] * (n+1)
cs = -1
i = 1
count = 0
while True:
    visited[i] = count
    count += 1
    i = A[i-1]
    if visited[i] != -1:
        cs = i
        break
#print (count, count-visited[cs], cs, visited[cs])
if k < n:
    print(B[k])
    exit()
cl = count - visited[cs]
a =(k-visited[cs]) % cl
current = cs-1
for i in range(a):
    current = A[current] -1
print(current+1)

Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	str s;
	cin >> s;
	int ans = 0;
	if (s[0] == 'R')
	{
		ans++;
		if (s[1] == 'R')
		{
			ans++;
			if (s[2] == 'R')
			{
				ans++;
			}
		}
	}
	else if (s[1] == 'R')
	{
		ans++;
		if (s[2] == 'R')
		{
			ans++;
		}
	}
	else if (s[2] == 'R')
	{
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
    int N;
    long long a[1000000];
    long long max = 0, min = 9999999999, i;
    
    scanf("%d", &N);
    //printf("%d\n", N);
    
    for(i = 0; i < N; i++){
        scanf("%lld", &a[i]);
        //printf("%lld\n", a[i]);
    }
    
    for(i = 0; i < N; i++){
        if(max <= a[i]){
            max = a[i];
        }
    }
    //printf("%lld\n", max);
    for(i = 0; i < N; i++){
        if(min >= a[i]){
            min = a[i];
        }
    }
    //printf("%lld\n", min);
    
    printf("%lld\n", max - min);
    
}


Measured memory_bytes: 1744
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , a;
    cin >> n;
    set < int > s;
    for( int i = 0 ; i < n ; i++ ){
        cin >> a;
        if ( s.count(a) == 1 ) s.erase(a);
        else s.insert(a);
    }
    cout << s.size();
}






Measured memory_bytes: 4992
#include<stdio.h>
 
void f(int n)
{
    if(!n)
        return;
    f(n/4);
    printf("%d",n%4);
}
int main()
{
    int s;
    for(;scanf("%d",&s),s!=-1;s?f(s):printf("%d",0),puts(""));
    return 0;
}

Measured memory_bytes: 612
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m;
char a[10005];

int main()
{
    cin >> n >> m;
    cin >> a;
    if(a[m-1] == 'A') a[m-1] = 'a';
    if(a[m-1] == 'B') a[m-1] = 'b';
    if(a[m-1] == 'C') a[m-1] = 'c';
    cout << a;
}

#endif // 1++

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

int main() {
  // 入力部(N)
  int N;
  cin >> N;

  // 約数をちょうど8つ持つ奇数の個数をカウントする変数。
  int ans = 0;

  // 奇数のみをカウントするので1からスタートして2ずつ増やす。
  for(int i = 1; i <= N; i+=2) {
    // i の約数の個数をカウントする変数。
    int cnt = 0;

    // 1以上i以下の範囲で全探索。
    for(int j = 1; j <= i; j++) {
      // i % j == 0 の場合の時の j は iの約数 である。
      if(i % j == 0) {
        cnt++;
      }
    }

    // 約数がちょうど8個の場合、ansに1を加算
    if(cnt == 8) {
      ans++;
    }
  }

  // ansは 約数をちょうど8つ持つ整数の個数をカウントする変数 なのでそのまま出力。
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

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

	bool ok = true;
	rep (i, s.size()) if (s[i] != t[i]) ok = false;

	if (ok)yn
	return 0;
}

Measured memory_bytes: 3628
C = [0] * 3
for i in range(3):
  C[i] = list(map(int, input().split()))
for i in range(3):
  D = [0] * 3
  for j in range(3):
    D[j] = C[i][j] - C[i - 1][j]
  if D[0] != D[1] or D[1] != D[2] or D[2] != D[0]:
    print('No')
    exit()
for i in range(3):
  D = [0] * 3
  for j in range(3):
    D[j] = C[j][i] - C[j][i - 1] 
  if D[0] != D[1] or D[1] != D[2] or D[2] != D[0]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string s;cin>>s;
  string t="keyence";
  int ok=0;
  for(int i=0;i<s.size();i++){
    for(int j=i-1;j<s.size();j++){
      if(s.size()-(j-i+1)!=7)continue;
      int out=0;
      int a=0;
      for(int n=0;n<s.size();n++){
        if(n>=i&&n<=j)continue;
        if(s[n]!=t[a])out++;
        a++;
      }
      if(out==0)ok++;
    }
  }
  if(ok)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
numbers = []
n = raw_input()
numbers = n.split(" ")
for i in range(5):
	numbers[i] = int(numbers[i])
W = numbers[0]
H = numbers[1]
x = numbers[2]
y = numbers[3]
r = numbers[4]

if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H:
	print "Yes"
else:
	print "No"

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

int main() {
	int n,l;
	cin>>n>>l;
	vector<string> s(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s.begin(),s.end());
	for(auto x : s){
		cout<<x;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
while(True):
    s = input()
    t = s.split()
    H,W = int(t[0]),int(t[1])

    if H == 0 and W == 0:
        break
    else:
        for h in range(H):
            c = '#.'
            out_c = c * int(W/2)
            if W%2 == 1:
                out_c = out_c + c[0]
            if h%2 == 1:
                out_c = out_c[1:] + c[int(W%2)]
            print(out_c)
        else:
            print('')
            


Measured memory_bytes: 5620
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int n, c1, c2, r, w;
char a[1005][1005];
string g[4] = {"aabcddbcbcaabcdd", "aabbabcc.ab..cba..cbabbaa", "aabc..ddbc....aabc..ddbcbc..aabc..dd", "aabbcc.dd.dd.a..d..da..d..dbdd.dd.b..d..dc..d..dc"};
int main()
{
	int i, j, k;
	cin >> n;
	if (n == 2) {
		cout << -1 << endl;
		return 0;
	}
	if (n == 3) {
		cout << "aa." << endl << "..a" << endl <<"..a";
		return 0;
	}
	c1 = n / 4;
	c2 = n % 4;
	c1--;
	memset(a, '.', sizeof(a));
	r = 0;
	for (i = 0; i < c1; i++) {
		w = 0;
		for (j = 0; j < 4; j++) {
			for (k = 0; k < 4; k++) {
				a[r + j][r + k] = g[0][w];
				w++;
			}
		}
		r += 4;
	}
	w = 0;
	for (j = 0; j < 4 + c2; j++) {
		for (k = 0; k < 4 + c2; k++) {
			a[r + j][r + k] = g[c2][w];
			w++;
		}
	}
	for (i = 0; i < n; i++) {
		for (j =0; j < n; j++) {
			printf("%c", a[i][j]);
		}
		puts("");
	}
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;
int main()
{
    int a;
    int b;
    cin>>a>>b;
    if (a-b>=1)
    {
        cout<<2*a-1;
    }
    if (b-a>=1)
    {
        cout<<2*b-1;
    }
    if (a-b==0)
    {
        cout<<a+b;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 110;
int n;
int G[MAX][MAX];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    memset(G, 0, sizeof(G));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int p, k;
        scanf("%d %d", &p, &k);
        while (k--) {
            int ne = 0;
            scanf("%d", &ne);
            G[p][ne] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j > 1) printf(" ");
            printf("%d", G[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3256
from itertools import product

n, m = map(int, input().split())
# スイッチがn個
# 電球がm個
k = []
for i in range(m):
    k.append(list(map(int, input().split())))
p = list(map(int, input().split()))

count = 0

for i in product([0,1], repeat=n):
    switch = []
    for j in range(m):
        on = 0
        for l in range(k[j][0]):
            if i[k[j][l+1]-1] == 1:
                on += 1
        if on % 2 == p[j]:
            switch.append(1)
    if sum(switch) == m:
        count += 1

print(count)



Measured memory_bytes: 9076