akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


int main()
{
	int A, B, C, D;
	int square1, square2;


	scanf("%d %d %d %d", &A, &B, &C, &D);

	square1 = A * B;
	square2 = C * D;

	if(square1 > square2)
		printf("%d\n", square1);
	else if(square2 > square1)
		printf("%d\n", square2);
	else
		printf("%d\n", square1);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main(int argc, char *argv[])
{
  int n, k = -1, i, j;
  int *A, *B, *C;
 
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    k = (int)fmax(k, A[i]);
    B[i] = 0;
  }
  C = (int *)malloc(sizeof(int) * (k + 1));
 
  for (i = 0; i <= k; i++) C[i] = 0;
  for (i = 0; i < n; i++) C[A[i]]++;
  //for (i = 1; i <= k; i++) C[i] += C[i-1];
  j = 0;
  while (C[j] == 0) j++;
  for (i = 0; i < n; i++) {
    B[i] = j;
    C[j]--;
    while (C[j] == 0) j++;
  }
 
  for (i = 0; i < n; i++) {
    if (i != n - 1) printf("%d ", B[i]);
    else printf("%d\n", B[i]);
  }
 
  return 0;
}

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

string s;

int main()
{
	cin>>s;
	if(s=="SAT")
		printf("1\n");
	if(s=="FRI")
		printf("2\n");
	if(s=="THU")
		printf("3\n");
	if(s=="WED")
		printf("4\n");
	if(s=="TUE")
		printf("5\n");
	if(s=="MON")
		printf("6\n");
	if(s=="SUN")
		printf("7\n");
	
	return 0;
}

Measured memory_bytes: 256
import math
def solver():
    n, m = map(int, input().split())
    def comb(n, r):
        if n - r < 0:
            return 0
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    print(comb(n, 2) + comb(m, 2))


if __name__ == '__main__':
    solver()


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(void) {

	long long n, a[100], cost = 0, sum = 0, minc = 99999999;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (int i = -100; i <= 100; i++)
	{
		cost = 0;
		for (int k = 0; k < n; k++)
		{
			cost += int(pow(a[k]-i, 2));
		}
		minc = min(minc, cost);
	}

	cout << minc << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MAX_N 21
#define INF 1e+9
using namespace std;
int main(void){
	int n,m;cin>>n>>m;
	int g[MAX_N][MAX_N];
	for(int i=0;i<MAX_N;++i)for(int j=0;j<MAX_N;++j)g[i][j]=INF;
	for(int i=0,a,b,c,d;i<m;++i){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		g[a][b]=c;
		g[b][a]=d;
	}
	int d[MAX_N][MAX_N];
	for(int i=0;i<MAX_N;++i)for(int j=0;j<MAX_N;++j)d[i][j]=(i==j)?0:INF;
	for(int i=1;i<=n;++i){
		bool f=false;
		for(;;){
			for(int j=1;j<=n;++j){//from
				for(int k=1;k<=n;++k){//to
					if(d[i][j]!=INF && d[i][j] + g[j][k] < d[i][k]){
						d[i][k] = d[i][j] + g[j][k];
						f=true;
					}
				}
			}
			if(f==false) break;
			f=false;
		}
	}
	int x1,x2,y1,y2;
	scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
	cout<<y1-y2-d[x1][x2]-d[x2][x1]<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;
    ll A[100005], B[100005];
    ll cnt1[100005], cnt2[100005];

    for (int i = 0;i <= N;i++){
        cin >> A[i];
    }

    for (int i = 0;i < N;i++){
        cin >> B[i];
    }

    ll sum = 0;
    for (int i = 0;i < N;i++){
        sum += min(A[i],B[i]);
        B[i] = max(0LL,B[i]-A[i]);
        sum += min(B[i],A[i+1]);
        A[i+1] -= min(B[i],A[i+1]);
    }

    
    cout << sum << endl;

    return 0;

}

Measured memory_bytes: 1792
from collections import defaultdict

N,K = map(int,input().split())

A = list(map(int,input().split()))

C = defaultdict(int)

for a in A: C[a] += 1

for k,v in sorted(C.items(),key=lambda x:x[1],reverse=True)[:K]:
    N -= v
        
print(N)

Measured memory_bytes: 39340
import java.util.*;
import java.io.*;
import static java.lang.System.*;

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

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String S = sc.next();
    boolean check = true;
    for(int i=0; i<3; i++){
      if(S.charAt(i) == S.charAt(i+1) ){
        check = false;
        break;
      }
    }
    if(check == true) out.println("Good");
    else out.println("Bad");
  }

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

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e6+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n,m;
    cin>>n>>m;
    vector<int> adj[n];
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=0;i<n;i++){
        cout<<adj[i].size()<<endl;
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
 
 
#define mp make_pair
 
using namespace std; 
 
typedef pair<int, int> pii; 
typedef long long int ll;



vector<int> out_e;

bool my_comp(int i, int j)
{
   if (out_e[i] == out_e[j])
        return i < j;
   return out_e[i] < out_e[j];
  
}


int main() {
    //freopen("test.txt", "r", stdin);
    //freopen("my_out.txt", "w", stdout);
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, n, m;
    cin >> n >> m;
    
    set<int, bool (*) (int, int)> vert(&my_comp);
    vector<int> in_e [n];
    out_e.assign(n, 0);
    vector<int> ans(n, 0);
    
    
    int u, v;
    
    for(i = 0; i < m; ++i)
    {
        cin >> u >> v;
        --u, --v;
        out_e[u]+=1;
        in_e[v].push_back(u);
    }
    
    for(i = 0; i < n; ++i)
    {
        vert.insert(i);
        
    }

   
    while (!vert.empty())
    {
        
        v = *vert.begin();
        vert.erase(v);
        
        
        for (i = 0; i < in_e[v].size(); ++i)
        {
            u = in_e[v][i];
            
            ans[u] = max(ans[u], ans[v] + 1);
            vert.erase(u);
            //vert.insert(u);
        }
        for (i = 0; i < in_e[v].size(); ++i)
        {
            
            u = in_e[v][i];
            out_e[u] -= 1;
            vert.insert(u);
        }
        
       // vert.erase(v);
       
    }
    
    cout << *max_element(ans.begin(), ans.end());
   
    
    return 0;
    
}

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

int main() {
  int n;
  cin >> n;
  int ans = n * n * n;
  cout << ans << endl;
  return 0;
}

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

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int t=min(b,d); int s=max(a,c);
  if(t-s<0)
    cout<<0<<endl;
  else
    cout<<t-s<<endl;
}
 


