akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
// Whenever you start to believe  yourself, people also start to believe in you
using namespace std;
int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
    int n=10;
   int ara[n];
   int i,j,k;
   for(i=0;i<n;i++)
   {
       cin>>ara[i];
   }
   qsort(ara,n, sizeof(int), cmpfunc);
   cout<<ara[n-1]<<endl;
   cout<<ara[n-2]<<endl;
   cout<<ara[n-3]<<endl;
    return 0;
}

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

int main()
{ 
	int a, b, c, n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b >> c;
		if (a*a==b*b+c*c||b*b==c*c+a*a||c*c==a*a+b*b) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3076
data = input().split(' ')

data_int = [int(data[i]) for i in range(3)]

if(data_int[0] - data_int[2] >= 0):
    print(str(data_int[0] - data_int[2]) + ' ' + str(data_int[1]))
else:
    result = data_int[1] - (data_int[2] - data_int[0])
    if(result < 0 ):
        result = 0
    print('0 ' + str(result))


Measured memory_bytes: 3060
program main
 implicit none
 integer n,val,ind,i,j
 integer, allocatable::a(:)
 read(*,*) n
 allocate(a(1:n))
 do i=1,n
  a(i) = -1
 end do
 read(*,*) val
 ind = 1
 a(1) = val
 do i=2,n
  read(*,*) val
  if(a(ind) >= val) then
   a(ind+1) = val
   ind = ind+1
  else
   do j=1,ind
    if(a(j) < val) then
     a(j) = val
     exit
    end if
   end do
  end if
 end do
 write(*,*) ind
end program main

Measured memory_bytes: 1024
import java.util.*;
import java.util.Map.Entry;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String key = String.valueOf(c);
            if(map.containsKey(key)){
                map.put(key, map.get(key) + 1);
            }else{
                map.put(key, 1);
            }
        }
        long ans = 0;
        for(Entry<String, Integer> e : map.entrySet()){
            ans += (long)e.getValue() * (long)(e.getValue() -1) /2;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 52668
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		
		while( true ) {
			int H = kb.nextInt();
			int W = kb.nextInt();
			
			if( 0==W && 0==H ) { break; }
			
			for( int i=0; i<H; i++ ) {
				for( int j=0; j<W; j++ ) {
					System.out.print( "#" );
				}
				System.out.print( "\n" );
			}
			System.out.print( "\n" );
		}
	}
}

