akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int L, R, d; cin >> L >> R >> d;
	cout << (R / d) - ((L - 1) / d) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3608
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-26 15:04:28 +0900
# LastModified: 2020-06-26 15:10:43 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    a, b, c = map(int, input().split())
    for i in range(100):
        if float((a*i-c)/b).is_integer():
            print("YES")
            return
    print("NO")



if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)n;(i)++)
int main(){
  int n,m; cin >> n >> m;
  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
  }
  vector<vector<int>> g(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  rep(i,n){
    bool f = true;
    rep(j,g[i].size()){
      if(h[g[i][j]] >= h[i]){
        f = false;
        break;
      }
    }
    if(f) {
      ans++;
    }
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 8740
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> ve;
int main()
{
	ll i,j,t;
	cin>>t;
	ll rem = t%10;
	if(rem == 2|| rem == 5|| rem== 4|| rem==7||rem==9)
	cout<<"hon"<<endl;
	else if(rem == 1|| rem == 6||rem== 8|| rem==0)
	cout<<"pon"<<endl;
	else
	cout<<"bon"<<endl;
}

Measured memory_bytes: 3640
import sys

input = sys.stdin.readline


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 10 ** 9 + 7
N = 2000  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


def main():
    S = int(input())
    A = S // 3
    ans = 0
    for i in range(A, 0, -1):
        rem = S - 3 * i
        ans = (ans + cmb(rem + i - 1, rem, p)) % p
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65456
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int[] dy = { -1, -1, -1, 0, 0, 1, 1, 1 };
		int[] dx = { -1, 0, 1, -1, 1, -1, 0, 1 };
		char[][] map = new char[8][8];
		for (int i = 0; i < 8; i++)
			map[i] = scanner.next().toCharArray();
		int flag = 0;
		int i = 0;
		while (true) {
			char my, en;
			if (i == 0) {
				my = 'o';
				en = 'x';
			} else {
				my = 'x';
				en = 'o';
			}
			int cnt = 0;
			int cx = 0, cy = 0, dr = 0;
			for (int y = 0; y < 8; y++)
				for (int x = 0; x < 8; x++) {
					int hy = i == 0 ? y : 7 - y;
					int hx = i == 0 ? x : 7 - x;
					if (map[hy][hx] != '.')
						continue;
					int cc = 0;
					int cdr = 0;
					for (int j = 0; j < 8; j++) {
						int c = 0;
						while (true) {
							int ny = hy + dy[j] * (c + 1);
							int nx = hx + dx[j] * (c + 1);
							if (nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)
								break;
							if (map[ny][nx] == en) {
								c++;
								continue;
							} else if (map[ny][nx] == my && c != 0) {
								cc += c;
								cdr |= (1 << j);
							}
							break;

						}
					}
					
					if (cc <= cnt)
						continue;
					cx = hx;
					cy = hy;
					dr = cdr;
					cnt = cc;
				}
			i = 1 - i;
			if (cnt == 0) {
				flag++;
				if(flag==2)
					break;
				continue;
			}
			flag = 0;
			map[cy][cx] = my;
			for (int j = 0; j < 8; j++) {
				if (((dr >> j) & 1) == 0)
					continue;
				for (int k = 1; true; k++) {
					int nx = cx + dx[j] * k;
					int ny = cy + dy[j] * k;
					if (map[ny][nx] == my)
						break;
					map[ny][nx] = my;
				}

			}


		}
		for (int j = 0; j < 8; j++)
			System.out.println(String.valueOf(map[j]));
	}
}

Measured memory_bytes: 18876
#include <stdio.h>
#include <ctype.h>

int main(int argc, char const *argv[])
{
    int alpha;

    alpha = getchar();

    if (alpha == tolower(alpha))
    {
        printf("a\n");
    }
    else
    {
        printf("A\n");
    }

    return 0;
}


Measured memory_bytes: 1592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main()
{
  int N;
  cin >> N;
  vi a(N+1);
  rrep(i,N) cin >> a[i];
  vi ans;
  vi b(N+1,0);

  for(int i=N;i>=1;i--){
      int sum = 0;
      for(int j=i;j<=N;j+=i){
          sum += b[j];//倍数の和
      }
      if(sum % 2 != a[i]){
           //規定に合わなかったらボールを入れてあげる
            b[i] = 1;
            ans.push_back(i);
      }
  }

  cout << ans.size() << endl;
  rep(i,ans.size()){
      cout << ans[i] << " ";
  }

}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

