akhauriyash/Code-Regression huggingface dataset:
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end


n = gif

a = gi
s1 = a.shift
s2 = a.inject(:+)
ans = (s1-s2).abs
rep (a.size-1) do |i|
s1 += a[i]
s2 -= a[i]
tmp = (s1-s2).abs
ans = tmp if ans > tmp
end

puts ans

Measured memory_bytes: 17644
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
A=V[::2]
B=V[1::2]
a=Counter(A)
b=Counter(B)
x=a.most_common(2)
y=b.most_common(2)
if x[0][0]!=y[0][0]:
  print((n//2-x[0][1])+(n//2-y[0][1]))
else:
  if len(x)>1 and len(y)>1:
    if x[0][1]>y[0][1]:
      print((n//2-x[0][1])+(n//2-y[1][1]))
    elif x[0][1]==y[0][1]:
      if x[1][1]>y[1][1]:
        print((n//2-x[1][1])+(n//2-y[0][1]))
      else:
        print((n//2-x[0][1])+(n//2-y[1][1]))
    else:
      print((n//2-x[1][1])+(n//2-y[0][1]))
  elif len(x)>1:
    print(n//2-x[1][1])
  elif len(y)>1:
    print(n//2-y[1][1])
  else:
    print(n//2)

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

int main(void) {
  vector<vector<int> > masu(5005);
  for (int i = 0; i < masu.size(); i++) {
    for (int j = 0; j < i+5; j++) {
      masu[i].push_back(0);
    }
  }


  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b, x;
    cin >> a >> b >> x;
    masu[a][b]++;
    masu[a][b+1]--;
    masu[a+x+1][b]--;
    masu[a+x+1][b+x+2]++;
    masu[a+x+2][b+1]++;
    masu[a+x+2][b+x+2]--;
  }

  // 左から右
  for (int i = 1; i <= n; i++) {
    for (int j = 2; j <= i; j++) {
      masu[i][j] += masu[i][j-1];
    }
  }

  // 上から下
  for (int j = 1; j <= n; j++) {
    for (int i = j+1; i <= n; i++) {
      masu[i][j] += masu[i-1][j];
    }
  }

  // 左上から右下
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      masu[j][j-i+1] += masu[j-1][j-i];
    }
  }

  int num = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      if (masu[i][j] >= 1) {
        num++;
      }
    }
  }

  cout << num << endl;
  return 0;
}

Measured memory_bytes: 62788
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	string r1, r2, r3, r4;
	for (int i = 0; i < ty - sy; i++) {
		r1.push_back('U');
	}
	for (int i = 0; i < tx - sx; i++) {
		r1.push_back('R');
	}

	r3.push_back('L');
	for (int i = 0; i < ty - sy + 1; i++) {
		r3.push_back('U');
	}
	for (int i = 0; i < tx - sx + 1; i++) {
		r3.push_back('R');
	}
	r3.push_back('D');

	for (int i = 0; i < r1.size(); i++) {
		if (r1.at(i) == 'U') {
			r2.push_back('D');
		}
		if (r1.at(i) == 'R') {
			r2.push_back('L');
		}
	}
	for (int i = 0; i < r3.size(); i++) {
		if (r3.at(i) == 'U') r4.push_back('D');
		if (r3.at(i) == 'L') r4.push_back('R');
		if (r3.at(i) == 'D') r4.push_back('U');
		if (r3.at(i) == 'R') r4.push_back('L');
	}

	cout << r1 << r2 << r3 << r4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N = 1e5 + 5;
string s;
int n, dp[N], f[N][3], sum[N];
bool bad = 1;
void add(int &x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	int n = s.length();
	/*
	We can see greedily that always picking the earliest possible spots to create an a or b is good
	enough.
	dp[i]: Number of different substrings we can create from the first i characters of s
	Then pass onto 2 positions j1 and j2, so that i + 1 -> j1 can create 'a', and to j2 create 'b'.
	For a, psum[j1] - psum[i] must mod 3 remainder 1. So we can know the remainder psum[j1] should
	have, and this can be easily found by a supporting array.
	*/
	s = " " + s;
	memset(sum, 0, sizeof sum);
	fw (i, 1, n + 1) sum[i] = sum[i - 1] + (s[i] == 'a' ? 1 : 2);
	memset(f, -1, sizeof f);
	/*
	f[i][j]: The first index k that considering the segment from i + 1 -> k, its sum MOD 3 is equal to
	j. Also, there are at least 2 adjancent characters that are equal (or the length is 1)
	*/
	fw (i, 1, n) if (s[i] == s[i + 1]) bad = 0;
	if (bad) {
		cout << "1";
		return 0;
	}
	bw (i, n + 1, 0) {
		fw (j, 0, 3) f[i][j] = f[i + 1][j];
		if (i) f[i][sum[i] % 3] = i;
	}
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	fw (i, 0, n + 1) {
		fw (j, 1, 3) {
			int k = (j + sum[i]) % 3;
			k = f[i][k];
			if (k != -1) add(dp[k], dp[i]);
		}
	}
	int ans = 0;
	fw (i, 1, n + 1) {
		if (sum[i] % 3 == sum[n] % 3) add(ans, dp[i]);
	}
	cout << ans;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int64_t L[N+1];
  L[0]=2;
  L[1]=1;
  
  for(int i=2;i<N+1;i++){
  	L[i]=L[i-1]+L[i-2];
  }
  cout << L[N] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> A){
    vll res(N, 0);
    rep(i, N - 1) res.at(A.at(i) - 1)++;
    for(auto x: res) cout << x << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> A(N-2+1);
    for(int i = 0 ; i < N-2+1 ; i++){
        ignore_ret(scanf("%lld",&A[i]));
    }
    solve(N, move(A));
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

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

    sort(A.begin(), A.end());

    ll maxa = A[N-1];

    ll diff = INF;
    ll ans = 0;
    REP(i, N){
        if(diff > abs(A[i] - double(maxa/2.0))){
            diff = abs(A[i] - double(maxa/2.0));
            ans = A[i];
        }
    }
    cout << maxa << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int cnt = 0;
        
        for (int i = 1; i <= N; i++) {
			if(i < 10) cnt++;
			if(i >=100 && i < 1000) cnt++;
			if(i >=10000 && i < 100000) cnt++;
			if(i >=1000000 && i < 10000000) cnt++;
		}
        System.out.println(cnt);
       
    }
}

Measured memory_bytes: 23636
fn main() {
    proconio::input! {
        n: usize,
        ds: [usize; n],
        m: usize,
        ts: [usize; m],
    }
    let mut dsm = std::collections::HashMap::new();
    for d in ds {
        *dsm.entry(d).or_insert(0) += 1;
    }
    for t in ts {
        if dsm.contains_key(&t) {
            *dsm.get_mut(&t).unwrap() -= 1;
            if *dsm.get(&t).unwrap() == 0 {
                dsm.remove(&t);
            }
        } else {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


Measured memory_bytes: 15676
//import java.lang.Math;
import java.util.*;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;

public class Main{

	public static void main(String[] arg) {

		HashSet<Integer> ht = new HashSet<Integer>();
		Scanner sc = new Scanner(System.in);
		int cnt = sc.nextInt();

		for (int i = 0; i < cnt; i++) {

			int cmt = sc.nextInt();

			switch (cmt) {

			case 0:
				int num = sc.nextInt();
				if(!ht.contains(num)) ht.add(num);
				
				
				System.out.println(ht.size());
				
				break;
			case 1:
				int num2 = sc.nextInt();
				int cnt2 = 0;
				if(ht.contains(num2)) cnt2=1;
				System.out.println(cnt2);
			}
		}
	}
}



Measured memory_bytes: 155024
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)

def main():
    @lru_cache(maxsize=None)
    def gcd(a, b):
        if a % b == 0:
            return b
        else:
            return gcd(b, a % b)

    def cul(n,x):
        l=len(x)
        b=[x[i] for i in range(l)]
        b.pop(n)
        tmp=b[0]
        for i in range(1,l-1):
            tmp=gcd(tmp,b[i])
        return tmp

    ans=0
    for i in range(p):
        s=cul(i,a[:p])
        if s>ans: ans=s
    print(ans)

if __name__=='__main__':
    N, *a = map(int, sys.stdin.read().split())
    p=50
    if p>N: p=N
    main()

Measured memory_bytes: 14620
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
using pii = pair<int, int>;
using lli = long long int;
lli b, w;

bool bfs(vector<vector<int> > &g){
  queue<int> que;
  que.push(0);
  vector<int> used(g.size(), 0);
  used[0] = 1;
  b = 1, w = 0;
  while(not que.empty()){
    int v = que.front();
    que.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int u = g[v][i];
      if(used[u] == 0){
        used[u] = -used[v];
        b += (used[u] > 0);
        w += (used[u] < 0);
        que.push(u);
      }else if(used[u] == used[v]) {
        return true;
      }
    }
  }
  return false;
}

int main(){
  lli n, m;
  std::cin >> n >> m;
  vector<vector<int> > g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    std::cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  if(bfs(g)) std::cout << n*(n - 1)/2 - m << std::endl;
  else std::cout << b*w - m << std::endl;
  return 0;
}


Measured memory_bytes: 6144
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << "[" << e << "] ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const T INF = numeric_limits<T>::max();
	vector<T> cost(V, INF);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(st, cost[st]);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				p_que.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	cin >> N >> Q;

	int u, v;
	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, 1);
		edges[v].emplace_back(u, 1);
	}

	vector<int> ans(N + 1);
	for (int i = 0; i < Q; i++) {
		int p, q;
		cin >> p >> q;
		ans[p - 1] += q;
	}

	DMP(ans);

	vector<int> visted(N);
	auto dfs = [&](auto &&f, int now, int par) -> void {
		visted[now] = 1;
		for (const auto &e : edges[now]) {
			if (!visted[e.to] && e.to != par) {
				ans[e.to] += ans[now];
				f(f,e.to, now);
			}
		}
	};

	dfs(dfs, 0, -1);

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

	return 0;
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int n, m, i, j;
	int A[1000] = {0};
	int B;
	int count[1000] = {0};
	int ans = 0;

	cin >> n >> m;

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

	for(i = 0; i < m; i++) {
		cin >> B;
		for(j = 0; j < n; j++) {
			if(A[j] <= B) {
				count[j]++;
				break;
			}
		}
	}

	for(i = 0; i < n; i++) {
		if(count[ans] < count[i]) {
			ans = i;
		}
	}

	cout << ans + 1 << endl;

	return 0;

}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
	// 2020/2/8 No.146
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	List<String> days = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
	int result = 7 - days.indexOf(str);
	System.out.println(result);
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(void){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);


  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  int a=A*B;
  int b=C*D;
  cout<<max(a,b)<<endl;
  
  
}



Measured memory_bytes: 256
//==========================================
// ABC142c
//
// 2019/09/28
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; ++i)
  {
    int temp;
    cin >> temp;
    v[temp-1]=i;
  }

  for(auto x: v) cout << x+1 << " " ;
  cout << endl;



  
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x[] = new int[5];
    for(int i = 0; i < 5; i++) {
      x[i] = stdIn.nextInt();
    }
    int k = stdIn.nextInt();

    int flag = 1;
    for(int i = 0; i < 4; i++) {
      for(int j = i+1; j < 5; j++) {
          int d = x[i] - x[j];
          if(Math.abs(d) > k) {flag = 0; break;}
      }
    }

    if(flag == 0) {
      System.out.println(":(");
    }else {
      System.out.println("Yay!");
    }
  }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    sort(A.begin(), A.end());
    ll l=0, r=200008;
    ll check=0;
    //幸福度m以上の握手が何個存在するかで二分探索
    while(l+1<r){
        ll m=(l+r)/2;
        ll count=0;
        //尺取り法で調べる
        ll L=0,R=N-1;
        while(1){
            if(A[L]+A[R]<m){L++;
                if(L>=N)break;
            }
            else {
                count+=N-L;
                R--;
                if(R<0)break;
            }
        }
        if(count>=M)l=m;
        else {r=m;
        check=count;}
    }

    vector<ll> ikou(N,0);
    ikou[N-1]=A[N-1];
    for(ll i=N-2;i>=0;i--){
        ikou[i]=ikou[i+1]+A[i]
    ;}
    ll ans=0;
    ll L=0,R=N-1;
        while(1){
            if(A[L]+A[R]<r){L++;
                if(L>=N)break;
            }
            else {
                ans+=ikou[L]+(N-L)*A[R];
                R--;
                if(R<0)break;
            }
        }
    ans+=l*(M-check);
    
    cout << ans << endl;


    return 0;
}


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


int main(){
    long long n, a, b;
    cin >> n >> b >> a;

    if(a == 0 && b == 0){
        cout << 0 << endl;
        return 0;
    }

    long long ab = a + b;
    long long N = n / ab;
    long long P = n % ab;

    long long ans;

    if(P <= b){
        ans = N*b + P;
    }else{
        ans = N*b + b;
    }

    cout << ans << endl;
}

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

signed main(){
	int n,maxi=0,crt=0,prev=-1;
	cin >> n;
	for (int i=0; i<n; ++i){
		int a;
		cin >> a;
		if (a > prev){
			maxi = max(crt,maxi);
			crt = 0;
		}
		else crt++;
		prev = a;
	}
	cout << max(crt,maxi);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a, b;
  std::cin >> a >> b;
  if (a < b)
  {
    for (int i = 0; i < b; i++) std::cout << a;
    std::cout << std::endl;
  }
  else
  {
    for (int i = 0; i < a; i++) std::cout << b;
    std::cout << std::endl;
  }
}


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.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x;
	cin >> x;
	if (x < 1200)
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;

} 

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    int size(int u) {
        return -p[root(u)];
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

    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.unite(a, b);
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r = max(r, uf.size(i));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template<class T> void cc(vector<T> a,unordered_map<T,int>& nm,vector<int>& c){
    sort(a.begin(),a.end());
    fr(i,a.size()){
        if(i<a.size()-1&&a[i]==a[i+1]) continue;
        nm[a[i]]=c.size();
        c.emplace_back(a[i]);
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n),c(n),d(m),e(m),f(m),v(2*n+m+1),h(n+2*m+1);
    fr(i,n){
        cin>>a[i]>>b[i]>>c[i];
        v[i]=a[i];
        v[i+n]=b[i];
        h[i]=c[i];
    }
    fr(i,m){
        cin>>d[i]>>e[i]>>f[i];
        v[i+n*2]=d[i];
        h[i+n]=e[i];
        h[i+n+m]=f[i];
    }
    unordered_map<int,int> nmv,nmh;
    vector<int> V,H;
    cc(v,nmv,V);cc(h,nmh,H);
    auto lv=vector(V.size(),vector<bool>(H.size()));
    auto lh=vector(V.size(),vector<bool>(H.size()));
    fr(i,n){
        a[i]=nmv[a[i]];
        b[i]=nmv[b[i]];
        c[i]=nmh[c[i]];
        for(int I=a[i];I<b[i];++I) lv[I][c[i]]=true;
    }
    fr(i,m){
        d[i]=nmv[d[i]];
        e[i]=nmh[e[i]];
        f[i]=nmh[f[i]];
        for(int J=e[i];J<f[i];++J) lh[d[i]][J]=true;
    }
    ll ans{};
    int X=nmv[0],Y=nmh[0];
    stack<pair<int,int>> st;
    st.emplace(X,Y);
    int limv=V.size()-1,limh=H.size()-1;
    if(X==limv or Y==limh) return puts("INF"),0;
    auto vis=vector(limv,vector<bool>(limh));
    while(!st.empty()){
        auto[x,y]=st.top();st.pop();
        if(vis[x][y]) continue;
        vis[x][y]=true;
        ans+=(ll)(V[x+1]-V[x])*(H[y+1]-H[y]);
        if(x==0 and !lh[x][y]) return puts("INF"),0;
        if(y==0 and !lv[x][y]) return puts("INF"),0;
        if(x+1==limv and !lh[x+1][y]) return puts("INF"),0;
        if(y+1==limh and !lv[x][y+1]) return puts("INF"),0;
        if(x>0 and !vis[x-1][y] and !lh[x][y]) st.emplace(x-1,y);
        if(y>0 and !vis[x][y-1] and !lv[x][y]) st.emplace(x,y-1);
        if(x+1<limv and !vis[x+1][y] and !lh[x+1][y]) st.emplace(x+1,y);
        if(y+1<limh and !vis[x][y+1] and !lv[x][y+1]) st.emplace(x,y+1);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 47320
num_list = []
while True:
    try:
        element = input()
    except EOFError:
        break

    num_list.append(int(element))

limit = num_list[-1]

ans_string = "Yay!"
# for i in range(len(num_list) - 1):
#     print(num_list[i + 1] - num_list[i])
#     if num_list[i + 1] - num_list[i] > limit:
#         ans_string = ":("

for i in range(len(num_list) - 1):
    for j in range(i, len(num_list) - 1):
        if num_list[j] - num_list[i] > limit:
            ans_string = ":("

print(ans_string)


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  set<string> st;
  string s; cin >> s;
  int k; cin >> k;
  rep(i,sz(s)) FOR(j,1,min(6ll,sz(s)-i+1)) st.insert(s.substr(i,j));
  int i = 1;
  for(auto x : st){
    if(i == k){
      cout << x << endl;
      break;
    }
    i++;
  }
}

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


def make_divisors(n):
    divisors = []
    s = n ** (1/2)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i > s:
                divisors.append(i-1)
            if i != n // i and n//i-1 > s:
                divisors.append(n//i - 1)
    return divisors
S = make_divisors(N)
print(sum(S))

Measured memory_bytes: 38768
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

vector<pair<LL,LL> > vec;
set<pair<LL,LL> > st, ts;
LL tot[10];

void hora(int tc) {
	LL r, c, n;
	cin>>r>>c>>n;
	pair<LL,LL> t;
	for(int i = 0;i < n;i++) {
		cin>>t.first>>t.second;
		vec.PB(t);
		st.insert(t);
	}
	LL alls = 0;
	for(auto x: st) {
		for(int i = -1;i <= 1;i++) {
			for(int j = -1;j <= 1;j++){
				int ii = x.FI + i;
				int jj = x.SE + j;
				if(ts.find({ii, jj}) != ts.end()) continue;
				if(ii <= 1 || jj <= 1 || ii >= r || jj >= c) continue;
				ts.insert({ii, jj});
				int tow = 0;
				for(int k = -1;k <= 1;k++) {
					for(int l = -1;l <= 1;l++) {
						int wi = ii + k;
						int wj = jj + l;
						if(st.find({wi, wj}) != st.end()) tow++;
					}
				}
				tot[tow]++;
				alls++;
			}
		}
	}
	tot[0] = (r - 2) * (c - 2) - alls;
	for(int i = 0;i <= 9;i++) cout<<tot[i]<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 64368
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    long[] M = {999_999_937, 1_000_000_007};
    long B = new Random().nextInt(999_999_937);
    int left = 0;
    int right = N / 2 + 1;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (possible(s, mid, N, B, M)) left = mid;
      else right = mid;
    }
    System.out.println(left);
  }

  private static boolean possible(char[] s, int K, int N, long B, long[] M) {
    long[] bn = new long[M.length];
    for (int i = 0; i < M.length; i++) {
      bn[i] = 1;
      for (int j = 0; j < K - 1; j++) {
        bn[i] *= B;
        bn[i] %= M[i];
      }
    }

    HashMap<Tuple, Integer> occurrences = new HashMap<>();
    long[] hash = new long[M.length];
    for (int i = 0; i < M.length; i++) {
      hash[i] = hash(s, K, B, M[i]);
    }
    occurrences.put(new Tuple(hash), 0);
    for (int i = 1; i <= N - K; i++) {
      for (int j = 0; j < M.length; j++) {
        hash[j] -= s[i - 1] * bn[j] % M[j];
        if (hash[j] < 0) hash[j] += M[j];
        hash[j] *= B;
        hash[j] %= M[j];
        hash[j] += s[i + K - 1];
        if (hash[j] >= M[j]) hash[j] -= M[j];
      }
      Tuple key = new Tuple(hash);
      if (occurrences.containsKey(key)) {
        if (occurrences.get(key) + K <= i) return true;
      }
      else occurrences.put(key, i);
    }
    return false;
  }

  private static long hash(char[] s, int len, long B, long M) {
    if (s.length < len) throw new IllegalArgumentException("len must be equal to or more than s.length: len=" + len + ", s.length=" + s.length);
    long hash = 0;
    for (int i = 0; i < len; i++) {
      hash *= B;
      hash %= M;
      hash += s[i];
      if (hash >= M) hash -= M;
    }
    return hash;
  }

  private static class Tuple {
    private final long[] elements;

    private Tuple(long[] elements) {
      this.elements = Arrays.copyOf(elements, elements.length);
    }

    @Override public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Tuple tuple = (Tuple) o;
      return Arrays.equals(elements, tuple.elements);
    }

    @Override public int hashCode() {
      return Arrays.hashCode(elements);
    }
  }
}


