akhauriyash/Code-Regression huggingface dataset:
import itertools
n = int(input())

A = [0]*n
x = []
y = []
for i in range(n):
    A[i] = int(input())
    xx = []
    yy = []
    for j in range(A[i]):
        xxx,yyy = map(int,input().split())
        xx.append(xxx)
        yy.append(yyy)
    x.append(xx)
    y.append(yy)


max = 0
B = (0,1)
false = 0
for i in itertools.product(B, repeat=n):
    for j in range(n):
        for k in range(A[j]):
            if i[j] == 1 and (i[x[j][k]-1] != y[j][k]):
                false = 1
                break
        if j == n-1:
            if max <= i.count(1) and not(false):
                max = i.count(1)
                ans = i
    false = 0


print(max)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

H, W, K = map(int, input().split())

s = []
for f in range(H):
    s.append(input())
    
nums = []

for j in s:
    nums.append(j.count('#'))
                     
def print_str(h, num, maxs):
    a = []
    it = 0
    for y in h:
        if y == '#':
            it += 1
            a.append(num)
            if it < maxs:
                num += 1
        else:
            a.append(num)
    ai = [str(i) for i in a]
    return(' '.join(ai))

counter = 0 
number = 1   
               
for x in range(len(nums)):
    if nums[x] == 0:
        counter +=1
    else:
        result = print_str(s[x], number, nums[x])
        for i in range(counter + 1):
            print(result)
        number += nums[x]
        counter = 0
        
if counter != 0:
    for g in range(counter):
        print(result)

Measured memory_bytes: 42220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MX 4000000000000
#define MN -4000000000000
int n;
int arr[3001];
int dp[3001][3001];
int calc(int start, int end){
	if(dp[start][end]!=MX){
		return dp[start][end];
	}
	if(end-start == 1){
		if(n&1)dp[start][end] = min(arr[start]-arr[end], arr[end]-arr[start]); 
		else   dp[start][end] = max(arr[start]-arr[end], arr[end]-arr[start]); 
		return dp[start][end];
	}
	if(((n&1) && ((end-start+1)&1)) || (!(n&1) && !((end-start+1)&1))){
		dp[start][end] = max(arr[start]+calc(start+1, end), arr[end]+calc(start, end-1));
	}
	else
		dp[start][end] = min(-arr[start]+calc(start+1, end), -arr[end]+calc(start, end-1));
	return dp[start][end];
}
signed main(){
	//freopen("input.txt","r",stdin);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			dp[i][j] = MX;
		}
	}
	calc(0, n-1);
	cout << dp[0][n-1];
	return 0;
}

Measured memory_bytes: 70784
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Seg = Tuple!(int, "s", int, "t");

