akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 1; i <= n; i++){
            if(i % 3 == 0){
                System.out.print(" " + i);
            } else {
                if(String.valueOf(i).contains("3")){
                    System.out.print(" " + i);
                }
            }
        }
        System.out.println();
    }
}
                    


Measured memory_bytes: 29296
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T,class U> istream& operator >> (istream &is, pair<T,U> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct { template <typename T> operator T() { T x; cin >> x; return x; } } IN;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n=IN;
    vector<int> a(n);
    cin>>a;
    int ans=a[0]-1;
    int cur=2;
    REPF(i,1,n) {
        if(a[i]==cur) {
            cur++;
            continue;
        }
        if(a[i]%cur==0) {
            ans++;
            a[i]-=cur+1;
        }
        ans+=a[i]/cur;
        a[i]%=cur;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t x, ans = 0;
    cin >> x;
    ans += (x / 11) * 2;
    if (x % 11 <= 6 && x % 11 != 0) {
        ans++;
    }
    else if (x % 11 > 6) {
        ans += 2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n;

int main(){
	cin >> n;
	
	for(int i = 1; i < 4000; i++){
		for(int j = 2; j < 4000; j++){
			if((4*i*j-n*(i+j)) < 1 || (n*i*j) / (4*i*j-n*(i+j)) < 0) continue;
			if((n*i*j) % (4*i*j-n*(i+j)) == 0){
				cout << i << " " << j << " " << (n*i*j) / (4*i*j-n*(i+j)) << endl;
				return 0;
			}
		}
	}
	
	return 0;
}

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

int main(void)
{
	int A, B, C;
	cin >> A >> B >> C;

	vector<int> table;
	table.push_back(A%B);
	do
	{
		int a = table.back() + A;
		a %= B;
		table.push_back(a);
	}while(table.front() !=table.back());

	string ret;
	if(find(table.begin(), table.end(), C) != table.end())
		ret = "YES";
	else
		ret = "NO";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
require 'bigdecimal'
require 'bigdecimal/util'

a, b = gets.split.map(&:to_d)
puts (a*b).floor

# # bの整数部
# bi = b.floor
# # bの小数部
# bf = b - bi
# bf = bf.floor(2)
# # (a*bの小数部)の整数部
# bfi = (a*bf).floor
# ans = a*bi + bfi
# puts ans

Measured memory_bytes: 14460
#include <bits/stdc++.h>
 
using namespace std;
 
inline void Boost() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
    Boost();

    int n, m;
    cin >> n >> m;

    cout << 1900 * m * (1 << m) + (n - m) * 100 * (1 << m); 
    return 0;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    const N = args[0]
    let nums = args.slice(1, args.length - 1);

    nums = Array.from(new Set(nums));
  	
  	console.log(parseInt(nums.length, 10));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,s,ans;
  cin >> n >> m;
  
  //for(int i=0;i<n;++i)
  ans=n*(n-1)/2+m*(m-1)/2;
  
  cout << ans << endl;
}
  

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=5e18;

int main() {
  ll n;
  cin >> n;
  map<string,ll> cnt;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    ans+=cnt[s];
    cnt[s]++;
  }
  cout << ans << endl;
}

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

vector<vector<int>> G;
vector<int> dp, used;

int dfs(int s){
    if(used[s]) return dp[s];

    used[s] = 1;
    int longest = 0;
    for(auto e: G[s]){
        longest = max(longest, dfs(e) + 1);
    }
    return dp[s] = longest;
}

int main(){
    int N, M; cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; i++)
    {
        int x, y; cin >> x >> y; x--, y--;
        G[x].push_back(y);
    }
    dp.assign(N, 0);
    used.assign(N, 0);
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(used[i] == 0){
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 8576
N, A, B = map(int, input().split())
S = input()

mem = list(S)
now = 0
fore=1
for i in range(N):
    if(mem[i]=='a'):
        if(now<(A+B)):
            now+=1
            print('Yes')
        else:
            print('No')

    elif(mem[i]=='b'):
        if(now<(A+B)):
            if(fore<=B):
                fore+=1
                now+=1
                print('Yes')
            else:
                print('No')
        else:
            print('No')

    else:
        print('No')


Measured memory_bytes: 9936
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

long[10^^5][4] CS;

int P = 10^^9+7;

void main()
{
    auto S = readln.chomp.to!(wchar[]);
    auto len = S.length;
    foreach_reverse(i, c; S) {
        if (i == len-1) {
            switch (c) {
                case 'C':
                    CS[2][len-1] = 1;
                    CS[3][len-1] = 1;
                    break;
                case '?':
                    CS[2][len-1] = 1;
                    CS[3][len-1] = 3;
                    break;
                default:
                    CS[3][len-1] = 1;
            }
        } else {
            foreach (j; 0..4) {
                CS[j][i] = CS[j][i+1];
            }
            switch (c) {
                case 'A':
                    CS[0][i] = (CS[0][i+1] + CS[1][i+1]) % P;
                    break;
                case 'B':
                    CS[1][i] = (CS[1][i+1] + CS[2][i+1]) % P;
                    break;
                case 'C':
                    CS[2][i] = (CS[2][i+1] + CS[3][i+1]) % P;
                    break;
                default:
                    CS[0][i] = (CS[0][i+1] * 3 + CS[1][i+1]) % P;
                    CS[1][i] = (CS[1][i+1] * 3 + CS[2][i+1]) % P;
                    CS[2][i] = (CS[2][i+1] * 3 + CS[3][i+1]) % P;
                    CS[3][i] = (CS[3][i] * 3) % P;
            }
        }
    }
    writeln(CS[0][0]);
}

Measured memory_bytes: 3736
import java.util.Scanner;

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

	     String n = sc.nextLine();
	     int N = Integer.parseInt(n);

	     for (int i = 0; i < N; i++) {
	    	 
			String a = sc.nextLine();
            String[] array = a.split(" ");
            String b = array[0];
            String c = array[1];

            
			int x = Integer.parseInt(array[0]);			
			int y = Integer.parseInt(array[1]);
			int z = Integer.parseInt(array[2]);
			
			if(x*x + y*y == z*z){
				System.out.println("YES");
			}else if(x*x + z*z == y*y){
				System.out.println("YES");
			}else if(y*y + z*z == x*x){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			
		}
		
		
	}

}

Measured memory_bytes: 31388
/*
      author  : nishi5451
      created : 14.08.2020 16:31:50
*/

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


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i=1; i<=n; i++){
        int now = 0;
        string s;
        s = to_string(i);
        rep(j,int(s.size())) now += s[j]-'0';
        if(a<=now && now<=b) ans+=i;
    }
    cout << ans << endl;
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n,k,A[MAXN],win,ofs[MAXN];
int main(){
	FAST
	cin>>n>>k;
	FOR(i,1,n)cin>>A[i];
	FOR(ii,1,k){
		mmst(ofs,0);
		FOR(i,1,n){
			++ ofs[max(1ll,i-A[i])], -- ofs[min(n,i+A[i])+1];
		}
		ll sum=0;
		FOR(i,1,n){
			sum+=ofs[i];
			A[i]=sum;
		}
		if(*min_element(A+1,A+n+1) == n) break;
	}
	FOR(i,1,n)cout<<A[i]<<' '; cout<<'\n';
}


Measured memory_bytes: 6776
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#define maxn 10005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define PI 3.1415926
using namespace std;
typedef long long ll;

int n;
int arr[11];

int dfs(int pos, int is_3, int is_5, int is_7, bool limit){
	if(pos == -1 && is_3 && is_5 && is_7) return 1;
	if(pos == -1) return 0;
	int up = limit ? arr[pos] : 9;
	int ans = 0;
	for(int i = 0 ; i <= up ; i++){
		if(!is_3 && !is_5 && !is_7 && i == 0){
			ans += dfs(pos - 1, is_3, is_5, is_7, limit && arr[pos] == i);
		}
		if(i == 3){
			ans += dfs(pos - 1, 1, is_5, is_7, limit && arr[pos] == i);
		}
		if(i == 5){
			ans += dfs(pos - 1, is_3, 1, is_7, limit && arr[pos] == i);
		}
		if(i == 7){
			ans += dfs(pos - 1, is_3, is_5, 1, limit && arr[pos] == i);
		}
	}
	return ans;
}

int init(){
	int len = 0;
	while(n){
		arr[len++] = n % 10;
		n /= 10;
	}
	return len - 1;
}

int main(){
    //freopen("Test.txt", "r", stdin);
    scanf("%d", &n);
    int pos = init();
    printf("%d\n", dfs(pos, 0, 0, 0, true));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	string s, t;
	cin >> s >> t;
	t.pop_back();
	if (s == t) {
		cout << "Yes\n"; 
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3132
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

using pii = pair<uint64_t, uint64_t>;

pii Norm(uint64_t x) {
    vector<uint64_t> p, d;
    for (int i = 2; i * i * i <= x; ++i) {
        if (x % i == 0) {
            p.push_back(i);
            d.push_back(0);
            while (x % i == 0) {
                d.back()++;
                x /= i;
            }
        }
    }
    if (x != 1) {
        uint64_t y = sqrt(x);
        if (y * y == x) {
            p.push_back(y);
            d.push_back(2);
        } else {
            p.push_back(x);
            d.push_back(1);
        }
    }
    uint64_t a = 1, b = 1;
    for (int i = 0; i < p.size(); ++i) {
        if (d[i] % 3 == 0) continue;
        a *= p[i];
        b *= p[i];
        if (d[i] % 3 == 1) {
            b *= p[i];
        } else {
            a *= p[i];
        }
    }
    return {a, b};
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int N;
    cin >> N;
    vector<uint64_t> s(N);
    cin >> s;

    // vector<uint64_t> A, B;
    set<pii> ps;
    map<uint64_t, int> cnt;

    for (auto x : s) {
        auto [a, b] = Norm(x);
        // A.push_back(a);
        // B.push_back(b);
        ps.insert({min(a, b), max(a, b)});
        cnt[a]++;
    }

    int ans = 0;
    for (const auto& [a, b] : ps) {
        if (a == b) ans++;
        else {
            ans += max(cnt[a], cnt[b]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 22744
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    A=S()
    if A=="SUN":
        print(7)
    elif A=="MON":
        print(6)
    elif A=="TUE":
        print(5)
    elif A=="WED":
        print(4)
    elif A=="THU":
        print(3)
    elif A=="FRI":
        print(2)
    elif A=="SAT":
        print(1)




if __name__ == "__main__":
    main()

Measured memory_bytes: 23960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

const ll MAX_V = 1e10;
ll k;
vector<ll> ans;

void dfs(ll v) {
    ans.push_back(v);
    reps(i, -1, 2) {
        ll m = v % 10 + i;
        if ((m < 0) || (m > 9)) continue;
        ll next = v * 10 + m;
        if ((next == 0) || (next >= MAX_V)) continue;
        dfs(next);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> k;
    reps(i, 1, 10) dfs(i);
    sort(all(ans));
    cout << ans[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
};
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
int main() {
	int n; cin >> n;
	rep(i, n) {
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		Segment s1{ {x1,y1},{x2,y2} };
		Segment s2{ {x3,y3},{x4,y4} };
		puts(isPrallel(s1, s2) ? "YES" : "NO");
	}
}

Measured memory_bytes: 3056
n_m = [int(n) for n in input().split()]
N = n_m[0]
M = n_m[1]

votes = [int(n) for n in input().split()]

total_votes = sum(votes)
thresh = total_votes / (4 * M) #better with mult?

count = 0

for A in votes:
    if 4*M*A >= total_votes:
        count += 1
    if count >= M:
        print('Yes')
        break

if count < M:
    print('No')


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

using namespace std;
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << a / b + (a % b != 0);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
const int MX = 100 + 10, MD = 1e9 + 7;
int n, m, a[MX], ans, tmp;
string s[MX], t[MX];
map <string, int> mp;
int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> t[i];
        mp[t[i]]--;
    }
    for(int i = 0; i < n; i++){
        ans = max(ans, mp[s[i]]);
    }
    cout << ans;
}




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

int main(){
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;
    
    bool ok = false;
    for(int i=0; i<K; i++){
        if(B <= A){
            B *= 2;
        }else if(C <= B){
            C *= 2;
        }
        
        if(B > A && C > B){
            ok = true;
            break;
        }
    }
    
    if(ok){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        int N;
        N=sc.nextInt();

        int num[]=new int[N];

        for(int i=0;i<N;i++){
            num[i]=sc.nextInt();
        }
        for(int i=0;i<N;i++){

            System.out.print(num[N-i-1]);
            if (i!=N-1) {
                System.out.print(" ");
            }else{
                System.out.println("");
            }
        }



        sc.close();
    }
}


Measured memory_bytes: 26276
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((in (map 'vector #'parse-integer (split (read-line) #\Space)))
       (a (aref in 0))
       (b (aref in 1))
       (c (aref in 2))
       (a+b (+ a b))
       (b+c (+ b c))
       (c+a (+ c a)))
  (if (or (= a+b c)
          (= b+c a)
          (= c+a b))
    (format t "Yes~%")
    (format t "No~%")))

Measured memory_bytes: 3432
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        exec();
    }

    static void exec() {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int length = String.valueOf(n).length();

        if(length % 2 == 0) {
            StringBuilder sb = new StringBuilder();
            for (int i = length-1; i > 0; i--) {
                if(i % 2 == 0) {
                    sb.append("0");
                } else {
                    sb.append("9");
                }
            }
            out.print(sb);
        } else if(length == 1) {
            out.print(n);
        } else {
            int count = 0;
            int base = 1;
            for (int i = 0; i <length-1 ; i++) {
                base = base * 10;
            }
            count = count + (n - base) + 1;

            StringBuilder sb = new StringBuilder();
            for (int i = length - 2; i > 0; i--) {
                if(i % 2 == 0) {
                    sb.append("0");
                } else {
                    sb.append("9");
                }
            }
            count = count + Integer.parseInt(sb.toString());
            out.print(count);

        }

        out.flush();

    }

}


Measured memory_bytes: 21588
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
int main() {
    ll a = -1;
    ll b = -1;
    ll c = -1;
    ll n, m;
    cin >> n >> m;
    for(int i=0;i<n+1;i++) {
        for(int j=0;j<n+1;j++) {
            c = (m - (i*10000 + j*5000))/1000;
            if ((i+j+c==n)&&(c >= 0)) {
                cout << i << ' ' << j << ' ' << c << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

int main() {
	int N, Q, year;
	cin >> N >> Q;
	unordered_map<int, string> a;
	a[1] = "kogakubu10gokan";
	vector<int> b{ 1 };
	for (int i = 0; i < N; ++i) {
		string name;
		cin >> year >> name;
		a[year] = name;
		b.emplace_back(year);
	}
	cout << a[*prev(upper_bound(b.begin(), b.end(), Q))] << endl;
}


Measured memory_bytes: 3208
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;cin.ignore();
  for(;n--;)
    {
      string s;
      getline(cin,s);
      //      cout<<s<<endl;
      //    return 0;
      for(int a=0;a<1000;a++)
	for(int b=0;b<1000;b++)
	  {
	    if(a%26==0 ||26%a==0)
	      continue;
	    string tmp;
	    tmp=s;
	    for(int i=0;i<tmp.size();i++)
	      {
		if(tmp[i]>='a'&&tmp[i]<='z')
		  {
		    tmp[i]=((a*tmp[i]-'a'+b)%26)+'a';
		  }
	      }
	    if( tmp.find( "that", 0 ) != string::npos || tmp.find( "this", 0 ) != string::npos )
	      {
		cout <<tmp << endl;
		a=1001;
		b=1001;
	      }
	    //	    else
	      //  cout<<tmp<<endl<<a<<" "<<b<<endl;
	  }
    }

}

Measured memory_bytes: 1216
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;

            string result = "NO";
            if (X == 3 || X == 5 || X == 7)
            {
                result = "YES";
            }
            Console.Write(result);

        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (n == i * j) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 504
import collections

n = int(input())
v = list(map(int, input().split()))
v1 = v[0:n - 1:2]
v2 = v[1:n:2]

c1 = collections.Counter(v1)
c2 = collections.Counter(v2)

c1_sort = sorted(c1.items(), key=lambda x:x[1], reverse=True)
c2_sort = sorted(c2.items(), key=lambda x:x[1], reverse=True)

if c1_sort[0][0] != c2_sort[0][0]:
    ans = n - c1_sort[0][1] - c2_sort[0][1]
else:
    if len(c1_sort) == 1 and len(c2_sort) == 1:
        ans = n // 2
    else:
        ans = n - max(c1_sort[0][1] + c2_sort[1][1], c1_sort[1][1] + c2_sort[0][1])
print(ans)


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

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s.at(k-1)=='A'){
            s.at(k-1)='a';
    }else if(s.at(k-1)=='B'){
            s.at(k-1)='b';
    }else{ s.at(k-1)='c';
        }
    
    cout<<s<<endl;
    }


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

MOD = int(1e9) + 7

N, M = map(int, input().split())
a = [True]*(N+1)

for i in range(1, M+1):
    n = int(input())
    a[n] = False

##
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if a[i]:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[-1])


Measured memory_bytes: 46680
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  int n;
  cin >> n;
  cout << n * n * n;
  hinata;
}

Measured memory_bytes: 256
N = int(input())
a = 0
lst = []
for i in range(N):
    lst.append(str(raw_input()))
M = int(input())
for j in range(M):
    T = str(raw_input())
    if (T in lst) == True:
        if a == 0:
            a = 1
            print "Opened by " + T
        else:
            a = 0
            print "Closed by " + T
    else:
        print "Unknown " + T

Measured memory_bytes: 6452
#include<iostream>

using namespace std;

void hikaku(){
	int a[10],n;
	for(int i = 0;i < 10;i++){
		cin >> a[i];
	}for(int i = 0;i < 9;i++){
		for(int j = i+1;j < 10;j++){
			if(a[i]<a[j]){
				n=a[i];
				a[i]=a[j];
				a[j]=n;	
			}
		}
	}for(int i = 0;i < 3;i++){
	   cout<<a[i]<<endl;
    }
}
int main (){
	hikaku();
return 0;
}

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





int main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  
  for (int i=0;i<tx-sx;i++){
    cout<<"R";
  }
  for (int i=0;i<ty-sy;i++){
    cout<<"U";
  }
  for (int i=0;i<tx-sx;i++){
    cout<<"L";
  }
  for (int i=0;i<ty-sy+1;i++){
    cout<<"D";
  }
  for (int i=0;i<tx-sx+1;i++){
    cout<<"R";
  }
  for (int i=0;i<ty-sy+1;i++){
    cout<<"U";
  }
  for (int i=0;i<1;i++){
    cout<<"L";
  }
    for (int i=0;i<1;i++){
    cout<<"U";
  }
  for (int i=0;i<tx-sx+1;i++){
    cout<<"L";
  }
  for (int i=0;i<ty-sy+1;i++){
    cout<<"D";
  }
  for (int i=0;i<1;i++){
    cout<<"R";
  }
  
  cout<<endl;
  
  
}












Measured memory_bytes: 256
/*#### bits/stdc++.h */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<deque>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
/*####*/

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%s\n",(b-a-1)%2?"Alice":"Borys");
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    int zero = 0, one = 0;
    int m = 0;
    for (int i=0; i<n;++i) {
        int x;
        cin >> x;
        if (x == 0)zero++;
        else if (x==1) one++;
        else {
            a[m] = x;
            m++;
        }
    }
    sort(a, a+m);
    if (m >= 2 && a[m-2] == 2 && a[m-1] == 3) {
        if (!(zero % 2 && one == 0 && m == 2))
            swap(a[m-2], a[m-1]);
    }
    if (zero % 2) {
        if (one == 0) {
            for (int i=1; i<m; ++i)
                cout << a[i] << endl;
            for (int i=0; i<zero-1; ++i)
                cout << 0 << endl;
            if (m)
                cout << a[0] << endl;
            cout << 0 << endl;
        } else {
            for (int i=0; i<m; ++i)
                cout << a[i] << endl;
            for (int i=0; i<zero-1; ++i)
                cout << 0 << endl;
            cout << 1 << endl;
            cout << 0 << endl;
            for (int i=0; i<one-1; ++i)
                cout << 1 << endl;
        }
    } else {
        for (int i=0; i<m; ++i) {
            cout << a[i] <<endl;
        }
        for (int i=0; i<zero; ++i)
            cout << 0 << endl;
        for (int i=0; i<one; ++i)
            cout << 1 << endl;
    }
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>

int main()
{
	const int cof[] = {100, 500, 1000};

	int A, B;
	while (~scanf("%d %d", &A, &B)) {
		if (A == 0 && B == 0)
			break;
		int diff = B - A;
		std::vector<int> pay(3, 0);
		for (int i = 2; i >= 0; --i) {
			while (diff >= cof[i]) {
				++pay[i];
				diff -= cof[i];
			}
		}
		printf("%d %d %d\n", pay[0], pay[1], pay[2]);
	}
	return 0;
}

Measured memory_bytes: 0
/**
 *    author:  Taichicchi
 *    created: 20.09.2020 18:50:50
 **/

#include <bits/stdc++.h>

#include <algorithm>
#include <atcoder/all>
#include <iostream>
#include <vector>

using namespace std;
using namespace atcoder;

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

int main() {
    ll N, Q;

    cin >> N >> Q;

    fenwick_tree<ll> fw(N);

    int a;

    rep(i, N) {
        cin >> a;
        fw.add(i, a);
    }

    rep(i, Q) {
        int q, x, y;
        cin >> q >> x >> y;

        if (q == 0) {
            fw.add(x, y);
        } else {
            cout << fw.sum(x, y) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 8220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int n,i,j,stack[15],ans[15],flag=0,aflag=0;

int main(){
	//for(i=0;i<15;i++)stack[i]=0,ans[i]=0;
	while(scanf("%d",&n)!=EOF){
	//for(i=0;i<8;i++){
		//scanf("%d",&n);
		if(n==0){
			flag--;
			ans[aflag]=stack[flag];
			//printf("\nans[%d]=%d \n",aflag,ans[aflag]);
			aflag++;
		}else{
			stack[flag]=n;
			//printf("\nstack[%d]=%d \n",flag,stack[flag]);
			flag++;
			
		}
	}
	for(i=0;i<aflag;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 0
S = [c for c in input()]
N = int(input())
r = 0

B = []

for i in range(N):
	values = input().split()
	if values[0] == '1':
		r ^= 1
	else:
		f = int(values[1]) - 1
		if f == r:
			B.append(values[2])
		else:
			S.append(values[2])

if r == 0:
	print(''.join(B[::-1] + S))
else:
	print(''.join(S[::-1] + B))






Measured memory_bytes: 77472
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int main()
{
	int x, y;
	while (cin >> x >> y&&x)
	{
		int r[40][40] = {};
		int d[40][40] = {};
		for (int i = 1; i <= y; i++)
		{
			{
				for (int j = 1; j < x; j++)
				{
					inin(k);
					if (k == 0)
					{
						r[i][j] = 1;
					}
				}
			}
			{
				if (i == y)continue;
				for (int j = 1; j <= x; j++)
				{
					inin(k);
					if (k == 0)
					{
						d[i][j] = 1;
					}
				}
			}
		}
		int flag[40][40];
		FOR(i, 40)FOR(j, 40)flag[i][j] = INT_MAX;
		priority_queue<piii, vector<piii>, greater<piii> > que;
		piii start = piii(1, pii(1, 1));
		que.push(start);
		flag[1][1] = 1;
		int DX[4] = { 0,-1,0,0 }, DY[4] = { 0,0,0,-1 };
		bool ok = false;
		while (!que.empty())
		{
			piii now = que.top(); que.pop();
			if (now.second.first == x&&now.second.second == y)
			{
				cout << now.first << endl;
				ok = true;
				break;
			}
			for (int i = 0; i < 4; i++)
			{
				int X = now.second.first + dx[i];
				int Y = now.second.second + dy[i];
				int XX = now.second.first + DX[i];
				int YY = now.second.second + DY[i];
				//if (XX < 0 || YY < 0)continue;
				if (i == 0 || i == 3)
				{
					if (d[YY][XX] == 0)continue;
				}
				else
				{
					if (r[YY][XX] == 0)continue;
				}
				if (flag[Y][X] <= now.first + 1)continue;
				piii next;
				next.first = now.first + 1;
				next.second.first = X;
				next.second.second = Y;
				flag[Y][X] = now.first + 1;
				que.push(next);
			}
		}
		if (!ok)
		{
			cout << 0 << endl;
		}

	}
}

Measured memory_bytes: 3016
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
using namespace std;

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

int main(){
	int N;
	cin >> N;
	rep(i, 10) {
		if (111 * i >= N) {
			cout << 111 * i;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    int sizeA = a.size(), sizeB = b.size();
    if (sizeA > sizeB) cout << "GREATER" << endl;
    if (sizeA < sizeB) cout << "LESS" << endl;
    if (sizeA == sizeB) {
        for (int i = 0; i < sizeA; i++) {
            if (a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            } else if (b[i] > a[i]) {
                cout << "LESS" << endl;
                return 0;
            } else {
                cout << "EQUAL" << endl;
                return 0;
            }
        }
    }
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  cout << 180 * (n-2)<< endl;
  return 0;
}


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

int sum_b(int n){
  int sum = 0;
  while (n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i=0;i<=N;++i){
    int sum_a = sum_b(i);
    if (sum_a >= A && sum_a <= B){
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int buf[100];
	int counter = 0;
	int a, b, i;
	char c;
	while(1){
		scanf("%d %c %d", &a, &c, &b);
		switch (c){
			case '+':
				buf[counter] = a + b;
				break;
			case '-':
				buf[counter] = a - b;
				break;
			case '*':
				buf[counter] = a * b;
				break;
			case '/':
				buf[counter] = a / b;
				break;
			default:
				goto _exit;
				break;
		}
		++counter;
	}
	_exit:
	for(i = 0; i < counter; i++){
		printf("%d\n", buf[i]);
	}
}



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

template <typename T> T sq(T a) { return a * a; }

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vector<pair<pair<int, int>, int>> circles(N);
	for (auto& it : circles) {
		cin >> it.first.first >> it.first.second >> it.second;
	}

	double mi = 0;
	double ma = 1e7;
	for (int z = 0; z < 200; z++) {
		double md = (mi + ma) / 2;
		bool good = false;
		auto checkPt = [&](double x, double y) { 
			int cnt = 0;
			for (auto it : circles) {
				cnt += hypot(x - it.first.first, y - it.first.second) * it.second  - md <= 1e-8;
			}
			if (cnt >= K) good = true;
		};

		for (int i = 0; i < N; i++) {
			checkPt(circles[i].first.first, circles[i].first.second);
		}
		for (int i = 0; i < N; i++) {
			for (int j = i+1; j < N; j++) {
				double x1, y1, x2, y2;
				tie(x1, y1) = circles[i].first, tie(x2, y2) = circles[j].first;
				double r1 = md / circles[i].second, r2 = md / circles[j].second;
				double d = hypot(x1 - x2, y1 - y2);
				if (r1 + r2 + d < 2 * max({r1, r2, d})) {
					continue;
				}
				double parallel = (sq(d) + sq(r1) - sq(r2)) / 2 / d;
				double perp = sqrt(max(0., sq(r1) - sq(parallel)));
				//perp = max(0., perp - 1e-7);
				double xmid = x1 + (x2 - x1) / d * parallel;
				double ymid = y1 + (y2 - y1) / d * parallel;
				double xa = xmid + (y2 - y1) / d * perp, ya = ymid - (x2 - x1) / d * perp;
				checkPt(xa, ya);
				double xb = xmid - (y2 - y1) / d * perp, yb = ymid + (x2 - x1) / d * perp;
				checkPt(xb, yb);
			}
		}
		if (good) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << fixed << setprecision(10) << ma << '\n';

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define MAXLOGN 18
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n;
map<int,int> mp[MAXN];
set<PP> s;
map<P,int> cnt;
int find(int u,P p)
{
    if(u==p.F) return p.S;
    return p.F;
}
P get(int u,int v)
{
    if(u>v) swap(u,v);
    return  P(u,v);
}
void merge(int x,int y)
{
    if(mp[x].size()<mp[y].size()) swap(x,y);
    for(auto it:mp[y])
    {
        int z=it.F; int num=it.S;
        mp[y][z]-=num; mp[z][y]-=num;
        if(!num) continue;
        P e=get(y,z);
        s.erase(PP(num,e));
        e=get(x,z);
        if(mp[x][z]) s.erase(PP(mp[x][z],e));
        mp[x][z]+=num; mp[z][x]+=num; s.insert(PP(mp[x][z],e));
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<2*(n-1);i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if(u>v) swap(u,v);
        mp[u][v]++; mp[v][u]++;
        cnt[P(u,v)]++;
    }
    for(auto p:cnt) s.insert(PP(p.S,p.F));
    for(int i=0;i<n-1;i++)
    {
        auto it=s.end(); it--;
        if(s.size()<=0||(*it).F!=2)
        {
            puts("NO");
            return 0;
        }
        P p=(*it).S;
        int u=p.F,v=p.S;
        s.erase(it); 
        mp[u][v]-=2; mp[v][u]-=2;
        merge(u,v);
    }
    puts("YES");
    return 0;
}



Measured memory_bytes: 51968
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
std::vector<long> edge[10005];
std::priority_queue<long> c;
long ans[10005];
long res;
long c_2[10005];

void dfs(long vis){
	ans[vis] = c.top();
	c.pop();
	for(int i = 0; i < edge[vis].size(); i++){
		long nx = edge[vis][i];
		if(ans[nx] == 0){
			dfs(nx);
		}
	}
	return;
}
	
int main(){
	scanf("%ld", &n);
	for(int i = 0; i < n-1; i++){
		long a, b;
		scanf("%ld%ld", &a, &b);
		edge[a-1].push_back(b-1);
		edge[b-1].push_back(a-1);
	}
	for(int i = 0; i < n; i++){
		long x;
		scanf("%ld", &x);
		c.push(x);
		c_2[i] = x;
	}
	
	std::sort(c_2, c_2+n);
	for(int i = 0; i < n-1; i++){
		res += c_2[i];
	}
	
	long min = LINF, vis = 0;
	for(int i = 0; i < n; i++){
		if(edge[i].size() < min){
			min = edge[i].size();
			vis = i;
		}
	}
	dfs(vis);
	
	printf("%ld\n", res);
	for(int i = 0; i < n; i++){
		printf("%ld", ans[i]);
		if(i < n-1){
			printf(" ");
		}else{
			printf("\n");
		}
	}
}
	


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll d;cin>>d;
    vector<ll>c(26);
    rep(i,26)cin>>c[i];
    vector<vector<ll> >s(d,vector<ll>(26));
    rep(i,d){
        rep(j,26)cin>>s[i][j];
    }
    vector<ll>last(26);
    vector<ll>v(d);
    ll ans=0;
    rep(i,d){
        ll ma=-inf*inf;
        ll idx=0;
        rep(t,26){
            ll cn=0;
            cn+=s[i][t];
            ll m=last[t];
            last[t]=i+1;
            rep(j,26){
                cn-=c[j]*(i-last[j]+1);
            }
            last[t]=m;
            if(cn>ma){
                ma=cn;
                idx=t;
            }
        }
        last[idx]=i+1;
        v[i]=idx+1;
    }
    rep(i,d){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 3724
n = int(input())
k = list(map(int, input().split()))
import collections
c = collections.Counter(k)
re = 1
if c[0] == 0:
  for i in range(n):
    re = re * k[i]
    if re > 10**18:
      print(-1)
      exit()
  print(re)
else:
  print(0)

Measured memory_bytes: 23784
#include <bits/stdc++.h>
using namespace std;
int Bsearch(int p[],int x,int n){
    int low=0,high=n-1,mid;
    while(low<=high){
        mid = (low + high)/2;
        if(p[mid]==x)
            return mid;
        else if(p[mid]>x)
            high = mid-1;
        else
            low = mid+1;
    }
    return -1;
}
int check(int find,int p[],int n){
    int k=find;
    while(true){
    k=k-1;
    if(k==0)
        return 0;
    int index = Bsearch(p,k,n);
    if(index==-1)
        return k;
    find+=1;
    index = Bsearch(p,find,n);
    if(index==-1)
        return find;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin >> x >> n;
    int p[n];
    for(int i=0;i<n;i++)
        cin >> p[i];
    sort(p,p+n);
    int find = x;
    if(Bsearch(p,find,n)==-1)
        cout << find;
    else{
    int ans = check(find,p,n);
    cout << ans ;}
    return 0;
}

Measured memory_bytes: 3656