Measured memory_bytes: 256
N, Q = [int(i) for i in input().split()]
S = input()
ary = [0]*(N+1)
af = False
ans = []
for i, s in enumerate(S):
    ary[i+1] = ary[i]
    if s == "A":
        af = True
    elif s == "C" and af:
        ary[i+1] += 1
        af = False
    else:
        af = False
for _ in range(Q):
    l, r = [int(i) for i in input().split()]
    ans.append(ary[r]-ary[l])
for a in ans:
    print(a)


Measured memory_bytes: 59864
import java.util.*;


class Graph2 {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private boolean[] visited = new boolean[totalVertex];
	private int[] indegree = new int[totalVertex];
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		visited = new boolean[totalVertex];
		indegree = new int[totalVertex];
		for (int i = 0; i < visited.length; i++) {
			visited[i] = false ;
		}
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			adjList.add(tmp);
			}
		int totalEdge = in.nextInt();
		for (int i = 0; i < totalEdge; i++) {
			int root = in.nextInt(); //get the root
			int node = in.nextInt(); //get the node root connect to
			adjList.get(root).add(node); //add the node to
			indegree[node]++; // update the indegree of the node
		}
		in.close();
	}
	LinkedList<Integer> result = new LinkedList<Integer>();
	public void DFS(int v) {
		LinkedList<Integer> nb = adjList.get(v);
		for(Integer i : nb) {
			if(visited[i] == false) {
				visited[i] = true;
				DFS(i);
			}
		}
		result.addFirst(v);
		}

	public void toposort() {
		for (int i = 0; i < totalVertex; i++) {
			if(indegree[i] == 0) {
				DFS(i);
			}
		}
		for(Integer i : result)
	        System.out.println(i);
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		g.toposort();
	}

}


Measured memory_bytes: 71296
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int i, j, n, q, k, lower_bound, upper_bound;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n + 1];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				k = sc.nextInt();
				lower_bound = Arrays.binarySearch(a, k);
				if(lower_bound < 0) {
					lower_bound = -lower_bound - 1;
					if(lower_bound > n) {
						lower_bound = n;
					}
					upper_bound = lower_bound;
				}else {
					upper_bound = lower_bound;
					while(lower_bound >= 1) {
						if(a[lower_bound] != a[lower_bound - 1]) {
							break;
						}
						lower_bound--;
					}
					while(upper_bound <= n - 1) {
						if(a[upper_bound] != a[upper_bound + 1]) {
							upper_bound++;
							break;
						}
						upper_bound++;
					}
				}
				System.out.println(lower_bound + " " + upper_bound);
			}
		}
	}
}


Measured memory_bytes: 114944
#include<bits/stdc++.h>
using namespace std;
int b[3],n;
int main()
{
	memset(b,0,sizeof(b));
	int f=0;
	string a;
	cin>>n>>a;
	int i=0;
	while(i<n) 
	{
		--a[i];
		if(a[i]=='1') f=1;
		b[a[i]-'0']+=(((n-1)&i)==i);
		++i;
	}
	if(b[1]&1) puts("1");
	else if((!f)&&(b[2]&1)) puts("2");
	else puts("0");
	return 0;
}

Measured memory_bytes: 5332
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))

q1,q2,q3=0,0,0

for i in range(n):
    if p[i]<=a:
        q1+=1
    elif p[i]<=b:
        q2+=1
    else:
        q3+=1

