akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

# N: 参加者数
# K: 初期スコア
# Q: 問題数
N, K, Q = list(map(int, input().split()))

# アイディア (基本的には Q だけ初期スコアからみんな減る)
# ただし、正解した人は正解数だけ Q より減り分が少ない
# なので、誰がどのくらい正解したのかを持つマップを作っておき、
# 出力のタイミングで引けばよい

correct_answer_nums = {}
for i in range(Q):
    who = int(input()) - 1  # 0 オリジンにする
    current = correct_answer_nums.get(who, 0)
    correct_answer_nums[who] = current + 1

for i in range(N):
    if 0 < (K - (Q - correct_answer_nums.get(i, 0))):
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
    string S;
    cin>>S;
    int cnt=0;
    REP(i,SZ(S)-1){
        if(S[i]!=S[i+1])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    x: usize,
    a: usize
    }
    let ans = if x < a {0} else {10};
    println!("{}", ans);
}


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

using namespace std;
using ll = long long;
const int INF = 1e9;

int main()
{
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, INF));
    for(int i = 0; i <= n; i++)dp[i][0] = i;
    for(int j = 0; j <= m; j++)dp[0][j] = j;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            dp[i][j] = min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 0 : 1)});
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 6820
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  inputV(a, n);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int x = 0;
  int y = 0;
  for(int i=0; i<n; i++){
    if( i % 2 == 0 ) x+=a[i];
    else y += a[i];
  }
  cout << x - y << 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> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-15
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int A[305][305];
int B[305][305];
ll ans = 0;
int used[305][305];
int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			scanf("%d",&A[i][j]);
		}
	}
	memset(used,false,sizeof(used));
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(k==i||k==j)continue;
				if(A[i][k]+A[k][j]==A[i][j]){
					used[i][j]=true;
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			B[i][j]=A[i][j];
			if(used[i][j])B[i][j]=INF;
			else ans += (ll)B[i][j];
			//cout << B[i][j] << ' ';
		}
		//cout << endl;
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				chmin(B[i][j],B[i][k]+B[k][j]);
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if((A[i][j]!=B[i][j])||(i==j&&B[i][j]!=0)){
				printf("-1\n");
				return 0;
			}
		}
	}
	cout << ans/2 << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n,j;
  n=s.size();
  j=1;
  
  int i;
  for(i=0;i<=(n-3)/2;i++){
    if(s.at(i)!=s.at((n-3)/2-i)){
      j=0;
    }
  }
  
  for(i=0;i<=n-1;i++){
    if(s.at(i)!=s.at(n-1-i)){
      j=0;
    }
  }
  
  if(j==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, x = gets.chomp.split.map(&:to_i)
l = gets.chomp.split.map(&:to_i)
d = 0
count = 1
1.upto(n) do |i|
  d += l[i-1]
  if d > x then
    break
  end
  count += 1 
end
puts count

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(void){
  string s;
  bool flag=true;
  bool f=true;
  int last, begin;
  int cnt=0;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    cnt++;
    if(s[i]=='A' && flag){begin = i; flag=false;}
    if(s[s.size()-i]=='Z' && f){last = s.size()-i;f=false;}
  }
  cout << last-begin+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N, A, B = list(map(int, input().split()))

    if (B - A) % 2 == 0:
        res = (B - A) // 2
    else:
        if N - A >= B:
            res = A + (B-A - 1) // 2
        else:
            res = (N-B+1) + (B-A - 1) // 2
    print(res)


if __name__ == '__main__':
    main()

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

int main(){
    string st;
    cin >> st;
    bool n = false,s = false,e = false,w = false;
    for(int i = 0;i < st.size();i++){
        if(st[i] == 'N')n = true;
        if(st[i] == 'S')s = true;
        if(st[i] == 'E')e = true;
        if(st[i] == 'W')w = true;
    }
    if(n ^ s || e ^ w)cout << "No" << endl;
    else cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) {
        cout << 'x';
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	String s = sc.next();
      	if(a >= 3200){
          System.out.println(s);
          return;
        }
      	System.out.println("red");
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<string.h>

int main(void){
	char str[20];
	int i;
	
	scanf("%s", str);
	int len = strlen(str);
	
	for(i = 0; i < len / 2; i ++){
		char tmp = str[i];
		str[i] = str[len - 1 - i];
		str[len - 1 - i] = tmp;
	}
	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 524
# -*- coding: utf-8 -*-
# 標準入力を取得
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 求解処理
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

# 結果出力
print(ans)


Measured memory_bytes: 47484
s = input()
answer = 0

if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        f = s[0]
        for j,b in enumerate(str(format(i,'b').zfill(len(s)-1))):
            if b == '1':
               f += ','
            f += s[j+1]
        answer += sum(int(i) for i in f.split(','))
    print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 201000
#define ac 800100
#define inf INT_MAX

int n, ans, pos, tot;
int s[AC], ss[AC];
int even[ac], odd[ac], l[ac], r[ac], pos_odd[ac], pos_even[ac]; 
bool num;

struct node{
	int l, r, pos, x;
};

struct cmp{
	bool operator () (node a, node b){
		return a.x > b.x;//堆是反的
	}
};

priority_queue<node, vector<node>, cmp> q;

inline int read()
{
	int x = 0;char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

inline void up(int a, int b){
	if(a < ans) ans = a, pos = b;
}

inline void update(int x)
{//因为是排列，所以必然有一个更小，因此保证了贪心的正确性
	int ll = x * 2, rr = ll + 1;
	if(even[ll] < even[rr]) even[x] = even[ll], pos_even[x] = pos_even[ll];
	else even[x] = even[rr], pos_even[x] = pos_even[rr];
	if(odd[ll] < odd[rr]) odd[x] = odd[ll], pos_odd[x] = pos_odd[ll];
	else odd[x] = odd[rr], pos_odd[x] = pos_odd[rr];
}

void build(int x, int ll, int rr)
{
	l[x] = ll, r[x] = rr;
	if(ll == rr)
	{
		if(ll & 1) even[x] = inf, odd[x] = s[ll];
		else even[x] = s[ll], odd[x] = inf;
		pos_even[x] = pos_odd[x] = ll;
		return ;
	}
	int mid = (l[x] + r[x]) >> 1;
	build(x * 2, ll, mid), build(x * 2 + 1, mid + 1, rr);
	update(x);
}

void find(int x, int ll, int rr)
{
	if(l[x] == ll && r[x] == rr)
	{
		if(num) up(odd[x], pos_odd[x]);
		else up(even[x], pos_even[x]);
		return ;
	}
	int mid = (l[x] + r[x]) >> 1;
	if(rr <= mid) find(x * 2, ll, rr);
	else if(ll > mid) find(x * 2 + 1, ll, rr);
	else find(x * 2, ll, mid), find(x * 2 + 1, mid + 1, rr);
}

inline void add(int ll, int rr)
{
	if(ll >= rr) return ;
	ans = inf, num = ll & 1;//如果ll是偶数，那么pos也应该是偶数，否则为奇数，因为要求奇偶是相对于当前区间的l而言的
	find(1, ll, rr);
	q.push((node){ll, rr, pos, ans});
}

void pre()
{
	n = read();
	for(R i = 1; i <= n; i ++) s[i] = read();	
}

void work()
{
	add(1, n);
	while(!q.empty())
	{
		node x = q.top();
		q.pop();
		ss[++ tot] = x.x;
		ans = inf, num = (x.pos + 1) & 1;//接下来那个数相当于在[pos + 1, r]中寻找相对与pos + 1为奇数位的最小值
		find(1, x.pos + 1, x.r), ss[++ tot] = ans;
		int tmp = pos;//add一次之后pos就改变了...
		add(x.l, x.pos - 1), add(x.pos + 1, tmp - 1), add(tmp + 1, x.r);
	}
	for(R i = 1; i <= n; i ++) printf("%d ", ss[i]);
	printf("\n");
}

int main()
{
	//freopen("in.in", "r", stdin);
	pre();
	build(1, 1, n);
	work();	
	//fclose(stdin);
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    stack<char> st;
    for(int i = 0; i < s.size(); i++){
        if (st.empty()) st.push(s[i]);
        else if (st.top() == 'S' && s[i] == 'T') st.pop();
        else st.push(s[i]);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

#define repeat(i, x) for (int i = 0; i < (int)(x); i++)

constexpr int MAX_N = 200000;

int size[MAX_N], cs[MAX_N];
int64 table[MAX_N], answer[MAX_N];
std::vector<int> G[MAX_N];

void DFS(int root, int parent, int color) {
    size[root] = 1;
    int64 temp = table[color];

    for (int child : G[root]) {
        if (child == parent) continue;

        // child を根とする、色が color である頂点を含まない部分木のなかで
        // 最大の木の頂点数(num)を計算したい。
        int64 before = table[color];
        DFS(child, root, cs[child]);
        int64 after = table[color],
              num = size[child] - (after - before);

        answer[color] -= num * (num - 1) / 2 + num;
        size[root] += size[child];
    }
    // 色が color の頂点で最も浅い位置にいるのは root なので
    table[color] = temp + size[root];
}

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

    int64 N;
    std::cin >> N;

    repeat (i, N) {
        std::cin >> cs[i];
        cs[i]--;
    }

    repeat (i, N - 1) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    repeat (i, N) {
        answer[i] = N * (N - 1) / 2 + N;
    }

    DFS(0, -1, cs[0]);

    // 色が i である頂点を含まず、かつ根を含む部分木について計算。
    repeat (i, N) {
        int64 num = N - table[i];
        answer[i] -= num * (num - 1) / 2 + num;
        std::cout << answer[i] << '\n';
    }

    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    cout << A.at(N-1) - A.at(0) << endl;
}


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debarr(x) for (auto i : x) cout << i << " "; cout << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 1000000007

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

	int n;
	cin >> n;

	int mx = (n - 1) / 2;
	int res = 0;
	for (int i = 1; i <= mx; i++) {
		res += (n - 1) / i;
	}
	for (int i = mx + 1; i < n; i++) res++;
	cout << res;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct edge{
    int to;
    int cost;
};
vector<int> color;
vector<int> used;
vector<vector<edge>> G;
void dfs(int i){
    for(edge e: G[i]){
        if(used[e.to] == 1) continue;
        if(e.cost % 2 == 0){
            color[e.to] = color[i];
            used[e.to] = 1;
            dfs(e.to);
        }
        else{
            color[e.to] = 1 - color[i];
            used[e.to] = 1;
            dfs(e.to);
        }
    }
}
int main(){
    int N;
    cin >> N;
    G.resize(N);
    used.resize(N, 0);
    color.resize(N);
    for(int i = 0; i < N - 1; i++){
        int s, g, c;
        cin >> s >> g >> c;
        s--;
        g--;
        edge e, e2;
        e.to = g;
        e2.to = s;
        e.cost = c;
        e2.cost = c;
        G[s].push_back(e);
        G[g].push_back(e2);
    }
    color[0] = 0;
    used[0] = 1;
    dfs(0);
    for(int i = 0; i < N; i++) cout << color[i] << endl;
}

Measured memory_bytes: 8576
#include <iostream>

using namespace std;

int main(){
    int N,ans=101,sum=0,A[101];
    cin>>N;
    for(int i=0;i<N;i++){
        cin >>A[i];
        sum+=A[i];
    }
    double average=(double)sum/N,min=999,a,b;//int,intの計算では値はintにしかならず、doubleにはならない:sum/N
    for(int i=0;i<N;i++){
        if(A[i]<average){
            a=average;
            b=A[i];
        }else{
            a=A[i];
            b=average;
        }
        if(min>a-b){
            min=a-b;
            ans=i;
        }
    }
    cout <<ans;
    return 0;
}

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

int main(){
 int a,b,c;
 cin >>a>>b>>c;
 
 int cnt =0;
 for(int x=a;x <=b;x++){
  if(c % x == 0) cnt++;
}

cout<<cnt<<endl;
}


Measured memory_bytes: 3100
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			int n = scan.nextInt();
			int sum = 0;
			
			if(n == 0) {break;}
				
			List<Integer> l = new ArrayList<Integer>();
			
			for(int i = 0; i < n; i++)
			{
				int input = scan.nextInt();
				l.add(input);
				sum += input;
			}
			
			float avg = sum/n;
			int ans = 0;
			for(int x : l)
			{
				if(x <= avg)
				{
					ans += 1;
				}
			}
			System.out.println(ans);
		}
		
	}

}



Measured memory_bytes: 60508
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

// repetition
// ----------------------------------------------------------------------------
#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGINT(x) printf("%d\n", x);
#define DEBUGFLOAT(x) printf("%f\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORINT(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORFLOAT(i, a, b,x ) FOR(i, a, b){ printf("%f ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPINT(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPFLOAT(i, n, x) REP(i, n){ printf("%f ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int cheese[3];
    int i, j;
    int n, r, size;

    while (1){
        scanf("%d %d %d", &cheese[0], &cheese[1], &cheese[2]);
        
        if (cheese[0] == 0 && cheese[1] == 0 && cheese[2] == 0){
            break;
        }

        for (i = 0; i < 3; ++i){
            for (j = i + 1; j < 3; ++j){
                if (cheese[i] > cheese[j]){
                    cheese[i] ^= cheese[j];
                    cheese[j] ^= cheese[i];
                    cheese[i] ^= cheese[j];
                }
            }
        }

        size = cheese[0] * cheese[0] + cheese[1] * cheese[1];
        
        scanf("%d", &n);

        for (i = 0; i < n; ++i){
            scanf("%d", &r);

            if ((r * 2) * (r * 2) > size){
                printf("OK\n");
            }
            else {
                printf("NA\n");
            }
        }
    }
                
    return 0;
}

Measured memory_bytes: 0
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();

function input(){return stdin.pop()};
var stdout = [];
function print(x){stdout.push(x)};


var n = parseInt(input());
var v = input().split(" ").map(n=>parseInt(n));
var c = input().split(" ").map(n=>parseInt(n));


var ans = 0;
for (i=0; i < n; i++){
    ans += Math.max(0, v[i]-c[i])
}


print(ans);


stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

const int N = 1e6 + 8;

int cnt[N];

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
		cnt[t]++;
	}
	int ans = 0;		
	for (int i = 0; i < n; i++) {
		int ok = 1;
		for (int j = 1; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				if (j != a[i]) ok &= !cnt[j];
				if (j > 1) ok &= !cnt[a[i] / j];
				if (j == 1) ok &= (cnt[a[i] / j] < 2);
			}
		}
		ans += ok;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7368
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[101];
  int len;
  int flg=0;
  
  scanf("%s",s);
  len=strlen(s);
  for(int i=0;i<len;i+=2){
    if(s[i]=='L'){
      flg=1;
      break;
    }
  }
  for(int i=1;i<len;i+=2){
    if(s[i]=='R'){
		flg=1;
      break;
    }
  }
  if(flg==1){
	printf("No\n");
  }
  else{
    printf("Yes\n");
  }
  return 0;
}
  