Measured memory_bytes: 32036
if __name__ == "__main__":
    n, q = map(int, input().split())
    tree = [[] for i in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    
    node = [0] * n
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        node[p] += x
    
    ans = [0] * n
    visited = [False] * n

    st = [[0, 0]]
    visited[0] = True
    
    while st:
        now_node, now_score = st.pop()

        now_score += node[now_node]

        ans[now_node] = now_score

        for nex in tree[now_node]:
            if not visited[nex]:
                visited[nex] = True
                st.append([nex, now_score])
    
    for i in range(n):
        ans[i] = str(ans[i])
    print(" ".join(ans))

Measured memory_bytes: 73496
const M: usize = 998244353;

fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        lr: [(usize, usize); k],
    }

    let mut dp = vec![0; n];
    dp[0] = 1;
    dp[1] = M - 1;
    for i in 0..(n - 1) {
        if dp[i] > 0 {
            for &(l, r) in &lr {
                let (l, r) = (i + l, i + r + 1);
                if l < n { dp[l] = (dp[l] + dp[i]) % M }
                if r < n { dp[r] = (M + dp[r] - dp[i]) % M }
            }
            dp[i + 1] = (dp[i + 1] + dp[i]) % M;
        }
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl                endl

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int x, int y) {                                                             //return x^y in order(log(y))
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
struct trio {
  T first{};
  T second{};
  T third{};
};
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class AMoveAndWin {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, A, B;
    cin >> N >> A >> B;
    int now = 0;
    while (true) {
      now++;
      if (now == bpm(10, 7)) {
        cout << "Draw" << endl;
        break;
      }
      int gap = abs(B - A) - 1;
      if ((A == 0 and B == 1)) {
        cout << "Borys" << endl;
        break;
      }
      if (gap % 2) {
        A++;
      } else if (A == 0) {
        A++;
      } else {
        A--;
      }
      gap = abs(B - A) - 1;
      if (B == N and A == N - 1) {
        cout << "Alice" << endl;
        break;
      }
      if (gap % 2) {
        B--;
      } else if (B == N) {
        B--;
      } else {
        B++;
      }
    }
  }
};


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  AMoveAndWin solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 384
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    td = [list(map(int, input().split())) for _ in range(n)]
    td.sort(reverse=True, key=lambda a: a[1])
    delicious = 0
    syurui = set()
    suteru = []
    for i in range(k):
        t, d = td[i]
        delicious += d
        if  t in syurui:
            suteru.append(d)
        else:
            syurui.add(t)
    #heapify(suteru)
    suteru.sort()
    neta = len(syurui)
    res = delicious + neta**2
    for i in range(k, n):
        t, d = td[i]
        if t in syurui:
            continue
        if len(suteru)==0:
            print(res)
            exit()
        syurui.add(t)
        x = suteru.pop(0)
        delicious += d - x
        neta += 1
        res = max(res, delicious+neta**2)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 30460
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n,t;
  scanf("%d %d",&n,&t);
  int from=0;
  int ans=0;
  for(int i=0;i<n;i++){
    int ti;
    scanf("%d",&ti);
    ans+=ti+t-max(from,ti);
    from=ti+t;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec  

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
void solve()
{
	int n,d;
	int cnt=0;
	cin>>n>>d;
	while(n--)
	{
		double x,y;
		cin>>x>>y;
		int dis=ceil((double)sqrt(x*x+y*y));
		if(dis<=d)
			cnt++;
	}
	cout<<cnt<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, long long A, long long B){
  ll ans=min(N*A,B);
  op(ans);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

class Combination{
	private:
		const static long long MOD = 1e9+7;
		const static long long MAX = 510000;
		vector<long long> fact;
		vector<long long> finv;
		vector<long long> inv;
	public:
		Combination() : fact(MAX),finv(MAX),inv(MAX){ //n,k <=10^7くらいまで
			fact[0] = fact[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for(int i=2;i<MAX;i++){
				fact[i] = fact[i-1] * i % MOD;
				inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
				finv[i] = finv[i-1] * inv[i] % MOD;
			}
		}

		long long nCk(long long n,long long k){
			if(n<k) return 0;
			if(n<0 || k<0) return 0;
			return fact[n] * (finv[k] * finv[n-k] % MOD) % MOD;
		}

		vector<long long> com; //n固定で n<=10^9, k <= 10^7
		void nCbigk(long long n){
			com.push_back(1);
            com.push_back(n);
            for(long long i=2;i<200010;i++){
                com.push_back((com[i-1] * (n-(i-1)) % MOD) * inv[i] % MOD);
            }
		}

};


long long modpow(long long a,long long n,long long p = 1e9+7){
    long long result = 1;
    while(n > 0){
        if(n & 1) (result *= a) %= p;
        (a*=a) %= p;
        n >>= 1;
    }
    return result;
}
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    Combination C;
    C.nCbigk(n);
    ll ans=modpow(2,n)-1;
    ans = ans - C.com[a] - C.com[b];
    while(ans<0) ans += mod;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int ms = 2e5 + 200;

vector<int> mp[300];
int st[300], ed[300];
int bit[ms];

void add(int p, int v) {
  while (p < ms) {
    bit[p] += v;
    p += p & -p;
  }
}

int sum(int p) {
  int ans = 0;
  while (p > 0) {
    ans += bit[p];
    p -= p & -p;
  }
  return ans;
}

char s[ms];

int main() {
  scanf(" %s", s);
  int n = strlen(s);
  for (int i = 0; s[i]; i++) {
    mp[s[i]].push_back(i);
    add(i + 1, 1);
  }
  int cnt = 0;
  for (int i = 0; i < 300; i++) {
    if (mp[i].size() & 1) cnt++;
    st[i] = 0, ed[i] = mp[i].size() - 1;
  }
  if (cnt > 1) {
    puts("-1");
    return 0;
  }
  long long ans = 0;
  for (int i = 0; 2 * i + 1 < n; i++) {
    int ml = 1, mr = 0, mdist = 1e8;
    char ch;
    for (int j = 0; j < 300; j++) {
      int sz = ed[j] - st[j] + 1;
      if (sz > 1){
        int l = mp[j][st[j]], r = mp[j][ed[j]];
        int ll = sum(l), rr = sum(r);
        int dist = ll + n - 2 * i - rr - 1;
        if (dist < mdist) {
          mr = r, ml = l;
          mdist = dist;
          ch = j;
        }
      }
    }
    add(ml + 1, -1);
    add(mr + 1, -1);
    st[ch]++;
    ed[ch]--;
    ans += mdist;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2680
A = input()
B = input()
finished = False
 
if len(A) > len(B):
  print("GREATER")
  finished = True
elif len(A) < len(B):
  print("LESS")
  finished = True
else:
  for i in range(len(A)):
    if A[i] > B[i]:
      print("GREATER")
      finished = True
      break
    elif A[i] < B[i]:
      print("LESS")
      finished = True
      break
 
if not finished:
  print("EQUAL")


Measured memory_bytes: 9048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int num1, num2, num3;
		
		if ((a < b) && (a < c)) {
			num1 = a;
			if (b < c) {
				num2 = b;
				num3 = c;
			} else {
				num2 = c;
				num3 = b;
			}
		} else if ((b < a) && (b < c)) {
			num1 = b;
			if (a < c) {
				num2 = a;
				num3 = c;
			} else {
				num2 = c;
				num3 = a;
			}
		} else {
			num1 = c;
			if (a < b) {
				num2 = a;
				num3 = b;
			} else {
				num2 = b;
				num3 = a;
			}
		}
		
		System.out.println(num1 + " " + num2 + " " + num3);
	}
}

Measured memory_bytes: 26276
x = (0..9).to_a.repeated_permutation(4).to_a
y = x.map { |a| a.inject(:+) }
loop do
  s = gets
  break if s.nil?
  n = s.chomp.to_i
  if n > 36
    puts 0
  else
    # puts x.select { |a| a.inject(:+) == n }.count
    puts y.select { |a| a == n }.count
  end
end

Measured memory_bytes: 8272
#include<iostream>
#include<cmath>

    int main() {
        int N, T, A, P;
        double Y=10000;
        std::cin >> N >> T >> A;
        int H[N+2];
        for (int i = 1; i <= N; i++)
            std::cin >> H[i];

        for (int i = 1; i <= N; i++) {
            double temp =std::abs(A-(T-(H[i] * 0.006)));
            if (temp < Y) {
                Y = temp;
                P = i;
            }
        }

        std::cout << P << std::endl;

        return 0;
    }

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    string s; cin>>s;
    int l=0,r=n,mid;
    while(r-l>1){
        mid=(l+r)/2;
        map<string,vector<int>> mp;
        rep(i,0,n-mid+1){
            mp[s.substr(i,mid)].push_back(i);
        }
        bool f=0;
        for(pair<string,vector<int>> p:mp){
            int pre=-inf,cnt=0;
            rep(i,0,p.second.size()){
                if(p.second[i]-pre>=p.first.size()){
                    pre=p.second[i]; cnt++;
                }
                if(cnt>=2)f=1;
            }
        }
        if(f)l=mid; else r=mid;
    }
    printf("%d\n",l);
    return 0;
}


Measured memory_bytes: 6784
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N;cin>>N;
    double x[20],Y=0;
    vector<string>u(20);
    for(int i=0;i<N;++i){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY")Y+=x[i];
        else Y+=(double)380000*x[i];
    }

    printf("%.8lf\n",Y);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int n=s.nextInt(),m=s.nextInt();
		int[] a=new int[n],b=new int[m];
		int[] f=new int[n*m];
		Arrays.setAll(a,i->s.nextInt());
		Arrays.setAll(b,i->s.nextInt());
		Arrays.sort(a);
		Arrays.sort(b);
		for(int i=1;i<n;++i){
			if(a[i]==a[i-1]){
				System.out.println(0);
				return;
			}
		}
		for(int i=1;i<m;++i){
			if(b[i]==b[i-1]){
				System.out.println(0);
				return;
			}
		}

		for(int i=0;i<n;++i){
			for(int j=0;j<m;++j){
				f[i*m+j]=Math.min(a[i],b[j]);
			}
		}

		Arrays.sort(f);

		long c=1;
		loop:
		for(int i=0;i<n;++i){
			for(int j=0;j<m;++j){
				if(a[i]==b[j]){
					b[j]=0;
					continue loop;
				}
			}
			c*=m-~Arrays.binarySearch(b,a[i]);
			c%=1000000007;
		}
		for(int j=0;j<m;++j){
			if(b[j]>0){
				c*=n-~Arrays.binarySearch(a,b[j]);
				c%=1000000007;
			}
		}

		for(int i=1;i<=n*m;++i){
			if(f[i-1]<i){
				System.out.println(0);
				return;
			}
			if(i<n*m&&f[i]==f[i-1]){
				c*=f[i-1]-i;
				c%=1000000007;
			}
		}

		System.out.println(c);
	}
}


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