print(min([q1,q2,q3]))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int A, B,K,cou,ans,mi;
	
	cou=0;
	ans=0;
	cin >> A >> B >> K;
	mi=min(A,B);
	for (int i = mi;i>0; i--){
		if (A%i == 0 && B%i == 0){
			cou++;
		}
		if (cou == K){
		    ans = i;
		    break;
		}
	}
	
	cout << ans << endl;
}

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

int main(){
	int x,y,z;
	cin >> x >> y;
	while(x!=0 || y!=0){
		if(x>y){
			cout << y << " " << x << endl;
		}
		else{
			cout << x << " " << y << endl;
		}
		cin >> x >> y;
	} 
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    
    if (a == 5 && b == 5 && c == 7)cout << "YES" << endl;
    else if (a == 5 && b == 7 && c == 5)cout << "YES" << endl;
    else if(a == 7 && b == 5 && c == 5)cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 100

int isPrime(int);

int main()
{
  int i,cnt=0,num,ans=0,judge=0;

  scanf("%d",&cnt);

  for( i = 0 ; i < cnt ; i++ ){
    scanf("%d",&num);
    ans = ans + isPrime(num);
  }

  printf("%d\n",ans);

  return 0;
}

int isPrime(int x){
  int i;

  if( x <= 3 )return 1;
  else if( x % 2 == 0 )return 0;
  else{
    for( i = 3 ; i <= sqrt(x) ; i=i+2 ){
      if( x % i == 0 )return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;main(){for(long long i,n,j[99999],s,a;;cout<<i<<endl){cin>>n;if(!n)break;for(i=s=0;i++<n;s+=a)cin>>a;for(i=n;i>1;cin>>j[--i]);for(sort(j+1,j+n);n>0;s+=j[n])i=max(n--*s,i);}}

Measured memory_bytes: 1688
#include <stdio.h>

int main(void)
{
	int p, min_p = 2000;
	int j, min_j = 2000;
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &p);
		if (min_p > p){
			min_p = p;
		}
	}
	for (i = 0; i < 2; i++){
		scanf("%d", &j);
		if (min_j > j){
			min_j = j;
		}
	}
	
	printf("%d\n", min_p + min_j - 50);
	
	return (0);
}

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

int main()
{
   long long int i,j,n,t,k,m;
   string s;
   cin>>s;
   if(s[s.size()-1]=='s')
   {
       //s.pop_back();
       s.push_back('e');
       s.push_back('s');
   }
   else{
    s.push_back('s');
   }
   cout<<s<<endl;



    return 0;

}


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

int checker(vector<char> MY, int k){
  int s=MY.size();
  vector<char> gard(k+1);
  vector<char> man(s-k-1);
  for(int i=0;i<k+1;i++){
    gard.at(i)=MY.at(i);
  }
  for(int i=0;i<s-k-1;i++){
    man.at(i)=MY.at(k+1+i);
  }
  sort(gard.begin(), gard.end());
  sort(man.begin(), man.end());
  for(int i=k;i>0;i--){
    if(gard.at(i-1)==gard.at(i)){
      gard.at(i)='0';
    }
  }
  for(int i=s-k-2;i>0;i--){
    if(man.at(i-1)==man.at(i)){
      man.at(i)='1';
    }
  }
  int counter=0;
  for(int i=0;i<k+1;i++){
    for(int j=0;j<s-k-1;j++){
      if(gard.at(i)==man.at(j)){
        counter++;
      }
    }
  }
  return counter;
}
  
int main(){
  int N; cin >> N;
  vector<char> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int count=0;
  for(int i=0;i<N-1;i++){
    if(checker(MY, i)>count){
      count=checker(MY, i);
    }
  }
  cout << count << endl;
}
  

Measured memory_bytes: 256
a = int(input())

b = {}
for _ in range(a):
    S = input()
    if S in b:
        b[S] += 1
    else:
        b[S] = 1

m = max(b.values())
l = []
for k in b:
    v = b[k]
    if v != m:
        continue
    l.append(k)

for s in sorted(l):
    print(s)

Measured memory_bytes: 32988
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
#define ALL(v) v.begin(), v.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int Main(int X, int Y) {
    if(X == 1 && Y == 1) {
        return 1000000;
    }
    else if(X == 1 && Y == 2) {
        return 500000;
    }
    else if(X == 2 && Y == 1) {
        return 500000;
    }
    else if(X == 1 && Y == 3) {
        return 400000;
    }
    else if(X == 3 && Y == 1) {
        return 400000;
    }
    else if(X == 2 && Y == 3) {
        return 300000;
    }
    else if(X == 3 && Y == 2) {
        return 300000;
    }
    else if(X == 1 && Y >= 4) {
        return 300000;
    }
    else if(X == 2 && Y >= 4) {
        return 200000;
    }
    else if(X == 3 && Y >= 4) {
        return 100000;
    }
    else if(Y == 1 && X >= 4) {
        return 300000;
    }
    else if(Y == 2 && X >= 4) {
        return 200000;
    }
    else if(Y == 3 && X >= 4) {
        return 100000;
    }
    else if(X== 2 && Y == 2) {
        return 400000;
    }
    else if(X == 3 && Y == 3) {
        return 200000;
    }
    else {
        return 0;
    }
}


int main() {
    int X, Y;
    cin >> X >> Y;
    int out = Main(X, Y);
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#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;

int main(){
    ll n, m;
    cin >> n >> m;
    vl a(n);
    rep(i, n) cin >> a[i];
    priority_queue<ll> q;
    rep(i, n) q.push(a[i]);
    rep(i, m) {
        auto p = q.top();
        q.pop();
        q.push(p/2);
    }
    ll ans = 0LL;
    rep(i, n) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
  int i;
  scanf("%lld",&i);
  return i;
}

signed main(){
  while(true){
    int n=read();
    if(n==0) return 0;
    string s[n];
    int cnt[n];
    int cnt_max=0;
    // cin >> s[0];
    // FOR(i,1,n){
    REP(i, n){
      // int first,last;
      int last;
      cin >> s[i];
      // first = s[i].find_first_of('.');
      last = s[i].find_last_of('.');
      if (last == -1) {
        cnt[i] = -1;
        continue;
      }
      s[i][last] = '+';
      // cnt[i] = last-first;
      cnt[i] = last;
      cnt_max = max(cnt_max,cnt[i]);
    }
    FOR(j,0,cnt_max+1){
      // int first=0,last=0;
      FOR(i,1,n){
        if(cnt[i] == j){
          // if(first == 0) first = i;
          // else last = i;
          FOR(k, i + 1, n) {
            if (cnt[k] < j) {
              break;
            }
            if (cnt[k] == j) {
              int first = i;
              int last = k;
              FOR (l, first + 1, last) {
                s[l][j] = '|';
              }
              break;
            }
          }
        }
      }
      // FOR(k,first+1,last){
      //   if(s[k].length() >= j) continue;
      //   if(s[k][j] == '.') s[k][j] = '|';
      // }
    }

    FOR(i,1,n){
      REP(j,cnt[i]){
        if(s[i][j] == '.') s[i][j] = ' ';
      }
    }
    REP(i,n) cout << s[i] << endl;
  }
}

Measured memory_bytes: 3900
#include "bits/stdc++.h"
using namespace std;

class UnionFind {
private:
	vector<int> Rank, Vol, Root;
public:
	UnionFind(int N) : Rank(N, 1), Vol(N, 1), Root(N) {
		for (int i = 0; i < N; i++) Root[i] = i;
	}
	int Find(int N) { return (N == Root[N] ? N : Root[N] = Find(Root[N])); }
	bool Same(int X, int Y) { return Find(X) == Find(Y); }
	void Union(int X, int Y) {
		X = Find(X), Y = Find(Y);
		if (X == Y) return;
		if (Rank[X] > Rank[Y]) Root[X] = Y, Vol[Y] += Vol[X];
		else if (Rank[X] < Rank[Y]) Root[Y] = X, Vol[X] += Vol[Y];
		else Root[Y] = X, Vol[X] += Vol[Y], Rank[X]++;
	}
	int Size(int N) { return Vol[Find(N)]; }
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind UF(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		UF.Union(A, B);
	}
	int ANS = -1;
	for (int i = 0; i < N; i++) {
		ANS = max(ANS, UF.Size(i));
	}
	cout << ANS << endl;
}

Measured memory_bytes: 8800
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int r;
    cin >> r;
    double pi = (double)22 / (double)7;
    double ans  = 2 * pi * r;
    cout << fixed << setprecision(5) << ans << "\n";
    return 0;
}

Measured memory_bytes: 3804
#include<stdio.h>
 
main()
{
    int d,e;
 
    scanf("%d",&d); //入力するデータセット数
 
    for(e=0;e<d;e++){
        int a=0,b=0,c=0;
 
        scanf("%d %d %d",&a,&b,&c);
        
        if( (a*a) + (b*b) == (c*c) ||
            (b*b) + (c*c) == (a*a) ||
            (c*c) + (a*a) == (b*b))
            printf("YES\n");
        else
            printf("NO\n");
    }
 return 0;
} 

Measured memory_bytes: 1008
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
d = {}
for i in range(N):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if a not in d:
        d[a] = 0
    d[a] += b

cost = 0
for k, v in sorted(d.items()):
    if M <= v:
        cost += k*M
        break
    else:
        cost += k*v
        M -= v
print(cost)

Measured memory_bytes: 23000
#include <iostream>

using namespace std;

#define LN 1000001
 
int main()
{
    int n;
    static int pn[LN];
    
    for (int i = 0; i < LN; i++){
        pn[i] = 1;
    }
    
    pn[0] = pn[1] = 0;
     
    for (int i = 2; i * i < LN; i++){
        if (pn[i] == 1){
            for (int j = i * i; j < LN; j += i){
                pn[j] = 0;
            }
        }
    }
     
    for (int i = 1; i < LN - 1; i++){
        pn[i + 1] += pn[i];
    }
     
    while (cin >> n){
        cout << pn[n] << endl;
    }
     
    return (0);
}

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

int main(){
    int a, b;
    int sum=1;
    int counter=0;
    cin >> a >> b;
    for(int i=0; sum<b; i++) {
        sum = sum+a-1;
        counter++;
        if(sum>=b) {
            break;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    map<int,ll> mp;
    rep(i,n) {
        int a,b;
        cin >> a >> b;
        mp[a] += b;
    }
    ll sum = 0;
    int ans = 0;
    rep(i,100001) {
        sum += mp[i];
        if(sum >= k) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, k; cin >> a >> b >> c >> k;
	int ans = 0;
	if (k >= a) k -= a, ans += a;
	else ans += k, k = 0;
	if (k >= b) k -= b, ans += 0;
	else ans += 0, k = 0;
	if (k >= c) k -= c, ans -= c;
	else ans -= k;
	cout << ans;
}

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

class Union_Find {
private:
    std::vector<int> par;
    std::vector<int> rank;

public:
    Union_Find(int n) { // ?????????: O(n)
	par = rank = std::vector<int>(n);
	for(int i=0; i<n; i++) {
	    par[i]  = i;
	    rank[0] = 0;
	}
    }

    int root(int x) { // ??¨??????????±???????: O(?±(n)) 
	if(par[x] == x) return x;
	return par[x] = root(par[x]); // ??????????????????????????????????????????
    }

    void unite(int x, int y) { // x,y????????????????????????: O(?±(n)) 
	x = root(x); y = root(y);
	if( x == y ) return;

	if( rank[x] < rank[y] ) par[x] = y;
	else {
	    par[y] = x;
	    if( rank[x] == rank[y] ) rank[x]++;
	}
    }

    bool same(int x, int y) { //x,y??????????????????????????????????????????: O(?±(n)) 
	return root(x) == root(y);
    }
};


struct Edge {
    int s;
    int t;
    int w;
    bool operator < (const Edge& tgt) const {
	return w > tgt.w;
    }
};
inline int Prim(const vector<vector<Edge>>& g) {
    const int V = g.size();
    priority_queue<Edge> pq;
    set<int> used;
    used.insert(0);
    for(auto& e : g[0]) {
	pq.push( e );
    }
    int ans = 0;
    while( used.size() != V and pq.size()>0 ) {
	auto e = pq.top(); pq.pop();
	if( used.find(e.s) != used.end() and  used.find(e.t) != used.end() ) continue;
	ans += e.w;
	used.insert(e.s);
	used.insert(e.t);
	for(auto& ne : g[e.s])
	    pq.push(ne);
	for(auto& ne : g[e.t])
	    pq.push(ne);
    }
    return ans;
}

inline int Kruskal(const vector<vector<Edge>>& g){
    const int V = g.size();
    vector<Edge> edges;
    for(auto& v : g) {
	for(auto& e : v) {
	    edges.push_back(e);
	}
    }
    sort(edges.begin(), edges.end());
    reverse(edges.begin(), edges.end());

    Union_Find uf(V);
    int ans = 0;
    for(auto& e : edges) {
	if( uf.same(e.s,e.t) ) continue;
	ans += e.w;
	uf.unite(e.s,e.t);
    }
    return ans;
}
    

int main () {

    int V,E;
    cin >> V >> E;

    vector<vector<Edge>> g(V);
    for (int i=0; i<E; ++i) {
	int s,t,w;
	cin >> s >> t >> w;
	g[s].push_back(Edge{s,t,w});
//	g[t].push_back(Edge{t,s,w});
    }
//    int ans = Prim(g);
    int ans = Kruskal(g);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6784
result = []
while true do
	n = gets.chomp.to_i
	if n == 0 then break end
	ary = []

	n.times{
		ary << gets.chomp.to_i
	}

	ary_min=ary.min
	ary_max=ary.max

	ary.each_with_index{|val, index| if val == ary_min then 
		ary.delete_at(index)
	    break
	    end}

	ary.each_with_index{|val, index| if val == ary_max then 
		ary.delete_at(index)
	    break
	    end}

	sum = 0
	ary.each{|val| sum += val}

	result << sum/ary.length 
end

result.each{|val| puts val}

Measured memory_bytes: 6100
program A319C
    implicit none
    integer(8)::n,i,j
    integer(8),dimension(26)::A,B
    character(50)::S
    A=0
    read*,n
    do i=1,n
        read*,S
        B=0
        do j=1,len_trim(S)
            B(ichar(S(j:j))-96)=B(ichar(S(j:j))-96)+1
        end do

        if(i==1)then
            A=B
        else
            do j=1,26
                A(j)=min(A(j),B(j))
            end do
        end if
    end do

    do i=1,26
        do j=1,A(i)
            write(*,fmt='(A)',advance='no')char(i+96)
        end do
    end do
    print'(A)',""
end program A319C

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,b[101];
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>b[i];
    b[0]=b[n]=1e9;
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=min(b[i],b[i+1]);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  # print(n, p, e)
  while n >= (p ** e) and n % (p ** e) == 0:
    n = n // (p ** e)
    score += 1
    e += 1
  else:
    while n >= p and n % p == 0:
      n = n // p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int n,t;
int a[N],b[N],c[N],p[N];
ll emp[N],full[N],del[N];

ll score(int i,ll k) {
	if (k>=a[i]) return (ll)a[i]*b[i]+(k-a[i])*c[i];
	else return k*b[i];
}
int main() {
	scanf("%d%d",&n,&t);
	rep(i,0,n) {
		scanf("%d%d%d",a+i,b+i,c+i);
		emp[i]=-(ll)a[i]*b[i];
		full[i]=(ll)(t-a[i])*c[i];
		del[i]=full[i]-emp[i];
	}
	ll l=-1,r=(ll)t*n;
	rep(i,0,n) p[i]=i;
	sort(p,p+n,[&](int a,int b) {
		return del[a]>del[b];
	});
	while (l+1<r) {
		ll md=(l+r)>>1;
		ll k=md/t;
		ll rem=md%t;
		ll sco=0;
		rep(i,0,n) sco+=emp[i];
		rep(i,0,k) {
			sco+=del[p[i]];
		}
		bool valid=0;
		rep(i,0,n) {
			ll nsco=sco;
			if (i>=k) {
				nsco+=score(p[i],rem);
			} else {
				nsco-=del[p[i]];
				nsco+=del[p[k]];
				nsco+=score(p[i],rem);
			}
			if (nsco>=0) valid=1;
		}
		if (valid) r=md; else l=md;
	}
	printf("%lld\n",r);
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

char buf[NUM];


int main(){

	scanf("%s",buf);

	int num = 0,ans = 0;

	for(int i = 0; buf[i] != '\0'; i++){
		if(buf[i] == 'R'){
			num += 1;
		}else{
			num -= 1;
		}

		if(num == 4){
			ans += 1;
			num = 0;
		}else if(num == -4){
			num = 0;
		}
	}

	printf("%d\n",ans);

	return 0;
}



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

using namespace std;

map<string, long long> mp;
set<string> st;
set<string>::iterator it;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, m = 0;
	string s;
	cin >> n;
	for(long long i = 0; i < n; ++i){
		cin >> s;
		++mp[s];
		m = max(m, mp[s]);
		st.insert(s);
	}
	for(it = st.begin(); it != st.end(); ++it) if(mp[*it] == m) cout << *it << endl;

	return 0;
}



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

    using Graph = vector<vector<int>>;
 
int main() {

    int r,g,b;
    cin>>r>>g>>b;


    if( (100*r+10*g+b)%4==0)
        cout<<"YES"<<endl;
    else
    {
        cout<<"NO"<<endl;
    }
    


 	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;
 
int n;
vector<int> a;
 
signed main() {

	cin >> n;

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

	int ans=0;
	for(int i = 1; i < n-1; i++){
		if((a[i] < a[i-1] && a[i] > a[i+1]) || (a[i] > a[i-1] && a[i] < a[i+1])) ans++;
	}

	cout << ans << endl;


	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));
String str = br.readLine();
Boolean isNull = str.equals("");
while(!isNull){
String[] datas = new String[8];
datas = str.split(" ",8);
double x1 = Double.parseDouble(datas[0]);
double y1 = Double.parseDouble(datas[1]);
double x2 = Double.parseDouble(datas[2]);
double y2 = Double.parseDouble(datas[3]);
double x3 = Double.parseDouble(datas[4]);
double y3 = Double.parseDouble(datas[5]);
double xp = Double.parseDouble(datas[6]);
double yp = Double.parseDouble(datas[7]);
double x = xp-x1;
double y = yp-y1;
double p = x2-x1;
double q = y2-y1;
double r = x3-x1;
double u = y3-y1;
double[] coefficient = new double[2];
coefficient = Simultaneous(p,r,x,q,u,y);
double s = coefficient[0];
double t = coefficient[1];
if(s<0||t<0){
System.out.println("NO");
}else if(s+t>0 && s+t<1){
System.out.println("YES");
}else{
System.out.println("NO");
}
str = br.readLine();
if(str==null)str="";
//str = str == null?"":str;
isNull = str.equals("");

}
}
public static double[] Simultaneous(double a,double b,double c,double d,double e,double f){
double x = (double) (e*c-b*f)/(a*e-b*d);
double y = (double) (a*f-c*d)/(a*e-b*d);
double[] answer = new double[2];
answer[0]=x;
answer[1]=y;
return answer;
}
}

Measured memory_bytes: 24512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, D;
    cin >> N >> D;

    if(N % (2 * D + 1) != 0){
        cout << N / (2 * D + 1) + 1 << endl;
    }else{
        cout << N / (2 * D + 1) << endl;
    }

    return 0;
}

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

#define FOR(a, n, i) for(ll i = a; i < n; i++)
#define FORR(a, n, i) for(ll i = n - 1; i >= a; i--)
#define FORIT(a, n, it) for (auto it = a; it != n; it++)
#define FORE(e, container) for (auto e : container)
#define FORIN(n, v) vll v(n); FOR(0, n, i) cin >> v[i];
#define FORINP(n, v) vpl v(n); FOR(0, n, i) cin >> v[i].ff >> v[i].ss;
#define WHT(t) int t; cin >> t; while(t--)
#define REP(n, i) FOR(0, n, i)

#define bb begin()
#define ee end()
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define in insert
#define ct count

#define MODF(x) (((x) % MOD) + MOD) % MOD
#define MP(a, b) make_pair(a, b)
#define ALL(container) container.bb, container.ee

using namespace std;

typedef long long ll;
typedef double dd;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvl; 
typedef vector<pll> vpl;
typedef set<ll> sll;
typedef set<pll> spl;
typedef map<ll, ll> mll;
typedef map<pll, ll> mpl;


const ll inf = numeric_limits<ll>::max(), 
         MAX = 1e6, 
         MOD = 1e9 + 7;

///////////////////////////////////////////////////////////
////////////////////    AUXILARY    ///////////////////////
///////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////
//////////////////////    MAIN    /////////////////////////
///////////////////////////////////////////////////////////



int main() {
    int n; cin >> n;
    mpl m;
    vpl vz;
    REP(n, i) {
        pll p; cin >> p.ff >> p.ss;
        ll h; cin >> h;
        if (h == 0) vz.pb(p);
        else m[p] = h;
    }
    REP(101, cx) {
        REP(101, cy) {
            sll s;
            FORE(mp, m) {
                s.in(mp.ss + abs(mp.ff.ff - cx) + abs(mp.ff.ss - cy));
            }
            if (s.size() > 1) continue;
            ll h = *s.bb;
            auto f = [&, h, cx, cy](pll p){return (abs(p.ff - cx) + abs(p.ss - cy)) >= h;};
            if (all_of(ALL(vz), f)) {
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ***************************CODE**********************//





int main(){
        int a[3][3];
        for(int i = 0; i < 3; i++){
                for(int j = 0; j <3 ; j++){
                        cin >> a[i][j];
                }
        }

        int x[3];
        int y[3];

        x[0] = 0;
        for(int i = 0; i < 3; i++){
                y[i] = a[0][i] - x[0];
        }
        for(int i = 0; i < 3; i++){
                x[i] = a[i][0] - y[0];
        }

        bool good = true;

        for(int i = 0; i < 3; i++){
                for(int j = 0; j < 3; j++){
                        if(x[i]+y[j] != a[i][j]){
                                good = false;
                        }
                }
        }

        if(good){
                cout << "Yes" << endl;
        }
        else{
                cout << "No" << endl;
        }
        return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[20];
    ll x[20][20];
    ll y[20][20];
    rep(i,0,N){
        cin >> A[i];
        rep(j,0,A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    ll ans = 0;
    rep(bit,0,(1LL<<N)){
        bool ok = true;
        ll syoujiki[21] = {};
        rep(i,0,N){
            if((bit>>i) & 1){
                syoujiki[i] = 1;
            }else{
                syoujiki[i] = 0;
            }
        }
        rep(i,0,N){
            rep(j,0,A[i]){
                if((bit>>i) & 1){
                    if(y[i][j] != syoujiki[x[i][j]]) ok = false;
                }
            }
        }
        if(ok){
            ans = max(ans, (ll)__builtin_popcount(bit));
        }
    }
    print(ans);

    

}

Measured memory_bytes: 384
n = int(input())
c = list(map(int, input().split()))
c.sort()
MOD = 1000000007
ans = 0
P = pow(4, n-1, MOD)
if n == 1:
  ans = c[0]*2 % MOD
else:
  for i in range(n):
    ans += P*c[i]*(n+1-i)
    ans %= MOD
 
print(ans)

Measured memory_bytes: 26800
var
	N,A,x,y,i,j,out,ans,nowt,nowf,ccc:Longint;
	F,T,gF,gT:Array[1..15]of Longint;
procedure dfs(id,nt,nf:Longint);
var
cnt,i:Longint;
begin
	if id=N+1 then begin
		cnt:=0;
		for i:=1 to N do if((nt>>(i-1))and 1)=1 then inc(cnt);
		if ans<cnt then ans:=cnt;
	end else begin
		if((((nt or nf)>>(id-1))and 1)=0)and(((nf or gF[id])and(nt or gT[id]))=0)then dfs(id+1,nt or gT[id],nf or gF[id])
		else dfs(id+1,nt,nf);
	end;
end;
begin
	read(N);
	for i:=1 to N do begin
		read(A);
		for j:=1 to A do begin
			read(x,y);
			dec(x);
			if y=0 then F[i]:=F[i] or (1<<x)else T[i]:=T[i] or (1<<x);
		end;
	end;
	for i:=1 to N do begin
		nowt:=1<<(i-1);
		nowf:=0;
		for ccc:=1 to N do begin
			for j:=1 to N do begin
				if ((nowt>>(j-1))and 1)=1 then begin
					nowt:=nowt or T[j];
					nowf:=nowf or F[j];
				end;
			end;
		end;
		gF[i]:=nowf;
		gT[i]:=nowt;
	end;
	dfs(1,0,0);
	writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int par[100010];
int depth[100010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
}
int main(){
    ll n,m,k;cin>>n>>m>>k;
    init(n);
    vector<ll>cnt(n+1);
    vector<ll>cnt2(n+1);
    rep(i,m){
        ll a,b;cin>>a>>b;
        unite(a,b);
        cnt2[a]++;
        cnt2[b]++;
    }
    REP(i,1,n+1){
        cnt[root(i)]++;
    }
    rep(i,k){
        ll a,b;cin>>a>>b;
        if(same(a,b)){
            cnt2[a]++;
            cnt2[b]++;
        }
    }
    REP(i,1,n+1){
        cout<<cnt[root(i)]-cnt2[i]-1<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 3200
#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

using cat = long long;

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

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> L(N), R(N);
	int min_R = OVER9000, max_L = 0, ans = 0;
	for(int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
		min_R = min(min_R, R[i]);
		max_L = max(max_L, L[i]);
		ans = max(ans, R[i]-L[i]+1);
	}
	if(min_R >= max_L) ans += min_R-max_L+1;
	vector< pair<int, int> > I(N);
	for(int i = 0; i < N; i++) I[i] = {L[i], i};
	sort(begin(I), end(I));
	multiset<int> SR;
	for(int i = 0; i < N; i++) SR.insert(R[i]);
	for(int i = 0; i < N-1; i++) {
		if(I[i].ff > min_R) break;
		SR.erase(SR.find(R[I[i].ss]));
		if(*begin(SR) >= max_L)
			ans = max(ans, min_R-I[i].ff+1 + *begin(SR)-max_L+1);
	}
	cout << ans << "\n";
	return 0;
}

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


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>> vec(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>vec[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int sum=0;
      for(int k=0;k<d;k++){
        int a=abs(vec[i][k]-vec[j][k]);
        sum+=a*a;
      }
      bool flag=false;
      for(int k=0;k<=sum;k++){
        if(k*k==sum){
          flag=true;
        }
      }
      if(flag) ans++;
    }
  }
  cout<<ans<<endl;    
}

Measured memory_bytes: 256
N = int(input())
plis = list(map(int, input().split()))
plis_sorted = plis.copy()
plis_sorted.sort()

if plis == plis_sorted:
	print("YES")
	exit()

for i in range(N):
	for j in range(i+1,N):
		ptmp = plis.copy()
		tmp = ptmp[i]
		ptmp[i] = ptmp[j]
		ptmp[j] = tmp
		if ptmp == plis_sorted:
			print("YES")
			exit()

print("NO")


Measured memory_bytes: 3064
from collections import Counter

def resolve():
	n = int(input())
	s = input()
	sum_e = [0]*(n+1)
	sum_w = [0]*(n+1)
	for i in range(n):
		ev = 1 if s[i] == 'E' else 0
		wv = 1 if s[i] == 'W' else 0
		sum_e[i+1] = sum_e[i] + ev
		sum_w[i+1] = sum_w[i] + wv
	ans = float('inf')
	if n == 2:
		print(1 if len(Counter(list(s)).keys()) == 2 else 0)
		return
	e_w = sum_e[-1] - sum_e[1]
	e_e = sum_w[n-1]
	ans = min(e_w, e_e)
	for i in range(n):
		v = sum_w[i-1] + (sum_e[-1] - sum_e[i])
		ans = min(ans, v)
	print(ans)
resolve()

Measured memory_bytes: 45552
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define mod (ll)1000000007
using namespace std;
string s;
ll dp[100001][13];
ll po[100001];
int main(){
    getline(cin,s);
    reverse(s.begin(),s.end());
    int n=s.size();
    dp[0][0]=1;
    po[0]=1;
    for(int i=1;i<=n;i++)
        po[i]=po[i-1]*10%13;
    for(int i=1;i<=n;i++) for(int j=0;j<13;j++){
        if(s[i-1]=='?'){
            for(int k=0;k<=9;k++)
                dp[i][j]=(dp[i][j]+dp[i-1][(j-(k*po[i-1])%13+13)%13])%mod;
        }
        else{
            dp[i][j]=(dp[i][j]+dp[i-1][(j-((s[i-1]-'0')*po[i-1])%13+13)%13])%mod;
        }
    }
    cout<<dp[n][5]%mod<<endl;
    return 0;
}

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

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

#include <vector>
#include <utility>


#include <algorithm>


void solve() {
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);

	int ans = 0;
	REP(i,n) {
		int t;
		scanf("%d", &t);
		if (t < a || t >= b) ans++;
	}

	printf("%d\n", ans);
}


int main() {
    solve();
}




Measured memory_bytes: 256