set<string> users;

int main(){ _;
  int n,m;
  string user;
  bool opened=false;
  cin>>n;
  REP(i,n){
    cin>>user;
    users.insert(user);
  }
  cin>>m;
  REP(i,m){
    cin>>user;
    if(users.count(user)==1){
      if((opened=!opened)){
	cout<<"Opened by "<<user<<endl;
      }else{
	cout<<"Closed by "<<user<<endl;
      }
    }else{
      cout<<"Unknown "<<user<<endl;
    }
  }
}

Measured memory_bytes: 1236
import sys
n = int(sys.stdin.readline().rstrip("\n"))
l = [False]*101
for a in range(26):
    for b in range(15):
        if 0<(4*a+7*b)<=100:
            l[4*a+7*b] = True
if l[n]:
    print('Yes')
else:
    print('No')

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

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

#include <bits/stdc++.h>
using namespace std;

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	int n;
	cin >> n;
	vector<int> as(n);
	vector<int> counts(4, 0);
	rep(i, n) {
		cin >> as[i];
		counts[as[i]]++;
	}

	vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n+1, -1)));
	
	//dp[i][j][k]...1枚の皿がi個、2枚の皿がj個、3枚の皿がk個のときに、必要な手数の期待値
	//dp[i][j][k] = (n-i-j-k) / n * dp[i][j][k] + i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1
	//(i+j+k)/n * dp[i][j][k] = i / n * dp[i-1][j][k] + j / n * dp[i+1][j-1][k] + k / n * dp[i][j+1][k-1] + 1

	dp[0][0][0] = 0;
	const double dn = n;
	rep(k, counts[3] + 1) {
		rep(j, n + 1) {
			rep(i, n + 1) {
				if (i == 0 && j == 0 && k == 0) continue;
				if (i + j + k > n) continue;
				double right = dn;
				if (i > 0) right += i * dp[i - 1][j][k];
				if (j > 0 && i < n) right += j * dp[i + 1][j - 1][k];
				if (k > 0 && j < n) right += k * dp[i][j + 1][k - 1];
				right *= 1.0 / (i + j + k);
				dp[i][j][k] = right;
			}
		}
	}
	cout << setprecision(10) << dp[counts[1]][counts[2]][counts[3]] << endl;
	return 0;
}


Measured memory_bytes: 216832
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 1e3 + 7;

struct block {
    int w, s, v;
    block(int _w, int _s, int _v) : w(_w), s(_s), v(_v) {}
};

int n;
const int M = 2e4 + 7;
long long dp[M];