Measured memory_bytes: 30804
#include<stdio.h>
#define N 200000

int main(){
  int n,nn[N],maxv,minv,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&nn[i]);
  }

  maxv = nn[1]-nn[0];
  minv = nn[0];
  
  for(j=1;j<n;j++){
    if(maxv<nn[j]-minv){
      maxv=nn[j]-minv;
    }
    if(minv>nn[j]){
      minv=nn[j];
    }
  }
  
  printf("%d\n",maxv);
  return 0;
}



Measured memory_bytes: 2632
#include<stdio.h>
#define S 100000
#define T 50000
int main(){
  int s[S],t[T],n,q,i,j=0,count=0,k,r,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  for(i=0;i<q;i++){
    k=t[i];
    l=0;
    r=n;
    while(1){
      m=(l+r)/2;
      if(s[m]==k){
	count++;
	break;
      }
      else if(s[m]<k){
	l=m+1;
      }
      else if(s[m]>k){
	r=m-1;
      }
      if(r<l){
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2284
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define prf(x) printf("%.20f", x)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(){
	cnt = 0;
	SET(point,0);
}
*/
struct hh{
	string pre,suf;
	bool operator < (const hh &x) const{
		if(pre.compare(x.pre)==0)
			return suf.compare(x.suf)<0;
		return pre.compare(x.pre)<0;
	}
};
map<hh,int> cnt;
int n, m, k,q;
string s;
int main(){
//	freopen("1", "r", stdin);
	sc(n);
	cin>>s;
	rep(i,0,(1<<n)-1){
		int x = i;
		string pre="",suf="";
		rep(j,0,n-1){
			if(x&1){
				pre = pre + s[j];
			}else{
				suf = s[j] + suf;
			}
			x >>= 1;
		}
		auto p = (hh){pre,suf};
		if(cnt.count(p))cnt[p]++;
		else cnt[p] = 1;//,cout<<pre<<" "<<suf<<endl;
	}
//	ln;
	ll ans = 0;
	rep(i,0,(1<<n)-1){
		int x = i;
		string pre="",suf="";
		rep(j,n,2*n-1){
			if(x&1){
				pre = s[j] + pre;
			}else{
				suf = suf + s[j];
			}
			x >>= 1;
		}
		auto p = (hh){pre,suf};
		ans += cnt[p];
//		if(cnt.count(p))
//			cout<<cnt.count(p)<<" "<<pre<<" "<<suf<<endl;
	}
	cout<<ans;
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


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

int main() {

	string s, t; cin >> s >> t;
	
	if (s.size() < t.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	vector<bool> hatenaIndex(s.size(), false);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '?') {
			hatenaIndex[i] = true;
			s[i] = 'a';
		}
	}
	
	vector<string> c;
	for (int i = 0; i < s.size()- t.size() + 1; i++) {		
		bool can = true;
		for (int j = i; j < i + t.size(); j++) {
			if (hatenaIndex[j]) continue;
			if (s[j] != t[j - i]) {
				can = false;
				break;
			}
		}

		if (can) {
			string ans = "";
			for (int j = 0; j < i; j++) ans += s[j];
			ans += t;
			for (int j = i + t.size(); j < s.size(); j++) ans += s[j];
			c.push_back(ans);
		}

	}

	sort(c.begin(), c.end());

	if(c.size()==0) cout << "UNRESTORABLE" << endl;
	else cout << c[0] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n][n];rep(i,0,n-1)rep(j,0,n-1)cin>>a[i][j];
    ll dp[1<<n];memset(dp,0,sizeof(dp));
    rep(k,0,n-1){
        if(a[0][k]==1){
            dp[1<<k]=1;
        }
    }
    rep(i,1,n-1){
        rep(j,0,(1<<n)-1){
            ll c=0;
            rep(k,0,n-1)if(j>=(1<<k)&&(j>>k)&1)c++;
            if(c!=i+1)continue;
            rep(k,0,n-1){
                if(a[i][k]==1&&(j>=(1<<k))&&(j>>k)&1){
                    Add(&dp[j],dp[j-(1<<k)]);
                }
            }
        }
    }
    /*rep(i,0,n-1){
     rep(j,0,(1<<n)-1){
     cout<<dp[i][j]<<" ";
     }cout<<endl;
     }*/
    ll p=(1<<n)-1;
    cout<<mod(dp[p])<<endl;
    return 0;
}






Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main() {
		int N, K;
		cin >> N >> K;
		set<int> st;
		for (int i = 0; i < K; ++i) {
				int t;
				cin >> t;
				st.insert(t);
		}

		bool flg = true;
		for (int i = N; i < N*10; i++) {
				string S = to_string(i);
				int t = i;
				for (int j = 0; j < S.size(); j++) {
						if (st.find(t%10) != st.end()) {
								flg = false;
								break;
						} else {
								t /= 10;
						}
				}

				if (!flg) flg = true;
				else {
						cout << i << endl;
						return 0;
				}
		}


		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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 print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, buf;
vector<ll> a;

bool hantei(ll x){
	ll sum = a[x];
	rep(i, 0, n){
		if(i != x){
			if(a[i] > 2*sum){
				return false;
			}
			sum += a[i];
		}
	}
	return true;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	
	rep(i, 0, n){
		cin >> buf;
		a.push_back(buf);
	}
	sort(a.begin(), a.end());
	ll ok = n-1;
	ll ng = -1;
	while(ok-ng > 1){
		ll mid = (ok+ng)/2;
		if(hantei(mid)){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	print(n-ok)
	return 0;
}

Measured memory_bytes: 1400
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
D=[0]*25
D[0]+=1
D[24]+=1
for i in range(N):
  if i%2==0:
    D[A[i]]+=1
  else:
    D[24-A[i]]+=1

for i in D:
  if i>1:
    print(0)
    exit()
p=0
ans=24
for i in range(1,25):
  if D[i]==1:
    d=(i-p)
    ans=min(d,ans)
    p=i
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int t,a,b;
    scanf("%d",&t);
    if(t==1)
    {
        printf("Hello World\n");
    }
    if(t==2)
    {
        scanf("%d %d",&a,&b);
    printf("%d\n",a+b);
    }
    return 0;
}


Measured memory_bytes: 128
/*I know about "bits/stdc++.h" 
But I am not using it for some technical issue*/

#include "iostream"
#include "algorithm"
#include "iomanip"
#include "vector"
#include "set"
#include "sstream"
#include "fstream"
#include "cstring"
#include "cmath"
#include "utility"
#include "map"
#include "bitset"
#include "cassert"
#include "deque"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,lg; cin>>n>>lg;
	if(lg % 2 == 0 && lg>= n*2 && lg<= n*4) cout<<"Yes" el;
	else cout<<"No" el;
  return 0;
}

Measured memory_bytes: 3656
import itertools

N = int(input())
d = [0]*N
for i in range(N):
    A = int(input())
    d[i] = [list(map(int,input().split())) for _ in range(A)]
ans = 0
l = [0,1]
for s in itertools.product(l, repeat = N):
    flag = 0
    for i in range(N):
        if s[i] == 1:
            for a in d[i]:
                if a[1] == 1:
                    if s[a[0]-1] == 1:
                        pass
                    else:
                        flag = -1
                else:
                    if s[a[0]-1] == 0:
                        pass
                    else:
                        flag = -1
    if flag == 0:
        ans = max(ans, s.count(1))
print(ans)


Measured memory_bytes: 3064
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int ans = n%1000;
		if(ans != 0)
		{
			ans = 1000-ans;
		}
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 3652
// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
using namespace std;

inline int In(){
	char c=getchar(); int x=0,ft=1;
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ft=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return x*ft;
}

const int N=2e5+5;
int n,h[N],e_tot=0;
struct Edge{
	int to,nex;
	Edge(){}
	Edge(int to,int nex):to(to),nex(nex){}
}e[N<<1];

inline void add(int u,int v){
	e[++e_tot]=Edge(v,h[u]); h[u]=e_tot;
}

int sz[N],cnt[N],fac[N],inv[N];

void dfs(int u,int pre){
	sz[u]=1;
	for(int i=h[u],v;i;i=e[i].nex){
		v=e[i].to; if(v==pre) continue;
		dfs(v,u); sz[u]+=sz[v];
	}
	if(u!=1) ++cnt[sz[u]],++cnt[n-sz[u]];
}

const int P=924844033;
int L,C,r[N<<2],F[N<<2],G[N<<2],H[N<<2];

inline void Add(int& x,int y){
	x+=y; if(x>=P) x-=P;
}

inline int Mul(int x,int y){
	return 1ll*x*y%P;
}

inline int fpow(int x,int k){
	int res=1;
	for(;k;k>>=1,x=Mul(x,x)) if(k&1) res=Mul(res,x);
	return res;
}

inline void NTT_prepare(int len){
	for(L=1,C=0;L<=len;L<<=1,++C);
	for(int i=0;i<L;++i) r[i]=(r[i>>1]>>1)|((i&1)<<(C-1));
}

void NTT(int* A,int op){
	for(int i=0;i<L;++i) if(i<r[i]) swap(A[i],A[r[i]]);
	for(int i=1;i<L;i<<=1){
		int Wn=fpow(5,(P-1)/(i<<1));
		if(op==-1) Wn=fpow(Wn,P-2);
		for(int j=0;j<L;j+=i<<1){
			int w=1;
			for(int k=0;k<i;++k,w=Mul(w,Wn)){
				int p=A[j+k],q=Mul(w,A[j+i+k]);
				A[j+k]=(p+q)%P; A[j+i+k]=((p-q)%P+P)%P;
			}
		}
	}
	if(op==-1){
		int inv_L=fpow(L,P-2);
		for(int i=0;i<L;++i) A[i]=Mul(A[i],inv_L);
	}
}

int main(){
	n=In();
	for(int i=1,u,v;i<n;++i){
		u=In(); v=In();
		add(u,v); add(v,u);
	}
	dfs(1,0); fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=n;++i) fac[i]=Mul(fac[i-1],i);
	for(int i=2;i<=n;++i) inv[i]=Mul(P-P/i,inv[P%i]);
	for(int i=1;i<=n;++i) inv[i]=Mul(inv[i-1],inv[i]);
	for(int i=0;i<=n;++i) G[i]=Mul(cnt[i],fac[i]);
	for(int i=0;i<=n;++i) H[i]=inv[n-i];
	NTT_prepare(n+n); NTT(G,1); NTT(H,1);
	for(int i=0;i<L;++i) F[i]=Mul(G[i],H[i]); NTT(F,-1);
	for(int i=1;i<=n;++i){
		int res=Mul(n,Mul(fac[n],Mul(inv[i],inv[n-i])));
		Add(res,P-Mul(inv[i],F[n+i])); printf("%d\n",res);
	}
	return 0;
}

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

long long a, b, c;

bool chk() {
    c -= a + b;
    if (c <= 0) return 0;
    // cout << c << endl;
    c = c * c;
    if (a * b * 4 < c) return 1;
    return 0;
}

int main() {
    cin >> a >> b >> c;
    if (chk()) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
bingo = []
for count in range(0,3):
    A = list(map(int,input().split()))
    bingo.append(A)

bingo1 = [0] * 3
bingo2 = [0] * 3
bingo3 = [0] * 3
N = int(input())

for count in range(0,N):
    inp = int(input())
    for count3 in range(3):
        bi = bingo[count3]
        for count2 in range(3):
            if bi[count2] == inp:
                if count3 == 0:
                    bingo1[count2] = 1
                if count3 == 1:
                    bingo2[count2] = 1
                if count3 ==2 :
                    bingo3[count2] = 1
bingF = False
#bingo判定
for count in range(3):
    #縦
    if bingo1[count] == 1 and bingo2[count] == 1 and bingo3[count] == 1:
        bingF = True

#横
if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    bingF = True
if bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    bingF = True

#斜め
if bingo1[0] == 1 and bingo2[1] == 1 and bingo3[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo2[1] == 1 and bingo1[2] == 1:
    bingF = True

if bingF == False:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
/*
 *  Author : H_Tatsuhiro ( Tatsuhiro Hashimoto )
 *  Created : 2020/08/29 21:14:55
 */

#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ilMAX 2147483647;
#define llMAX 9223372036854775807;
#define ullMAX 18446744073709551615;
#define SORT(v) sort((v).begin(), (v).end());
#define REV(v) reverse((v).begin(), (v).end());
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

void solve() {
    string S, T; cin >> S >> T;
    int n = T.length(), ans = 100000;
    for (int i = 0; i <= S.length() - n; i++) {
        string str = S.substr(i, n);
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (str[j] != T[j]) cnt++;
        }
        ans = min(cnt, ans);
    }
    if (ans == 100000) cout << n << endl;
    else cout << ans << endl;
}

signed main() {
    prepare
    solve();
}

Measured memory_bytes: 3644