void main() {
    int n, c;
    scan(n, c);

    auto cs = new Seg[][](c, 0);

    foreach (i ; 0 .. n) {
        int si, ti, ci;
        scan(si, ti, ci);
        cs[ci-1] ~= Seg(si, ti);
    }

    foreach (i ; 0 .. c) {
        cs[i].sort();
    }

    auto ims = new int[](2 * 10^^5 + 1);

    foreach (i ; 0 .. c) {
        if (cs[i].empty) continue;
        ims[cs[i][0].s]++;
        ims[cs[i][0].t + 1]--;

        foreach (j ; 1 .. cs[i].length) {
            if (cs[i][j].s == cs[i][j-1].t) {
                ims[cs[i][j].s + 1]++;
                ims[cs[i][j].t + 1]--;
            }
            else {
                ims[cs[i][j].s]++;
                ims[cs[i][j].t + 1]--;
            }
        }
    }

    foreach (i ; 1 .. 2*10^^5) {
        ims[i] += ims[i-1];
    }

    debug {
        writeln(ims[0 .. 20]);
    }

    int ans = ims.reduce!max;

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 5116
#include <bits/stdc++.h>
typedef long long int lli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

//lli dp[1005][2010][2][2];

lli f(lli* arr,lli l, lli r){
    bool sorted=1;
    loop(i,l+1,r){
        if(arr[i-1]>arr[i]){
            sorted=0;
            break;
        }
    }
    if(sorted) return r-l;
    lli mid=(l+r)/2;
    return max(f(arr,l,mid),f(arr,mid,r));
}

int32_t main(){
    fast_io
    lli i = 0,j = 0;
//   freopen("input.txt","r",stdin);
//   freopen("output.txt","w",stdout);

    lli n;
    ldb m;
    cin >> n>> m;
    ldb arr[n];

    ldb tot=0;
    loop(i,0,n){
        cin >> arr[i];
        tot+=arr[i];
    }
    sort(arr,arr+n,greater<lli>());
    ldb bd=tot/(4*m);
    bool flag=1;
    loop(i,0,m){
        if(arr[i]<bd) flag=0;
    }

    if(flag) cout << "Yes"; 
    else cout << "No";
    cout << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int solve(const string X) {
    int left = 0;
    int count = 0;
    for (int i = 0; i < (int) X.size(); i++) {
        if (X[i] == 'S') {
            left++;
            count++;
        } else {
            if (left == 0) {
                count++;
            } else {
                left--;
                count--;
            }
        }
    }
    return count;
}

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

    cout << solve(X) << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

string ans = "";


int main(){
    ll n;
    cin >> n;
    while(n){
        ans += 'a' + (n-1) % 26;
        n = (n-1) / 26;
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long X = scan.nextLong();

        long depo = 100;
        int ans = 0;

        while(X > depo) {
            depo *= 1.01;
            ans++;
        }

        os.println(ans);
    }

}

Measured memory_bytes: 26996
// abc135c: City Savers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int main(){
  int n;in(n);
  vi a(n+1);
  upto(i,0,n+1,1) in(a[i]);

  ll c = 0;
  upto(i,0,n,1){
    int bi; in(bi);
    int m = min(a[i],bi);
    a[i]-=m;
    bi-=m;
    c+=m;
    if(a[i]<=0 && bi>0){
      m = min(a[i+1],bi);
      a[i+1]-=m;
      c+=m;
    }
  }
  oute(c);
}

Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
int ans[505][505];
int main()
{
    scanf("%d",&k);
    if(k==1)
    {
        printf("1\n1\n");
        return 0;
    }
    n=(k+3)/4*2;
    printf("%d\n",n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            ans[i][j]=(i+j-1)%n+1;
            if(i&1) ans[i][j]+=n;
        }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(ans[i][j]>k) ans[i][j]-=n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            printf("%d ",ans[i][j]);
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderTemplate {
    class Program {
        static void Main (string[] args) {
            var N = ReadInt ();
            var A = ReadInts ();

            /*
            1.ソートして最小のものを選ぶ
            2.最小のもので他のリストの余りをmapで求める(0になったら要素から抜ける)
            3.リストが1個なら終了 そうでないなら1.へ
            */
            Console.WriteLine (go (A));
        }

        static int go (IEnumerable<int> a) {
            return a.Aggregate ((accm, item) => {
                var m = Math.Max (accm, item);
                var n = Math.Min (accm, item);
                return GCD (m, n);
            });
        }

        /* Input & Output*/
        static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }
        static List<int> ReadInts () {
            return Console.ReadLine ().Split (' ').Select (c => int.Parse (c)).ToList ();
        }
        static List<List<int>> ReadColumns (int n) {
            /*
            入力例
            A1 B1
            A2 B2
            ...
            An Bn

            出力例
            [[A1,A2,...,An], [B1,B2,...,Bn]]
            */
            var seq = Enumerable.Range (0, n).Select (i => ReadInts ()).ToList ();
            return Enumerable.Range (0, seq.First ().Count ()).Select (i => seq.Select (items => items[i]).ToList ()).ToList ();
        }
        static void PrintEnum<T> (IEnumerable<T> list) {
            Console.Write (list.First ());
            foreach (var item in list.Skip (1)) {
                Console.Write ($" {item}");
            }
            Console.Write ("\n");
        }
        static void PrintLnEnum<T> (IEnumerable<T> list) {
            foreach (var item in list) {
                Console.WriteLine (item);
            }
        }

        /* Numeric Function */
        static int Fact (int n) {
            return Enumerable.Range (1, n).Aggregate (1, ((i, k) => i * k));
        }
        static int PermNum (int n, int m) {
            if (m > n) {
                return 0;
            }
            return Enumerable.Range (n - m, m + 1).Aggregate (1, ((i, k) => i * k));
        }
        static int CombNum (int n, int m) {
            return PermNum (n, m) / Fact (m);
        }
        // 最大公約数 (m ≧ n)
        static int GCD (int m, int n) {
            if (n == 0) {
                return m;
            } else {
                return GCD (n, m % n);
            }
        }
        // 最小公倍数 (m ≧ n)
        static int LCM (int m, int n) {
            return GCD (m, n) / (m * n);
        }

    }
}

Measured memory_bytes: 19296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,p;
  cin>>n;

  for(int i;i<n;i++){
    cin>>k>>p;
    if(k%p!=0){
      cout<<k%p<<endl;
    }else{
      cout<<p<<endl;
    }
  }
    
    

}