int main(){
  int n;
  cin >> n;
  int x,y,b,p;
  double hutu,wari;
  for(int i = 0;i < n;i++){
    cin >> x >> y >> b >> p;
    hutu = x * b + y * p;
    wari = (x * max(b,5) + y * max(p,2))*0.8;
    if(hutu > wari){
      cout << wari << endl;
    }else{
      cout << hutu << endl;
    }

  }
  return 0;
}








Measured memory_bytes: 3276
#include<iostream>
#include<algorithm>
#include<vector>
typedef std::pair<char,int> info;

bool cmp(const info &p,const info &q){
  return p.second > q.second;
}

int main(){
  int a,s;
  std::vector<info> vec;
  while(true){
    std::cin >> a >> s;
    if(a+s == 0)break;
    vec.clear();
    vec.push_back(info('A',a+s));
    for(int i=1;i<=4;i++){
      std::cin >> a >> s;
      vec.push_back(info((char)('A'+i),a+s));
    }
    sort(vec.begin(),vec.end(),cmp);
    std::cout << vec[0].first << " " << vec[0].second << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1196
n, t = map(int, input().split())
a = list(map(int, input().split()))
count = 0
l = []
max = 0
min = a[0]
for i in range(1,n):
    if a[i] < min:
        min = a[i]
    if a[i] - min > max:
        max = a[i] - min
    l.append(a[i] - min)
print(l.count(max))

Measured memory_bytes: 20408
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

constexpr long mod = 1000000000 + 7;

long solve(int n, const std::vector<long>& values)
{
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum = (sum + values[i]) % mod;
  }

  long result = 0;
  for (int i = 0; i < n; ++i) {
    sum = (sum - values[i]) % mod;
    if (sum < 0) sum += mod;

    result = (result + (values[i] * sum) % mod) % mod;
  }

  return result;
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<long> values(n);
  for (auto& v : values) {
    std::cin >> v;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, values) << std::endl;
}


Measured memory_bytes: 4832
def main():
    from math import ceil
    from itertools import accumulate
    from bisect import bisect_left
    n, h, *ab = map(int, open(0).read().split())

    x = max(ab[::2])
    *y, = filter(lambda i: i >= x, ab[1::2])
    y = sorted(y, reverse=True)
    *z, = accumulate(y)

    if z[-1] <= h:
        print(len(y) + ceil((h - z[-1]) / x))
    else:
        print(bisect_left(z, h) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25508
import sys
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    if data[s-1]!=0 and data[s-1]!=c:
        print(-1)
        sys.exit()
    if s==1 and c==0 and n!=1:
        print(-1)
        sys.exit()
    data[s-1]=c
if data[0]==0 and n!=1:
    data[0]=1
ans=0
for i in range(n):
    ans+=data[i]*10**(n-i-1)
print(ans)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define dbg puts("bug bug bagum");
#define CHECK(x) cout << (#x) << " is " << (x) << endl;
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pr printf
#define sc scanf
#define IN(x) scanf("%d",&x);
#define INL(x) scanf("%lld",&x);
#define OUT(x) printf("%d",x);
#define OUTL(x) printf("%lld",x);
#define SP printf(" ");
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 200005
#define MOD 1000000007
#define INF (1 << 31)
#define nl '\n'
#define ext exit(0)
#define fast ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
#define newl printf("\n")
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define fora(i,n) for(int (i)=0; (i) < (n); (i)++)
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define pqmin(x) priority_queue<x, vector<x>, greater<x> >
#define pqmax(x) priority_queue<x>
#define sortd(x) sort(all(x), greater<int>())
#define gcd(x,y) __gcd(x,y)
#define lcm(x,y) __lcm(x,y)
#define fact(x) factorial(x)
#define sieve(x) normal_sieve(x)
#define bsieve(x) bitwise_sieve(x)
#define bprime(x) !Chk(x)
#define runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define in_file freopen("input.txt", "r", stdin)
#define out_file freopen("output.txt", "w", stdout)
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef pair<int,int> pii;
typedef pair<int,pii > tii;
typedef vector <int> VI;
typedef vector<ll> VL;
typedef set<int> SI;

///code starts from here..........................................
int main() {
    fast;
    //in_file;
    //out_file;
    int a,b; cin>>a>>b;
    if(a>9 || b>9)cout<<"-1"<<endl;
    else cout<<a*b<<endl;

   return 0;
}
///code ends here..................................................


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

#define NIL -1

vector< vector<int> > edge;
vector<int> answer;

class Result
{
public:
    vector<int> path;
    int cost;
};

Result rec(int v, vector< vector<int> > visited, int cost) {
    Result result;
    result.cost = cost;
    int maxCost = cost;
    for(int i=0; i<edge.size(); i++) {
        if(visited[v][i]) continue;
        if(edge[v][i]==NIL) continue;
        visited[v][i] = visited[i][v] = 1;
        Result r = rec(i, visited, cost+edge[v][i]);
        if(maxCost >= r.cost) continue;
        maxCost = r.cost;
        result = r;
        result.path.insert(result.path.begin(), i);
    }
    return result;
}
void solve() {
    Result result;
    int maxCost = NIL;
    vector< vector<int> > visited(edge.size(), vector<int>(edge.size(), 0));
    for(int i=0; i<edge.size(); i++) {
        Result r = rec(i, visited, 0);
        if(maxCost >= r.cost) continue;
        maxCost = r.cost;
        result = r;
        result.path.insert(result.path.begin(), i);
    }
    cout<<result.cost<<endl;
    for(vector<int>::iterator i=result.path.begin(); i!=result.path.end(); i++) {
        if(i!=result.path.begin()) cout<<" ";
        cout<<*i+1;
    }
    cout<<endl;
}

int main() {
    int ns, nl;
    while(cin>>ns>>nl, ns|nl) {
        edge.clear();
        edge.resize(ns);
        for(int i=0; i<ns; i++) edge[i].resize(ns, NIL);
        for(int i=0; i<nl; i++) {
            int s1, s2, d;
            cin>>s1>>s2>>d;
            s1--; s2--;
            edge[s1][s2] = edge[s2][s1] = d;
        }
        solve();
    }
}

Measured memory_bytes: 1228
// https://www.youtube.com/watch?v=1CaS4pSpS3c     lana is <3
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod = LLONG_MAX;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N =21000000;

void solve(){

	int x;
	cin>>x;
	cout<<1-x<<'\n';

}


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif

	int t=1;
	//cin>>t;
	while ( t-- )
		solve();
}

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

const long long maxs = 1e9;

long long n, k, s, rest;

int main() {
	cin >> n >> k >> s;
	for (int i=0; i<k; i++) {
		cout << s << ' ';
	}
	if (s == maxs)
		rest = maxs - 1;
	else
		rest = maxs;
	for (int i=0; i<n-k; i++) {
		cout << rest << ' ';
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repb(i,r,l) for(int i=r;i>l;i--)
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator

void solve() {
	ll h, w;
	cin >> h >> w;
	if(h > w) swap(h, w);
 
	ll ans = (w % 3 > 0) * h;
	ans = min(ans, (h % 3 > 0) * w);
	for(ll i = 1; i < w; ++i) {
		ll mx = max(i * h, (w - i) * ((h + 1) / 2));
		ll mn = min(i * h, (w - i) * (h / 2));
		ans = min(ans, mx - mn);
	}
	for(ll i = 1; i < h; ++i) {
		ll mx = max(i * w, (h - i) * ((w + 1) / 2));
		ll mn = min(i * w, (h - i) * (w / 2));
		ans = min(ans, mx - mn);
	}
	cout << ans;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,p;
  cin >> a >> p;
  p+=a*3;
  cout << p/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 11000000

using namespace std;


int main() {
	bool exist[numarr];
	int s, a, i;
	cin >> s;
	a = s;
	for (i = 1; i < numarr; i++)
		exist[i] = false;
	i = 2;
	exist[s] = true;
	while (1)
	{
		if (a % 2 == 0)
			a = a / 2;
		else a = 3 * a + 1;
		if (exist[a])
			break;
		exist[a] = true;
		i++;
	}
		cout << i << endl;
}

Measured memory_bytes: 11008
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			int W=in.nextInt(),H=in.nextInt();
			if(W==0)break;
			
			
			int dp[][]=new int[H][W];
			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++)dp[i][j]=0;
			}
			
			
			int ow=in.nextInt();
			for(int i=0;i<ow;i++) {
				int w=in.nextInt()-1,h=in.nextInt()-1;
				dp[h][w]=-1;
			}
			
			for(int i=0;i<H;i++) {
				if(dp[i][0]==-1)break;
				dp[i][0]=1;
			}
			
			for(int i=0;i<W;i++) {
				if(dp[0][i]==-1)break;
				dp[0][i]=1;
			}
			
			
			for(int i=1;i<H;i++) {
				for(int j=1;j<W;j++) {
					if(dp[i][j]==-1)continue;
					else if(dp[i-1][j]==-1)dp[i][j]=dp[i][j-1];
					else if(dp[i][j-1]==-1)dp[i][j]=dp[i-1][j];
					else {
						dp[i][j]=dp[i-1][j]+dp[i][j-1];
					}
				}
			}
			
			System.out.println(dp[H-1][W-1]);
		}
		
	}

}



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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
    cout << b+c << endl;
  }
  else if(b >= a && b>=c){
    cout << a + c << endl;
  }
  else if(c >= a&& c>=b){
    cout << a+b << endl;
  }
}

