akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int N, M;

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

    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i, M) cin >> a.at(i) >> b.at(i);

    set<int> mid;
    REP(i, M) {
        if (a[i] == 1) {
            mid.insert(b[i]);
        }
    }

    REP(i, M) {
        if (b[i] == N) {
            auto it = mid.find(a[i]);
            if (it != mid.end()) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <algorithm>
struct X
{
    int data;
    int index;
    int me;
};
bool cmp(X &a, X &b){
    return a.data < b.data;
}
bool cmp2(X &a, X &b){
    return a.index < b.index;
}
int main(){
    int n;
    X x[200001];
    scanf("%d",&n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d",&x[i].data);
        x[i].index=i;
    }
    std::sort(x+1,x+n+1,cmp);
    int m=(n>>1) + 1;
    int t=x[m].data;
    int t2=x[m-1].data;
    for (int i=1;i<m;i++){
        x[i].me=t;
    }
    for (int i=m;i<=n;i++){
        x[i].me=t2;
    }
    std::sort(x+1,x+n+1,cmp2);
    for (int i=1;i<=n;i++){
        printf("%d\n", x[i].me);
    }
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n;
cin >> n;
vector<int> x(n),y(n);
rep(i,n) cin >> x[i] >> y[i] ;

long double sum = 0;

vector<int> town(n);
rep(i,n) town[i] = i;
do
{
    rep(i,n-1) sum += (long double)sqrt(pow((x[town[i]]-x[town[i+1]]),2) + pow((y[town[i]]-y[town[i+1]]),2));

} while (next_permutation(all(town)));

auto fact = [&](int p){
    int res = 1;
    for(int i=p;i>0;i--) res *= i;
    return res;
};

long double ans = sum / fact(n) ;
cout << fixed << setprecision(10) << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, m;
    cin >> n >> m;
    int arr[n + 5];
    ll sum[n + 5] = {};
    ll ans = 0;
    for(int i = 1; i <= n; i++)
        cin >> arr[i];
    map<int, int> mp;
    for(int i = 1; i <= n; i++)
        sum[i] = sum[i - 1] + arr[i];
    for(int i = 0; i <= n; i++)
    {
        ans += mp[sum[i] % m];
        mp[sum[i] % m]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4352
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W = MI()
    def is_inside(to):
        return 0<=to[0]<H and 0<=to[1]<W
    S=[ST() for _ in range(H)]
    queue = deque([(0,0)])
    visited = set()
    ans=0
    for s in S:
        ans += Counter(s)["."]
    for i in range(H*W+1):
        tmp = deque()
        while queue:
            fr = queue.popleft()
            if fr in visited:
                continue
            visited.add(fr)
            for dh,dw in [(-1,0),(0,-1),(1,0),(0,1)]:
                to = (fr[0]+dh,fr[1]+dw)
                if to not in visited and is_inside(to) and S[to[0]][to[1]]==".":
                    tmp.append(to)
        queue = tmp
        if (H-1,W-1) in tmp:
            print(ans-(i+2))
            return
    print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 41200
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

class UnionFind {
private:
	int n;
	vector<int> a;
public:
	UnionFind(int n) : n(n), a(n, -1) {}
	int find(int x) { return a[x] < 0 ? x : (a[x] = find(a[x])); }
	bool same(int x, int y) { return find(x) == find(y); }
	bool same(Pii& p) { return same(p.first, p.second); }
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (a[x] > a[y]) swap(x, y);
		a[x] += a[y];
		a[y] = x;
		n--;
		return true;
	}
	bool unite(Pii& p) { return unite(p.first, p.second); }
	int size() const { return n; }
	int size(int x) { return -a[find(x)]; }
};

vector<string> sm;
int get_index(string& x){
	return lower_bound(sm.begin(), sm.end(), x) - sm.begin();
}

int main(){
	int n; cin >> n;
	set<string> s;
	vector < pair<string, int> >  vi;
	FOR(i, n){
		string a; int x; cin >> a >> x;
		s.insert(a);
		vi.emplace_back(a, x);
	}
	sm = vector<string>(s.begin(), s.end());

	vector<int> v(n);
	FOR(i, n){
		v[get_index(vi[i].first)] = vi[i].second;
	}

	UnionFind uf(n);

	int m; cin >> m;
	FOR(i, m){
		string s, t; cin >> s >> t;
		int si = get_index(s);
		int ti = get_index(t);
		uf.unite(si, ti);
	}

	map<int, vector<int>> mp;
	FOR(i, n){
		mp[uf.find(i)].push_back(i);
	}
	ll ans = 0;
	for (auto kv : mp) {
		int tmp = 10000000;
		for (auto x : kv.second) tmp = min(tmp, v[x]);
		ans += tmp * sz(kv.second);
	}
	cout << ans << endl;

}

Measured memory_bytes: 2324
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int A[N+1];
    int B[N];
    REP(i,N+1) cin >> A[i];
    REP(i,N) cin >> B[i];

    ll ans = 0;
    for(int i = N; i >= 1; i--){
        if(A[i] <= B[i-1]){
            B[i-1] -= A[i];
            ans += A[i];
        }
        else{
            ans += B[i-1];
            B[i-1] = 0;
        }
        if(B[i-1] < 0) B[i-1] = 0;
      	if(A[i-1] >= B[i-1]) ans += B[i-1];
      	else ans += A[i-1];
        A[i-1] -= B[i-1];
        if(A[i-1] < 0) A[i-1] = 0;
    }
    //if(A[0] <= B[0]) ans += A[0];
    //else if(A[0] >= B[0]) ans += B[0];

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "stdio.h"
int main() {
	int a, b;
	int ans[] = { 1,2,3 };
	scanf("%d", &a);
	scanf("%d", &b);
	for (int i = 0; i < 3; i++) {
		if (ans[i] != a && ans[i] != b){
			printf("%d", ans[i]);
		}
	}
 
	return 0;
}

Measured memory_bytes: 888
import itertools

_N, _M = input().split()
N=int(_N)
M=int(_M)
A=[]
for i in range(0,N):
    A.append(input())
B=[]
for j in range(0,M):
    B.append(input())

ref_tuple = itertools.product(range(0,N-M+1),range(0,N-M+1))
t=False
for ref_row_a, ref_col_a in ref_tuple:
    for row_b, col_b in itertools.product(range(0,M),range(0,M)):
        if not A[ref_row_a+row_b][ref_col_a+col_b]==B[row_b][col_b]:
            break
        if (row_b, col_b)==(M-1,M-1):
            t=True
            break
    if t:
        break

if t:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
can = [0]
gets
a = gets.split.map(&:to_i)
gets
m = gets.split.map(&:to_i)
a.each_with_index {|e,i|
  if i == 0
    can << e
  else
    can = Marshal.load(Marshal.dump(can + can.map {|ele| ele + e}))
  end
  can.uniq!
}
m.each{|e|
  if can.include?(e)
    puts 'yes'
  else
    puts 'no'
  end
}

Measured memory_bytes: 6420
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	string rev = str;
	reverse(rev.begin(), rev.end());
	if(str == rev) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    map<int,int> m;
    for(int i=0;i<n;i++){
        if(m.count(A[i])){
            m.erase(A[i]);            
        }else{
            m[A[i]]++;
        }
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 5248
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static int cnt = 0;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			putCntMap(map, a);
		}
		sc.close();

		Integer[] k = map.keySet().toArray(new Integer[0]);
		if (k.length > 3) {
			System.out.println("No");
		} else if (k.length == 3) {
			Arrays.parallelSort(k);
			int v0 = map.get(k[0]);
			int v1 = map.get(k[1]);
			int v2 = map.get(k[2]);
			if (v0 == v1 && v1 == v2) {
				if ((k[0] ^ k[1]) == k[2]) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else if (k.length == 2) {
			Arrays.parallelSort(k);
			if (k[0] == 0) {
				int v0 = map.get(k[0]);
				int v1 = map.get(k[1]);
				if (v0 * 2 == v1) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else if (k.length == 1) {
			if (k[0] == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

	static void putCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 63424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[2][N];
		for (int i = 0; i < 2; i++) {
			for (int j = 0 ; j < N ; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		int sum = A[0][0];
		for (int j = 0 ; j < N ; j++) {
			sum += A[1][j];
		}
		
		int max = sum;
		for (int j = 1 ; j < N ; j++ ) {
			sum += A[0][j];
			sum -= A[1][j - 1];
			if ( max < sum ) {
				max = sum;
			}
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 21844
import math


def find(a, b):
    for bxn in range(math.ceil(b / 0.1), math.ceil((b + 1) / 0.1)):
        for axn in range(math.ceil(a / 0.08), math.ceil((a + 1) / 0.08)):
            if axn == bxn:
                return axn
    return -1


A, B = map(int, input().split())
print(find(A, B))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n; cin>>n;
   float sum=0; float arr[n];
   for(int i=0;i<n;i++)
      cin>>arr[i];
   sort(arr,arr+n);
   if(n==1)
     cout<<n;
   else
   {
      sum=(arr[0]+arr[1])/2; 
     for(int i=2;i<n;i++)
     {
         sum=(sum+arr[i])/2;
     }
     cout<<sum;
   }
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List

data Vec = Vec {getX :: Double, getY :: Double}

crossp :: Vec -> Vec -> Double
crossp x y = getX x * getY y - getX y * getY x

subVec :: Vec -> Vec -> Vec
subVec v1 v2 = Vec {getX = getX v1 - getX v2, getY = getY v1 - getY v2}

eps :: Double
eps = 0.0000000001

main = do
  n <- readLn :: IO Int
  xs <- input n (map read . words) :: IO [[Double]]
  mapM_ putStrLn $ solve xs

solve :: [[Double]] -> [String]
solve = map parallel

parallel :: [Double] -> String
parallel [x1, y1, x2, y2, x3, y3, x4, y4 ] | abs (crossp v1 v2) < eps = "YES"
                                           | otherwise = "NO"
  where v1 = Vec {getX = x2, getY = y2} `subVec` Vec {getX = x1, getY = y1}
        v2 = Vec {getX = x4, getY = y4} `subVec` Vec {getX = x3, getY = y3}

input :: Int -> (String -> a) -> IO [a]
input n f = map f <$> replicateM n getLine

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

const int MOD = 1e9+7;

typedef long long ll;
typedef pair<int,int> pii;
char str[100005];
int main() {
//	freopen("TASK.in","r",stdin);freopen("TASK.out","w",stdout);
	scanf("%s",str+1);
	int len=strlen(str+1);
	for(int i=1;i<=len;i++) {
		if(i+1<=len and str[i]==str[i+1]) {
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}
		if(i+2<=len and str[i]==str[i+2]) {
			cout<<i<<" "<<i+2<<endl;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
typedef double ld;
const int maxn=500005;
struct Point{
	ld x,y;
	inline Point(){}
	inline Point(ld _x,ld _y){
		x=_x;y=_y;
	}
}dir,Queue[maxn<<2];
ld t[maxn],v[maxn];
inline Point operator + (const Point &a,const Point &b){
	return Point(a.x+b.x,a.y+b.y);
}
inline Point operator - (const Point &a,const Point &b){
	return Point(a.x-b.x,a.y-b.y);
}
inline ld operator * (const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}
inline bool check(Point x,Point y,Point z){
	return (y-x)*(z-y)<0;
}
inline ld lv(Point x,Point y){
	return (x.y-y.y)/(x.x-y.x);
}
const ld eps=1e-8;
int front,finish,n,L;
int main(){
	read(n);read(L);
	rep(i,1,n)scanf("%lf%lf",&t[i],&v[i]);
	Queue[front=finish=n]=Point(0,0);
	Queue[++finish]=Point(v[1],v[1]*t[1]);
	rep(i,1,n){
		dir=dir+Point(v[i],v[i]*t[i]);
		while(L+eps<Queue[finish].x+dir.x)finish--;
		double k=lv(Queue[finish],Queue[finish+1]),y=Queue[finish].y+k*(L-Queue[finish].x-dir.x);
		Queue[++finish]=Point(L-dir.x,y);
		printf("%.7lf\n",(Queue[finish].y+dir.y)/L);
		Point now(-dir.x,-dir.y);
		while(front<finish&&!check(now,Queue[front],Queue[front+1]))
			front++;
		Queue[--front]=now;
	}
	return 0;
}


Measured memory_bytes: 25472
from sys import stdin


def get_result(data):
    S = data[0]
    if S[2] == S[3] and S[4] == S[5]:
       return 'Yes'
    return 'No'


if __name__ == '__main__':
    data = list(map(str, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  kk=max(i-k,0)
  dp[i]=min(d+abs(hh-h[i])for d,hh in zip(dp[kk:i],h[kk:i]))
print(dp[n-1])


Measured memory_bytes: 55388
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = iss()
    print('YES' if N in '753' else 'NO')



if __name__ == '__main__':
    main()


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

using namespace std;

ll getNewNum(ll f,ll l,ll i)
{
    ll j;
    for(j=0;j!=i;j++)
        f = 10*f+9;

    f = 10*f + l;

    return f;
}

ll findP(ll p,ll n)
{
    ll d = 0,a,b;

    b = p%10;
    while(p)
    {
        d++;
        a = p%10;
        p /= 10;
    }

    //  a -> first, b -> last, d -> # digits

    ll d_ = 0,f,l,m;
    ll ncopy = n;
    l = n%10;
    while(ncopy)
    {
        d_++;
        f = ncopy%10;
        ncopy /= 10;
    }

    // f -> first, l -> last, d_ -> # digits

    string s = to_string(n);
    s.erase(0,1);

    if(s.empty())
        m = 0;
    else
        s.erase(s.size()-1,1);

    if(s.empty())
        m = 0;
    else
        m = stoi(s);

    ll count = 0;

    if(a == b)
        count++;

    ll i,j,New;
    for(i=0;i+2<=d_;i++)
    {
        New = getNewNum(b,a,i);     // define

        if(New <= n)
            count += pow(10,i);

        else
        {
            if(b == f)
            {
                if(a <= l)
                    count += m+1;
                else
                    count += m;
            }
        }
    }

    return count;
}

ll countP(ll n)
{
    // ll d = 0,a,b;
    // ll ncopy = n;
    //
    // b = n%10;
    // while(ncopy)
    // {
    //     d++;
    //     a = ncopy%10;
    //     ncopy /= 10;
    // }

    // a -> first, b -> last, d -> # digits

    ll count = 0;

    int i;
    for(i=1;i!=n+1;i++)
    {
        //cout<<i<<'\n';
        if(i%10)
        {
            count += findP(i,n);        // define
            //cout<<i<<' '<<findP(i,n)<<'\n';       // remove
        }
    }

    return count;
}

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

    cout<<countP(n);        // define
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<n;i++)
        cout<<(s==1e9?s-(i>=k):s+(i>=k))<<(i+1==n?'\n':' ');
}


Measured memory_bytes: 1280
def main():
    N = int(input())
    X = N // 15
    Y = N % 15
    m = [0, 1, 2, 0, 4, 0, 0, 7, 8, 0, 0, 11, 0, 13, 14]
    cnt = [0, 1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 7, 8]
    csm = [0, 1, 3, 3, 7, 7, 7, 14, 22, 22, 22, 33, 33, 46, 60]
    ans = X * 60 + (X-1) * X // 2 * 120 + cnt[Y] * (15*X) + csm[Y]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61992
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
  vi p(a), q(b), r(c);

  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];

  sort(all(p),greater<int>());
  sort(all(q),greater<int>());
  sort(all(r),greater<int>());

  vi eat;
  rep(i, x) eat.eb(p[i]);
  rep(i, y) eat.eb(q[i]);

  sort(all(eat));

  int idx = 0;
  while (eat[idx] < r[idx] && idx < c) {
    eat[idx] = r[idx];
    ++idx;
  }

  cout << accumulate(all(eat),0LL) << endl;

  return (0);
}


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

int main() {
    int R, G, B, n;
    cin >> R >> G >> B >> n;
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 0; i + R <= n; i++) dp[i + R] += dp[i];
    for (int i = 0; i + G <= n; i++) dp[i + G] += dp[i];
    for (int i = 0; i + B <= n; i++) dp[i + B] += dp[i];
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = input()

# print(H, W, S)
T = [[0]* W for h in range(H)]
blocks = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            T[h][w] = -1
            blocks += 1

def is_inside(w, h, W, H):
    if w >= 0 and w < W and h >= 0 and h < H:
        return True
    return False

# print(T)
V = deque([(0, 0)])
while len(V) != 0:
    v = V.popleft()
    # print('v={}'.format(v))
    h = v[0]
    w = v[1]
    t = T[h][w]
    if is_inside(h - 1, w, H, W):
        if T[h - 1][w] != -1 and T[h - 1][w] == 0:
            T[h - 1][w] = t + 1
            V.append((h - 1, w))
    if is_inside(h + 1, w, H, W):
        if T[h + 1][w] != -1 and T[h + 1][w] == 0:
            T[h + 1][w] = t + 1
            V.append((h + 1, w))
    if is_inside(h, w - 1, H, W):
        if T[h][w - 1] != -1 and T[h][w - 1] == 0:
            T[h][w - 1] = t + 1
            V.append((h , w - 1))
    if is_inside(h, w + 1, H, W):
        if T[h][w + 1] != -1 and T[h][w + 1] == 0:
            T[h][w + 1] = t + 1
            V.append((h , w + 1))

t = T[H - 1][W - 1]
if t == 0:
    print(-1)
else:
    print(W * H - blocks - t - 1)


Measured memory_bytes: 40940
#include <iostream>
#include <stack>
#include <cstdlib>

using namespace std;


int main(void)
{
    int x, y;
    stack<int> S;
    string s;

    while (cin >> s) {
        if (s[0] == '+') {
            x = S.top(); S.pop();
            y = S.top(); S.pop();
            S.push(x + y);
        } else if (s[0] == '-') {
            x = S.top(); S.pop();
            y = S.top(); S.pop();
            S.push(y - x);
        } else if (s[0] == '*'){
            x = S.top(); S.pop();
            y = S.top(); S.pop();
            S.push(y * x);
        } else {
            S.push(atoi(s.c_str()));
        }
    }

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

    return 0;
}



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

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


Measured memory_bytes: 256
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


_,k = LI()
a = LI()

a = list(map(lambda x:x-1,a))

# 訪れる順序、indexは移動回数
route = [0]
# 訪れた番号、高速検索用にhash tableを使う
visited = set([0])
next = a[0]

while True:
    if next in visited:
        loopStart = route.index(next)
        break
    else:
        route.append(next)
        visited.add(next)
        next = a[next]

# print(route)
# print(loopStart)

beforeLoop = route[:loopStart]
# print(beforeLoop)
loop = route[loopStart:]
# print(loop)

# loop前
if k < loopStart:
    ans = beforeLoop[k]
# loop後
else:
    numOfLoops,mod = divmod((k-(loopStart)),len(loop))
    # print(numOfLoops,mod)
    ans = loop[mod]

ans += 1
print(ans)

Measured memory_bytes: 148372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pint pair<int, int>
#define Pll  pair<ll, ll>
#define Tint tuple<int, int, int>
#define Tll  tuple<ll, ll, ll>
#define PI   3.141592653589793

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    ll r = a % b;
    while (r != 0) {
        a = b;  b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int k;
    cin >> k;
    ll v = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                v += gcd(a, gcd(b, c));
            }
        }
    }
    cout << v << endl;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

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

	const int n = s.size();

	rep(i,26){
		bool add = true;
		char ch = char('a' + i); 
		for(auto &it:s){
			if(it == ch) add =false;
		}

		if(add){
			cout << s << string(1,ch) << endl;
			return 0;
		}
	}

	vector<int> ary;
	rep(i,n) ary.push_back(s[i]-'a');

	bool ok = next_permutation(begin(ary),end(ary));
	if(ok){
		rep(i,n){
			const char cur = char(ary[i] + 'a');
			cout << cur;
			if(s[i] != cur) break;
		}	
		cout << endl;
	}else{
		cout <<  -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define nl			    "\n"
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,n)         for (int i = 0; i < n; ++i)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


int n, weight;
int dp[105][100004];
int v[105], w[105];

int solve(int pos, int wgh ) {
	//base
    if (wgh <0) return 0;
	if (pos < 0) return 0;
	//lookup case
	if (dp[pos][wgh] != -1) return dp[pos][wgh];
	//rec
	int rel, op1 = INT_MIN;
	if (wgh - w[pos] >= 0)	op1 = v[pos] + solve(pos - 1, wgh - w[pos]);
	int op2 = solve(pos - 1, wgh);
	rel = max(op1, op2);
	dp[pos][wgh]=rel;
	return rel;
}

/*
3 8
3 30
4 50
5 60
*/
int32_t main()
{
	FIO;

	cin >> n >> weight;
	fr(i, n) {cin >> w[i] >> v[i];}
	memset(dp, -1, sizeof dp);
	cout << solve(n-1, weight);

}


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

int main() 
{
    long long N;
    cin >> N;
    
    long long ans = 1e18;
    for (long long i = 1; i*i <= N; i++) {
        if (N % i != 0) {
            continue;
        }
        long long sum = N / i;
        ans = min(ans, sum+i-2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<bitset>
#include<iterator>
#include <stack>
#define ll long long
typedef long double ld;
#define all(v) ((v).begin()),((v).end())
#define vec2(n,m) vector<vector<ll>>vv(n + 10, vector<ll>(m + 10, 0));
#define p_q1   priority_queue<int,vector<int>,greater<int>>pq1;
#define format(n) fixed<<setprecision(n)
#define ll_min LLONG_MIN;
#define ll_max LLONG_MIN;
#define endl "\n"
#define F first 
#define S second
#define mkpr(x,y)  make_pair(x,y)
using namespace std;
void weza()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main()
{
    weza();
    ll n;
    cin >> n;
    ll x = n / 500;
    ll y = n % 500;
    y /= 5;
    cout << x * 1000 + y * 5 << endl;
}

Measured memory_bytes: 256
'use strict';
const p = s => console.log(s);

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let N = input[0].split(" ")[0];
  let A = input[1].split(" ");
  let map = new Map();

  for(let i =0; i < N; i++) {
    map[i+1] = 0;
  }
  for(let i =0; i < A.length; i++) {
    map[A[i]]++;
  }

  for(let i =0; i < N; i++) {
    p(map[i + 1]);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){

    int n; cin >> n;
    map<int,int> mapa;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        mapa[x]++;
    }

    int res = 0;
    for(auto par : mapa)
        res += min(par.second, par.second >= par.first ? par.second-par.first : par.second);
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 4736
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    ans = min(c, a + b + 1) + b
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61844
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
 
int main() {
  int N, M;
  cin >> N >> M;
  ll dp[N+2], h;
  dp[0] = 1;
  dp[1] = 1;

  rep(i, M){
    cin >> h;
    dp[h] = -1;
  }

  for(int i = 2; i < N+1; i++){
    if(dp[i]==-1) continue;
    else if (dp[i-1] == -1) dp[i] = dp[i-2];
    else if (dp[i-2] == -1) dp[i] = dp[i-1];
    else dp[i] = dp[i-1] + dp[i-2];
    dp[i] %= MOD;
  }

  if (dp[N] == -1) dp[N] = 0; 
  cout << dp[N]%MOD << endl;

}


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

int main() {
    vector<int> v(3);
    for (int i = 0; i < 3; ++i) cin >> v[i];
    sort(v.rbegin(), v.rend());
    int ans = 0;
    if ((v[0] - v[1]) % 2 == 1) {
        ans++;
        v[1]++;
        v[2]++;
    }
    if ((v[0] - v[1]) % 2 == 0) ans += (v[0] - v[1]) / 2;
    if ((v[0] - v[2]) % 2 == 1) {
        ans++;
        v[0]++;
        v[1]++;
    }
    if ((v[0] - v[2]) % 2 == 0) ans += (v[0] - v[2]) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
        double a,b;
        scanf("%lf",&a);
        scanf("%lf",&b);

        if(a > b){
            printf("GREATER\n");
        }else if(a < b){
            printf("LESS\n");
        }else if(a == b){ 
            printf("EQUAL\n");
        }
        return 0;


    }



Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	b := scanInt()
	n := scanInt()

	if n < b {
		c := n
		fmt.Fprintln(wr, (a*c)/b-a*(c/b))
	} else {
		c := b-1
		fmt.Fprintln(wr, (a*c)/b-a*(c/b))
	}

}


Measured memory_bytes: 1760
#include <iostream>
using namespace std;
int aj[1010][1010]={},ao[1010][1010]={},ai[1010][1010]={};
int main(){
	int M,N,K,a,b,c,d;
	char ch;
	cin>>M>>N>>K;
	for(int i=1;i<=M;i++){
		for(int j=1;j<=N;j++){
			cin>>ch;
			aj[i][j]=aj[i-1][j]+aj[i][j-1]-aj[i-1][j-1]+(ch=='J');
			ao[i][j]=ao[i-1][j]+ao[i][j-1]-ao[i-1][j-1]+(ch=='O');
			ai[i][j]=ai[i-1][j]+ai[i][j-1]-ai[i-1][j-1]+(ch=='I');
		}
	}
	
	for(int i=0;i<K;i++){
		cin>>a>>b>>c>>d;
		a--;b--;
		cout<<aj[a][b]+aj[c][d]-aj[a][d]-aj[c][b]<<" "<<ao[a][b]+ao[c][d]-ao[a][d]-ao[c][b]<<" "<<ai[a][b]+ai[c][d]-ai[a][d]-ai[c][b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13040
#include<iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  if((s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) || (s[0] == s[1] && s[1] == s[2] && s[2] != s[3]) || (s[0] != s[1] && s[1] == s[2] && s[2] == s[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n, m, cnt, revcnt;
int first[100010], nxt[100010], ver[100010];
int revf[100010], revn[100010], revv[100010], revdeg[100010];
void add(int x, int y)
{
	ver[++cnt] = y;
	nxt[cnt] = first[x];
	first[x] = cnt;
	revv[++revcnt] = x;
	revn[revcnt] = revf[y];
	revf[y] = revcnt;
}
int vis[100010];
int d[100010];
int deg[100010], fa[100010], root;

void dfs(int x)
{
//	fa[x] = f;
	for (int i = first[x]; i; i = nxt[i])
	if (!vis[ver[i]])
	{
		dfs(ver[i]);
		if (d[ver[i]] < d[x] + 1)
			fa[ver[i]] = x, d[ver[i]] = d[x] + 1;
	}
}
void spfa(int root)
{
	priority_queue<pair<int, int> >q;
	q.push(make_pair(d[root], root));
	while (!q.empty())
	{
		int x = q.top().second;
		q.pop();
		if (vis[x])
			continue;
		vis[x] = 1;
		for (int i = first[x]; i; i = nxt[i])
		{
			int y = ver[i];
			if (d[y] < d[x] + 1)
			{
				d[y] = d[x] + 1;
				fa[y] = x;
				q.push(make_pair(d[y], y));
			}
		}
	}
}
int q[100010], front = 1, tail = 1;
void topesort()
{
//	queue<int> q;
	for (int i =1; i <= n; ++i)
	if (revdeg[i] == 0)
		q[tail++] = i;
	while (front < tail)
	{
		int x = q[front++];
//		q.pop();
		for (int i = revf[x]; i; i = revn[i])
		{
			int y = revv[i];
			if (--revdeg[y] == 0)
				q[tail++] = y;
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m + n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		add(a, b);
		++deg[b];
		++revdeg[a];
	}
	for (int i = 1; i <= n; ++i)
	if (!deg[i])
		root = i;
//	dfs(root);
//	spfa(root);
	topesort();
	for (int i = n; i > 0; --i)
	{
		for (int j = first[q[i]]; j; j = nxt[j])
			fa[ver[j]] = q[i];
	}
	for (int i = 1; i <= n; ++i)
		cout << fa[i] << endl;
	return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
bool palindrome(string s,int l)
{
    int fl=1;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==s[l-i-1])fl*=1;
        else fl*=0;
    }
    if(fl)return true;
    else return false;
}
int main(){
    FIO
    string s;
    cin>>s;
    int fl2=1;
    if(palindrome(s,s.size()))
    {
        for(int i=0;i<s.size()/2;i++)
        {
            if(s[i]==s[s.size()/2-i-1])fl2*=1;
            else fl2*=0;
        }
        int fl=1;
        for(int i=s.size()/2+1;i<s.size();i++)
        {
            if(s[i]==s[s.size()-i-1])fl*=1;
            else fl*=0;
        }
        if(fl&&fl2)cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
}

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

void bfs(vector<int> *edges,int s,bool v[])
{
    queue<int> q; q.push(s);
    v[s]=1;
    while(!q.empty())
    {
        int z=q.front(); q.pop();
        for(int i=0; i<edges[z].size(); i++)
        {
            if(!v[edges[z][i]])
            {
                v[edges[z][i]]=1;
                q.push(edges[z][i]);
            }
        }
    }
}

int main()
{
    int n,m,ans=0;
    cin>>n>>m;
    vector<int> edges[n];
    for(int i=0; i<m; i++)
    {
        int a,b,c;
        cin>>a>>b>>c; a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    bool v[n]={0};
    for(int i=0; i<n; i++)
    {
        if(!v[i])
        {
            bfs(edges,i,v);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;

int H, W, N;
int a[10020];
int x[100][100];

int main(){
  cin >> H >> W;
  cin >> N;
  for(int i = 0; i < N; i++)  cin >> a[i];
  int n = 1;

  for(int i = 0; i < H; i++){
    if(i % 2 == 0){
      for(int j = 0; j < W; j++){
        if(a[n-1] == 0) n++;
        x[i][j] = n;
        a[n-1]--;
      }
    }
    else{
      for(int j = W-1; j >= 0; j--){
        if(a[n-1] == 0) n++;
        x[i][j] = n;
        a[n-1]--;
      }
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << x[i][j] << " ";
    }
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 384
# 2019/07/01
# AtCoder Beginner Contest 100 - C

# Input
n = int(input())
a = list(map(int, input().split()))

ans = 0

# Count divide 2
for i in range(n):
    wka = a[i]
    while wka % 2 == 0:
        ans += 1
        wka = wka / 2

# Output
print(ans)


Measured memory_bytes: 4148
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Moves
ll n,m,k;
ll ar[200005],br[200005];

int main()
{
    cin>>n>>m>>k;
    for(ll i=1;i<=n;i++)
    {
        cin>>ar[i];
        ar[i]+=ar[i-1];
    }
    for(ll i=1;i<=m;i++)
    {
        cin>>br[i];
        br[i] += br[i-1];
    }
    ll ans = 0;
    ll left,right,mid,add;
    for(ll i=0;i<=n;i++)
    {
        if(ar[i]>k)
            break;
        ll baki=k-ar[i];
        left = 1,right=m,mid=(left+right)/2;
        add = 0;
        while(left<=right)
        {
            if(br[mid]<=baki)
            {
                add = mid;
                left = mid+1;
            }
            else
            {
                right = mid-1;
            }
            mid = (left+right)/2;
        }
        ans = max(ans,i+add);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6692
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())))[::-1]
B=sorted(list(map(int,input().split())))[::-1]
C=sorted(list(map(int,input().split())))[::-1]
ans=[]
for a in range(len(A)):
  for b in range(len(B)):
    for c in range(len(C)):
      if (a+1)*(b+1)*(c+1)>K:
        break
      ans.append(A[a]+B[b]+C[c])

ans=sorted(ans)[::-1]
for i in range(min(K,len(ans))):
  print(ans[i])


Measured memory_bytes: 9980
N, K = map(int, input().split(" "))
R, S, P = map(int, input().split(" "))
T = input().strip()
hands = {i:[] for i in range(K)}
win_hand = {0:'s', 1:'p', 2:'r'}
point = {0:R, 1:S, 2:P}

for i, s in enumerate(T):
    hands[i % K].append(s)

ans = 0
for k in range(K):
    if len(hands[k]) != 0:
        dp = [[0 for _ in range(3)] for i in range(len(hands[k]) + 1)]
        for i in range(1, len(hands[k]) + 1):
            for j in range(3):
                # i番目にjの手を出す -> R, S, P
                dp[i][j] += max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3])
                if hands[k][i - 1] == win_hand[j]:
                    dp[i][j] += point[j]
        ans += max(dp[len(hands[k])])
print(ans)

Measured memory_bytes: 63716
# include<iostream>
using namespace std;
int main (){
int a,b,c,d;
cin>>a>>b>>c>>d;
if (abs(a-c)<=d)
    cout<<"Yes";
else {
    if (abs(a-b)<=d && abs(c-b)<=d)
        cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vll X;



int main(){

    
    cin >> N;
    rep(ni,N){
        ll ltmp;
        cin >> ltmp;
        X.push_back(ltmp);
    }
    sort(X.begin(),X.end());

    ll minX = X[0];
    ll sumX=0;
    rep(ni,N) sumX += (X[ni] - minX);

    ll center1 = sumX/N + minX;
    ll center2 = sumX/N + minX + 1;

    ll ans1 = 0;
    ll ans2 = 0;

    rep(ni,N){
        ans1+=pow( (X[ni]-center1)  ,2.0);
        ans2+=pow( (X[ni]-center2)  ,2.0);
    }

    if(ans1<ans2) cout << ans1 << endl;
    else cout << ans2 << endl;

}

Measured memory_bytes: 256
def solve(N, K, A):
    numbers = {}
    for a in A:
        numbers[a] = numbers.get(a, 0) + 1
    if len(numbers) <= K:
        return 0
    return N - sum(sorted(numbers.values(), key=lambda x: -x)[:K])
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print solve(N, K, A)

Measured memory_bytes: 30728
#!/usr/bin/ruby
#encoding: utf-8

# 配列の共通部分を作る演算"&"を使う場合。

n,m = gets.split.map(&:to_i)
ka = Array.new(n)
(0..n-1).each do |i|
  ka[i] = gets.split.map(&:to_i)
end

inter = ka[0]

(0..n-1).each do |i|
   ka[i].shift
#   p ka[i]

   inter = inter & ka[i]
end

puts inter.size

Measured memory_bytes: 1788