akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0){
            break;}
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2036
n = int(input())

li = [0]*(10**5)

for i in range(1,10**2+1):
    for j in range(1,10**2+1):
        for k in range(1,10**2+1):
            li[i**2+j**2+k**2+i*j+j*k+k*i] += 1
            
for i in range(1,n+1):
    print(li[i])

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

string s;

int main(){
	cin >> s;
	sort(s.begin(),s.end());
	if (s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)

{

   int i,n,num,min=1000001,max=-1000001;

   long sum=0;

   scanf("%d",&n);   

   for(i=0;i<n;i++)

   {

       scanf("%d",&num);

       sum+=num;             

       if(min>num){

           min=num;

       }

          

       if(max<num){

           max=num;

       }

   }

   printf("%d %d %ld\n",min,max,sum);

   return 0 ;

}

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

int main(){
    int n;
    cin >> n;
    vector<int> num(n);
    
    for(int i=0; i < n ; i++ ){
        cin >> num[i];
    }
    for(int i=0; i < n ; i++ ){
        cout << num[n-1-i]; 
        //num.pop_back();
        if(i < n-1){
            cout << " ";
        }
    }
    cout << endl;
    return(0);
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	map<char, int> M;
	int i;
	bool ok = true;
	int l = s.length();
	for(i=0; i<l; i++){
		M[s[i]]++;
	}
	for(auto it = M.begin(); it!=M.end(); it++){
		if((it->second)&1){
			ok = false;
			break;
		}
	}
	if(ok) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int LL;
typedef long double dd; 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,-1,1};
LL dp[2000001];
LL mod=1e9+7;
using namespace std;
 void solve(){
 LL n; 
 cin>>n; 
 LL ans=0;
 for(LL i=1;i<=n; i++){
   LL k;
   cin>>k; 
   if(i%2==1&&k%2==1){
     ans++;  
   }
 }
 cout<<ans<<endl; 
 }
  
int main(){
//LL t;
 //cin>>t;
// while(t--){
   solve();
//  }
  
   return 0;
   }

Measured memory_bytes: 3616
from sys import setrecursionlimit
setrecursionlimit(100000)
def rad_reach(b,h,dist,E,rad):
	cnt = 1
	if dist < rad:
		for nxt in E[h]:
			if nxt == b:
				continue
			cnt += rad_reach(h,nxt,dist+1,E,rad) 
	return cnt
def solve():
	N,K = map(int,raw_input().split())
	pairs = []
	E = [[] for i in xrange(N)]
	for i in xrange(N-1):
		a,b = map(lambda x:int(x)-1,raw_input().split())
		E[a].append(b)
		E[b].append(a)
		pairs.append((a,b))
	ans = N
	rad = K/2
	if K % 2 == 0:
		for c in xrange(N):
			ans = min(ans,N-rad_reach(-1,c,0,E,rad))
	else:
		for c1,c2 in pairs:
			ans = min(ans,N-rad_reach(c2,c1,0,E,rad)-rad_reach(c1,c2,0,E,rad))
	print ans
solve()

Measured memory_bytes: 99228
package main

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

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func main() {
	sum := 0
	N := getInt()
	dArray := make([]int, N)
	for i := 0; i < N; i++ {
		dArray[i] = getInt()
	}

	for i := 0; i < N-1; i++ {
		buf := 0
		for j := i + 1; j < N; j++ {
			buf += dArray[j]
		}
		sum += dArray[i] * buf
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
function main()
    s=sread()
    if s[end]=='s'
        println(s*"es")
    else
        println(s*"s")
    end    
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,readline())
myreads(ty)=map(x->parse(ty,x),split(readline()))
main()

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

using namespace std;

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


    if(s.length() <= k){
        cout << s << endl;
    } else {
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  vector<ll> A(5);
  for (auto& _a : A) cin >> _a;
  ll t1 = A[0]*60 + A[1];
  ll t2 = A[2]*60 + A[3];
  if (t2 < t1) t2 += 24*60;
  t2 -= t1;
  t2 -= A.back();
  t2 = max(t2, 0LL);
  cout << t2 << endl;
                 
  

}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;













struct node {
    node *ch[2];
    node() {
	ch[0]=ch[1]=NULL;
    }
};






ll n, l;
node *trie;


void add(string s) {
    node *cur = trie;
    for (char c: s) {
	if (cur->ch[c-'0'] == NULL) cur->ch[c-'0'] = new node();
	cur = cur->ch[c-'0'];
    }
}

ll G;

void dfs(node *at, int len=0) {
    if (len == l) return;
    int count = 0;
    if (at->ch[0] == NULL) count++;
    if (at->ch[1] == NULL) count++;

    if (count == 1) {
	//compute grundy number
	//g[0] = 0
	//g[i] = mex(0, g[i-1], g[i-1]^g[i-2], g[i-1]^g[i-2]^g[i-3], ...)

	//it turns out g[i] follows a pattern:
	//largest pw2 that divides height of subtree
        ll cur = l-len;
	ll res = 1;
	while (cur%2 == 0) {
	    res=res*2;
	    cur=cur/2;
	}
	G = G ^ res;
    }

    for (int i=0; i<2; i++) {
	if (at->ch[i] != NULL) {
	    dfs(at->ch[i], len+1);
	}
    }
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    trie=new node();
    cin>>n>>l;
    for (int i=0; i<n; i++) {
	string s; cin>>s;
	add(s);
    }

    dfs(trie);



    if (G==0) out("Bob");
    out("Alice");

    

    return 0;
}


Measured memory_bytes: 5100
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  string s;
  cin >> s;
  
  cout << s[0] << s.size()-2 << s[s.size()-1] << endl;


 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include <algorithm> 
#include<map>
#include<string>
#include<unordered_map>
#include <set>
#include <unordered_set>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >>s;
	cin >> t;
	vector<long long>arr;
	long long ans = 0;
	for (int i = 0; i < s.size() - t.size() + 1; i++) {
		for (int j = i; j < i + t.size(); j++) {
			if (s[j] != t[j - i]) {
				ans++;
			}
		}
		arr.push_back(ans);
		ans = 0;
	}
	sort(arr.begin(), arr.end());
	cout << arr[0];
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <map>
#include <set>
using namespace std;

int main(){
	int A,B,C,ans=0;
	cin>>A>>B>>C;
//	while(!(A%2)&&!(B%2)&&!(C%2)&&ans<1e4){
//		int A2,B2,C2;
//		A2=(B+C)/2;
//		B2=(A+C)/2;
//		C2=(A+B)/2;
//		A=A2,B=B2,C=C2;
//		ans++;
//		cerr<<ans<<"=="<<A<<" "<<B<<" "<<C<<"\n";
//	}
//	if(ans==10000) ans=-1;
	
	int countA,countB,countC,temp;
	countA=countB=countC=0;
	//count A
	temp=A;
	while(temp%2==0){
		temp/=2;
		countA++;
	}
	//count B
	temp=B;
	while(temp%2==0){
		temp/=2;
		countB++;
	}
	//count C
	temp=C;
	while(temp%2==0){
		temp/=2;
		countC++;
	}
	
	ans=min(countA,min(countB,countC));
	
	if(!(A==B||A==C||B==C)&&((countA==countC&&countA==countB))) ans++;
	if(countA&&countB&&countC)if(A==B&&A==C) ans=-1;
	
	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
int a,b,x;
cin>>a>>b>>x;
if(b-a+1<=x*2){
   for(int i=a;i<=b;i++){
       cout<<i<<endl;
   }
}
  else{
        for(int i=a;i<a+x;i++){
        cout<<i<<endl;
    }
    for(int i=b-x+1;i<=b;i++){
        cout<<i<<endl;
    }
}
}

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

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

	rep(i,0,t.size()){
		if( s == t ){ Yes; ret 0;}
		
		string s2 = "";
		s2 += s[s.size()-1];
		rep(i,0,s.size()-1){
			s2 += s[i];
		}
		
		s = s2;
		//cout << s << endl;
	}
	
	No;
	ret 0;
}

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

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

    int left = 0, right = (int)s.size() - 1;
    int res = 0;
    while (left < right) {
        if (s[left] == s[right]) {
            left++;
            right--;
        } else if (s[left] == 'x' && s[right] != 'x') {
            res++;
            left++;
        } else if (s[left] != 'x' && s[right] == 'x') {
            res++;
            right--;
        } else {
            cout << "-1" << endl;
            return 0;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        boolean[] isRoot = new boolean[n];
        Arrays.fill(isRoot, true);

        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            if (left != -1) isRoot[left] = false;
            if (right != -1) isRoot[right] = false;
            nodes[id] = new Node(id, left, right);
        }

        for (int i = 0; i < n; i++) {
            if (isRoot[i]) {
                solve(nodes, -1, i, 0);
                break;
            }
        }

        StringBuilder sb = new StringBuilder("");
        for (Node node: nodes) {
            sb.append("node ").append(node.id);
            sb.append(": parent = ").append(node.parent);
            sb.append(", sibling = ").append(node.sibling);
            sb.append(", degree = ").append(node.degree);
            sb.append(", depth = ").append(node.depth);
            sb.append(", height = ").append(node.height);
            sb.append(", ").append(node.type);
            sb.append("\n");
        }
        System.out.print(sb);
    }

    public static int solve(Node[] nodes, int parent, int id, int depth) {
        if (id == -1) {
            return -1;
        }

        Node node = nodes[id];

        node.parent = parent;

        if (node.left != -1) nodes[node.left].sibling = node.right;
        if (node.right != -1) nodes[node.right].sibling = node.left;

        node.degree = ((node.left == -1) ? 0 : 1) + ((node.right == -1) ? 0 : 1);
        node.depth = depth;
        node.height = Math.max(solve(nodes, id, node.left, depth + 1), solve(nodes, id, node.right, depth + 1)) + 1;

        if (node.parent == -1) node.type = "root";
        else if (node.left == -1 && node.right == -1) node.type = "leaf";
        else node.type = "internal node";

        return node.height;
    }
}