Measured memory_bytes: 128
# 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 <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	ll one, two;
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	one = min({ q * 4,h * 2,s });
	two = min(one * 2, d);
	cout << (n / 2 * two + n % 2 * one) << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

class UnionFind
{
    std::vector<int> data;
    int root_count;

public:
    UnionFind(int size) : data(size, -1), root_count(size) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
            root_count--;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
    int count()
    {
        return root_count;
    }
};

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

    ll n, m, q;
    cin >> n >> m >> q;
    set<vector<int>> ones, zeros;
    UnionFind uf(n);
    vector<int> a(q), b(q), c(q);
    int one = 0, zero = 0;
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        if (c[i] == 0)
        {
            if (uf.find(a[i], b[i]) == false)
            {
                zero++;
                zeros.emplace(vector<int>{a[i], b[i], c[i]});
                uf.unite(a[i], b[i]);
            }
        }
        else
        {
            one++;
            ones.emplace(vector<int>{a[i], b[i], c[i]});
        }
    }
    if (m == n - 1 && one)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < q; i++)
    {
        if (c[i] == 0)
            continue;
        if (uf.find(a[i], b[i]))
        {
            cout << "No" << endl;
            return 0;
        }
    }
    ll sz = uf.count(), ma = sz * (sz - 1) / 2 + (int)zeros.size();
    if (sz <= 2 && one)
    {
        cout << "No" << endl;
        return 0;
    }
    if (m > ma)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 11264
