akhauriyash/Code-Regression huggingface dataset:
n = int(input())
for i in range(n):
    s = input().split(" ")
    s = [int(j) for j in s]
    s.sort()
    a = s[0]
    b = s[1]
    c = s[2]

    if(a**2+b**2==c**2):
        print("YES")
    else:
        print("NO")

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

int main () {
	int N , M ; cin >> N >> M ;
	vector <int > cnt (M , 0);
	for ( int i = 0; i < N ; ++ i ) {
		int K; cin >> K ;
		for ( int j = 0; j < K ; ++ j ) {
			int A; cin >> A ; --A ;
			++ cnt [ A ];
		}
	}
	int ans = 0;
	for ( int i = 0; i < M ; ++ i ) {
		if ( cnt [ i ] == N ) {
			++ ans ;
		}
	}
	cout << ans << endl ;
	return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int p[m], r[m];
  string result;
  for(int i=0;i<m;++i){
    cin >> p[i];
    cin >> result;
    if(result == "AC") r[i]=1;
    else r[i]=0;
  }
  
  bool cor[n];
  int pen[n];
  int pennum =0;
  int num = 0;
  for(int i=0;i<n;++i){
    cor[i]=false;
    pen[i]=0;
  }
  for(int i=0;i<m;++i){
    if(r[i]==1){
      if(cor[p[i]-1]==false){
        num++;
        cor[p[i]-1]=true;
      }
    }else{
      if(cor[p[i]-1]==false){
        pen[p[i]-1]++;
      }
    }
  }
  for(int i=0;i<n;++i){
    if(cor[i] == true){
      pennum+=pen[i];
    }
  }
  printf("%d %d\n",num,pennum);
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main(){
 int x,a,b;
 cin>>x>>a>>b;
 if(b-a<=0)
  cout<<"delicious"<<endl;
 else if(b-a<=x)
  cout<<"safe"<<endl;
 else if(b-a>x)
  cout<<"dangerous"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,K,h,i,T;

	scanf("%d%d",&N,&K);
	 
	for(i=0;i<N;i++){
		scanf("%d",&h);
              if(K<=h)T++;}

	printf("%d",T);

	return 0;

}

Measured memory_bytes: 128
import math
A, B, C, D = map(int, input().split())

#Cについて
divByC = 0
r = A % C
if r != 0:
    d = A + (C - r)
else:
    d = A
if d <= B:
    divByC = (B - d + 1) // C
    if (B - d + 1) % C != 0:
        divByC += 1
# print(r, d, divByC)

#Dについて
divByD = 0
r = A % D
if r != 0:
    d = A + (D-r)
else:
    d = A
if d <= B:
    divByD = (B - d + 1) // D
    if (B-d+1) % D != 0:
        divByD += 1
# print(r, d, divByD)

lcm = C * D // math.gcd(C, D)

divByBoth = 0
r = A % lcm
if r != 0:
    d = A + (lcm-r)
else:
    d = A
if d <= B:
    divByBoth = (B - d + 1) // lcm
    if (B - d + 1) % lcm != 0:
        divByBoth += 1
# print(r, d, divByBoth)

print((B - A + 1) - (divByC + divByD - divByBoth))


Measured memory_bytes: 9140
N, M, Q = list(map(int, input().split(' ')))
st_ed = {}
for i in range(M):
    l, r = list(map(int, input().split(' ')))
    st_ed[(l, r)] = st_ed.get((l, r), 0) + 1

memo_g = {}
def g(p, q):
    if p == q:
        return st_ed.get((p, q), 0)
    if not (p, q) in memo_g:
        memo_g[(p, q)] = st_ed.get((p, q), 0) + g(p + 1, q)
    return memo_g[(p, q)]

memo_f = {}
# memo[(p, q)] = memo[(p, q-1)] + sum([st_ed.get((i, q), 0) for i in [1,2,3...p]])
def f(p, q):
    if p == q:
        return st_ed.get((p, q), 0)
    if not (p, q) in memo_f:
        temp = f(p, q - 1) + g(p, q)
        memo_f[(p, q)] = temp
    return memo_f[(p, q)]

memo = {}
for i in range(Q):  # 1e5
    p, q = list(map(int, input().split(' ')))
    if not (p, q) in memo:
        temp = f(p, q)
        memo[(p, q)] = temp
    print(memo[(p, q)])



Measured memory_bytes: 122456
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cctype>

using namespace std;

#define ll long long

const ll mod = (ll)1e9 + 7;

ll mypow(ll a, ll n) {
    ll ans = 1;
    while (n) {
        if (n & 1) {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }
    return ans;
}

void solve() {
    int n;
    scanf("%d", &n);
    ll ans = mypow(10, n);
    ll temp = (mypow(9, n) * 2 % mod - mypow(8, n) + mod) % mod;
    printf("%lld\n", (ans - temp + mod) % mod);
    return ;
}

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

Measured memory_bytes: 3204
#include <stdio.h>

int main(void)
{
    int n, x, i, j;

    scanf("%d", &n);

    for (i = 3; i <= n; ++i){
        if (i % 3 == 0) printf(" %d", i);

        else{
            for (j = i; j > 0; j /= 10 ){
                if (j % 10 == 3){
                    printf(" %d", i);
                    break;
                } 

            }
        }

        
    }

    printf("\n");


    return 0;
}


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

using namespace std;

int main(void)
{
  //5+ 1854-
  int N, M;
  cin>>N>>M;
  if(N>=10 || M>=10){
    cout<<-1<<endl;
  }
  else{
    cout<<N*M<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;

    ll ans = 1ll << 60;
    rep(i, X+1) {
        ll a = i;
        ll c = max(2*(X - a), 0ll);
        ll b = max((2*Y - c + 1)/2, 0ll);
        
        ans = min(ans, a*A + b*B + c*C);
    }
    rep(i, Y+1) {
        ll b = i;
        ll c = max(2*(Y - b), 0ll);
        ll a = max((2*X - c + 1)/2, 0ll);
        
        ans = min(ans, a*A + b*B + c*C);
    }
    cout << ans << endl;
}


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


int main(){
    int N,x;
    cin >> N >> x;
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a,a+N);
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(i==N-1){
            if(x == a[i]) ans++;
        }
        else if(x-a[i]>=0){
            x -= a[i];
            ans++;
        }
        else break;
        
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = 0; i < (a); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<ll> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll W;
  cin >> n >> W;
  VL w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  VVL c(4);
  rep(i, n) {
    c[w[i]-w[0]].push_back(v[i]);
  }
  rep(i, 4) {
    if(c[i].empty()) continue;
    sort(rall(c[i]));
    rep(j, c[i].size()-1) {
      c[i][j+1] += c[i][j];
    }
  }
  rep(i, 4) c[i].push_back(0);
  ll ans = 0;
  rep(a, c[0].size()) {
    rep(b, c[1].size()) {
      rep(d, c[2].size()) {
        rep(e, c[3].size()) {
          if (w[0] * ((a + 1) % c[0].size()) + (w[0] + 1) * ((b + 1) % c[1].size()) + (w[0] + 2) * ((d + 1) % c[2].size()) + (w[0] + 3) * ((e + 1) % c[3].size()) > W) continue;
          ans = max<ll>(ans, c[0][a] + c[1][b] + c[2][d] + c[3][e]);
        }
      }
    }
  }
  out(ans);
  return 0;
}


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

#define int long long

using namespace std;

int fdiv(int a, int b){
  return (int)(a/b);
}

signed main() {
  int n;
  cin >> n;

  vector<int> c(n-1);
  vector<int> s(n-1);
  vector<int> f(n-1);

  //vector<int> ans(n-1);

  for (int i = 0; i < n-1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n-1; i++) {
    int ans = 0;
    for(int j = i; j < n-1; j++){
      int tmp = f[j] * ceil((double)ans/(double)f[j]);
      //cerr << ans <<"/" <<f[j] << "="  << ceil((double)ans/(double)f[j]) << endl;
      tmp = max(tmp, s[j]);
      //cerr << j << ":" << tmp << "+" << c[j] << endl;
      ans = tmp + c[j];
    }
    cout << ans << endl;
  }  
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    map<int, int>Map;
    int n, x, ans=0;
    cin>>n;
    while(n--) scanf("%d", &x), Map[x]++;
    for(auto it : Map){
        if(it.first!=it.second){
            if(it.second<it.first) ans += it.second;
            else ans += it.second-it.first;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4736
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    S: str = input()
    ans = 0
    for s1 in range(10):
        idx1 = S.find(str(s1))
        if idx1 == -1:
            continue

        for s2 in range(10):
            idx2 = S.find(str(s2), idx1+1)
            if idx2 == -1:
                continue

            for s3 in range(10):
                idx3 = S.find(str(s3), idx2+1)
                if idx3 >= 0:
                    ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){

    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    bool left = true;
    bool right = true;
    bool top = true; 
    bool bottom = true;

    if(x - r < 0) left = false;
    if(x + r > w) right = false;
    if(y - r < 0) bottom = false;
    if(y + r > h) top = false;

    if(left && right && bottom && top)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    //cout << ((left && right && bottom && top) ? "Yes" : "No") << endl;
/*
    int W,H,x,y,r; cin>>W>>H>>x>>y>>r;
    bool f=true;
    if(x-r<0) f=false;
    if(x+r>W) f=false;
    if(y-r<0) f=false;
    if(y+r>H) f=false;
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
*/
    
    
}




Measured memory_bytes: 3092
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A;
    cin >> N >> A;

    N = N % 500;
    if(A>=N){
        p_yes();
    }else{
        p_no();
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();

		int z = 0;

		while (true) {

			int x = scan.nextInt();
			String op = scan.next();
			int y = scan.nextInt();

			if (op.equals("+"))
				z = x + y;
			if (op.equals("-"))
				z = x - y;
			if (op.equals("*"))
				z = x * y;
			if (op.equals("/"))
				z = x / y;

			if (op.equals("?"))
				break;

			str.append(z + "\n");
		}

		System.out.print(str);

	}
}

Measured memory_bytes: 18072
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()
    val list = (1..n).map { 
        val (s, p) = readListOfString()
        Triple(s, p.toInt(), it)
    }
    val sortedList = list.sortedByDescending { it.second }.sortedBy { it.first }
    sortedList.forEach { println(it.third) }
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 35952
#include <stdio.h>

int main()
{
	int W;
	int H;
	int x;
	int y;
	int r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if((0 <= x-r) && (x+r <= W) && (0 <= y-r) && (y+r <= H))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}



Measured memory_bytes: 2104
from itertools import combinations_with_replacement
def main():
    N, M, Q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(Q)]
    ans = 0
    for x in combinations_with_replacement(range(1, M+1), N):
        point = 0
        for a, b, c, d in abcd:
            if x[b-1] - x[a-1] == c:
                point += d
        if ans < point:
            ans = point
    print(ans)

if __name__ == '__main__':
    main()


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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    int l = 0, r = n + 1;
    for (int i = 1; i <= m; i++) {
        int x, y; cin >> x >> y;
        l = max(l, x);
        r = min(r, y);
    }
    cout << max(0, r - l + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N, M;
  cin >> N >> M;
  ll cnt[33]={};
  ll i, j;
  
  for(i=0; i<N; i++) {
    ll K;
    cin >> K;
    
    for(j=0; j<K; j++) {
      ll t;
      cin >> t;
      t--;
      cnt[t]++;
    }
    
  }
  
  ll ans=0;
  for(i=0; i<M; i++) {
    if(cnt[i]==N) ans++;
  }
  
  pt(ans);
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,c = 0;
    cin >> k;
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(l,1,k+1){
                c += gcd(i,gcd(j,l));
            }
        }
    }
    PRINT(c);
}



