akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;
int n, m, q;
vector<int> a, b, c, d;
int ans;
void calc(vector<int> A){
    if(A.size() == n+1){
    int now = 0;
    rep(i, 0, q){
        if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        calc(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i, 0, q){
        cin >> a[i] >> b[i] >> c[i] >> d[i]; 
    }
    calc(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
s = gets.chomp

if s == "keyence"
  puts "YES"
  exit
end

l = s.length
l.times do |i|
  (l-i).times do |j|
    x = s[i..(i + j)]
    if s.sub(x, "") == "keyence"
      puts "YES"
      exit
    end
  end
end
puts "NO"

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> v(n);
  int i;
  for(i=0;i<n;i++) cin >> p[i];
  for(i=0;i<n;i++) v[i]=p[i];
  sort(p.begin(),p.end());
  int cnt=0;
  for(i=0;i<n;i++){
    if(v[i]!=p[i]) cnt++;
  }
  if(cnt<=2) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}

Measured memory_bytes: 3660
import math
from collections import defaultdict, Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
A = [int(i) for i in input().split()]
v_list = []
mod = 10 ** 9 + 7
LCM_dict = defaultdict(int)
for i in range(N):
    prime_cnt = Counter(prime_factorize(A[i]))
    for k, v in prime_cnt.items():
        LCM_dict[k] = max(LCM_dict[k], v)
    v_list.append(prime_cnt)
ans = 0
for i in range(N):
    prime_cnt = v_list[i]
    tmp_value = 1
    for k, v in LCM_dict.items():
        cnt = 0 if k not in prime_cnt.keys() else prime_cnt[k]
        tmp_value = pow(k, v - cnt) * tmp_value
        tmp_value = tmp_value % mod
    ans += tmp_value
    ans = ans % mod
print(ans)

Measured memory_bytes: 79828
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
k = int(input())
a, b = map(int, input().split())

for i in range(a, b+1):
    if i%k == 0:
        print('OK')
        sys.exit()
print('NG')

Measured memory_bytes: 10468
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
string s;
int p;
int bns();
int g_A(){
  int a=0;
  if(s[p]=='S'){
    p+=2;
    a=bns();
    a=a*a%1000000007;
    p++;
  }
  else if(isdigit(s[p])){
    while(isdigit(s[p])){
      a=a*10+(s[p]-'0');
      p++;
    }
  }
  return a;
}
int bns(){
  int a=g_A();
  while(s[p]=='>'&&s[p+1]=='>'&&(isdigit(s[p+2])||s[p+2]=='S')){
    p+=2;
    int b=g_A();
    a>>=min(b,60LL);
  }
  return a;
}
main(){
  while(getline(cin,s),s[0]!='#'){
    p=0;
    s.erase(remove(s.begin(),s.end(),' '),s.end());
    cout<<bns()<<endl;
  }
}

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

int main() {
  int N, M; cin >> N >> M;
  auto imos = vector<vector<int>>(M, vector<int>(N + 1, 0));
  for (int j = 1; j <= N; ++j) {
    int x; cin >> x;
    --x;
    ++imos[x][j];
  }
  for (int i = 0; i < M; ++i) {
    for (int j = 1; j <= N; ++j) imos[i][j] += imos[i][j - 1];
  }

  auto dp = vector<int>(1 << M + 1, N);
  dp[0] = 0;
  for (int S = 0; S < 1 << M; ++S) {
    int cur = 0;
    for (int i = 0; i < M; ++i) if (S & 1 << i) cur += imos[i][N];
    for (int i = 0; i < M; ++i) {
      if (S & 1 << i) continue;
      int exist = imos[i][cur + imos[i][N]] - imos[i][cur];
      int need = imos[i][N] - exist;
      dp[S | 1 << i] = min(dp[S | 1 << i], dp[S] + need);
    }
  }
  cout << dp[(1 << M) - 1] << endl;

  return 0;
}



Measured memory_bytes: 18912
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,k,ans=1;
    cin>>n>>k;
    ans=k;
    k--;
    n--;
    while(n--)
        ans*=k;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;

int main() {
  LL n;
  vector<char> s;

  cin >> n;
  string str;
  cin >> str;
  for (LL i = 0; i < n; ++i) {
    const char c = str[i];
    s.push_back(c);
  }

  vector<LL> nw;
  for (LL i = 0; i < n; ++i) {
    if (i == 0) {
      nw.push_back((LL)0);
    } else {
      auto this_nw = nw.back();
      if (s[i - 1] == 'W') {
        this_nw++;
      }
      nw.push_back(this_nw);
    }
//    cout << nw.back() << "\n";
  }

  vector<LL> ne;
  for (LL i = n - 1; i >= 0; --i) {
    if (i == n - 1) {
      ne.push_back((LL)0);
    } else {
      auto this_ne = ne.back();
      if (s[i + 1] == 'E') {
        this_ne++;
      }
      ne.push_back(this_ne);
    }
  }
  reverse(ne.begin(), ne.end());

  vector<LL> cost;
  for (LL i = 0; i < n; ++i) {
    cost.push_back(nw[i] + ne[i]);
//    cout << nw[i] << " " << ne[i] << endl;
  }
  auto min_cost_it = std::min_element(cost.begin(), cost.end());

  cout << *min_cost_it << endl;
}



Measured memory_bytes: 16628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 110//??方式?宏是一个好?法 
int target;int a;
int test[MAX][MAX]= {0};
int length,width;
int co[4][2]= {{0,-1},{0,1},{-1,0},{1,0}};
int check(int i,int x,int y)
{
	if(((x+co[i][0])>=0&&(x+co[i][0])<length)&&((y+co[i][1])>=0&&(y+co[i][1])<width))
	return 1;
	else 
	return 0;
}
void run(int x,int y,const int style) {
	for(int i=0; i<4; i++) {
		if(check(i,x,y)) {
			if(test[x+co[i][0]][y+co[i][1]]==style) {
				if(test[x+co[i][0]][y+co[i][1]]>0)
				{
					test[x+co[i][0]][y+co[i][1]]*=-1;//火?的map233333 
					
					run(x+co[i][0],y+co[i][1],style);
				}
			} 
		}
		//如果是-1?明之前走?就不用走了，如果是2就没法走了 
	}
}
int main() {
	char str[MAX];
	scanf("%d %d",&width,&length);
	while(length!=0&&width!=0) {
		memset(&test[0][0],0,sizeof(test));
		target=0;
		for(int j=0; j<width; j++) {
			scanf("%s",str);
			for(int i=0; i<length; i++) {
				if(str[i]=='#') {
					test[i][j]=2;
				} else if(str[i]=='*') {
					test[i][j]=1;
				} else if(str[i]=='@') {
					test[i][j]=3; 
				}
			}
		}
		for(int j=0; j<width; j++) {
			for(int i=0; i<length; i++) {
				if(test[i][j]>0)
				{
					
					run(i,j,test[i][j]);//走到?就?明走完了一片 
					target++;
					//一株? 
				} 
			}
		}
		
		
		printf("%d\n",target);
		scanf("%d %d",&width,&length);//注意??? 
	}
}

Measured memory_bytes: 1548
<?php
$A=[];
for($i=97;$i<123;$i++) $A[chr($i)]=0;

while(1){
	$S=trim(fgets(STDIN));
	if(!$S){break;}

	foreach(str_split($S) as $c){
		$n=ord($c);
		if(64<$n && $n<91) ++$A[chr($n+32)];
		elseif(96<$n && $n<123) ++$A[$c];
	}
}

for($i=97;$i<123;$i++){
	$c=chr($i);
	echo $c,' : ',$A[$c],PHP_EOL;
}

Measured memory_bytes: 15516
N, X, M = map(int, input().split())

ans = 0
flag = [0]*(10**5 + 2)
lst = [X]

for i in range(N):
    X = (X**2)%M

    if flag[X] == 1:
        break

    flag[X] = 1
    lst.append(X)

preindex = lst.index(X)

preloop = lst[:preindex]
loop = lst[preindex:]

loopnum = (N - len(preloop))//len(loop)
loopafternum = (N - len(preloop))%len(loop)

ans = sum(preloop) + sum(loop)*loopnum + sum(loop[:loopafternum])
print(ans)

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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;

int main() {
	FASTER;
	int l,r,d;
	cin >> l >> r >> d;
	int ans = 0;

	for(int i = l ; i<=r;i++)if(i%d == 0) ans++;

	cout << ans;

}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  map<int,int> a;
  map<int,int> b;
  rep(i,n){
    int x;
    cin>>x;
    if(i%2==0) {
      if(a.count(x)) a.at(x)++;
      else a[x]=1;
    }
    else {
      if(b.count(x)) b.at(x)++;
      else b[x]=1;
    }
  }

  vector<pair<int,int>> p;
  vector<pair<int,int>> q;
  p.pb({0,0});
  q.pb({0,0});
  for(auto y : a) {
    auto z=mp(y.se,y.fi);
    p.pb(z);
  }
  for(auto y : b) {
    auto z=mp(y.se,y.fi);
    q.pb(z);
  }

  sort(all(p));
  reverse(all(p));
  sort(all(q));
  reverse(all(q));

  ll ans;
  if(p[0].se!=q[0].se) ans=n-p[0].fi-q[0].fi;
  else ans=n-max(p[0].fi+q[1].fi,p[1].fi+q[0].fi);

  cout << ans << endl;
}

Measured memory_bytes: 6136
h, w, t = map(int,input().split())
c = []

for i in range(h):
    temp = list(input())
    c.append(temp)

ans = 0

for i in range(2**h):
    list_i = list(bin(i)[2:])
    list_i = [int(x) for x in list_i]
    while len(list_i) != h:
        list_i.insert(0, 0)
    for j in range(2**w):
        temp = 0
        list_j = list(bin(j)[2:])
        list_j = [int(x) for x in list_j]
        while len(list_j) != w:
            list_j.insert(0, 0)
        for k in range(w):
            for l in range(h):
#                print(w-1-k,h-1-l)
                if c[l][k] == '#' and list_i[l] != 1 and list_j[k] != 1:
                    temp += 1
        if temp == t:
            ans += 1

print(ans)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
long long n,m,u,v,w,q,k,d[100001],used[100001];
vector< pair<int,long long> >ve[100001];
void dfs(int s) {
    used[s] = 1;
    int sz = ve[s].size();
    for (int i = 0;i<sz;i++) {
        u = ve[s][i].first;
        w = ve[s][i].second;
        if (used[u] == false) {
            d[u] = d[s] + w;
            dfs(u);
        }
    }
}
int main(){
    cin>>n;
    for (int i = 1;i<n;i++) {
        cin>>u>>v>>w;
        ve[u].push_back(make_pair(v,w));
        ve[v].push_back(make_pair(u,w));
    }
    cin>>q>>k;
    dfs(k);
    while (q--) {
        cin>>u>>w;
        cout<<d[u] + d[w]<<endl;
    }
    return 0;
}

Measured memory_bytes: 15104
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	vector<int>nums(10);
	for (int i = 0; i < 10; ++i) {
		cin >> nums[i];
	}
	sort(nums.begin(), nums.end(), greater<int>());
	for (int i = 0; i < 3; ++i) {
		cout << nums[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long ans=0;
	for(int i=0;i<s.length();i++){
		ans+=s[i]-'0';
	}
	if(ans%9==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char ch; cin>>ch;
	if (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') cout<<"vowel";
	else cout<<"consonant";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
#define mod 2019

ll gcd(ll a,ll b){
    if(b==0){return a;}
    else{return gcd(b,a%b);}
}

int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll MIN=(c*d)/gcd(c,d);//最小公倍数

	ll ans_c=b/c-(a-1)/c;//cで割れるものの個数
	ll ans_d=b/d-(a-1)/d;//dで割れるものの個数
	ll ans_cd=b/MIN-(a-1)/MIN;//c,dどちらでも割れる数の個数

	cout<<b-(a-1)-(ans_c+ans_d-ans_cd)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;

class Main {
    static int TABLE_SIZE = 50;

    public static void main(String[] args) throws Exception {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(r.readLine());
        String[] str = r.readLine().split(" ");

        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(str[i]);
        }

        LinkedList<Integer>[] listTable = generateHashedTable(arr);

        int q = Integer.parseInt(r.readLine());
        String[] str2 = r.readLine().split(" ");

        Integer[] arr2 = new Integer[q];
        for(int i = 0; i < q; i++) {
            arr2[i] = Integer.parseInt(str2[i]);
        }

        int count = 0;
        for(Integer v: arr2) {
            if (search(listTable, v)) {
                count ++;
            }
        }

        System.out.println(count);
    }

    private static LinkedList<Integer>[] generateHashedTable(Integer[] arr) {
        @SuppressWarnings("unchecked")
        LinkedList<Integer>[] listTable = (LinkedList<Integer>[]) new LinkedList[TABLE_SIZE];

        for (Integer v : arr) {
            int h = generateHash(v);
            if (listTable[h] == null) {
                listTable[h] = new LinkedList<>();
            }

            LinkedList<Integer> list = listTable[h];
            list.add(v);
        }

        return listTable;
    }

    private static boolean search(LinkedList<Integer>[] listTable, Integer searchNum) {
        int h = generateHash(searchNum);

        LinkedList<Integer> list = listTable[h];
        if (list == null) { return false; }

        return list.contains(searchNum);
    }

    private static int generateHash(Integer v) {
        int h = v.hashCode();
        if (h < 0) {  h = 0 - h; }
        return h % TABLE_SIZE;
    }
}

Measured memory_bytes: 28040
def actual(N):
    answer = 0

    odd_numbers = range(1, N + 1, 2)

    is_divisor = lambda num, i: num % i == 0

    for odd_num in odd_numbers:
        divisor_count = 0

        for i in range(1, odd_num + 1):
            if is_divisor(odd_num, i):
                divisor_count += 1

        if divisor_count == 8:
            answer += 1

    return answer

N = int(input())
print(actual(N))

Measured memory_bytes: 9048
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n = II()
a = [0] * (n+1)
a[0] = 2
a[1] = 1
for i in range(2, n+1):
    a[i] = a[i-1] + a[i-2]
print(a[n])


Measured memory_bytes: 66028
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution


int32_t main()
{
    IOS
    
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<pair<int,int>> v;
    for(int i=1;i<=a;i++)
    {
    	int x;
    	cin>>x;
    	v.push_back({x,1});
    }
    for(int i=1;i<=b;i++)
    {
    	int x;
    	cin>>x;
    	v.push_back({x,2});
    }
    for(int i=1;i<=c;i++)
    {
    	int x;
    	cin>>x;
    	v.push_back({x,0});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int co=0,ans=0;
    for(int i=0;i<v.size();i++)
    {

    	if(v[i].second==0 and co!=x+y)
    	{
    		co++;
    		ans+=v[i].first;
    	}
    	if(v[i].second==1 and x>0 and co!=x+y)
    	{
    		x--;
    		ans+=v[i].first;
    	}
    	if(v[i].second==2 and y>0 and co!=x+y)
    	{
    		y--;
    		ans+=v[i].first;
    	}
    }
    cout<<ans;

}       


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,m,t;
int table[7][7][7];

int py[510],px[510];

int game(int iy,int ix,int f){
	bool ok=false;
	rep(z,n) if(table[z][iy][ix]==0){
		ok=true;
		table[z][iy][ix]=f;
		break;
	}
	if(!ok)
		return 0;

	rep(z,n)rep(y,n)rep(x,n){
		range(dz,-1,2)range(dy,-1,2)range(dx,-1,2){
			if(dz==0&&dy==0&&dx==0)
				continue;
			int nz,ny,nx;
			nz=z+dz*(m-1),ny=y+dy*(m-1),nx=x+dx*(m-1);
			if(nz<0||n<=nz)
				continue;
			if(ny<0||n<=ny)
				continue;
			if(nx<0||n<=nx)
				continue;
			int cnt=0;
			rep(i,m) cnt+=(f==table[z+dz*i][y+dy*i][x+dx*i]);
			if(cnt==m)
				return f;
		}
	}
	return -2;
}

int main(void){
	while(cin >> n >> m >> t){
		if(n==0)
			break;
		rep(z,7)rep(y,7)rep(x,7) table[z][y][x]=0;
		range(i,1,t+1){
			cin >> py[i] >> px[i];
			py[i]--,px[i]--;
		}
		bool gameend=false;
		range(i,1,t+1){
			int ans=game(py[i],px[i],(i%2)?-1:1);
			if(ans!=-2){
				if(ans==1)
					cout << "White " << i << endl;
				else if(ans==0)
					cout << "Draw" << endl;
				else
					cout << "Black " << i << endl;
				gameend=true;
				break;
			}
		}
		if(!gameend)
			cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#include<vector>
using namespace std;
const int limit = 100010;
struct edge{
	int to;
	long long cost;
};
vector<edge> tree[limit];
long long depth[limit];
void dfs(int v, int p, long long d) {
	depth[v] = d;
	for (auto &e:tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

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

	for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back({b, c});
		tree[b].push_back({a, c});
	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}

	return 0;
}


Measured memory_bytes: 16104
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
#define re register
using namespace std;
struct ios{
	inline char fchar(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
//	#define getchar fchar
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char x){putchar(x);return *this;}
}io;
const int N = 6e5+5;

ll a,b;
int main()
{
	io>>a>>b;
	ll ans1 = (a+b)/2;
	if(a==b){puts("0");return 0;}
	if((a+b)%2==0){io<<ans1;return 0;}
	else puts("IMPOSSIBLE");
    return 0;
}

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

string s;

int main() {
	cin>>s;
	for (int i=0;i<3;i++) {
		if (s[i]=='7') {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3640
N ,T =map(int,input().split())
t = list(map(int,input().split()))
ans = 0

for i in range(1,N):
    if t[i] - t[i-1] >=T:
        ans += T
    else:
        ans += t[i] - t[i-1]
ans += T

print(ans)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int r; cin >> r;

    cout << r*r << endl;
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
S = input()

# 求解処理
ACGT = ["A", "C", "G", "T"]


def is_acgt(s: str) -> bool:
    return s in ACGT


N = len(S)
ans = 0
for s in range(N):
    S_s = S[s]
    if not is_acgt(S_s):
        continue
    acgt_length = 1
    for e in range(s + 1, N):
        S_e = S[e]
        if not is_acgt(S_e):
            break
        acgt_length += 1
    ans = max(ans, acgt_length)

# 結果出力
print(ans)


Measured memory_bytes: 8972
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

const int maxn=55,maxm=2505;
int n,m;
struct edge{
	int v,next;
}e[maxm];
int head[maxn],cnt;
int dfn[maxn],low[maxn],index;
int ans;

int read();
void readdata();
void add(int u,int v);
void tarjan(int u,int fa);

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

int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

void readdata()
{
	n=read(),m=read();
    for(int i=1;i<=m;i++)
	{
		int a,b;
		a=read(),b=read();
		add(a,b);
		add(b,a);
    }
    for(int i=1;i<=n;i++)
    {
    	if(!dfn[i])
    	{
    		tarjan(i,i);
		}
	}
    printf("%d\n",ans);	
}

void add(int u,int v)
{
	e[++cnt].v=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}

void tarjan(int u,int fa)
{
    dfn[u]=low[u]=++index;
    for(int i=head[u];i;i=e[i].next)
	{
        int v=e[i].v;
        if(!dfn[v])
		{
            tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]) 
			ans++;
        }
		else if(v!=fa)
        low[u]=min(low[u],dfn[v]);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int maxn = 5007, mod = int(1e9) + 7;
typedef long long ll;
char str[maxn];
int ans[maxn][maxn], len, n;
ll power_mod(ll p, int q) {
    ll ret = 1;
    while (q) {
        if (q & 1) ret = ret * p % mod;
        p = p * p % mod;
        q >>= 1;
    }
    return ret;
}
int max(int a, int b) { return a > b ? a : b; }
void init() {
    len = int(strlen(str)), ans[0][0] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            ans[i + 1][j + 1] = int((1ll * ans[i][j] * 2 % mod + ans[i + 1][j + 1]) % mod);
            ans[i + 1][max(j - 1, 0)] = int((0ll + ans[i][j] + ans[i + 1][max(j - 1, 0)]) % mod);
        }
    }
}

int main() {
    scanf("%d%s", &n, str);
    init();
    printf("%d\n", int(power_mod(power_mod(2, len), mod - 2) * ans[n][len] % mod));
    return 0;
}

Measured memory_bytes: 70600
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    W: i64,
    H: i64,
    x: i64,
    y: i64,
    r: i64,
    }
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        println!("Yes");
    }
    else{
        println!("No");
    }
}
//nを入力後ctrl+Z


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i=A; i<B+1; i++) {
    string si = to_string(i);
    if (si.at(0)==si.at(4) && si.at(1)==si.at(3)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d,ans=0;
	cin >> a>>b>>c>>d;
	if (a <= b) {
		ans += a;
	}
	else {
		ans += b;
	}
	if (c <= d) {
		ans += c;
	}
	else {
		ans += d;
	}
	cout << ans<<endl;
}

Measured memory_bytes: 380
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    sort(a.begin(), a.end());
    
    int min_ = *(a.begin());
    int max_ = *(a.end() - 1);
    
    cout << max_ - min_ << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  bool flg = false;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "Y"){
      flg = true;
    }
  }
  if (flg) {
      cout << "Four" << endl;
  } else {
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans = 0,temp=0;
    for(int i=0;i<3;++i){
        if(s[i] == 'R'){
            temp += 1;
        }
        else{
            ans = max(ans,temp);
            temp = 0;
        }

    }
    ans = max(ans,temp);
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
using System;
public class Hello{
    public static void Main(){
        string line;
        while((line=Console.ReadLine()) !=null){///// repeat unless no input
            coreProcess(line);
        }
    }
    
    public static void coreProcess(string line){
        string [] input=line.Split(' ');
        double a=int.Parse(input[0]);
        double b=int.Parse(input[1]);
        double c=int.Parse(input[2]);
        double d=int.Parse(input[3]);
        double e=int.Parse(input[4]);
        double f=int.Parse(input[5]);
        
        double y=(a*f-d*c)/(a*e-d*b);
        double x=(c-b*y)/a;
        System.Console.WriteLine("{0:f3} {1:f3}",x, y);
    }
    
}

Measured memory_bytes: 5660
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int n;
	cin >> n;
	int k, p;
	for (int o = 0; o < n; o++) {
		cin >> k >> p;
		cout << (k%p ? k%p : p) << endl;
	}
}

Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String args[]) throws IOException{
		InputStreamReader inputStreamReader = new InputStreamReader(System.in);
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		int n = Integer.parseInt(bufferedReader.readLine());
		StringBuilder answer = new StringBuilder();
		for(int i=0; i<n; i++){
			String[] dataSet = bufferedReader.readLine().split(" ");
			double x = Math.pow(Integer.parseInt(dataSet[0]), 2);
			double y = Math.pow(Integer.parseInt(dataSet[1]), 2);
			double z = Math.pow(Integer.parseInt(dataSet[2]), 2);
			
			if(x+y==z || x+z==y || y+z==x){
				answer.append("YES\n");	
			}else{
				answer.append("NO\n");	
			}
		}
		System.out.print(answer);
	}	
}

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

int main() {
	for(;;){
		int n,x,ans=0;
		cin>>n>>x;	//n???3??\???100??\???
		if(n==0&&x==0)break;
		
		for(int i=1;i<=n-2;i++){
			for(int j=i+1; j<=n-1; j++){
				for(int k=j+1; k<=n; k++){
					if(i+j+k==x)ans+=1;
					
					
				}
			}
			
		}
			
	
	cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
print("Yes" if A+B >= C else "No")

Measured memory_bytes: 5148
use std::io::*;
use std::str::FromStr;
use std::cmp;


macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



fn main() {
    let n = read();
    let mut v: Vec<(i32, i32, i32)> = (0..n).map(|_| (read(), read(), read())).collect();
    v.insert(0, (0, 0, 0));
    let yes = v[..].windows(2).all(|w| {
        let (t, x, y) = w[0];
        let (nt, nx, ny) = w[1];
        let time = nt - t;
        let dist = (nx - x).abs() + (ny - y).abs();
        dist <= time && time % 2 == dist % 2
    });
    println!("{}", if yes { "Yes" } else { "No" });
}


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

int main() {
  string S;
  cin >> S;
  vector<char> op(4);
  int ans;
  int k = 0;
  for (int i=0; i < 8; i++) {
    ans = S.at(0) - '0';
    op.at(3) = i % 2 == 0 ? '-' : '+' ;
    op.at(2) = (i / 2) % 2 == 0 ? '-' : '+' ;
    op.at(1) = ((i / 2) / 2) % 2 == 0 ? '-' : '+' ;
    for (int j=1; j <= 3; j++) {
      if (op.at(j) == '-')  ans -= S.at(j) - '0';
      else  ans += S.at(j) - '0';
    }
    if (ans == 7) {
      k = 1;
      break;
    }
    if (k == 1) break;
  }
  for (int i=0; i < 3; i++) {
    cout << S.at(i) << op.at(i + 1);
  }
  cout << S.at(3) << "=7" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
char str[10];
int main(){
    scanf("%s",str+1);
    if(str[1] == 'R' && str[2] == 'R' && str[3] == 'R'){
        printf("3");
    }
    else{
        bool flag = false;
        for(int i = 1;i <= 2;i++){
            if(str[i] == 'R' && str[i+1] == 'R'){
                flag = true;
                printf("2");
                break;
            }
        }
        if(!flag){
            flag = false;
            for(int i = 1;i <= 3;i++){
                if(str[i] == 'R'){
                    printf("1");
                    flag  = true;
                    break;
                }
            }
            if(!flag){
                printf("0");
            }
        }
    }
}

Measured memory_bytes: 1644
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
        sc.Scan()
        return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, "")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()
        spl := strSprit(line)

        a, b, c := false, false, false

        for _, t := range spl {
                switch t {
                case "a":
                        a = true
                case "b":
                        b = true
                case "c":
                        c = true
                }
        }

        if a && b && c {
                fmt.Println("Yes")
        } else {

                fmt.Println("No")
        }

}


Measured memory_bytes: 640
n = gets.to_i
a = Array.new(n, 0)
np = Math.sqrt(n).ceil
(1..np).each { |x|
  (1..np).each { |y|
    (1..np).each { |z|
      t = x * x + y * y + z * z + x * y + y * z + z * x
      a[t - 1] = a[t - 1].to_i + 1
    }
  }
}
a.take(n).each { puts _1 }

Measured memory_bytes: 14916
M,D = map(int,input().split())

ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            ans += 1
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>
using namespace std;


int main(){
	int N,A,B,C,array[100],i,result = 0,kari;
	scanf("%d",&N);
	scanf("%d %d",&A,&B);
	scanf("%d",&C);
	for(i = 0;i < N;i++) scanf("%d",&array[i]);
	sort(array,array + N);
	reverse(array,array + N);
	for(i = 0;i < N;i++){
		kari = C / (A + B * i);
		if(kari > result) result = kari;
		C+=array[i];
	}
	printf("%d\n",result);
	return 0;
}

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

//freopen("file_name.in", "r", stdin);
//freopen("file_name.out", "w", stdout);

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

typedef long long ll;

#define eb emplace_back

#define all(v) (v).begin(),(v).end()

#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//-DBL_MAX
//__builtin_popcountll(ll x) - __builtin_popcount(int x)

#define prin(a) cout << #a << " = " << (a) << endl
#define prinv(v) {cout << #v << " = "; for(auto it : v) cout << it << " "; cout << endl;}
#define ppal(a)  cout << #a << endl

const int N = 1e5+10;

ll dp[N];
ll h[N];

int main(){
    ll n, k;
    cin >> n >> k;
    fr(i,n) scanf("%lld", h+i);
    
    for(int i = n-2;i>=0;i--){
        ll &ans = dp[i];
        ans = abs(h[i]-h[i+1])+dp[i+1];
        frr(j,1,k){
            if(i+j==n) break;
            ans = min(ans,abs(h[i]-h[i+j])+dp[i+j]);
        }
    }   
    
    cout << dp[0] << endl;
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

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

        if (500 * K >= X) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int n, l[100];
ll ans = 0;

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

	sort(l, l + n);

	for (int i = 0; i < n - 2; ++i)
		for (int j = i + 1; j < n - 1; ++j)
			for (int k = j + 1; k < n; ++k) {
				if (l[i] == l[j] || l[j] == l[k])
					continue;
				if (l[i] + l[j] > l[k])
					++ans;
			}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> ans(n + 1, 1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        if (a[u] >= a[v]) {
            ans[v] = 0;
        }
        if (a[v] >= a[u]) {
            ans[u] = 0;
        }
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        res += ans[i];
    }
    cout << res << "\n";

    return 0;
}


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

int main(){
    ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    ll b = abs(A - B);
    bool o = false;
    for(ll i=0; i<N-1; i++){
        ll p = i, m = N-1 - i;
        ll n = C*p - D*m, x = D*p - C*m;
        if(n <= b&&b <= x){
            o = true;
        }
    }
    if(o){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}



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

int main() {
	int A, B;
	cin >> A >> B;
	cout << "100 100" << endl;
	bool white;
	vector<vector<bool>> ans(100, vector<bool>(100, false));
	ans[0][0] = true;
	A--; B--;

	if (A > B) {
		white = false;
		A += B;
		B = A - B;
		A = A - B;
	}
	else
		white = true;

	// A <= B である
	int c = 0, d = 0;
	while(A) {
		ans[c + 1][d + 1] = true;
		ans[c + 1][d + 2] = true;
		ans[c + 1][d + 3] = true;
		ans[c + 2][d + 1] = true;
		ans[c + 2][d + 3] = true;
		ans[c + 3][d + 1] = true;
		ans[c + 3][d + 2] = true;
		ans[c + 3][d + 3] = true;
		c += 4;
		if (c == 100) {
			c = 0;
			d += 4;
		}
		A--; B--;
	}
	while (B > 1) {
		ans[c + 1][d + 1] = true;
		ans[c + 1][d + 3] = true;
		c += 2;
		if (c == 100) {
			c = 0;
			d += 4;
		}
		B -= 2;
	}
	if (B) {
		ans[c + 1][d + 1] = true;
	}
	for (int i = 0;i < 100;i++) {
		for (int j = 0;j < 100;j++) {
			if (ans[i][j] == white)
				cout << '#';
			else
				cout << '.';
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x ;
	int ans = 0;
	ll sum = 0;
	while(sum < x){
		sum += ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256