import java.io.*;
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n][4];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                arr[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(n, arr));
    }

    private static int solve(int day, int[][] input) {
        int[] a = new int[input.length];
        int[] b = new int[input.length];
        int[] c = new int[input.length];
      
      	a[0] = input[0][0];
      	b[0] = input[0][1];
      	c[0] = input[0][2];
      
      	for (int i = 1; i < input.length; i++) {
        	a[i] = input[i][0] + Math.max(b[i - 1], c[i - 1]);
          	b[i] = input[i][1] + Math.max(a[i - 1], c[i - 1]);
          	c[i] = input[i][2] + Math.max(a[i - 1], b[i - 1]);
        }
      	return Math.max(a[input.length - 1], Math.max(b[input.length - 1], c[input.length - 1]));
    }
}


Measured memory_bytes: 96968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t1,t2,a1,a2,b1,b2;cin>>t1>>t2>>a1>>a2>>b1>>b2;
	ll v1=a1-b1;ll v2=a2-b2;
		ll x1=v1*t1,x2=v2*t2;
		if(x1>0&&(x1+x2)>0)
		{
			//while(1);
			cout<<0<<endl;
			return 0;
		}
		else if(x1>0&&(x1+x2)==0)
		{
			//while(1);
			cout<<"infinity"<<endl;
			return 0;
		}
		else if(x1>0&&(x1+x2)<0)
		{
			//while(1);
			ll res=(-x1-x2);
			ll ans=x1/res;
			if(x1%res!=0)
			cout<<2ll*(ans)+1ll<<endl;
			else cout<<2ll*(ans)<<endl;
			return 0;
		}
		else if(x1<0&&(x1+x2)<0)
		{
			//while(1);
			cout<<0<<endl;
			return 0;
		}
		else if(x1<0&&(x1+x2)==0)
		{
			//while(1);
			cout<<"infinity"<<endl;
			return 0;
		}
		else if(x1<0&&(x1+x2)>0)
		{
			//while(1);
			ll xx=-x1;
			if(xx%(x1+x2)!=0)
			cout<<2ll*(xx/(x1+x2))+1ll<<endl;
			else cout<<2ll*(xx/(x1+x2))<<endl;
			return 0;
		} 
	return 0;
 } 
 /*

*/