Measured memory_bytes: 3652
ans = Array.new
range = gets.to_i
range.times do |i|
  data = gets.split(/\s/)
  num1 = Math.sqrt(data[0].to_i * data[0].to_i + data[1].to_i * data[1].to_i)
  num2 = Math.sqrt(data[1].to_i * data[1].to_i + data[2].to_i * data[2].to_i)
  num3 = Math.sqrt(data[2].to_i * data[2].to_i + data[0].to_i * data[0].to_i)
  if data[2].to_i == num1 || data[0].to_i == num2 || data[1].to_i == num3
    ans[i] = "YES"
  else
    ans[i] = "NO"
  end
end
ans.each do |j|
  puts j
end

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  string s;
  cin >> s;
  int ok1 = 0, ok2 = 0;
  for (char x : s)
    if (x == 'A')
      ok1 = 1;
    else
      ok2 = 1;
  if (ok1 && ok2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3568
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 998244353;
ll dp[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> p(k);
    for (auto &[l, r] : p)
        cin >> l >> r;
    dp[1] = 1;
    for (ll i = 2; i <= n; i++)
    {
        for (auto [l, r] : p)
            dp[i] += dp[max(0L, i - l)] - dp[max(0L, i - r - 1)] + M, dp[i] %= M;
        if (i < n)
            dp[i] += dp[i - 1];
        dp[i] %= M;
    }
    cout << dp[n];
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(N, 0);
  int a,b; 
  for (int i=0; i<M; i++){
    cin >> a >> b;
    road.at(a-1) += 1;
    road.at(b-1) += 1;
  }
  for (int i=0; i<N; i++){
    cout << road.at(i) << endl;
  }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9 + 7

N,K = map(int,read().split())

# 左からの流入量、コスト
L = N*(N-1)//2+1
dp = np.zeros((N,L),dtype=np.int64)
dp[0,0] = 1

for _ in range(1,N+1):
    prev = dp
    dp = np.zeros_like(prev)
    for n in range(N):
        x = prev[n]
        # どれかを不動点に残りを等個数だけ左右に流す
        dp[n,n:] += x[:L-n] * (n+n+1)
        # 左からのものを採用、自身は左に流す
        if n > 0: dp[n-1,n-1:] += x[:L-n+1] * n
        # 右からのものを採用、自身は右に流す
        if n+1 < N: dp[n+1,n+1:] += x[:L-n-1] * (n+1)
    dp %= MOD

x = dp[0]
if K&1:
    answer = 0
elif K//2 < L:
    answer = x[K//2]
else:
    answer = 0
print(answer)

Measured memory_bytes: 13896
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

signed main(){
    IOS
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
  int a,b,h,m;
  cin >>a>>b>>h>>m;
  int mn = h*60+m;
  double c = mn/2.0;
  double d = mn*(6.0);
  if(c>=d){
    double u = min(c-d,360-c+d);
    double ans = double(sqrt(double(pow(a,2)+pow(b,2))-(2.0)*a*b*cos(M_PI*(u/180))));
    printf("%0.20f",ans);
  }
  else{
    double u = min(d-c,360+c-d);
    double ans = double(sqrt(double(pow(a,2)+pow(b,2))-(2.0)*a*b*cos(M_PI*(u/180))));
    printf("%0.20f",ans);
  }
    return 0;
}

Measured memory_bytes: 4128
c =[]

for _ in range(3):
    c1,c2,c3 = map(int,input().split())
    c.append((c1,c2,c3))

a_test = [[0,0,0] for _ in range(2)]
b = [0,0,0]

for a1 in range(c[0][0]+1):
    dec = [True,True]
    for j in range(3):
        b[j] = c[0][j] - a1
    
    for i in range(2):
        for j in range(3):
            a_test[i][j] = c[i+1][j] - b[j]
            
        a_set = set(a_test[i])
        if len(a_set) != 1:
            dec[i] = False
    if all(dec):
        break
        
if all(dec):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
import fractions

A,B,C,D = map(int,input().split())

Min = (C * D) // fractions.gcd(C, D)

Sum_A = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//(Min))
Sum_B = B - (B//C + B//D - B//(Min))
Sum = Sum_B - Sum_A

print(Sum)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

const string YES = "YES";
const string NO = "NO";

struct union_find {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> count;

    union_find(ll n) : par(n, 0), rank(n, 0), count(n, 1) {
        for(ll i = 0; i < n; ++i){ par.at(i) = i; }
    }

    ll find(ll x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = find(par.at(x));
        }
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y){ return; }
        if(rank.at(x) < rank.at(y)){
            par.at(x) = y;
        }else{
            par.at(y) = x;
            if(rank.at(x) == rank.at(y)){
                rank.at(x)++;
            }
        }

        ll new_count = count.at(x) + count.at(y);
        count.at(find(x)) = new_count;
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    ll size(ll x){
        return count.at(find(x));
    }
};

int main(){
    ll n, m;
    cin >> n >> m;

    union_find uf(n + m);
    vector<bool> used(m, false);
    REP(i, n){
        ll ki;
        cin >> ki;
        REP(j, ki){
            ll li;
            cin >> li;
            li--;
            uf.unite(i, n + li);
            used.at(li) = true;
        }
    }

    const ll num_used = accumulate(ALL(used), 0);
    const ll num_not_used = m - num_used;
    const ll x = uf.size(0);

    if(x + num_not_used == n + m){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int fN = 0;
            for (char d : String.valueOf(N).toCharArray()) {
                fN += Character.getNumericValue(d);
            }
            out.println(N % fN == 0 ? "Yes" : "No");
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21324
module Main (main) where

import           Control.Monad
import qualified Data.ByteString.Char8     as C8
import           Data.Maybe

main :: IO ()
main = do
  [[r],[g]] <- replicateM 2 readInts
  print . showAnswer $ solve (r,g)

type Input  = (Int, Int)
type Output = Int

solve :: Input -> Output
solve (r,g) = 2*g-r

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | AB Bool
  | Number Int

instance Show Answer where
  show (YesNo b)  = if b then "Yes" else "No"
  show (AB b)     = if b then "A"   else "B"
  show (Number i) = show i

Measured memory_bytes: 380
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // not prime num
            return false;
        }
    }
    // prime num
    return true;
}

struct edge{
    int cost, to;

    edge(int in_cost, int in_to){
        cost=in_cost;
        to=in_to;
    }
    bool operator<(const edge &a) const
    {
        return cost > a.cost;
    }
};

bool isJudge(ll a, ll b, ll num, vector<ll>& v){
    ll v_size=v.size();
    vector<ll>calc(v.size());

    rep(i,v_size) calc[i]=v[i];
    rep(i,v_size) calc[i]-=(b*num);
    ll c=a-b;
    ll cnt=0LL;

    rep(i,v_size){
        if(calc[i]<=0) continue;
        cnt+=((calc[i]/c)+(calc[i]%c!=0));
    }

    return cnt<=num;
}

int main() {
    int N;
    ll a,b;

    cin >> N >>a >> b;
    vector<ll> h(N);
    rep(i,N){
        cin >> h[i];
    }
    ll large=1000000000, small=0LL, middle;

    while(large>small+1){
        middle=(large + small)/2;
        if(isJudge(a,b,middle,h)){
            large=middle;
        }else{
            small = middle;
        }
    }
    cout << large << endl;
    return 0;
}


Measured memory_bytes: 1792
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int xMax = Math.max(x, java.util.stream.IntStream.range(0, n).map(i -> scanner.nextInt()).max().orElse(-100));
        int yMax = Math.min(y, java.util.stream.IntStream.range(0, m).map(i -> scanner.nextInt()).min().orElse(100));
        System.out.println(xMax < yMax ? "No War" : "War");
    }
}