int main() {
    scanf("%d", &n);
    vector <block> T;
    for (int i = 0; i < n; ++i) {
        int w, s, v;
        scanf("%d %d %d", &w, &s, &v);
        T.push_back(block(w, s, v));
    }
    
    sort (T.begin(), T.end(), [](block &a, block &b) -> bool {
       return a.s + a.w < b.s + b.w; 
    });
    
    for (auto u : T) {
        for (int w = u.s + u.w; w >= u.w; --w) {
            dp[w] = max(dp[w], u.v + dp[w - u.w]);
        }
    }
    
    long long res = 0;
    for (int i = 0; i < M; ++i) res = max(res, dp[i]);
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 764
import itertools

N, K = map(int,input().split())
D = list(map(int,input().split()))
N = str(N)
d = []
d_min = 10
for i in range(10):
    if i in D:
        continue
    else:
        if i != 0:
            d_min = min(d_min, i)
        d.append(str(i))
if '0' in d:
    ans = str(d_min) + '0' * len(N)
else:
    ans = str(d_min) * (len(N) + 1)
ans = int(ans)
for s in itertools.product(d, repeat=len(N)):
    s = ''.join(s)
    s = int(s)
    if s >= int(N):
        ans = min(ans, s)
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
 
int main()
{
  int n, S[10000], q, T[500], C, i, j, flag;
  C = 0;
 
  scanf("%d", &n);

  for(i = 0;i < n;i++) scanf("%d", &S[i]);

  scanf("%d", &q);

  for(i = 0;i < q;i++) scanf("%d", &T[i]);

  for(i = 0;i < q;i++){
    flag = 0;
    for(j = 0;j < n && flag == 0;j++){
      if(S[j] == T[i]){
        C++;
        flag = 1;
      }
    }
  }
 
  printf("%d\n", C);
 
  return 0;
}

Measured memory_bytes: 1796
import java.io.*;
import java.util.*;
 
public class Main{
	int N, C, K;
	int[] T;
	public void solve(){
		N = nextInt();
		C = nextInt();
		K = nextInt();
		T = new int[N];
		for(int i = 0; i < N; i++){
			T[i] = nextInt();
		}
		Arrays.sort(T);
		
		int count = 1;
		int time = T[0];
		int ans = 1;
		for(int i = 1; i < N; i++){
			if(time + K < T[i] || count >= C){
				ans++;
				count = 1;
				time = T[i];
			}else{
				count++;
			}
		}
		out.println(ans);
	}
	

	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 38436
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

vector<pair<string, string>> vec;
vector<pair<string, string>> vec2;

int main(void){
	int N; cin >> N;
	string S; cin >> S;

	for(int i = 0; i < (1<<N); i++){
		string str = "", others = "";
		for(int j = 0; j < N; j++){
			if(((i>>j)&1) == 1) str = str + S[j];
			else others = others + S[j];
		}
		// cout << str << "    " << others  << '\n';
		vec.push_back(make_pair(str, others));
	}

	// debug("aaaaaaaa\n");

	for(int i = 0; i < (1<<N); i++){
		string str = "", others = "";
		for(int j = 0; j < N; j++){
			if(((i>>j)&1) == 1) str = str + S[N+j];
			else others = others + S[N+j];
		}
		reverse(begin(str), end(str));
		reverse(begin(others), end(others));
		// cout << str << "    " << others  << '\n';
		vec2.push_back(make_pair(str, others));
	}

	sort(begin(vec2), end(vec2));
	// for(auto& x: vec2) cout << x.first << '\n';

	ll res = 0;
	for(auto x: vec){
		ll dif = upper_bound(begin(vec2), end(vec2), x) - lower_bound(begin(vec2), end(vec2), x);
		if(dif > 0){
			res += dif;
			// debug(x.first);
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 62444
def main():
    n,m=map(int,input().split())
    uf=UnionFind(n)
    for a,b in (map(lambda x: int(x)-1, input().split()) for _ in range(m)):
        uf.union(a,b)
    print(max((uf.size(x) for x in uf.roots())))

class UnionFind():
    '''Union-Find'''
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y) -> bool:
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
if __name__ == "__main__":
    main()

Measured memory_bytes: 18420
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
using namespace std;

signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define vi vector<int>
#define vii vector<vector<int>>
#define mod 1000000007
#define fo(i,n) for(int i=0;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pb(x) push_back(x)
typedef long long ll;

void print_Array(int arr[],int start,int end){
    for(int i=start;i<end;i++){
        printf("%d ",arr[i]);
    }
}


int main(){
    int N;
    cin>>N;
    vi x(4,0);
    fo(i,N){
        string s;
        cin>>s;
        char ch=s[0];
        if(ch=='A') x[0]++;
        else if(ch=='W') x[1]++;
        else if(ch=='T') x[2]++;
        else x[3]++;
    }
    cout<<"AC x "<<x[0]<<endl;
    cout<<"WA x "<<x[1]<<endl;
    cout<<"TLE x "<<x[2]<<endl;
    cout<<"RE x "<<x[3]<<endl;
}



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

using namespace std;
typedef long long ll;

int main() {
    string b;
    cin >> b;
    vector<string> base{"A","C","G","T"};
    vector<string> ref{"T","G","C","A"};
    for(int i=0;i<4;i++){
        if(b==ref[i]) {
            cout << base[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int cost[]=new int[n];
        for(int i=0;i<n;i++) {
            cost[i]=input.nextInt();
        }
        System.out.println(solve(n,cost));
    }
    public static int solve(int n,int[] cost) {
        int dp[]=new int[n];
        dp[1]=Math.abs(cost[0]-cost[1]);
        for(int i=2;i<n;i++) {
            dp[i]=Math.min(dp[i-1]+Math.abs(cost[i]-cost[i-1]),dp[i-2]+Math.abs(cost[i]-cost[i-2]));
        }
        return dp[n-1];
    }
}


Measured memory_bytes: 50436
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
int main() {
 loop(i,10000){
putout(-1);
 }
 
 
 
 
 
 
 
 
 
 
 
 
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  string W[N];
  REP(i, N) cin >> W[i];
  REP(i, N-1){
    if(W[i].back() != W[i+1].front()){
      cout << "No" << endl;
      return 0;
    }
  }
  REP(i, N){
    REP(j, i+1){
      if(W[i] == W[j] && i!=j){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b;
  cin >> a >> b;
  if(a==1&&b!=1)
    cout << "Alice" << endl;
  else if(a!=1&&b==1)
    cout << "Bob" << endl;
  else if(a>b)
    cout << "Alice" << endl;
  else if(a<b)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
K=int(input())
c=0
for k in range(K):
    if(B>=C):
        C*=2
    elif(A>=B):
        B*=2
    if(A<B and B<C):
        print('Yes')
        c=1
        break
if(c==0):
    print('No')

Measured memory_bytes: 9176
import sys
from fractions import gcd
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    A, B, C, D = readnums()
    g = C * D // gcd(C, D)
    c1 = B // C
    c2 = (A - 1) // C
    d1 = B // D
    d2 = (A - 1) // D
    g1 = B // g
    g2 = (A - 1) // g
    print(B - A + 1 + (g1 - g2) - (c1 - c2) - (d1 - d2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5072
#include <iostream>
#include <vector>

using namespace std;
typedef pair<char, char> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> trans(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> trans[i].first >> trans[i].second;
		}
		int num;
		cin >> num;

		vector<char> c(num);
		for(int i = 0; i < num; ++i)
		{
			cin >> c[i];
		}
		for(int i = 0; i < num; ++i)
		{
			bool flag = true;
			for(int j = 0; j < n; ++j)
			{
				if(c[i] == trans[j].first)
				{
					cout << trans[j].second;
					flag = false;
				}
			}
			if(flag)
			{
				cout << c[i];
			}
		}
		cout << endl;
	}
}

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

Measured memory_bytes: 988
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
using namespace std; 


/*start:17/5/19 16:09*/
/*end:17/5/19   16:32  */

int n,i,x;
long long int y,k;
long long int a[100005];
int  main()
{
	cin>>n>>k;
	memset(a,0,sizeof(a));
	for(i=1;i<=n;i++)
	{
		cin>>x>>y;
		a[x]+=y;
	}
	for(i=0;i<=100000;i++)
	{
		if(k<=a[i])
		{
		//	cout<<k<<endl;
		//	cout<<a[i];
			cout<<i<<endl;
			return 0;
		}
		k-=a[i];
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ans1 = (x / 11) * 2;
    x -= (x / 11) * 11;
    cout << ans1 + (x > 0) + (x > 6)  << endl;

    return 0;
}


Measured memory_bytes: 3632
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var withoutTax = Math.Round(N / 1.08);
            var withTax = Math.Floor(withoutTax * 1.08);

            for (var i = 1; i <= 50000; i++)
            {
                if (Math.Floor(i * 1.08) == N)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(":(");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
  ll n;std::cin >> n;
  n--;
  ll ans = 0;
  for(ll a=1;a<=n;a++){
    ans += n/a;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int f=1;
  for(int i=1;i<n;i++)
  {
    if(i<10)
    {
       if(n%i==0 && n/i<10)
        { 
         f=1;
         break;
        }
    }
    else
    {
      f=0;
      break;}
  }
  if(f==1)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h> 
int main() {
	
	int n;
	scanf("%d",&n);
	int a[100];
	int i,j,w;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0)printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
inline int get_num(){
	char ch;
	int num=0;
	ch=getchar();
	while(ch<'0'||ch>'9'){ch=getchar();}
	while(ch>='0'&&ch<='9'){num=(num<<3)+(num<<1)+ch-'0';ch=getchar();}
	return num;
}
int n,q,b,c;
int const maxn=1e5+10;
long long a[maxn],sum=0,tot[maxn];
int main(){
	n=get_num();
	for(int i=1;i<=n;i++){
		a[i]=get_num();
		tot[a[i]]++;
		sum+=a[i];
	}
	q=get_num();
	for(int i=1;i<=q;i++){
		b=get_num(),c=get_num();
		tot[c]+=tot[b];
		sum=sum+(c-b)*tot[b];
		printf("%lld\n",sum);
		tot[b]=0;
	}
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S, T; cin >> S >> T;
	int ans = 0;
	F0R(i, S.size()) ans += S[i] != T[i];
	print(ans);
}

Measured memory_bytes: 3800
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    for(int i = 0; i < Q; i++) cin >> A.at(i);

    vector<int> point(N, A.size());
    for(int i = 0; i < Q; i++) point.at(A.at(i) - 1)--;

    for(int i = 0; i < N; i++){
        if(K - point.at(i) <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;


int main() {

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;

    int x4 = x1 - dy;
    int y4 = y1 + dx;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
#define mp make_pair
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecisi
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll wa = 0;
    rep(i,N){
        cin >> vec[i];
        wa += vec[i];
    }
    rep(i,N - 1){
        vec[i + 1] += vec[i];
    }
    ll ans = INF;
    for(ll i = 0;i < N - 1;i++){
        ans = min(ans,abs(vec[i] * 2 - wa));
    }
    cout << ans << endl;
    //cout << wa << "\n";
    //vecout(vec);
}


Measured memory_bytes: 4772
n,m = map(int, input().split())

solved = set()
correct = 0
penalty = 0
penalty_memo = [0] * (n+1)

for _ in range(m):
    p,s = input().split()
    p = int(p)

    if p not in solved:
        if s == "WA":
            penalty_memo[p] += 1
        else:
            correct += 1
            penalty += penalty_memo[p]
            solved.add(p)

print(correct, penalty)

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

#define fi first
#define se second

const int N = 100100;

using namespace std;

long long n;
vector < long long > d;

long long solve(long long n, int *a, int *b)
{
        d.resize(n + 1);
        for(int i = 0; i <= n; i++){
                d[i] = 0;
        }
        long long res = 0;
        for(int i = n; i >= 0; i--){
                res = max(res, i + d[i]);
                for(int j = 0; j < 3; j++){
                        if(i >= a[j]){
                                d[i - a[j]] = max(d[i - a[j]], d[i] + b[j]);
                        }
                }
        }
        return res;
}

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        int a[3], b[3];
        cin >> n >> a[0] >> a[1] >> a[2];
        cin >> b[0] >> b[1] >> b[2];
        n = solve(n, a, b);
        n = solve(n, b, a);
        cout << n << "\n";
}


Measured memory_bytes: 195584
#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'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 105;
ll n, w, weight[N], value[N], dp[N][100005];
ll solve(int idx, ll fWeight){
    if(fWeight > w)
        return -2e9;
    if(idx >= n){
        if(fWeight <= w) return 0;
        else return -2e9;
    }
    if(dp[idx][fWeight] != -1)
        return dp[idx][fWeight];
    ll mx = max(solve(idx + 1, fWeight + weight[idx]) + value[idx],
                solve(idx + 1, fWeight));
    dp[idx][fWeight] = mx;
    return mx;
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> n >> w;
    for(int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];
    cout << solve(0, 0);
    return 0;
}

Measured memory_bytes: 85596
S=input()
T=input()

Ls=[0]*26
Lt=[0]*26

for i in range(len(S)):
    Ls[ord(S[i])-ord("a")]+=1
    Lt[ord(T[i])-ord("a")]+=1
    
Ls.sort()
Lt.sort()

flag=True
for i in range(len(Ls)):
    if Ls[i]!=Lt[i]:
        flag=False
        break
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 41840
#include <iostream>
#include <vector>
#include <cmath>
#define NMAX 15
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[NMAX - 1] = { 0 };
	int x[NMAX][NMAX - 1] = { 0 };
	int y[NMAX][NMAX - 1] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < a[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int max = 0;
	for (int i = 0; i < pow(2, n); i++) {
		int test = i;
		int tf[NMAX];
		for (int j = 0; j < n; j++) {
			tf[j] = test % 2;
			test /= 2;
		}

		bool suc = true;
		for (int j = 0; j < n; j++) {
			if (tf[j] == 1) {
				for (int k = 0; k < a[j]; k++) {
					if (tf[x[j][k] - 1] != y[j][k]) {
						suc = false;
						goto LABEL_NEXT;
					}
				}
			}
		}
	LABEL_NEXT:
		if (suc) {
			test = i;
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if (test % 2 == 1)
					cnt++;
				test /= 2;
			}
			if (cnt > max) {
				max = cnt;
			}
		}
	}

	cout << max << endl;

	return 0;
}

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

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

int main()
{
    int n; cin >> n;
    vector<int> a(n);

    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int sum = 0;
    for (int i = 0; i < n-1; i++) sum += a[i];
    
    if(a[n-1]<sum) cout << "Yes";
    else cout << "No";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll n,k,x,y;
  cin>>n>>k>>x>>y;
  n>=k?cout<<k*x+(n-k)*y<<endl:cout<<x*n<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>

using namespace std;
typedef long long ll;
const int maxn = 100005;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "w", stdout);
#endif
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;
  int ret=0;
  for(int i=0;i<n;i++){
    if(a[i]==b[i]&&a[i]==c[i])ret+=0;
    else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])ret+=1;
    else ret+=2;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n;
	cin >> n;

	for (int i = 1; i <= 9; i++) {
		if (n / i <= 9 && n % i == 0) {
			cout << "Yes" << endl;
			break;
		}
		if (i == 9) {
			cout << "No" << endl;
		}
	}

	return 0;
}

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

#define MAX_W 100
#define MAX_H 100

char room[MAX_W][MAX_H];
int W,H;

const int direc[4][2] = {
    {0, -1},
    {1, 0},
    {0, 1},
    {-1, 0},
};

void dfs(const int& row, const int& col, const char c);

int main() {
    while(cin>>H>>W, W > 0) {
        int step = 0;
        int col, row;
        for (row = 0; row < H; ++row) {
            for (col = 0; col < W; ++col) {
                cin >> room[row][col];
            }
        }
        for (row = 0; row < H; ++ row) {
            for(col = 0; col < W; ++ col) {
                if(room[row][col] != '!') {
                    dfs(row, col, room[row][col]);
                    ++ step;
                }
            }
        }
        cout<<step<<endl;
    }
    return 0;
}

void dfs(const int& row, const int& col, const char c) {
    room[row][col] = '!';
    for(int d = 0; d < 4; ++ d) {
        int curRow = row + direc[d][1];
        int curCol = col + direc[d][0];
        if(curRow >= 0 && curRow < H && curCol >= 0 && curCol < W && room[curRow][curCol] == c) {
            dfs(curRow, curCol, c);
        }
    }
}



Measured memory_bytes: 3832
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def rotate(self):
        prev_s2 = self.s2
        self.s2 = self.s4
        self.s4 = self.s5
        self.s5 = self.s3
        self.s3 = prev_s2
    def top(self):
        return self.s1
    def front(self):
        return self.s2
    def right(self):
        return self.s3

    def isSameDice(self, anotherDice):
        if self.s1 == anotherDice.s1 and \
           self.s2 == anotherDice.s2 and \
           self.s3 == anotherDice.s3 and \
           self.s4 == anotherDice.s4 and \
           self.s5 == anotherDice.s5 and \
           self.s6 == anotherDice.s6:
            return True
        return False


dices = []
n = int(input())
for i in range(n):
    s1, s2, s3, s4, s5, s6 = map(int, input().split())
    dices.append(Dice(s1, s2, s3, s4, s5, s6))

flag = False
for i in range(n):
    j = i+1
    while j < n:
        for k in range(6):
            if k % 2 == 0:
                dices[j].north()
            else:
                dices[j].west()

            for l in range(4):
                dices[j].rotate()
                if dices[j].isSameDice(dices[i]):
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
        j += 1
    if flag:
        break

if flag:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 6824
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int a, b, ans = 0;
    
    cin >> a;
    
    ans += a / 500 * 1000;
    b = a % 500;
    
    ans += b / 5 * 5;
    
    
    
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [a, b] <- fmap read . words <$> getLine
    if any ((== 0) . (`mod` 3)) [a, b, a + b]
        then putStrLn "Possible"
        else putStrLn "Impossible"

Measured memory_bytes: 508
#include<stdio.h>
int main(){
	int A,B,count=0;
	scanf("%d %d",&A,&B);
	if (A > B) {
		count += A;
		A -= 1;
	}
	else {
		count += B;
		B -= 1;
	}
	if (A > B) {
		count += A;
	}
	else {
		count += B;
	}
	printf("%d\n", count);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	ll N; cin >> N;
	int key = 0;//何桁か
	int key2;
	if (N < 10) {
		cout << N << endl;
	}
	else {
		int sum = 0;
		while (N > 0) {
			if (N < 10) {
				key2 = N;
			}
			sum += N % 10;
			N /= 10;
			key++;
		}
		if ((key - 1) * 9 == sum - key2) {
			cout << key2 + (key - 1) * 9 << endl;
		}
		else {
			cout << (key2 - 1) + (key - 1) * 9 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := (float64(n - n/2)) / float64(n)

	_, _ = fmt.Fprintf(writer, "%.10f", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    
    int n;

    cin >> n;

    vector<int> arr(n);
    vector<int> dp(n);

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

    dp[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i-2] + abs(arr[i] - arr[i-2]),
                    dp[i-1] + abs(arr[i] - arr[i-1]));
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
def isPrime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    
    i = 3
    while i**2 <= x:
        if x % i == 0:
            return False
        i += 2
    return True


n = int(input())
cnt = 0
for i in range(n):
    if isPrime(int(input())):
        cnt += 1

print(cnt)





















Measured memory_bytes: 5612
#include<iostream>

int main(){

	int ar[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	int K;
	std::cin >> K;

	std::cout << ar[K-1] << std::endl;

	return 0;
}



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

std::map<char, std::vector<int> > char_map;

void init_map(){
    for(char c = 'a'; c<='z'; c++){
        std::vector<int> vec;
        char_map.insert(std::make_pair(c, vec));
        //char_map.emplace_hint(char_map.end(), c, vec);
    }
}

void read_str(std::string &str){
    for(int i=0; i<str.size(); ++i){
        char_map.at(str[i]).push_back(i);
    }
}

void replace(std::string &str, char c, char r){
    /*
    for(int i=0; i<str.size(); ++i){
        if(str[i] == c){
            str[i] = r;
        }else if(str[i] == r){
            str[i] = c;
        }
    }*/
    std::vector<int> c_vec = char_map.at(c);
    std::vector<int> r_vec = char_map.at(r);
    std::vector<int> temp;
    for(int i=0; i<c_vec.size(); ++i){
        str[c_vec[i]] = r;
    }
    for(int i=0; i<r_vec.size(); ++i){
        str[r_vec[i]] = c;
    }
    temp = c_vec;
    char_map.at(c) = char_map.at(r);
    char_map.at(r) = temp;
}

std::vector<int> count(std::string str){
    std::vector<int> vec(26);
    for(int i=0; i<str.size(); i++){
        vec[str[i]-'a']++;
    }
    return vec;
}

int main(){
    std::string str1, str2;
    std::cin >> str1;
    std::cin >> str2;

    std::vector<int> vec1 = count(str1);
    std::vector<int> vec2 = count(str2);

    std::sort(vec1.begin(), vec1.end());
    std::sort(vec2.begin(), vec2.end());

    if(vec1 == vec2){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    /*
    init_map();
    read_str(str1);
    for(int i=0; i<str1.size(); ++i){
    //while(str1.empty() == false){
        if(str1[i] != str2[i]){
            replace(str1, str1[i], str2[i]);
            //std::cout << str1 << std::endl;
            //std::cout << str2 << std::endl;
        }
    }*/

    /*
    for(char c = 'a'; c<='z'; ++c){
        std::vector<int> vec = char_map.at(c);
        std::cout << c << ": ";
        for(int i=0; i<vec.size(); i++){
            std::cout << vec[i] << ", ";
        }
        std::cout << std::endl;
    }
    */

    //std::cout << str1 << std::endl;
    //std::cout << str2 << std::endl;
    /*
    if(str1 == str2){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }*/

    return 0;
}

Measured memory_bytes: 904