Measured memory_bytes: 256
from bisect import *
while 1:
	N,M = map(int,raw_input().split())
	if N == 0: break
	P = [int(raw_input()) for i in range(N)] + [0]
	P = sorted(set(i+j for i in P for j in P))
	s = bisect(P,M) - 1
	print max(i + P[bisect(P,M-i) - 1] for i in P[:s])

Measured memory_bytes: 48680
//解説AC

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

class Edge
{
public:
    int from,to,cost;
    Edge(int a, int b, int c) {
        from = a; to = b; cost = c;
    }
};


const int MAX = 1010;        // Set
vi dist(MAX);
vector<bool> negative(MAX);
vector<Edge> edges;


void bellmanford(int s, int N)
{
        fill(dist.begin(), dist.end(), 1LL<<60);
        dist[s] = 0;

        for (int node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                        }
                }
        }
        for (int node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                                negative[e.to] = true;
                        }
                }
        }
}

signed main()
{
        int N, M;
        cin >> N >> M;
        for (int i=0;i<M;i++){
                int a, b, c;
                cin >> a >> b >> c;
                Edge e(a, b, -c);
                edges.push_back(e);
        }

        bellmanford(1, N);
        if (negative[N]) {
                cout << "inf" << endl;
        } else {
                cout << -dist[N] << endl;
        }

}