Measured memory_bytes: 28500
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;


// indexを保存して値の昇順にソート
bool comp_p(const pair<ll, pair<string, ll>>& l, const pair<ll, pair<string, ll>>& r) {
	return l.second < r.second;
}
// あとは次のようにする
// vector<pll> X;
// for (i = 0; i < N; i++){
// 	ll x;
// 	cin >> x;
// 	X.push_back(pll(i, x));
// }
// sort(X.begin(), X.end(), comp_p);


int main() {
	ll i, j;

	ll N;
	cin >> N;
	vector<string> S;
	vll P;
	for (i = 0; i < N; i++) {
		string s;
		ll p;
		cin >> s;
		cin >> p;
		p *= -1;
		S.push_back(s);
		P.push_back(p);
	}

	vector < pair<ll, pair<string, ll>>> R;
	for (i = 0; i < N; i++) {
		pair<string, ll> r;
		r.first = S[i];
		r.second = P[i];
		R.push_back(pair<ll, pair<string, ll>>(i, r));
	}
	sort(R.begin(), R.end(), comp_p);

	for (auto e : R) {
		cout << e.first + 1 << endl;
	}


	return 0;
}


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

void main()
{
    auto hwk = readln.split.to!(int[]);
    auto H = hwk[0];
    auto W = hwk[1];
    auto K = hwk[2];

    char[][] MAP;
    MAP.length = H;
    size_t sx, sy;
    foreach (i; 0..H) {
        MAP[i] = readln.chomp.to!(char[]);
        foreach (j, c; MAP[i]) if (c == 'S') {
            sx = j;
            sy = i;
        }
    }
    auto memo = new bool[][](H, W);
    memo[sy][sx] = true;
    auto ss = [[sx.to!int, sy.to!int]];
    foreach (_; 0..K) {
        if (ss.empty) break;
        int[][] nss;
        foreach (s; ss) {
            foreach (d; [[1,0], [0,1], [-1,0], [0,-1]]) {
                auto x = s[0] + d[0];
                auto y = s[1] + d[1];
                if (x < 0 || x >= W || y < 0 || y >= H || memo[y][x] || MAP[y][x] == '#') continue;
                memo[y][x] = true;
                nss ~= [x, y];
            }
        }
        ss = nss;
    }

    int r = int.max;
    foreach (y; 0..H) foreach (x; 0..W) if (memo[y][x]) {
        if (x == 0 || y == 0 || x == W-1 || y == H-1) r = 0;
        r = min(r, min((y-1+K)/K, (x-1+K)/K, (H-y+K-2)/K, (W-x+K-2)/K));
    }
    writeln(r+1);
}