Measured memory_bytes: 256
#include <iostream>

int main(void) {
	int A, B, C;
	std::cin >> A >> B >> C;
	if(A + B + C == 5 + 7 + 5 && A * B + B * C + C * A == 5 * 7 + 7 * 5 + 5 * 5 && A * B * C == 5 * 7 * 5) {
		std::cout << "YES\n";
	} else {
		std::cout << "NO\n";
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    using namespace std ;
    int main(){
        int a,b,c;
        cin>>a>>b>>c;
        if(min(abs(a-b),min(abs(b-c),abs(c-a)))==abs(a-b)){
            if(abs(a-c)>abs(b-c)){
                cout<<abs(b-a)+abs(b-c)<<endl;
                return 0;
            }
            else{
                cout<<abs(a-b)+abs(a-c)<<endl;
                return 0;
            }
            return 0;
        }
        if(min(abs(a-b),min(abs(b-c),abs(c-a)))==abs(c-b)){
            if(abs(a-c)>abs(b-a)){
                cout<<abs(c-b)+abs(b-a)<<endl;
                return 0;
            }
            else{
                cout<<abs(c-b)+abs(a-c)<<endl;
                return 0;
            }
            return 0;
        }
        if(min(abs(a-b),min(abs(b-c),abs(c-a)))==abs(a-c)){
            if(abs(a-b)>abs(b-c)){
                cout<<abs(c-a)+abs(b-c)<<endl;
                return 0;
            }
            else{
                cout<<abs(a-c)+abs(a-b)<<endl;
                return 0;
            }
            return 0;
        }
        return 0 ;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[35];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i = 0; i < n; i++){
		int k;
		cin>>k;
		for(int j = 0; j < k; j++){
			int c;
			cin>>c;
			a[c]++;
		}
	}
	int sum = 0;
	for(int i = 0; i <= m; i++){
		if(a[i] == n)
			sum++;
	}
	cout<<sum<<endl;
	return 0;
} 

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n, a, b;
	cin >> n >> a >> b;

	cout << min(a, b) << " ";

	if ((a + b) >= n) {
		cout << a + b - n << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

	if(nextInt()*500>=nextInt()){
    	System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
      
  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H,N;
    cin >>H>>N;
    
  	for(int i=0;i<N;i++){
      int A;
      cin >> A;
      H-=A;
    }
  
  	if(H<=0)
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
  
  	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	i64 n, k; cin >> n >> k;
	
	i64 ret = 0;
	for(int i = 1; i <= n; i++) {
		i64 a = i % k, b = (k - a) % k, c = (k - a) % k;
		if((b + c) % k) continue;
		
		if(b) ret += ((n - b) / k + 1) * ((n - c) / k + 1);
		else ret += ((n - b) / k) * ((n - c) / k);
	}
	
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	rep(i, s.length())printf("x");
	printf("\n");

	Please AC;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;cin>>s;
    if(s[0]=='R'&& s[1]=='R' && s[2]=='R')
        cout<<"3";
    else if((s[0]=='R' && s[1]=='R')|| (s[1]=='R' && s[2]=='R'))
        cout<<"2";
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
        cout<<"1";
    else cout<<"0";
    cout<<endl;


}


Measured memory_bytes: 3556
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);

    if(N == 19 || N == 29 || N== 39 || N==49 || N==59 || N==69 || N==79 || N==89 || N>=90 && N<=99)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using lli =    long long int ; using namespace std;
bool isprime(lli n); lli gcd(lli a, lli  b);
lli lcm(lli n, lli m); lli fact(lli n);
double dgr(double a); int fixMod(int a, int b);
long long  ncr(int n, int r); void fast();
lli maxSubArraySum(lli a[], lli size);
lli compute(lli h, lli n, int cur);
lli const L = 0;
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010
int main()
{
	fast();
	lli n; cin>>n;
	pair<pair<string ,lli>,lli>rest[n];
	for(int i=0;i<n;i++)
	{
	    lli w;string s;
	    cin>>s>>w;
	    rest[i]={{s,-w},i+1};
	}
	sort(rest,rest+n);
	for(int i=0;i<n;i++)
	cout<<rest[i].second<<endl;
}
	void fast() {
		ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout);
#endif 
	}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