Measured memory_bytes: 3732
N, K = gets.chomp.split.map(&:to_i)
ab = readlines.map{|line| line.chomp.split.map(&:to_i)}.sort_by{|a| a[0]}
index = 0

N.times{|i|
    index += ab[i][1]
    if index >= K then
        p ab[i][0]
        break
    end
}

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

typedef long long ll;
typedef unsigned long long ull;

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

    bool f=true;
    for(int i=1;i<N;i++){
        if(A[i-1]>=A[i]){
            f=false;
            break;
        }
    }
    if(f){
        cout << 1 << endl;
        return 0;
    }

    int l=1, r=N;
    while(r-l>1){
        int m=(l+r)/2;

        map<int,int> state;
        for(int i=1;i<N;i++){
            if(A[i-1]>=A[i]){
                int j = A[i];
                state.erase(state.lower_bound(j+1), state.end());
                state[j]++;
                while(state[j]>=m){
                    state[j]=0;
                    if(j<=1){
                        goto ng;
                    }else{
                        state[j-1]++;
                        j--;
                    }
                }
            }
        }
        ok: r = m; cerr << "m=" << m << ": ok" << endl; continue;
        ng: l = m; cerr << "m=" << m << ": ng" << endl; continue;
    }
    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 1152
a, b = [ int(v) for v in input().split() ]
mod = 10**9+7
ans = 0
if a == b:
	p = 1
	for i in range(a):
		p = ( (i+1) * p ) % mod
	ans = (p*p*2)%mod