Measured memory_bytes: 12540
import math
A, B, H, M = map(int,open(0).read().split())
jishin = 30 * H + 0.5 * M
hunshin = M * 6
kakuAB = jishin - hunshin
kakuAB = math.radians(kakuAB)
C = abs(A**2 + B**2 - 2*A*B*math.cos(kakuAB)) ** 0.5
print(C)

Measured memory_bytes: 9532
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define MAX_W 10000

int n, W;
int v[MAX_N], w[MAX_N], m[MAX_N];

int
solve()
{
	int dp[MAX_W + 1];
	int deq[MAX_W + 1];  // ?????????(??????????????????)
	int deqv[MAX_W + 1]; // ?????????(???)
	int a;
	int i, j;

	for (i = 0; i <= MAX_W; ++i)
		dp[i] = 0;

	for (i = 0; i < n; ++i)
	{
		for (a = 0; a < w[i]; ++a)
		{
			int s = 0, t = 0; // ????????????????????¨????°?
			for (j = 0; j * w[i] + a <= W; ++j)
			{
				// ????????????????°???? j ?????????
				int val = dp[j * w[i] + a] - j * v[i];
				while (s < t && deqv[t - 1] <= val)
					t--;

				deq[t] = j;
				deqv[t++] = val;

				// ?????????????????????????????????
				dp[j * w[i] + a] = deqv[s] + j * v[i];
				if (deq[s] == j - m[i])
					s++;
			}
		}
	}

	return dp[W];
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d %d", &n, &W);
	for (i = 0; i < n; ++i)
		scanf("%d %d %d", &v[i], &w[i], &m[i]);

	printf("%d\n", solve());
	return 0;
}

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