class Node {
    public int id;
    public int parent;
    public int sibling = -1;
    public int degree;
    public int depth;
    public int height;
    public String type;
    public int left;
    public int right;

    public Node(int id, int left, int right) {
        this.id = id;
        this.left = left;
        this.right = right;
    }
}

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

int func(int x){
  int a=0;
  while(x>0){
    a+=x%10;
    x/=10;
  }
  return a;
}
int main(){
  int N;
  cin >> N;
  if (N%func(N)==0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import numpy as np  

n, w = map(int, input().split()) 

dp = np.array([0] * (w+1)) 

for i in range(n):
    weight, value = map(int, input().split())

    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value) 

print(int(dp[-1]))

Measured memory_bytes: 14796
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int opt = 3*n*n;
        System.out.println(opt);
    }
}

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

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a[] = new int[3];
            for (int i = 0; i < 3; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            int odd = 0;
            int even = 0;

            for (int i = 0; i < 3; i++) {
                if (a[i] % 2 == 0) {
                    even++;
                } else {
                    odd++;
                }
            }

            if (even == 2) {
                ans++;
                for (int i = 0; i < 3; i++) {
                    if (a[i] % 2 == 0) a[i]++;
                }
            } else if (odd == 2) {
                ans++;
                for (int i = 0; i < 3; i++) {
                    if (a[i] % 2 == 1) a[i]++;
                }

            }
            int mx = Math.max(a[0], Math.max(a[1], a[2]));
            for (int i = 0; i < 3; i++) {
                ans += (mx - a[i]) / 2;
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 22740
#include    <stdio.h>
/* Aizu Online Judge Problem 	*/
/* Volume0 0003:Is it Right Triangle	*/

int check_rihgt_triangle(int side_1, int side_2, int side_3);
void change(int *a, int *b);

int main(void)
{
	int side_1, side_2, side_3;
	int i;

	scanf("%d", &i);

	for(;i > 0; i--){
		scanf("%d %d %d", &side_1, &side_2, &side_3);
		if(check_rihgt_triangle(side_1, side_2, side_3)){
			printf("YES\n");
		} else{
			printf("NO\n");
		}
	}
	return 0;
}

int check_rihgt_triangle(int side_1, int side_2, int side_3)
{
	int ret;

	if(side_1 > side_2){
		change(&side_1, &side_2);
	}
	if (side_2 > side_3) {
		change(&side_2, &side_3);
	}
	if((side_1 * side_1 + side_2 * side_2) == (side_3 * side_3)){
		ret = 1;
	} else{
		ret = 0;
	}
	return ret;
}

void change(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

Measured memory_bytes: 580
using System;

namespace Sumple1
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int n = cin.NextInt();
            string s = n.ToString();
            bool x = false;
            for(int i = 0; i < 3; i++)
            {
                if(s[i] == '7'){
                    x = true;
                }
            }
            if (x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll h(n);
  rep(i, n) {
    cin >> h[i];
  }

  ll ans = 1;
  ll m = h[0];

  REP(i, n) {
    if (h[i] >= m) {
      ans++;
    }
    chmax(m, h[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

int main(){
  int N;cin>>N;
  int bits = 0;
  vector<int> A(N);

  rep(i,N){
    int x;cin>>x;
    A[i] = x;
    bits ^= x;
  }

  rep(i,N){
    cout<<(A[i]^bits)<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 4044
#include <iostream>

int pow2(int x);

int main()
{
    int side1, side2, diagonal;
    char ch;

    int cnt_rect = 0, cnt_lozen = 0;

    while (std::cin >> side1 >> ch >> side2 >> ch >> diagonal) {
        if (pow2(side1) + pow2(side2) == pow2(diagonal)) {
            cnt_rect++;
        }
        if (side1 == side2) {
            cnt_lozen++;
        }
    }

    std::cout << cnt_rect << std::endl << cnt_lozen << std::endl;

    return 0;
}

int pow2(int x)
{
    return (x * x);
}

Measured memory_bytes: 1160
#include <cstdio>
    using namespace std;
     
    int a, b, c;
    int main()
    {
         while(scanf("%d %d %d", &a, &b, &c) != EOF)
        {
             if(c >= a && c <= b)
                    printf("Yes\n");
             else printf("No\n");
        }
    }

Measured memory_bytes: 128
def modinv(a):
    b=MOD
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%MOD

MOD=10**9+7
N,M,K=map(int,input().split())

b=1
for i in range(1,K-1):
    b=(b*(N*M-1-i)*modinv(i))%MOD

x=0
for i in range(1,N):
   x=x+i*(N-i)
x=(x*M*M)%MOD

y=0
for j in range(1,M):
    y=y+j*(M-j)
y=(y*N*N)%MOD
    
ans=b*(x+y)%MOD
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char c[3];
int main(){
	int x;
	cin>>x;
	for(int i=x;i<1000;i++)
		if((i/100)==(i/10)%10&&i/100==i%10)
		{
			cout<<i;
			return 0;
		}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

        map <string,int> f;
        int n;
        cin>>n;
        ll sol=0;
        while(n--)
        {
                string s;
                cin>>s;
                sort(s.begin(),s.end());
                sol+=f[s]++;
        }
        cout<<sol<<"\n";


        return 0;
}
/**

**/


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

typedef long long ll;
typedef vector<int> vi;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    //freopen("E:\\Codes\\Problem\\C++\\AAA.txt", "r", stdin);
    //freopen("C:\\Users\\Dell\\Desktop\\Problem\\BBB.txt", "w", stdout);
	
	int n;
	cin>>n;
	
	if(n)cout<<0;
	else cout<<1;
	

}



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

int main(){
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A[i];
  vector<int> num(N,-1);
  int now = 0;
  int next = 0;
  int ans = 0;
  bool end = false;
  for(int64_t i=0; i<K; i++){
    now = next;
    num[now] = i;
    next = A[now] - 1;
    if(!end && num[next] != -1){
      int64_t loop = num[now] - num[next] + 1;
      i += ((K + 1 - num[now]) / loop -1) * loop;
      
      end = true;
    }
  }
  cout << next+1 << endl;
}

Measured memory_bytes: 4836
import itertools

N, M, Q = map(int, input().split())
G = [list(map(int, input().split())) for i in range(Q)]

A_cands = list(itertools.combinations_with_replacement(list(range(1, M+1)), N))       

ans = 0
for cand in A_cands:
    cand_score = 0
    for i in range(Q):
        a, b, c, d = G[i]
        if cand[b - 1] - cand[a - 1] == c:
            cand_score += d
    ans = max(cand_score, ans)
print(ans)
        

Measured memory_bytes: 21484
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N;
    scan(N);
    vector<int> a(N);
    for (size_t i = 0; i < N - 1; i++) {
        int x;
        scan(x);
        a[x - 1]++;
    }

    vprint(a);

    return 0;
}

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


#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}



int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    vec<int> num(3,-1);
    set<string> st1{};//１桁目の履歴
    set<string> st2{};//2
    set<string> st3{};//3
    set<string> st{};//パスワードの履歴

    
    string a,b,c;

    rep(i,n){
        a=s[i];
        if (!st1.count(a)){
            st1.insert(a);
            loop(j,i+1,n){
                b=a+s[j];
                if(!st2.count(b)){
                    st2.insert(b);
                    loop(k,j+1,n){
                        c=b+s[k];
                        if(!st3.count(c)){
                            st3.insert(c);
                        }
                    }
                }
            }
        }
    }
    // for(auto v :st3){
    //     cout<<v<<endl;
    // }
    cout<<st3.size()<<endl;
    return 0;

}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
map<string,int> cnt;
string str[101];
int n,m,ans;
int main() {
    cin >> n;
    for (int i = 1;i <= n;i++) {
        cin >> str[i];
        cnt[str[i]]++;
    }
    cin >> m;
    for (int i = 1;i <= m;i++) {
        string x;
        cin >> x;
        cnt[x]--;
    }
    for (int i = 1;i <= n;i++) ans = max(ans,cnt[str[i]]);
    printf("%d",ans);
    return 0;
}

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

int main(void) {
	int N = 0;
	cin >> N;

	int* *A = new int*[N];
	for (int i = 0; i < N; i++)
		A[i] = new int[N];

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			A[i][j] = 0;

	for (int i = 0; i < N; i++) {
		int u, v,w;
		cin >> u;
		u--;

		cin >> v;
		for (int j = 0; j < v; j++) {
			cin >> w;
			w--;
			A[u][w] = 1;
		}
	}

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (j) cout << " ";
			cout << A[i][j];
		}
		cout << "\n";
	}
}


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

int main(){
	int n;
	cin>>n;
	vector<int> vec(n);
	for(int i=0;i<n;i++) cin>> vec.at(i);
	
	int o=vec.size();
	
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	int u=vec.size();
	
	if(o==u) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vp v(n);
    rep(i,n) cin >> v[i].second >> v[i].first;
    rep(i,n) v[i].second--;
    priority_queue<int,vector<int>,greater<int>> pq;
    priority_queue<P> pq2;
    sort(rall(v));
    ll sum = 0;
    vb ch(n,false);
    rep(i,k) {
        sum += v[i].first;
        if(ch[v[i].second]) pq.push(v[i].first);
        else ch[v[i].second] = true;
    }
    rep2(i,k,n) {
        if(!ch[v[i].second]) pq2.push(v[i]);
    }
    ll ans = sum;
    ll ki = 0;
    rep(i,n) if(ch[i]) ki++;
    ans += ki*ki;
    while(!pq.empty() && !pq2.empty()) {
        if(ch[pq2.top().second]) {
            pq2.pop();
        } else {
            sum -= pq.top();
            pq.pop();
            sum += pq2.top().first;
            ch[pq2.top().second] = true;
            pq2.pop();
            ki++;
            chmax(ans,sum+ki*ki);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  std::vector<char> s(n);
  for (size_t i = 0; i < n; i++) {
    std::cin >> s[i];
  }

   std::vector<char>::iterator itr;
  do {
    itr=s.end();
    s.erase(unique(s.begin(), s.end()), s.end());
  } while(itr!=s.end());

  std::cout << s.size() << '\n';




return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int[] count = new int[n];
        for (int i = 0; i< n; i++) {
            int a = sc.nextInt() - 1;
            arr[i] = a;
            count[a]++;
        }

//        debug(arr);
//        debug(count);

        long total = 0;
        for (int i = 0; i < n; i++) {
            total += ((long) count[i]) * (count[i] - 1) / 2;
        }

//        debug(total);

        for (int i = 0; i< n; i++) {
            System.out.println(total - (count[arr[i]] - 1));
        }

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 100720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=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{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    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]; 
  }
};

int main(){
    ll n;cin >> n;
    vector<int>ans;
    // string base = "zabcdefghijklmnopqrstuvwxy";
    // --n;
    string base = "abcdefghijklmnopqrstuvwxyz";
    int K = 26;
    // ans.push_back(n%K);
    // n/=K;
    while(n!=0){
        --n;
        // cout << n<<" "<<n%K << endl;
        ans.push_back(n%K);
        n/=K;
        // if(n==1)break;
    }
    reverse(ans.begin(),ans.end());
    string rel="";
    rep(i,ans.size()){
        rel.push_back(base[ans[i]]);
    }
    cout << rel << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define debug(x) cout << " >> " << #x << " "<<x<<endl;
void Solve_Case()
{
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> v(n,k);
  map<int,int> mp;
  int query;
  int    qq = q;
  while(q--)
  {
      cin >> query;
      mp[query-1]++;
  }
  for(int i=0;i<n;i++)
    if(v[i] -  qq + mp[i]  > 0)  cout << "Yes\n";
    else cout << "No\n";

}
signed main()
{
    int TestCases=1;

    while(TestCases--)
    {
        Solve_Case();
    }
	return 0;
}


Measured memory_bytes: 7680
import sys
import math


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


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ng = 0
    ok = 10 ** 9 + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        ans = sum(list(map(lambda x: math.ceil(x / mid) - 1, A)))

        # for i in range(N):
        #     ans += A[i]//mid -1
        #     if A[i]%mid !=0:
        #         ans +=1

        if ans <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()


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

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

    int n = s.size();

    sort(s.begin(), s.end());
    //cout << s << endl;

    bool flag = true;
    for(int i = 0; i < n - 1; i++){
        for(int j = i+1; j < n; j++){
            if(s.at(i) == s.at(j)){
                flag = false;
            }
        }
    }

    if(flag){
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

int main() {
    char s[4] = {};
    for (Int i = 0; i < 4; i++) cin >> s[i];
    string a = "";
    string b = "";
    a = a + s[0] + s[1];
    b = b + s[2] + s[3];
    if (!(("01" <= a && a <= "12") || ("01" <= b && b <= "12"))) {
        dump("NA");
    }
    else if ("01" <= a && a <= "12" && "01" <= b && b <= "12") {
        dump("AMBIGUOUS");
    }
    else if ("01" <= a && a <= "12") {
        dump("MMYY");
    }
    else if ("01" <= b && b <= "12") {
        dump("YYMM");
    }
    else {
        dump("NA");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin>>N>>K;
    char B[K];
    map<char,int> m;
    rep(i,K){
        cin>>B[i];
        m[B[i]]++;
    }
    while(true){
        string s=to_string(N);
        bool z=true;
        rep(i,s.size()){
            if(m[s[i]]!=0) {
                z=false;
                break;
            }
        }
        if(z) break;
        else N++;
    }
    cout << N << endl;




}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll A[100000],B[100000];
std::vector<LP> C;
ll N;
ll ans;
ll a,b;
int main()
{
  cin>>N;
  rep(i,N){
    cin>>A[i]>>B[i];
    C.pb(LP(-A[i]-B[i],i));
  }
  sort(C.begin(),C.end());
  ans = 0;
  rep(i,N){
    if(i%2LL==1) b += B[C[i].sc];
    else a+= A[C[i].sc];
  }
  cout<<a-b<<endl;
}


Measured memory_bytes: 3444
n,l = map(int,input().split())
count = 0
if l >= 1:
    for i in range(n):
        count = count + l + i
    count = count - l
elif -l <= n - 1 and l < 1:
    for i in range(n):
        count = count + l + i
else:
    for i in range(n):
        count = count + l + i
    count = count - l - n + 1
print(count)

Measured memory_bytes: 3064
function Main(arg)
{
  var N = arg.split("\n")[0].split(" ")[0]-0;
  var M = arg.split("\n")[0].split(" ")[1]-0;
  var c = arg.split("\n").slice(1);

  var arr = new Array(N);
  arr.fill(-1);
  for (var i = 0; i < M; i++){
    var idx = (c[i].split(" ")[0] - 0)-1;
    var tmp = c[i].split(" ")[1] - 0;
    if (arr[idx] === -1) {
      arr[idx] = tmp;
      continue;
    }

    if (arr[idx] === tmp) {
      continue;
    }
    console.log(-1);
    return;
  }

  for (var i = 0; i < N; i++){
    if (arr[i] === -1) {
      if (N !==1 && i === 0) {
        arr[i] = 1;
      }
      else {
        arr[i] = 0; 
      }
    }
  }
  
  var ans = arr.join("") - 0;
  var asd = ans + "";
  if (asd.length !== N) {
    console.log(-1);
    return;
  }
  
  console.log(ans);
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
	if(s[0]!='A'||(s[1]>='A'&&s[1]<='Z')||(s[s.length()-1]>='A'&&s[s.length()-1]<='Z')){
		cout<<"WA\n";return 0;
	}
	int cnt=0;
	for(int i=2;i<s.length()-1;i++){
		if(s[i]=='C')cnt++;
		else if(s[i]>='A'&&s[i]<='Z'){
			cout<<"WA\n";return 0;
		}
		if(cnt>1)break;
	}
	if(cnt==1){
		cout<<"AC\n";
		return 0;
	}
	cout<<"WA\n";return 0;
}

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

int arr[3][3];

int ans[3][3];
int main()
{
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cin>>arr[i][j];
    }
    int n;
    cin>>n;
    while(n--){
        int a;
        cin>>a;
        for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a==arr[i][j]) ans[i][j] = 1;
        }
    }
    }
    int flag=0;
    for(int i=0;i<3;i++){
        if(ans[i][0]&&ans[i][1]&&ans[i][2]){cout<<"Yes"<<endl; return 0;}
    }

    for(int j=0;j<3;j++){
        if(ans[0][j]&&ans[1][j]&&ans[2][j]){cout<<"Yes"<<endl; return 0;}
    }

    if(ans[0][0]&&ans[1][1]&&ans[2][2]||ans[2][0]&&ans[1][1]&&ans[0][2]){cout<<"Yes"<<endl; return 0;}

    cout<<"No";




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN],cnt[2];
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    for(int i = 1 ; i <= N ; ++i) {
        if(a[i] & 1) {puts("first");return 0;}
    }
    puts("second");
    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
m = [0]*9
color = [0]*9
for i in a:
    if 1 <= i and i <= 399:
        m[0] = 1
        color[0] = 1
    elif 400 <= i and i <= 799:
        m[1] = 1
        color[1] = 1
    elif 800 <= i and i <= 1199:
        m[2] = 1
        color[2] = 1
    elif 1200 <= i and i <= 1599:
        m[3] = 1
        color[3] = 1
    elif 1600 <= i and i <= 1999:
        m[4] = 1
        color[4] = 1
    elif 2000 <= i and i <= 2399:
        m[5] = 1
        color[5] = 1
    elif 2400 <= i and i <= 2799:
        m[6] = 1
        color[6] = 1
    elif 2800 <= i and i <= 3199:
        m[7] = 1
        color[7] = 1
    else:
        color[8] += 1

print(max(sum(m),1), sum(color))

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

syougen = [ [] for _ in range(N) ]
for i in range(N):
    num = int(input())
    for j in range(num):
        x, y = map(int, input().split())
        syougen[i].append([x, y])

#print(syougen)
ans = 0
for bit in range(1 << N):
    break_flag = 0
    for i in range(N):
        if (bit >> i) & 1:
            for j in range(len(syougen[i])):
                if ((bit>>(syougen[i][j][0]-1))&1) != syougen[i][j][1]:
                    break_flag = 1
                    break
            if break_flag == 1:
                break
        if i == N-1:
            ans = max(ans, bin(bit).count("1"))
print(ans)

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

//V以下の素数列挙。O(V log log V)
int V = 2180; //V * V * V >= 10^10
vector<int> prime;
void init() {
        vector<bool> is_prime(V + 1, true);
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= V; i ++) {
                if (is_prime[i]) {
                        prime.push_back(i);
                        for (int j = i + i; j <= V; j += i) is_prime[j] = false;
                }
        }
}

int main() {
        init();
        int n;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; i ++) cin >> a[i];
        unordered_map<ll, pll> cnts; //その数字の個数と、その数字のペア的なやつの数
        for (auto v : a) {
                ll val = 1, another = 1;
                for (auto p : prime) {
                        if (v % p != 0) continue;
                        int cnt = 0;
                        while (v % p == 0) {
                                cnt ++;
                                v /= p;
                        }
                        if (cnt % 3 == 1) {
                                val *= p;
                                another *= p * p;
                        } else if (cnt % 3 == 2) {
                                val *= p * p;
                                another *= p;
                        }
                }
                if (v > 1) {
                        ll tmp = sqrt(v);
                        ll root = 0;
                        for (int i = -1; i < 2; i ++) if ((tmp + i) * (tmp + i) == v) root = tmp + i;
                        val *= v;
                        if (root) another *= root;
                        else another *= v * v;
                }
                cnts[val].second = another;
                cnts[val].first ++;
        }
        auto tmp = cnts;
        ll ans = 0;
        for (auto u : tmp) if (u.first != 1 && cnts[u.second.second] < u.second) ans += u.second.first;
        if (cnts[1].first != 0) ans ++;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 18120
N = int(input())
A = list(map(int, input().split()))
c = 0
t = 0
while t == 0:
  A = [num/2 for num in A]
  B = [int(num) for num in A]
  if A == B:
    c += 1
  else:
    t += 1
print(c)

Measured memory_bytes: 64912
def left(arr, idx):
    if L[idx] != None:
        return L[idx]

    if arr[idx] == '<':
        if idx == 0:
            ret = 1
        else:
            ret = left(arr, idx-1) + 1
    else:
        ret = 0

    L[idx] = ret
    return ret
        
def right(arr, idx):
    if R[idx] != None:
        return R[idx]

    if arr[idx] == '>':    
        if idx == len(arr)-1:
            ret =  1
        else:
            ret = right(arr, idx+1) + 1
    else:
        ret = 0
    R[idx] = ret
    return ret

def main():
    S = list(input())
    N = len(S)
    A = [0 for _ in range(N+1)]
    
    global L; L = [None for _ in range(N)]
    global R; R = [None for _ in range(N)]

    for i in range(N):
        j = N - i - 1
        L[i] = left(S, i)
        R[j] = right(S, j)
    
    L = [0] + L
    R = R + [0]

    for i in range(len(A)):
        A[i] = max(L[i], R[i])
            
    print(sum(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 39472
/**
 * Created by hiramekun at 20:56 on 2019-09-28.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vector<P> a(n);
    rep(i, n) {
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(all(a));
    vl ans(n);

    rep(i, n) {
        cout << a[i].S + 1 << ' ';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3200
import numpy
N, K = map(int, input().split())
p = numpy.array(list(map(int, input().split())))
P = []
nowsum = 0
for p1 in p:
    nowsum += p1
    P.append(nowsum)

max = 0
nowsum = 0
for i in range(N-K+1):
    if i == 0:
        temp = P[K-1]
    else:
        temp = P[i+K-1]-P[i-1]
    if max < temp:
        max = temp
        maxno = i
exsum = 0
for i in range(K):
    temp = p[i+maxno]
    exsum += (0.5*temp*(temp+1))/temp
print(exsum)


Measured memory_bytes: 33740