elif abs(a - b) == 1:
	if a < b:
		a, b = b, a
	p = 1
	for i in range(b):
		p = ( (i+1) * p ) % mod
	ans = (p*p*a)%mod
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>

using namespace std;

long long int fivePower(int y){
    long long int z= y;
    for(int i=0;i<4;i++){
        z*=y;
    }
    return z;
}

int main() {

    //cout<<(long long int)(fivePower(150)-fivePower(149))<<endl;
    //cout<<(long long int)fivePower(100)<<endl;
    //cout<<(long long int)(fivePower(150)-fivePower(149))<<endl;
    int x;
    cin>>x;
    // b>0
    for(int i=0;i<=150;i++){
        for(int j=0;j<i;j++){
            if(fivePower(i)-fivePower(j)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
            if(fivePower(i)+fivePower(j)==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a[100000],b[100000],c[100000];
    long long ans=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    sort(a,a+n);
    sort(c,c+n);
    for(int i=0;i<n;i++)ans+=(c+n-upper_bound(c,c+n,b[i]))*(lower_bound(a,a+n,b[i])-a);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int n,a[555];
int dp[444][444];
signed main(){
    cin>>n;
    rep(i,0,n+1)rep(j,0,n)dp[j][i]=inf;
    rep(i,0,n){
        cin>>a[i];
        dp[i][1]=0;
    }
    int sum[555];
    rep(i,0,n){
        if(!i)sum[i]=a[i];
        else sum[i]=sum[i-1]+a[i];
    }
    //cout<<"Find"<<endl;
    rep(i,2,n+1){
        rep(j,0,n-i+1){
            rep(k,1,i){
                dp[j][i]=min(dp[j][k]+dp[j+k][i-k]+sum[j+i-1]-(j==0?0:sum[j-1]),dp[j][i]);
            }
            //cout<<j<<" "<<i<<" "<<dp[j][i]<<endl;
        }
    }
    cout<<dp[0][n]<<endl;return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	
	int team[200], t_rank[200];
	
	int N;
	
	cin >> N;
	
	int a, b, c, d;
	
	for(int i = 0; i <= N; i++){
		team[i] = 0;
	}
	
	for(int i = 0; i < N * (N - 1) / 2; i++){
		cin >> a >> b >> c >> d;
		if(c > d){
			team[a] += 3;
		}else if(c < d){
			team[b] += 3;
		}else if(c == d){
			team[a]++;
			team[b]++;
		}
	}
	
	int rank = 1;
	
	int count;
	
	for(int i = N * 3; i >= 0; i--){
		count = 0;
		for(int j = 1; j <= N; j++){
			if(team[j] == i){
				count++;
				t_rank[j] = rank;
			}
		}
		rank += count;
	}
	
	for(int i = 1; i <= N; i++){
		cout << t_rank[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int dp[1<<18][55];
int p[20];
int q[20];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	if(c==mod-7){
		for(int i=0;i<a;i++){
			if(i)printf(" ");
			if(i<b)printf("%d",c);
			else printf("%d",1);
		}
		printf("\n");
	}else{
		for(int i=0;i<a;i++){
			if(i)printf(" ");
			if(i<b)printf("%d",c);
			else printf("%lld",mod-7);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1280
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int cnt[310000];

int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int A;
		cin >> A;
		cnt[A] += 1;
	}
	sort(cnt, cnt + N + 1);
	long long int pos = N;
	long long int rem = N;
	long long int ans = N;
	for(int i = 1; i <= N; i++){
		if(ans > N / i){
			ans = N / i;
		}
		while(cnt[pos] > ans){
			rem -= cnt[pos];
			pos -= 1;
		}
		while(rem + (N - pos) * ans < i * ans){
			ans -= 1;
			while(cnt[pos] > ans){
				rem -= cnt[pos];
				pos -= 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

using namespace std;

int n, m;
int a[100000];

int main(){
  cin >> n >> m;
  rep(i, m){
    cin >> a[i];
  }
  int ans = max(a[0] - 1, n - a[m - 1]);
  rep(i, m - 1){
    ans = max((a[i + 1] - a[i]) / 2, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3208
function Main(input) {
    const a = input.trim();
    
    if(isUpperCase(a)){
        console.log('A');
    }else{
        console.log('a');
    }
 
}

function isUpperCase (str) {
    return str.match(/^[A-Z]+$/);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29604
n,k=io.read("*n","*n","*l")
snuke={}
for i=1,n do
    snuke[i]=1
end
a={}    
for i=1,k do
    a[i]={}
    d=io.read("*n","*l")
    for j=1,d do
        a[i][j]=io.read("*n")
        if snuke[a[i][j]]==1 then
            snuke[a[i][j]]=0
        end
    end
end

counter=0
for i=1,n do
    counter=counter+snuke[i]
end
print(counter)

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


int main() {
  string s;
  cin >> s;
  if (s[0] != s[1] && s[1] != s[2] && s[0] != s[2]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1000000009;

int n, m;
char field[55][55];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int dist[55][55];
typedef std::pair<int, int> P;

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++){
        scanf("%s", &field[i][1]);
    }
    for(int i = 0; i <= n+1; i++){
        field[i][0] = '#';
        field[i][m+1] = '#';
        for(int j = 0; j <= m+1; j++){
            dist[i][j] = INF;
        }
    }
    for(int j = 0; j <= m+1; j++){
        field[0][j] = '#';
        field[n+1][j] = '#';
    }
    /*
    for(int i = 0; i <= n+1; i++){
        printf("%s\n", field[i]);
    }
    */
    int whitecnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(field[i][j] == '.'){
                whitecnt++;
            }
        }
    }
    std::queue<P> que;
    dist[1][1] = 0;
    que.push(P(1, 1));
    while(!que.empty()){
        P pos = que.front();
        que.pop();
        int x = pos.first;
        int y = pos.second;
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(field[nx][ny] == '.' && dist[nx][ny] == INF){
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx, ny));
            }
        }
    }
    /*
    for(int i = 0; i <= n+1; i++){
        for(int j = 0; j <= m+1; j++){
            if(dist[i][j] == INF){
                printf("INF ");
            }else{
                printf("%3d ", dist[i][j]);
            }
        }
        printf("\n");
    }
    */
    if(dist[n][m] == INF){
        printf("-1\n");
    }else{
        printf("%d\n", whitecnt - dist[n][m] - 1);
    }
    return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans=100000;
	int now=s[0]-'0'+s[1]-'0';
	for(int i=2;i<s.size();i++)
	{
		now=(s[i-2]-'0')*100+(s[i-1]-'0')*10+(s[i]-'0');
		if(abs(now-753)<ans)
			ans=abs(now-753);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, d, a;
	cin >> n >> d >> a;
	V<P> monster(n);
	rep(i, n) {
		int x, h;
		cin >> x >> h;
		monster[i] = P(x, h);
	}
	
	sort(all(monster));

	V<ll> use(n);
	V<ll> usesum(n + 1);

	rep(i, n) {
		int k = lower_bound(all(monster), P(monster[i].first - 2 * d, 0)) - monster.begin();
		int bomb = usesum[i] - usesum[k];
		use[i] = max((monster[i].second + a - 1) / a - bomb, 0);
		usesum[i + 1] = usesum[i] + use[i];
	}

	cout << usesum[n] << endl;

}

Measured memory_bytes: 4992
from collections import Counter


def main():
    class UnionFind:
        def __init__(self, size):
            self.data = [-1] * size

        def find(self, x):
            if self.data[x] < 0:
                return x
            else:
                self.data[x] = self.find(self.data[x])
                return self.data[x]

        def union(self, x, y):
            x, y = self.find(x), self.find(y)
            if x != y:
                if self.data[y] < self.data[x]:
                    x, y = y, x
                self.data[x] += self.data[y]
                self.data[y] = x
            return (x != y)

    MAX = 10 ** 5 + 1
    uf = UnionFind(2 * MAX)

    N, *XY = map(int, open(0).read().split())

    for x, y in zip(*[iter(XY)] * 2):
        uf.union(x, y + MAX)

    X = Counter(uf.find(i) for i in range(MAX))
    Y = Counter(uf.find(i) for i in range(MAX, MAX * 2))
    res = sum(X[i] * Y[i] for i in range(MAX * 2))

    print(res - N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38580
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}


template<typename V>
V compress(V v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}
template<typename T>
map<T, int> dict(const vector<T> &v){
  map<T, int> res;
  for(int i=0;i<(int)v.size();i++)
    res[v[i]]=i;
  return res;
}
map<char, int> dict(const string &v){
  return dict(vector<char>(v.begin(),v.end()));
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<string> ans;

  vector<int> vs(n,0);
  MFP([&](auto dfs,int x)->void{
        if(x==n){
          string s(n,'#');
          for(int i=0;i<n;i++) s[i]=char('a'+vs[i]);
          ans.emplace_back(s);
          return;
        }
        int l=*max_element(vs.begin(),vs.begin()+x);
        for(int i=0;i<=l+1;i++){
          vs[x]=i;
          dfs(x+1);
        }
      })(1);

  ans=compress(ans);
  for(auto s:ans) cout<<s<<newl;
  return 0;
}


Measured memory_bytes: 7912
#include <stdio.h>
#include <memory.h>
typedef struct{
	int num;
	double bmi;
}data;
data a[1000000];
int main(void){
	int n,i,ans;
	double h,w,m,t;
	while(scanf("%d",&n),n){
		memset(a,0,sizeof(a));
		for(i=0;i<n;i++){
			scanf("%d %lf %lf",&a[i].num,&h,&w);
			h/=100;
			a[i].bmi=w/(h*h);
		}
		m=1000000;
		for(i=0;i<n;i++){
			t=a[i].bmi-22;
			if(t<0)t*=-1;
			if(m>t){
				ans=a[i].num;
				m=t;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 16260