bool check(long long n) {
  for (int i=2; i<=sqrt(n); i++) {
    if (n / i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  long long n;
  cin>>n;
  long long orig_n = n;
  vector<long long> ds;
  int size = sqrt(n) + 1;
  bool is_prime[size];
  for (int i=0; i<size; i++) {
    is_prime[i] = true;
  }
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i=2; i<size; i++) {
    for (int j=2*i; j<size; j+=i) {
      is_prime[j] = false;
    }
  }
  int cnt = 0;
  for (long long i=2; i<size; i++) {
    if (!is_prime[i]) {
      continue;
    }
    long long tmp = i;
    while (n % tmp == 0) {
      ++cnt;
      n /= tmp;
      tmp *= i;
    }
    if (n == 1) {
      break;
    }
  }
  if (n > sqrt(orig_n) && check(n)) {
    ++cnt;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 4556
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int n;
int a[100010], b[100010];
vector<vector<int>> edge;
int d1[100010], dn[100010];

void dfs(int d[], int node) {
	for (auto itr = edge[node].begin(); itr < edge[node].end(); itr++) {
		if (d[*itr] != INF)continue;
		d[*itr] = d[node] + 1;
		dfs(d, *itr);
	}
	return;
}


int main() {
	int i; 
	cin >> n;
	edge.resize(n);
	for (i = 0; i < 100010; i++) {
		d1[i] = INF; dn[i] = INF;
	}

	for (i = 0; i < n-1; i++) {
		int pa, pb; cin >> pa >> pb;
		pa--; pb--;
		a[i] = pa; b[i] = pb;
	}

	for (i = 0; i < n - 1; i++) {
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}

	d1[0] = 0; dn[n - 1] = 0;
	dfs(d1, 0);
	dfs(dn, n-1);

	int f = 0, s = 0;
	for (int i = 0; i < n; i++) {
		if (d1[i] <= dn[i]) {
			f++;
		}
		else s++;
	}

	cout << ((f > s) ? "Fennec" : "Snuke") << endl;

	return 0;
}

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

int main(){
    vector<pair<int, int>> cd;
    int N, m, c, d;
    cin >> N >> m;
    int ans = N + 1;
    for(int i = 0; i < m; ++i){
        cin >> c >> d;
        cd.push_back({c, d});
    }
    sort(cd.begin(), cd.end());
    int start = 0, end = 0;
    for(int i = 0; i < m; ++i){
        if(start == 0){
            start = cd[i].first;
        }
        if(cd[i].first <= end || end == 0){
            if(cd[i].second > end){
                end = cd[i].second;
            }
        }else{
            ans += 2 * (end - start);
            start = cd[i].first;
            end = cd[i].second;
        }
    }
    ans += 2 * (end - start);
    cout << ans << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7L;

ll N,Y;

int main(){

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

cin>>N>>Y;

for(ll i=0; i<=2000; i++){
  for(ll j=0; j<=2000; j++){

    if(N-i-j<0) continue;
    ll money=10000*i+5000*j+1000*(N-i-j);
    if(money==Y){
      cout<<i<<" "<<j<<" "<<N-i-j<<endl;
      return 0;
    }

  }
}

cout<<-1<<" "<<-1<<" "<<-1<<endl;


}



Measured memory_bytes: 256
N =int(input())
AB = []
for i in range(N):
    a,b = map(int,input().split())
    AB.append((b,a))

AB.sort()
time =0

for b,a in AB:
    if time +a >b:
        print("No")
        exit()
    time +=a
    
print("Yes")
        

Measured memory_bytes: 94372
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
struct info{
    long long int w,v;
    //info(long long a,long long int b){
    //    w=a;v=b;
    //}
    bool operator<(const info &a){
        return v>a.v;
    }
};
int main(){
    long long int N,W;
    cin>>N>>W;
    info lis[101];
    for(int i=0;i<N;i++)cin>>(lis[i]).w>>(lis[i]).v;
    long long int wmin=2100000000;
    for(int i=0;i<N;i++)wmin=min(wmin,lis[i].w);
    info betulis[4][100];
    long long int betusize[4]={0};
    for(int i=0;i<N;i++){
        if(lis[i].w==wmin){
            betulis[0][betusize[0]]=lis[i];
            betusize[0]++;
        }
        else if(lis[i].w==wmin+1){
            betulis[1][betusize[1]]=lis[i];
            betusize[1]++;
        }
        else if(lis[i].w==wmin+2){
            betulis[2][betusize[2]]=lis[i];
            betusize[2]++;
        }
        else if(lis[i].w==wmin+3){
            betulis[3][betusize[3]]=lis[i];
            betusize[3]++;
        }
    }
    for(int i=0;i<4;i++)sort(betulis[i],betulis[i]+betusize[i]);
    long long int ans=0;
    for(int i=0;i<=betusize[0];i++){
        for(int j=0;j<=betusize[1];j++){
            for(int k=0;k<=betusize[2];k++){
                for(int ii=0;ii<=betusize[3];ii++){
                    long long int kariv=0,kariw=0;
                    //printf("[%d][%d][%d]\n",i,j,k);
                    for(int l=0;l<i;l++){
                        kariv+=betulis[0][l].v;
                        kariw+=betulis[0][l].w;
                    }
                    for(int l=0;l<j;l++){
                        kariv+=betulis[1][l].v;
                        kariw+=betulis[1][l].w;
                    }
                    for(int l=0;l<k;l++){
                        kariv+=betulis[2][l].v;
                        kariw+=betulis[2][l].w;
                    }
                    for(int l=0;l<ii;l++){
                        kariv+=betulis[3][l].v;
                        kariw+=betulis[3][l].w;
                    }
                    if(kariw<=W){
                        ans=max(ans,kariv);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val B = readLine()!!.split(" ").map(String::toInt)
    val ans = B[0] + B.last() + B.windowed(2) { it.min()!! }.sum()
    println(ans)
}

fun <T, R> List<T>.windowed(size: Int, transform: (List<T>) -> R): List<R> {
    return (0..this.size - size).map { i ->
        transform(this.slice(i until i + size))
    }
}

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

bool check(string S, string T){
  bool ans = true;
  for (int i=0; i<S.size(); i++){
    if(S[i] != '?' && S[i] != T[i]){
      ans = false;
    }
  }
  return ans;
}

string fill(string S){
  for(int i=0; i<S.size(); i++){
    if(S[i] == '?') S[i] = 'a';
  }

  return S;
}


int main(){
  string S, T;
  cin >> S >> T;

  vector<string> cand;

  int ls = S.size(), lt = T.size();
  if(ls < lt){
    cout << "UNRESTORABLE" << endl; return 0;
  }

  for(int i=0; i<ls-lt+1; i++){
    string tmp = S.substr(0,i) + T + S.substr(i+lt);
    if(check(S,tmp)){
      cand.push_back(fill(tmp));
    }
  }

  if (cand.empty()){
    cout << "UNRESTORABLE" << endl; return 0;
  } else {
    sort(cand.begin(), cand.end());
    cout << cand[0] << endl;
  }
}

Measured memory_bytes: 256
import math
n = int(input())
lis = []
cou = 0
ans = 0
for i in range(n):
  a = int(input())
  cou = max(cou,a)
  lis.append(a)
num = []
for i in range(1,cou+1):
  if cou % i == 0:
    num.append(i)
for nu in lis:
  co = 0
  while num[co] < nu:
    co += 1
  ans += (num[co]-nu)
print(ans)


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

using namespace std;

using dijkstra_cost = long long;

template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex
{
	T cost;
	Vertex(T v1) : cost(v1) {}
	Vertex() {}
};
using vertex = Vertex<dijkstra_cost>;

template<class T>
struct Edge
{
	int to;
	T cost;
	Edge(int t, T c) : to(t), cost(c) {}
	Edge() {}
};
using edge = Edge<dijkstra_cost>;
using graph = Graph<vertex, edge>;

template<class V, class E>
void Dijkstra(Graph<V, E>& G, int s, dijkstra_cost INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	using Q_T = pair<dijkstra_cost, int>;
	priority_queue<Q_T, vector<Q_T>, greater<>> q;
	q.emplace(0, s);
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		if (a.first >= v[a.second].cost) continue;
		v[a.second].cost = a.first;
		for (auto& p : e[a.second]) {
			if (p.cost == INF_COST) continue;
			if (a.first + p.cost < v[p.to].cost) q.emplace(a.first + p.cost, p.to);
		}
	}
}

void SoundHound2018_D() {
	int N, M, s, t;
	cin >> N >> M >> s >> t;
	s--;t--;
	graph G(N), G2(N);
	for (int i = 0; i < M; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--;b--;
		G.add_edge(a, b, c);
		G.add_edge(b, a, c);
		G2.add_edge(a, b, d);
		G2.add_edge(b, a, d);
	}
	Dijkstra(G, s, LLONG_MAX);
	Dijkstra(G2, t, LLONG_MAX);
	vector<long long> ans(N);
	for (int i = 0; i < N; i++) {
		ans[i] = G.v[i].cost + G2.v[i].cost;
	}
	for (int i = N - 1; i > 0; i--) {
		ans[i-1] = min(ans[i], ans[i-1]);
	}
	for (int i = 0; i < N; i++) {
		cout << (long long) 1e15 - ans[i] << endl;
	//	cout << ans[i] << endl;
	//	cout << G.v[i].cost << " " << G2.v[i].cost << endl;
	}
}

int main() {
	SoundHound2018_D();
}

Measured memory_bytes: 19000
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=1000000+5;
typedef long long ll;
struct node{
    int u,v,nxt;
}edge[N*2];
int head[N],mcnt;
int du[N];
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
    du[u]++;
}
ll I,P,Q;
bool tag[N];
bool vis[N];
bool flag;
void dfs(int u){
    vis[u]=1;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(!vis[v]){
            tag[v]=tag[u]^1;
            dfs(v);
        }
        else
            if(tag[u]==tag[v])
                flag=false;
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=n;i++){
        if(vis[i])
            continue;
        if(du[i]==0){
            I++;
            continue;
        }
        flag=true;
        dfs(i);
        if(flag)
            Q++;
        else
            P++;
    }
    ll ans=1ll*2*I*n-1ll*I*I+1ll*P*P+2ll*P*Q+2ll*Q*Q;
    printf("%lld\n",ans);
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
 
const int maxn = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c <= 21) {
        cout << "win\n";
    }
    else {
        cout << "bust\n";
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]

ans = 700

if s[0] == 'o':
    ans = ans+100
if s[1] == 'o':
    ans = ans+100
if s[2] == 'o':
    ans = ans+100

print(ans)


Measured memory_bytes: 38256