int main(){
	ll n, k;
	cin >> n >> k;
	ll cnt[(int)(1e5)+1];
	for(ll i=0; i<(ll)(1e5)+1; i++) cnt[i]=0;
	for(ll i=0; i<n; i++){
		ll a, b;
		cin >> a >> b;
		cnt[a]+=b;
	}
	for(ll i=1; i<=(ll)(1e10); i++){
		k-=cnt[i];
		if(k<=0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else cout << "consonant" << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const int maxn = 1<<17;
const int mod = 1e9+7;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
int coutt[4][2]= {{0,1},{1,0},{-1,0},{0,-1}};
ll a[100000];
ll f(ll x,ll y,ll z)
{
    return x*x+y*y+z*z+x*y+y*z+x*z;
}
int main()
{

    int n;
    scanf("%d",&n);
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                a[f(i,j,k)]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        printf("%lld\n",a[i]);
    }
 	return 0;
}


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    string S;
    cin>>S;

    char base = S[S.length()/2];
    for (int n = 1; n <= S.length() / 2; n++) {
        if (S[S.length()/2-n] != base || S[S.length()/2+n-(S.length()%2==0 ? 1 : 0)] != base) {
            cout<<(S.length()+1)/2+n-1<<endl;
            return 0;
        }
    }

    cout<<S.length()<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

  int N, M; cin >> N >> M;

  vector < pair<ll, int> > key(M);
  for (int i = 0; i < M; i++){
    ll A; int B; cin >> A >> B;
    key[i].first = A;

    int cnt = 0;
    for (int j = 0; j < B; j++){
      int C; cin >> C; C--;
      cnt += pow(2, C);
    }
    key[i].second = cnt;
  }

  int all = pow(2, N);

  ll DP[M + 1][all];
  for (int i = 0; i < M + 1; i++){
    for (int j = 0; j < all; j++){
      DP[i][j] = 1e15;
    }
    DP[i][0] = 0;
  }

  for (int i = 0; i < M; i++){
    ll value = key[i].first;
    int num = key[i].second;
    for (int j = 0; j < all; j++){
      DP[i + 1][(j | num)] = min(DP[i][j] + value, min(DP[i][(j|num)], DP[i+1][(j|num)]));  
    }

    for (int j = 0; j < all; j++){
      if (DP[i + 1][j] == 1e15 && DP[i][j] != 1e15){
        DP[i + 1][j] = DP[i][j];
      }
    }
  }
  

  if (DP[M][all - 1] != 1e15){
    cout << DP[M][all - 1] << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define all(v) (v).begin(),(v).end()
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  
  //main
  ll ans = 0;
  FOR(i,N){
    if((i+1)%3!=0 && (i+1)%5!=0){
      ans += i+1; 
    }
  }
  
  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3688
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	char[] s = rstring.to!(char[]).map!(x => 'x').array;
	s.writeln;
	
}

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

int main()
{
    vector<vector<int>> A(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;

    vector<vector<bool>> bingo(3, vector<bool>(3, false));
    int b;
    for (int i = 0; i < N; i++)
    {
        cin >> b;
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (b == A[j][k])
                {
                    bingo[j][k] = true;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++)
    {
        int flag = true;
        for (int j = 0; j < 3; j++)
        {
            flag = flag & bingo[i][j];
        }
        if (flag)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        bool flag = true;
        for (int j = 0; j < 3; j++)
        {
            flag = flag & bingo[j][i];
        }
        if (flag)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (bingo[0][0] & bingo[1][1] & bingo[2][2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (bingo[0][2] & bingo[1][1] & bingo[2][0])
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#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 SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集

bool visited[1010][1010];

int dxy[5] = {-1,0,1,0,-1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);
  
  int H, W; cin >> H >> W;
  int sy,sx,gy,gx;
  cin >> sy >> sx >> gy >> gx;
  vector<string> f;
  REP(i,H){
    string s; cin >> s;
    f.push_back(s);
  }

  sy--; sx--;
  gy--;gx--;
  vector<vector<int>> dist(H, vector<int>(W, INT_MAX));
  dist[sy][sx] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push({0,sy*W + sx});

  while(q.size()){
    auto v = q.top();
    q.pop();


    int y = v.second/W, x = v.second%W;
    if(dist[y][x] < v.first) continue;    
    for(int i=-2; i<=2; i++){
      for(int j=-2; j<=2; j++){
        int ny = y+i, nx = x+j;
        if(ny >= 0 && ny < H && nx >= 0 && nx < W && f[ny][nx] == '.'){
          if(dist[ny][nx] > dist[y][x] + 1){
            dist[ny][nx] = dist[y][x] + 1;
            q.push({dist[ny][nx], ny*W + nx});
          }
        }
      }
    }
    for(int i=0; i<4; i++){
      int ny = y + dxy[i], nx = x + dxy[i+1];
      if(ny >= 0 && ny < H && nx >= 0 && nx < W && f[ny][nx] == '.'){
        if(dist[ny][nx] > dist[y][x]){
          dist[ny][nx] = dist[y][x];
          q.push({dist[ny][nx],ny*W + nx});
        }
      }
    }

  }
  int ans = dist[gy][gx];
  if(ans == INT_MAX){
    ans = -1;
  }
  cout << ans << endl;


  return 0;
}


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

import sys
import math

def main():
    datas=[]
    n,distance = map(int,input().split())
    datas=[list(map(int,input().split())) for _ in range(n)]
    counter=0
    for i in datas:
        if distance >= math.sqrt(i[0]**2+i[1]**2):
            counter+=1
        else:
            continue
    print(counter)

if __name__ == "__main__":
    main()

Measured memory_bytes: 45456
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int n;
	unsigned long res=1;

	cin>>n;

	for(int i=2;i<=n;i++) res*=i;

	cout<<res<<endl;

	return 0;
}

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

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

  int s = S.size();
  int t = T.size();
  bool frag = false;
  for (int i = s-t; i > -1; i--) {
    int tmp = 0;
    for (int j = 0; j < t; j++) {
      if (S[i+j]=='?' || (int)(S[i+j]-'a') == (int)(T[j] - 'a')) tmp++;
    }
    if (tmp == t) {
      for (int j = 0; j < t; j++) {
        char a = T[j];
        S[i+j] = a;
      }
      frag = true;
      break;
    }
  }
  if (frag) {
    for (int i = 0; i < s; i++) {
      if (S[i] == '?') cout<<'a';
      else cout<<S[i];
    }
    cout<<endl;
  }
  else cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 508
#include <stdio.h>
#include <math.h>
int main(void){
    int a,b,r=0;double x=0,y=0;
    while(scanf("%d,%d",&a,&b),a||b){
        x+=a*cos(r*M_PI/180.0);
        y+=a*sin(r*M_PI/180.0);
        r+=b;
    }
    printf("%d\n%d\n",(int)y,(int)x);
    return 0;
}

Measured memory_bytes: 604