Measured memory_bytes: 3052
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#define Max 100005*2
#define INF 1000000000000000000
#define getMax(a,b) a<b?b:a
#define getMin(a,b) a<b?a:b
using namespace std;



int main(){

	int a,b;
	scanf("%d%d",&a,&b);
	if(a > b){
		int tmp = b;
		b = a;
		a = tmp;
	}

	for(int i=0;i<b;i++)
		printf("%d",a);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
// reiview
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 200010;

ll n;
ll a[MAXN], b[MAXN];

bool check(int k) {
  ll mod = 1 << (k + 1);
  for (int i=0;i<n;i++) {
    a[i] = a[i] % mod;
    b[i] = b[i] % mod;
  }
  sort(b, b+n);

  ll cnt = 0;
  ll mask = 1 << k;
  for (int i=0;i<n;i++) {
    cnt += lower_bound(b, b+n, 2 * mask - a[i]) - lower_bound(b, b+n, mask - a[i]);
    cnt += lower_bound(b, b+n, 4 * mask - a[i]) - lower_bound(b, b+n, 3 * mask - a[i]);
  }
  return cnt % 2 == 1;
}

void solve() {
  ll ans = 0;
  // 2^k+1でmodを取るので大きい方からやればコピーしなくていい
  for (int i=30;i>=0;i--) {
    if (check(i)) {
      ans += 1 << i;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3328
s = input()
k = ['R', 'U', 'D']
g = ['L', 'U', 'D']
k_count = 0
g_count = 0
kisuu = 0
guusuu = 0
for i in range(0, len(s)):
  if i%2 != 0:
    guusuu += 1
    if (s[i] in g) == True:
      g_count += 1
  if i%2 == 0:
    kisuu += 1
    if (s[i] in k) == True:
      k_count += 1
if kisuu == k_count and guusuu == g_count:
  print('Yes')
else:
  print('No')


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

#define int long long

const int N = 100 + 3;
vector<int> g[N];
int time_entry[N];
int time_exit[N];
bool visited[N];
int dfs_timer = 1;

void dfs(int s){
   	visited[s] = true;
    time_entry[s] = dfs_timer++;
   	for(auto it : g[s]){
	  if (!visited[it]) dfs(it);	  	
	}
	time_exit[s] = dfs_timer++;
}
	
int32_t main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) visited[i] = false;
  for(int i = 0; i < n; i++){
	  int m, deg;
	  cin >> m >> deg;
	  m--;
	  for (int i = 0; i < deg; i++){
		  int x;
		  cin >> x;
		  x--;
		  g[m].push_back(x);  
	  }  
   }
  for(int i = 0; i < n; i++){
	    if (!visited[i]) dfs(i);
	}
  for(int i = 0; i < n; i++){
	   int idx = i + 1;
	   cout << idx << " "<< time_entry[i] <<  " "<< time_exit[i] << endl;  
	}     	
}



Measured memory_bytes: 3144
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int N;
int x[8],y[8];

double fact(int n){
    if(n == 0)return 1;
    return fact(n - 1) * n;
}

double dist(int p1,int p2){
    return sqrt(pow(x[p1] - x[p2],2) + pow(y[p1] - y[p2],2));
}


int main(){

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

    double sum = 0;
    double f = fact(N);

    for(int i = 0;i < N;i++){
        for(int j = i;j < N;j++){
            if(i == j)continue;
            sum += dist(i,j) * fact(N - 1) * 2;
        }
    }

    cout << fixed << setprecision(15) << sum / f << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}


signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

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

    int a;
    cin>>a;
    int ans=a+a*a+a*a*a;
    cout<<ans;

} 
    


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    cout << N*N*N << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3652
k = int(input())
n = 1
dif = 1
cnt = 0

while cnt!=k:
  sn = 0
  for ele in str(n):
    sn+=int(ele)

  m = n+dif
  sm = 0
  for ele in str(m):
    sm+=int(ele)
  if (n/sn) <= (m/sm):
    print(n)
    cnt+=1
    n+=dif
  else:
    n-=dif
    dif*=10
    n+=dif

Measured memory_bytes: 3188
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	w := make([]int, n)
	sum := make([]int, n+1)
	sum[0] = 0
	for i := 0; i < n; i++ {
		sc.Scan()
		w[i], _ = strconv.Atoi(sc.Text())
		sum[i+1] = sum[i] + w[i]
	}

	min := 10000

	for i := 0; i < n;i++{
		g1 := sum[i]
		g2 := sum[n] - sum[i]
		if min > abs(g2-g1) {
			min = abs(g2-g1)
		}
	}
	fmt.Println(min)
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


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

int main(){
    int n,ans=0,m=0;cin>>n;
    for(int i=0;i<n;i++){
        int k;cin>>k;
        ans+=k;
        m=max(m,k);
    }
    ans-=(m/2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[85], amt = 1000;
 
int32_t main()
{
    fast;
    int n; cin >> n; 
    Rep(i, 1, n) cin >> a[i];
    Rep(i, 1, n-1) {
        int stocks = 0;
        if(a[i] < a[i+1]) stocks = amt / a[i];
        amt += (a[i+1] - a[i]) * stocks;
    }
    cout << amt << "\n";

    
    
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

void Solve();

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


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

void Solve(){
  ll n;
    cin>>n;
  ll s=0;
  ll t=0;
  vll C(n);
  ll c=0;
  ll ans=0;

  FOR(i,0,n){
    ll a;
    cin>>a;
    s+=a;
    C[i]+=a;
  }

  FOR(i,0,n){
    ll b;
    cin>>b;
    t+=b;
    C[i]-=b;
    if(C[i]<0){
      ans++;
      c+=C[i];
    }
  }

  if(s<t){
    cout<<-1<<endl;
    return;
  }

  SORT(C);
  ll I=n-1;
  while(c<0){
      c+=C[I];
      ans++;
      I--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn combi(mut n: u64, mut m: u64) -> u64 {
    m = min(n-m, m);

    let mut ans = 1;
    // uint64_t r = 1;
    // for (uint64_t d = 1; d <= k; ++d) {
    //     r *= n--;
    //     r /= d;
    // }

    for d in 1..m+1 {
        ans *= n;
        n -= 1;
        ans /= d;
    }
    ans
}

fn main() {
    input!{
      n: usize,
      p: u64,
      aa: [u64; n]
    }

    let mut even = 0u64;
    let mut odd = 0u64;

    for a in aa {
        if a%2 == 0 {
            even += 1;
        } else {
            odd += 1;
        }
    }

    let mut ans = 0;
    for e in 0..even+1 {
        for o in 0..odd+1 {
            if o%2 != p {
                continue;
            }
            ans += combi(even, e as u64) * combi(odd, o as u64)
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	static int dp[][];

	static int solve(int i, int C[], int A[][], int X, int curUnd[], int M, int price) {
		int flag = 0;
		for (int j = 0; j < curUnd.length; j++) {
			if (curUnd[j] < X) {
				flag = 1;
			}
		}
		if (flag == 0)
			return price;
		if (i < 0)
			return Integer.MAX_VALUE;
		int a = solve(i - 1, C, A, X, curUnd, M, price);
		int newCur[] = new int[M];
		for (int j = 0; j < newCur.length; j++)
			newCur[j] = curUnd[j] + A[i][j];
		int b = solve(i - 1, C, A, X, newCur, M, price + C[i]);
		return Integer.min(a, b);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt(), X = sc.nextInt();
		int C[] = new int[N], A[][] = new int[N][M];
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for (int j = 0; j < M; j++)
				A[i][j] = sc.nextInt();
		}
		dp = new int[N][2];
		dp[0][0] = 0;
		int curUnd[] = new int[M];
		int ans = solve(N - 1, C, A, X, curUnd, M, 0);
		System.out.println((ans != Integer.MAX_VALUE) ? ans : -1);
		sc.close();
	}
}


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

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

        sort(A, A+N, greater<int>());

        int index = 0;
        int iter = N/2;
        long long ans = 0;
        for(int i=0;i<iter;i++){
                ans += A[index]<<1;
                index++;
        }
        ans -= A[0];
        if(N%2 == 1){
                ans += A[index];
        }

        cout << ans << endl;

        return 0;
}





Measured memory_bytes: 4316
#include <cstdio>
#include <algorithm>
using namespace std;
int n, h, a, b[100005], ma, ans;
int main() {
	int i;
	scanf("%d%d", &n, &h);
	for(i=0; i<n; i++) {
		scanf("%d%d", &a, &b[i]);
		ma = max(ma, a);
	}
	sort(b, b+n);
	for(i=n-1; i>=0 && h>0; i--) {
		ans++;
		h -= max(b[i], ma);
	}
	if(h>0) ans += (h+ma-1)/ma;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)

Measured memory_bytes: 167984
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
*c,=map(int,input().split())

s=0
bef=float('inf')
for i in range(n):
      s+=b[a[i]-1]
      if bef+1==a[i]:
            s+=c[a[i]-2]
      bef=a[i]
print(s)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, k, ctr = 0;
   cin >> n >> k;
   while (n > 0)
   {
      n /= k;
      ctr++;
   }
   cout << ctr << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define Q 8
#define A -1
#define U 1
#define true 1
#define false 0


int row[Q],col[Q],rt[2*Q-1],l[2*Q-1];
int X[Q][Q];
int datar=100;

void suit(){
  int i;
  for(i=0;i<Q;i++){
    row[i]=A;
    col[i]=A;
  }
  for(i=0;i<2*Q-1;i++){
    rt[i]=A;
    l[i]=A;
  }
}

void print(){
  int i,j;
  double mathe;

  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
      if(X[i][j]==true){
	if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
       if(row[i] == j)printf("Q");
       else printf(".");
    }
    printf("\n");
  }
}


void resuit(int i){
  int j;
  if(i == Q){
    print();
    return;
  }

  for(j=0;j<Q;j++){
    if(U == col[j] || U == rt[i+j] || U == l[i-j+Q-1])continue;
    row[i]=j;
    col[j]=U;
    rt[i+j]=U;
    l[i-j+Q-1]=U;
    resuit(i+1);
    row[i]=A;
    col[j]=A;
    rt[i+j]=A;
    l[i-j+Q-1]=A;
  }
}

int main(){
  suit();

  int i,j,u,r,c;
  

  for(i=0;i<Q;i++){
    for(j=0;j<Q;j++){
      X[i][j]=false;
    }
  }

    scanf("%d",&u);

    for(i=0;i<u;i++){
      scanf("%d %d",&r,&c);
      X[r][c]=true;
    }

    resuit(0);

    return 0;
}

      




Measured memory_bytes: 2132
import heapq
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

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

edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x].append([z,y])
    edge[y].append([z,x])
print(prim_heap())


Measured memory_bytes: 34976
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int N;
	std::string S;

	std::cin >> N;
	std::cin >> S;

	int ret = 0;
	for (auto i = 0; i < N; ++i) {
		if (S[i] == '.')
			++ret;
	}

	int x = ret;
	for (auto i = 0; i < N; ++i) {
		if (S[i] == '.')
			--x;
		else
			++x;
		ret = std::min(ret, x);
	}

	std::cout << ret << "\n";
}


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

int main(){
    int n, ans=1;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int cur = d[0];
    rep2(i, 1, n) if(d[i] > cur) {
        ans++;
        cur = d[i];
    }
    cout << ans << endl;
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
ll n,a,b,c,d;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>a>>b>>c>>d;
    ll diff=abs(b-a);
    if( diff>(n-1)*d) cout<<"NO\n";

    else {

        if(b<a) swap(b,a);
        rep(times,0,n-2){
            ll xx=a-times*c;
            ll cdiff=b-xx;
            if(cdiff<=(n-1-times)*d && cdiff>=(n-1-times)*c){
                cout<<"YES\n";
                return 0;
            }
        }
        rep(times,0,n-2){
            ll xx=a-times*d;
            ll cdiff=b-xx;
            if(cdiff<=(n-1-times)*d && cdiff>=(n-1-times)*c){
                cout<<"YES\n";
                return 0;
            }
        }
        cout<<"NO\n";
    }
}


Measured memory_bytes: 256
#include <iterator>
#include <vector>
#include <algorithm>
#include <deque>
#include <cstdio>
using namespace std;
#pragma region
class FastIO {
  static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
  char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
  char tmp_s[20];

public:
  FastIO() {
    fread(rdata, 1, rdata_sz, stdin);
    rb = rdata; wb = wdata;
  }
  ~FastIO() {
    fwrite(wdata, 1, wb - wdata, stdout);
  }

  template<typename T>
  inline void read_i(T &x) {
    bool neg = false;
    x = 0;
    while((*rb < '0' || *rb > '9') && *rb != '-') ++rb;
    if(*rb == '-') {
      neg = true;
      ++rb;
    }
    while('0' <= *rb && *rb <= '9') {
      x = 10 * x + (*rb - '0');
      ++rb;
    }
    if(neg) x = -x;
  }

#define pc(x) *(wb++) = x
  template<typename T>
  inline void writeln_i(T x) {
    if (x == 0) { pc('0'); pc('\n'); return; }
    if(x < 0) { pc('-'); x = -x; }
    char *t = tmp_s;
    while(x) {
      T y = x / 10;
      *(t++) = (x - y*10) + '0';
      x = y;
    }
    while(t != tmp_s) pc(*(--t));
    pc('\n');
  }
#undef pc
};
FastIO io;
#pragma endregion
static const int64_t INF = 1e18;
int main() {
    int A, B, Q;
    io.read_i(A);
    io.read_i(B);
    io.read_i(Q);
    deque<int64_t> s(A), t(B), x(Q);
    for (auto& i : s) io.read_i(i);
    for (auto& i : t) io.read_i(i);
    s.push_back(INF);
    s.push_front(-INF);
    t.push_back(INF);
    t.push_front(-INF);
    for (auto& i : x) {
        io.read_i(i);
        auto b = lower_bound(s.begin(), s.end(), i);
        auto d = lower_bound(t.begin(), t.end(), i);
        auto ans = INF;
        for (auto j : {*(b - 1), *b}) {
            for (auto k : {*(d - 1), *d}) {
                auto m = min(abs(j - i) + abs(k - j), abs(k - i) + abs(j - k));
                if (m < ans) ans = m;
            }
        }
        io.writeln_i(ans);
    }
}

Measured memory_bytes: 8832
n = int(input())
cake_p = 4
donuts_p =7
cake = [i*cake_p for i in range((100//cake_p)+1)]
donuts = [i*donuts_p for i in range((100//donuts_p)+1)]
#print(cake,donuts)
ans='No'
for i in cake:
  for x in donuts:
    if i+x==n:
      ans='Yes'
#      print(ans)
      
if ans=='Yes':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		char[] s=sc.nextLine().toCharArray();
		char[] t=sc.nextLine().toCharArray();
		int i=0;
		for(int j=0;j<3;j++) {
			if(s[j]==t[j])i++;
		}
		System.out.println(i);
	}
}

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





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

    for(int i=0; i<N; i++){
        cost[i] = 0;
    }
    cost[1] = abs(arr[1] - arr[0]);

    for(int i=2; i<N; i++){
        cost[i] = min(cost[i-1]+ abs(arr[i] - arr[i-1]), cost[i-2]+ abs(arr[i]- arr[i-2]) );
    }
    cout<<cost[N-1]<<endl;
    return 0;
}

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

int main() {
    int goal;
    while(cin >> goal, goal) {
        bool flag = false;
        int stack = 0;
        for(int i = 0; i < 12; ++i) {
            int a, b;
            cin >> a >> b;
            stack += a - b;
            if(!flag && stack >= goal) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if(!flag) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
n=int(input())
a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

m=0
for i in range(a,b+1):
    if i//n==i/n:
        m+=1
if m>0:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 61580
n,m=map(int,input().split())
l=[list(input().split()) for _ in range (m)]

a=0
p=0
al=[0]*n
pl=[0]*n

for i in range (m):
  if al[int(l[i][0])-1]==0:
    if l[i][1]=='AC':
      a+=1
      al[int(l[i][0])-1]=1
    else:
      pl[int(l[i][0])-1]+=1
      
for k in range (n):
  if al[k]==1:
    p+=pl[k]
    
print (a,p)

Measured memory_bytes: 27444
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int N; string S;
	while(cin >> N >> S){
		vector<int> v(N);
		bool find = false;
		for(int i=0;i<2;i++){
			if(find) break;
			for(int j=0;j<2;j++){
				if(find) break;
				v[0] = i;
				v[1] = j;
				for(int k=2;k<N;k++){
					v[k] = (v[k-1]+v[k-2]+(S[k-1]=='x'))%2;
				}
				bool valid = true;
				for(int k=N-1;k<=N;k++){
					valid &= (v[(k-1)%N]+v[k%N]+v[(k+1)%N])%2 == (S[k%N]=='o'?0:1);
				}
				if(valid){
					for(int k=0;k<N;k++) cout << char(v[k]==0 ? 'S' : 'W');
					cout << endl;
					find = true;
				}
			}
		}
		if(!find) cout << -1 << endl;
	}
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int n=s.length();
		String a=s.substring(0,(n-1)/2);
		String b=s.substring((n-1)/2+1);
		String c;
		String d;
      	int m=a.length();
		if(m%2==0){
			c=a.substring(0,m/2);
          	d=a.substring(m/2);
		}else{
			c=a.substring(0,(m-1)/2);
          	d=a.substring((m-1)/2+1);
		}
      	String br=new StringBuffer(b).reverse().toString();
      	String dr=new StringBuffer(d).reverse().toString();
		if(a.equals(br)&&c.equals(dr)){
    	  System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

int32_t main() {
  while (true) {
    uint32_t N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0) break;

    vector<tuple<uint32_t, uint32_t, string>> years;
    for (uint32_t _ = 0; _ < N; _++) {
      string name;
      uint32_t base_year, western_year;
      cin >> name >> base_year >> western_year;
      years.push_back(make_tuple(western_year, base_year, name));
    }

    for (uint32_t _ = 0; _ < Q; _++) {
      uint32_t year;
      cin >> year;
      bool found = false;
      for (auto iter = years.begin(); iter < years.end(); iter++) {
        uint32_t western_year = get<0>(*iter);
        uint32_t base_year = get<1>(*iter);
        uint32_t start_year = western_year + 1 - base_year;
        if (start_year <= year && year <= western_year) {
          found = true;
          cout << get<2>(*iter) << " " << year - start_year + 1 << endl;
          break;
        }
      }
      if (!found) {
        cout << "Unknown" << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll count = 0;
  rep(i, n)rep(j, 2){        
    if (a[i+j] > b[i]){
      a[i+j] -= b[i];
      count += b[i];
      b[i] = 0;
    }
    else {
      b[i] -= a[i+j];
      count += a[i+j];
      a[i+j] = 0;
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 4844
A, B, C, X= [int(input()) for i in range(4)]


Num = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a*500 + b*100 + c*50 == X):
                Num += 1
print(Num)
                

Measured memory_bytes: 39664
Cnd = list(map(int,input().split()))
Cnd = sorted(Cnd)
result = 'No'
if Cnd[0]==Cnd[1]+Cnd[2]:
	result ='Yes'
if Cnd[0]+Cnd[1]==Cnd[2]:
	result ='Yes'
print(result)

Measured memory_bytes: 3060
dic = [[] for i in range(31)]
dic[1].append([1])

def func(n):
  if dic[n]:
    return dic[n]
  else:
    dic[n].append([n])
    for i in range(n - 1, 0, -1):
      for l in func(n - i):
        if i >= l[0]:
          dic[n].append([i] + l)
    return dic[n]
func(30)

def main():
  while True:
    n = int(input())
    if not n:
      break
    for l in dic[n]:
      print(" ".join(map(str, l)))
main()


Measured memory_bytes: 9776
#include <bits/stdc++.h>
    using namespace std;
	#define all(x) (x).begin(),(x).end()
	#define ll long long
	#define ld long double
	#define vl vector<long long>
	#define vvl vector<vector<long long>>
	#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
	#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
	#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
	#define pll pair<long long,long long>
	#define pb push_back
	#define mp make_pair
	#define mt make_tuple
	#define vvc vector<vector<char>>
	#define vc vector<char>
	#define vvb vector<vector<bool>>
	#define vb vector<bool>
	#define maxe(x) *max_element(all(x))
	#define mine(x) *min_element(all(x))
	#define Size(x) ((int)(x).size())
	const long long INF = 1LL << 60;
	const long double pi = 3.1415926535897932;
	long long MOD = 1000000007;
	int dx[4]={1,0,-1,0};
	int dy[4]={0,1,0,-1};

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

	signed main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
        string S;
        cin>>S;
        if(Size(S)%2==1){
            cout<<"No"<<endl;
            return 0;
        }
        rep(i,Size(S)){
            if(S[i]!='h'){
                cout<<"No"<<endl;
                return 0;
            }
            i++;
            if(S[i]!='i'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define PI 3.14159265358979323846264338327950L
#define e18 1000000000000000000

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

    char alpha;

    cin >> alpha;

    if (isupper(alpha))
    {
        cout << "A" << endl;
    }else
    {
        cout<<"a" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; i++)
            {
                for (int i2 = 1; i2 <= 9; i2++)
                {
                    Console.WriteLine(i + "x" + i2 + "=" + i * i2);
                }
            }
        }
    }
}

Measured memory_bytes: 5524
#include <iostream>

using namespace std;
using ll = unsigned long long;
int main() {
    int n, k;
    cin >> n >> k;
    ll a[n], nw = 1, old = 1;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < k; ++i)
        old += a[i];
    for(int i = k; i < n; ++i){
        nw = (old - a[i - k]) + a[i];
        if(nw > old)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        old = nw;
    }
    return 0;
}

Measured memory_bytes: 5132
/***
	chauhan176's code

	DO WHATEVER IT TAKES!!!
	Nothing happens , nothing happens and then everything happens.
	But the thing is nothing happens in air:)-
***/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define maxn 300005
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define stringio cin.ignore(256, '\n')  //to take string input after taking integer inputs
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;

typedef pair<int,int>pi;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int mx = 1000007;
vector<ll>di;
void diisor(ll n)
{
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if((n/i)==i)
                di.pb(i);
            else {di.pb(i);di.pb((n/i));}
        }
    }
}
int main()
{
    fastio;
    ll n;
    cin>>n;
    ll ans=inf;
    diisor(n);
    for(ll i : di)
    {
        //cout<<i<<" ";
        ans = min(ans,(i+(n/i)));
    }
    cout<<(ans-2)<<endl;
    return 0;
}


Measured memory_bytes: 384
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
N, M = 0, 0
A, B = [], []


def set_inputs():
    global N, M, A, B
    N, M = get_list_of_int()
    get_data(M, A=int, B=int)
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    s = "".join(list(map(lambda x: chr(ord("A") + x), A + B)))
    for i in range(N):
        print(s.count(chr(ord("A") + i + 1)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256