akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    double a, b;
    cin >> a >> b;

    // 処理
    // 出力
    if (a > b) {
        cout << "GREATER" << endl;
    } else if (a < b) {
        cout << "LESS" << endl;
    } else {
        cout << "EQUAL" << endl;
    }

    return 0;
}


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


using namespace std;



int main() {

	int N;
	string* W;
	bool key = true;

	cin >> N;

	W = new string[N];

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

	for (int i = 0; i < N - 1; i++) {
		if (W[i][W[i].size() - 1] != W[i + 1][0]) {
			key = false;
			goto answer;
		}
	}

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (W[i] == W[j]) {
				key = false;
				goto answer;
			}
		}
	}


answer:

	if (key) {
		cout << "Yes";
		}
	else {
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<cstring> 
#include<cstdlib>
#include<set>
#include<vector>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
const int inf =9999999;

int main()
{     int t;
	cin>>t;
     if(t%10==3)
     cout<<"bon"<<endl;
     else if(t%10==0||t%10==1||t%10==6||t%10==8)
     cout<<"pon"<<endl;
     else
     cout<<"hon"<<endl;

	
}
	 
		
	  	
	  

Measured memory_bytes: 3060
def f(a, t)
    s = 0
    xs = a.map(&:first)
    a.each do |x, y|
        s += y * (xs - [x]).map{|u| (t - u).to_f / (x - u)}.inject(:*)
    end
    s
end

loop do
    d = gets.to_i   
    break if d == 0
    points = (0..d+2).map {|x| [x, gets.to_f]}
    
    (0..d+2).each do |i|
        a = points.dup
        a.delete_at(i)
        x_c, y_c = a.pop
        d = (y_c - f(a, x_c)).abs
        if  d < 0.001
            puts i
            break
        end
    end     
end 

Measured memory_bytes: 8920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;

const ll INF = 9223372036854775807;
const int inf = 2147483647;

int main() {
    int n;
    cin >> n;
    string res = "No";
    REP(i,100){
        if(n%7==0&&n>=0){
            res = "Yes";
        }
        n-=4;
    }
    put(res)
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final long IMAX = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		long K = Long.parseLong(sc.next());
		int[] A = new int[N];
		int idx;
		for (idx = 0; idx < N; idx++) {
			A[idx] = Integer.parseInt(sc.next());
		}
		sc.close();

		long cnt = 0;
		long sum = 0;
		long numP, numN;

		int inIdx;
		for (idx = 0; idx < N; idx++) {
			numP = 0;
			numN = 0;
			for (inIdx = 0; inIdx < N; inIdx++) {
				if (idx > inIdx) {
					// 基準より前
					if (A[idx] > A[inIdx]) {
						++numP;
					}
				} else if (idx < inIdx) {
					// 基準より後
					if (A[idx] > A[inIdx]) {
						++numN;
					}
				}
			}
			if (K % 2 == 0) {
				// Kが偶数
				// 前たす
				sum = (K/2) * (K-1) % IMAX * numP % IMAX;
				cnt += sum;
				// 後ろたす
				sum = (K+1) * (K/2) % IMAX * numN % IMAX;
				cnt += sum;
			} else {
				// Kが奇数
				// 前たす
				sum = K * ((K-1)/2) % IMAX * numP % IMAX;
				cnt += sum;
				// 後ろたす
				sum = ((K+1)/2) * K % IMAX * numN % IMAX;
				cnt += sum;
			}

			// あまり
			if (cnt >= IMAX) {
				cnt = cnt % IMAX;
			}
		}

		System.out.println(cnt);

	}

}


Measured memory_bytes: 26400
S = [c for c in input()]
K = int(input())

for i in range(len(S)) :
    t = (ord('z') - ord(S[i]) + 1) % 26 #編集コスト
    
    if t <= K :
        K -= t
        S[i] = 'a'

K %= 26

S[-1] = chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a'))

ans = ''.join(S)

print(ans)


Measured memory_bytes: 4212
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <bitset>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define MAXN 1010100
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll __int64
#define INF 0x7fffffff
#define cs(s) freopen(s,"r",stdin)
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
#define eps 1e-10
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
//head
int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
	LL a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c)cout<<b+c<<endl;
	else cout<<b+b+a+1<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	n := getInt()
	a := getInt()
	b := getInt()

	allSum := powMod(2, n) - 1

	ta := calcTop(n, a)
	ba := calcBottom(a)
	aSum := calcMod(ta * powMod(ba, mod - 2))

	tb := calcTop(n, b)
	bb := calcBottom(b)
	bSum := calcMod(tb * powMod(bb, mod - 2))

	allSum -= aSum
	if allSum < 0 {
		allSum += mod
	}

	allSum -= bSum
	if allSum < 0 {
		allSum += mod
	}

	fmt.Println(allSum)
}

func calcBottom(m int) int {
	value := 1
	for i := 1; i <= m; i++ {
		value = calcMod(value * i)
	}
	return value
}

func calcTop(n, m int) int {
	value := 1
	for i := n - m + 1; i <= n; i++ {
		value = calcMod(value * i)
	}
	return value
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

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

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
N,K = map(int,input().split())
MOD = 10**9+7
A = [i for i in range(0,N+1)]
cum_A = [0]*(N+2)
for i in range(1,N+2):
  cum_A[i] = cum_A[i-1]+A[i-1]
  
ans = 0
for k in range(K,N+2):
  ans += cum_A[-1] - cum_A[-k-1] - cum_A[k] + 1
  ans%=MOD
  
print(ans%MOD)

Measured memory_bytes: 27184
// author - saiku_ni_naro
// TO THE TOP

#include<bits/stdc++.h>
using namespace std;
#define F_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl '\n'
#define For(i,a,n) for(int i=(a);i<=(n);i++)
#define RFor(i,a,n) for(int i=(n);i>=(a);i--)
#define SET(a,val) memset((a),(val),sizeof((a)))
#define X first
#define Y second
#define pb push_back
#define over(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define inp(x) cin>>x;
#define oup(x) cout<<x<<endl;

const int N = 7;
char a[N][N];

void solving_problem(){
    
    int H,W,K; cin>>H>>W>>K;

    For(i,0,H-1){
        For(j,0,W-1) cin>>a[i][j];
    }

    int ans = 0;

    For(Maski,0,(1<<(H))-1){
        For(Maskj,0,(1<<(W))-1){
            int cnt = 0;

            For(i,0,H-1){
                For(j,0,W-1){
                    if((Maski&(1<<i)) || (Maskj&(1<<j))) continue;
                    if(a[i][j] == '#') cnt++;
                }
            }
            if(cnt == K) ans++;
        }
    }

    cout<<ans<<endl;
}

signed main(){
    F_IO;

    int testcases = 1; 
    // cin>>testcases;

    For(i,1,testcases){
        // cout<<"Cases #"<<i<<": ";
        solving_problem();
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int A,B;
	cin >> A  >> B;

	cout << 6 - A - B << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

int main(){
    int A,B,M;scanf("%d %d %d",&A,&B,&M);
    int a[200000];for(int i=0;i<A;i++)scanf("%d",&a[i]);
    int b[200000];for(int i=0;i<B;i++)scanf("%d",&b[i]);
    int x[200000],y[200000],c[200000];
    for(int i=0;i<M;i++){
        scanf("%d %d %d",&x[i],&y[i],&c[i]);
    }
    int sum[200000]={};
    for(int i=0;i<M;i++){
        sum[i]=a[x[i]-1]+b[y[i]-1]-c[i];
    }
    qsort(a,A,sizeof(int),asc_cmp);
    qsort(b,B,sizeof(int),asc_cmp);
    int ans=a[0]+b[0];
    for(int i=0;i<M;i++){
        ans=min(ans,sum[i]);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 5244
#include<iostream>
using namespace std;
static const int N = 100;
void trace(int A[], int n){
    for(int i = 0; i < n; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
void InsertionSort(int A[], int n){
    for(int i = 1; i < n; i++){
        int targetA = A[i];
        int j = i - 1;
        while( j >= 0 && A[j] > targetA){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = targetA;
        trace(A,n);
    }
}
int main(){
    int n;
    int A[N+1];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    trace(A,n);
    InsertionSort(A,n);
}

Measured memory_bytes: 3080
N = int(raw_input())
s = raw_input()

D = ["SS", "SW", "WS", "WW"]
A = "SW"

s += s[0]
for d in D:
    a = d
    for i in range(1, N+1):
        k = 0
        if a[i] == "W":
            k += 1
        if s[i] == "x":
            k += 1
        if a[i-1] == "W":
            k += 1
        a += A[k % 2]
    if a[:2] == a[-2:]:
        print a[:-2]
        exit()
print -1


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

int main(){
    int n,k;
    cin >> n >> k;
    int ans=0;
    
    rep(i, n){
        int h;
        cin >> h;
        if(h >= k) ans+=1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;
int a[26]={};
int b[26]={};
void solve(){
    string s,t;cin>>s>>t;
    string x="",y="";
    int l;
    fol(i,s.size()){
        l = s[i]-'a';
        a[l]++;
    }
    fol(i,t.size()){
        l=t[i]-'a';
        b[l]++;
    }
    fol(i,26){
        while(a[i]!=0){
            x+=((char)'a'+i);
            a[i]--;
        }
    }
    fol(i,26){
        while(b[i]!=0){
            y=(char)('a'+i)+y;
            b[i]--;
        }
    }
    if (x<y){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
}

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


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

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<long> A(N);
    for (auto &a : A) cin >> a;
    sort(A.begin(), A.end());
    vector<pair<int,long>> BC(M);
    for (auto& bc : BC) cin >> bc.first >> bc.second;
    sort(BC.rbegin(), BC.rend(), [](auto l, auto r) {return l.second < r.second;});
    long ans = 0;
    for (auto bc : BC) {
        auto end = lower_bound(A.begin(), A.end(), bc.second);
        if (end - A.begin() > bc.first)
            end = A.begin() + bc.first;
        ans += bc.second * (end - A.begin());
        A.erase(A.begin(), end);
    }

    for (auto a : A) ans += a;
    cout << ans << endl;

    
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    int cnt = 0;
    rep(i,n){
        if(a[i]<0)cnt++;
    }
    if(cnt%2==0){
        ll ans = 0;
        rep(i,n)ans += abs(a[i]);
        cout << ans << endl;
    }else{
        rep(i,n)a[i]=abs(a[i]);
        sort(all(a));
        ll ans = -2*a[0];
        rep(i,n)ans+=a[i];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> a(n), b(n), c(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  rep(i, n) cin >> c.at(i);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll sum = 0;
  vector <ll> v(n);
  rep(i, n) {
    auto itr = upper_bound(c.begin(), c.end(), b.at(i));
    v.at(i) = distance(itr, c.end());
    sum += v.at(i);
  }
  rep(i, n-1) {
    v.at(i+1) += v.at(i);
  }
  ll res = 0;
  rep(i, n) {
    auto itr = upper_bound(b.begin(), b.end(), a.at(i));
    if (itr == b.begin()) {
      res += sum;
    } else if (itr == b.end()) {
      continue;
    } else {
      ll j = distance(b.begin(), itr);
      res += sum-v.at(j-1);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll n,t,c,p;
  cin >> n>>t;
  vector <int> v;
  for(int i=0;i<n;i++){
    cin >> c>> p;
    if(p<=t) v.push_back(c);
  }
  if(v.size()==0) cout <<"TLE"<<endl;
  else{
    sort(v.begin(),v.end());
    cout << v[0]<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int check(int ,int *,int );
int main(void){
  int n,q,S[10000],key,i,count;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0,count=0;i<q;i++){
    scanf("%d",&key);
    if(check(key,S,n)==1)count++;
  }
  printf("%d\n",count);
  return 0;
}
int check(int key,int *S,int n){
  int i=0;
  while(S[i]!=key && i<n)i++;
  if(i==n)return 0;
  else return 1;
}


Measured memory_bytes: 2144
# Wrote in Apr 3, 2020 13:52 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".split(\" \").map(&:to_i)")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #a yori ue
    self.sort.select{|n|n>=a}
  end
  def downer(a) #a yori shita
    self.sort.select{|n|n<=a}
  end
end
#---------------

def main()
  r,c = inp
  table = minp(r)
  r.times do |n|
      table[n].push(table[n].inject(:+))
  end
  array = []
  c.times do |n|
      array.push(table.transpose[n].inject(:+))
  end
  table.push(array)
  table[table.size-1].push(table[table.size-1].inject(:+))
  puts table.map{|n| n.join(" ") }.join("\n")
end
main()


Measured memory_bytes: 15492
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
import sys
#DEBUG = True
DEBUG = False
if DEBUG:
    f=open("202006_5th/C_input.txt")
else:
    f=sys.stdin
#----
M,N,K=map(int,f.readline().split())
ans=0
__=N
M_shelf=list(map(int,f.readline().split()))
N_shelf=list(map(int,f.readline().split()))
M_partial=[]
N_partial=[]
M_partial.append(0)
N_partial.append(0)
#----
for _ in range(M):
    M_partial.append(M_partial[_]+M_shelf[_])
for _ in range(N):
    N_partial.append(N_partial[_]+N_shelf[_])
for _ in range(M+1):
    R=K-M_partial[_]
    if R<0:
        break
    while R<N_partial[__]:
        __-=1
    ans=max(ans,_+__)
print(ans)
f.close()

Measured memory_bytes: 47512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int h,w;
    cin>>h>>w;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#')cout<<"#";
            else{
                int ans=0;
                for(int k=0;k<3;k++){
                    for(int l=0;l<3;l++){
                        if(s[i-1+k][j-1+l]=='#'&&i-1+k>=0&&j-1+l>=0&&i-1+k<h&&j-1+l<w)ans++;
                    }
                }
                cout<<ans;
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	ll a,b,c;
	std::cin >> a >> b >> c;
	
	if (a%2 == 0 && a == b && a==c){ std::cout << -1 << std::endl; return 0;}
	else if (a%2 != 0 || b%2 != 0 || c%2 != 0){ std::cout << 0 << std::endl; return 0;}

	ll ans = 0;
	while(true)
	{
		++ans;
		ll tmp_a = b/2 + c/2;
		ll tmp_b = a/2 + c/2;
		ll tmp_c = a/2 + b/2;
		a = tmp_a, b = tmp_b, c = tmp_c;
		if(tmp_a%2 != 0 || tmp_b%2 != 0 || tmp_c%2 != 0) break;
	}

	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll cnt[200005];
ll a[200005];
int main() {
  IOS;
  int n, k, s;
  cin >> n >> k >> s;
  if (s < 1000000000) {
    for (int i = 0; i < k; i++)
      cout << s << ' ';
    for (int i = 0; i < n - k; i++)
      cout << s + 1 << ' ';
    cout << endl;
  } else {
    for (int i = 0; i < k; i++)
      cout << s << ' ';
    for (int i = 0; i < n - k; i++)
      cout << s - 1 << ' ';
    cout << endl;
  }
}


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

int N, M, key[100005];

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        key[a]++;
        key[b]++;
    }
    bool flag = false;
    for(int i = 1; i <= N; i++){
        if(key[i] % 2){
            flag = true;
            break;
        }
    }
    if(flag){
        printf("NO\n");
    }
    else{
        printf("YES\n");
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll cnt = -1;
    rep(i, n) {
        ll c = a[i], t = 0;
        while(c % 2 == 0) {
            t++;
            c /= 2;
        }
        if (cnt == -1) {
            cnt = t;
        }
        else if (cnt != t) {
            cout << 0 << endl;
            return 0;
        }
    }
    ll lcm = a[0];
    reps(i, 1, n) lcm = lcm / __gcd(lcm, a[i]) * a[i];
    cout << (m / (lcm / 2) - m / lcm) << endl;
    return 0;
}


Measured memory_bytes: 1024
#A - Table Tennis Training
N,A,B = list(map(int, input().split()))

Lab = B-A
La = A-1
Lb = N-B

if Lab%2==0:
    #case Lab is even
    ans = Lab//2
else:
    #case Lab is odd
    ans = min(La,Lb) + 1 + Lab//2

print(ans)

Measured memory_bytes: 2940
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(input())
K = int(input())
N = len(S)
ans = 0
last_same = False
if N==1:
    print(K//2)
    exit()
for i in range(1,N):
    if S[i]!=S[i-1]:
        break
else:
    print(N*K//2)
    exit()
p = False

#前からと後ろからで連続しているかずをかぞえあげる.
pre_num = 0
l_num = 1
if S[0]==S[-1]:
    pre_num = 1
    for i in range(1,N-1):
        if S[i]==S[i-1]:
            pre_num += 1
        else:
            break
    l_num = 1
    for i in range(N-1,0,-1):
        if S[i]==S[i-1]:
            l_num += 1
        else:
            break

for i in range(pre_num,N-l_num):
    if p:
        p = False
        continue
    if S[i]==S[i+1]:
        ans += 1
        p = True

ANS = (pre_num//2) + ans*K + ((pre_num+l_num)//2)*(K-1) + (l_num//2)

print(ANS)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	int K;
	cin >> S >> K;

	int pt = 0;
	K--;
	while (K) {
		if (S[pt] != '1') break;
		pt++;
		K--;
	}

	cout << S[pt] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MLT[3] = { 2,3,5 };

ll n, d;
ll cost[3];

map<ll, ll> mem;

ll rec(ll x) {
	if (x == 0) return 0;
	if (mem.count(x)) return mem[x];
	ll ret = LLONG_MAX;
	if (d < LLONG_MAX / x) ret = d * x;
	REP(i, 3) {
		ll y = (x + MLT[i] - 1) / MLT[i] * MLT[i];
		if (y / MLT[i] < x) {
			ll cur = abs(y - x) * d + cost[i] + rec(y / MLT[i]);
			ret = min(ret, cur);
		}
		ll z = x / MLT[i] * MLT[i];
		if (z / MLT[i] < x) {
			ll cur = abs(z - x) * d + cost[i] + rec(z / MLT[i]);
			ret = min(ret, cur);
		}
	}
	return mem[x] = ret;
}

ll solve() {
	mem.clear();
	return rec(n);
}

void run() {
	scanf("%lld%lld%lld%lld%lld", &n, &cost[0], &cost[1], &cost[2], &d);
	printf("%lld\n", solve());
}

int main() {
	int ncase; scanf("%d", &ncase); FORE(i, 1, ncase) run();
	return 0;
}


Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vin a(n);
  rep(i,0,n)cin>>a[i];
  vin b(n);
  b=a;
  sort(all(b));
  int cet=b[n/2-1];
 rep(i,0,n){
   if(a[i]>cet){
    cout<<cet<<endl; 
   }
   else{
     
       cout<<b[n/2]<<endl;
     
     
   }
 }
}

Measured memory_bytes: 4832
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<string> v;
vector<string> f[7] = {
	{"11", "11"},
	{"1", "1", "1", "1"},
	{"1111"},
	{"01", "11", "10"},
	{"110", "011"},
	{"10", "11", "01"},
	{"011", "110"}
};
bool contain(vector<string> v1, vector<string> v2) {
	for(int i = 0; i <= (int)(v1.size() - v2.size()); i++) {
		for(int j = 0; j <= (int)(v1[0].size() - v2[0].size()); j++) {
			bool flag = true;
			for(int k = 0; k < v2.size(); k++) {
				if(v1[i + k].substr(j, v2[0].size()) != v2[k]) {
					flag = false; break;
				}
			}
			if(flag) return true;
		}
	}
	return false;
}
int main() {
	v.resize(8);
	while(cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7]) {
		for(int i = 0; i < 7; i++) {
			if(contain(v, f[i])) cout << (char)(i + 65) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int com_asc_int(const void *n1,const void *n2){
   if(*(int*)n1 > *(int*)n2)return 1;
   else if(*(int*)n1 < *(int*)n2)return -1;
   else return 0;
}

int main(){
   int n;scanf("%d",&n);
   int d[101];
   int ans=0;
   for(int i = 0;i < n;i++){
      scanf("%d",&d[i]);
   }
   qsort(d,n,sizeof(int),com_asc_int);
   for(int i = 0;i < n-1;i++){
      if(d[i]!=d[i+1])ans++;
   }
   printf("%d",ans+1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) A>B?A:B
#define MIN(A,B) A<B?A:B
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-12
#define ld long double
#define modulo 998244353
#define tmplarge (lli)1e4
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;



int main()
{
    int n;
    scanf("%d",&n);
    if (n<1200)
        printf("ABC");
    else if (n<2800)
        printf("ARC");
    else
        printf("AGC");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100001

int table[NUM],a[NUM],c[NUM],d[NUM];

int main(){

	int N;
	scanf("%d",&N);

	for(int i = 1; i <= N; i++)table[i] = 0;

	for(int i = 1; i <= N; i++){
		scanf("%d",&a[i]);
		table[a[i]]++;
	}

	int tmp;
	for(int i = 1; i <= N; i++){
		scanf("%d",&tmp);
		table[tmp]--;
	}

	bool FLG = true;

	for(int i = 1; i <= N; i++){
		if(table[i] > 0){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("Yes\n");
		return 0;
	}

	for(int i = 1; i <= N; i++){
		if(table[a[i]] <= 0){
			c[i] = a[1];
			d[i] = a[1];
		}else{
			c[i] = a[1];
			d[i] = a[2];
		}
	}

	printf("No\n");
	printf("%d",c[1]);
	for(int i = 2; i <= N; i++)printf(" %d",c[i]);
	printf("\n");

	printf("%d",d[1]);
	for(int i = 2; i <= N; i++)printf(" %d",d[i]);
	printf("\n");

	return 0;
}



Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int pos;
  cin >> s >> pos;
 
  vector<string> t;
 
  for (int k = 0; k < (int)s.size(); k++) {
    for (int l = 1; l <= 5; l++) {
      t.push_back(s.substr(k, l));
    }
  }
  sort(t.begin(), t.end());
  unique(t.begin(), t.end());
  cout << t[pos-1] << endl;
}

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

int main() {
  string s;
  cin>>s;
  int res=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+') res++;
    else res--;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int K = sc.nextInt();
			int[] A = new int[K];
			for(int i = 0 ; i < K ; i++){
				A[i] = sc.nextInt();
			}
		sc.close();

		int count = 0;
		complete :
		for(int i = N ; i <= 99999 ; i++){
			String T = Integer.toString(i);

			next:
			for(int j = 0 ; j < T.length() ; j++){
				String m = T.substring(j, j+1);
				for(int k = 0 ; k < A.length ; k++){
					if(Integer.parseInt(m) == A[k]){
						count = 0;
						break next;
					}
					else{
						count++;
					}
				}
				int pp = K * T.length();
				if(pp == count){
					System.out.println(i);
					break complete ;
				}
			}
		}
	}
}


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

#define ll long long

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

	int k, n;
	cin >> k >> n;

	int a[n];
	for (int i = 0; i < n; ++i) cin >> a[i];

	int max_diff = 0;
	for (int i = 0; i < n; ++i) {
		max_diff = max(max_diff, (a[i] - a[(i - 1 + n) % n] + k) % k);
	}

	cout << k - max_diff;
}


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

int main()
{
    int size;
    string inp;
    cin >> size >> inp;
    if (inp.size() <= size)
        cout << inp;
    else
    {
        inp.erase(size);
        cout << inp << "...";
    }
    return 0;
}


Measured memory_bytes: 3632
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

n,m=map(int,input().split())
UF=UF(n)
for i in range(m):
  x,y,z=map(int,input().split())
  UF.unite(x-1,y-1)
print(UF.groupnum())

Measured memory_bytes: 7856
MOD = 10**9+7
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)

if len(set(A)) < N or len(set(B)) < M:
    print(0)
    exit()
if A[0] != N * M or B[0] != N * M:
    print(0)
    exit()

ans = 1
i, j = 0, 0
for value in range(N * M, 0, -1):
  while i < N - 1 and A[i + 1] >= value: i += 1
  while j < M - 1 and B[j + 1] >= value: j += 1
  if A[i] == value and B[j] == value: pass
  elif A[i] == value: ans = (ans * (j + 1)) % MOD
  elif B[j] == value: ans = (ans * (i + 1)) % MOD
  else:
    mult = (i + 1) * (j + 1) - (N * M - value)
    ans = (ans * max(mult, 0)) % MOD

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int count = 0;
	for (int i = min(a,b); i > 0; i--) {
		if (a%i == 0 && b%i == 0) {
			count++;
		}
		if (count == k) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans;
  for (ll i = 0; i < S.length(); i++) {
    ans += S[i];
    ans += T[i];
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin>>n;
  	int k;
  	cin>>k;
    vector<int> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
      for(int j=1;j<=min(n-1,k);j++)
      {
        if(i+j<n && dp[i+j]> (dp[i]+abs(arr[i]-arr[i+j])))
            dp[i+j] = dp[i]+abs(arr[i]-arr[i+j]);
      }
    }
    // for(int i=0;i<n;i++)
    //     cout<<dp[i]<<endl;
    cout<<dp[n-1];
    
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    vector<ll>ans;
    for(ll i = 1 ; i * i <= n ; i++){
        if( n % i == 0 ){
            if( n / i == i){
                ans.push_back(i);
            }
            else{
                ans.push_back(i);
                ans.push_back(n/i);
            }
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    ll d = 1e13,r,t;
    for(ll i:ans){
        for(ll j:ans){
            if(i*j==n&&abs(i-j)<d){
                r=i;
                t=j;
                d=abs(i-j);
            }
        }
    }
    cout<<fixed<<setprecision(0)<<r-1+t-1<<endl;
    return 0;
}

Measured memory_bytes: 384
#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)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[20][20];
ll score[(1 << 16) + 3];
ll dp[(1 << 16) + 3];
void solve() {
    cin >> n;
    rep(i, n) rep(j, n) cin >> a[i][j];

    rep(s, 1 << n) {
        ll res = 0;
        rep(i, n) loop(j, i + 1, n) {
            if (((s >> i) & 1) == 1 && ((s >> j) & 1) == 1) res += a[i][j];
        }
        score[s] = res;
    }

    rep(s, 1 << n) {
        auto unused = s ^ ((1 << n) - 1);
        for (int ss = unused; ss > 0; ss = (ss - 1) & unused) {
            if (!(ss > s)) break;
            maxs(dp[s | ss], dp[s] + score[ss]);
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 1408
H, W = map(int, input().split())
T = [[] for i in range(H)]
for i in range(H):
    a = input()
    T[i] = a

S = []
for i in range(H):
    if T[i] == "." * W:
        continue
    else:
        S.append(list(T[i]))

m = len(S)
Z = [[] for i in range(m)]
for i in range(W):
    flag = False
    for j in range(m):
        if S[j][i] == "#":
            break
        if j == m - 1:
            flag = True
    if flag:
        continue
    else:
        for j in range(m):
            Z[j].append(S[j][i])

for i in range(m):
    print("".join(Z[i]))

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int even = 0, odd = 0;
    for (auto &&x : a)
    {
        if (x % 2)
            even++;
        else
            odd++;
    }

    bool can = even % 2 == 0;
    cout << (can ? "YES" : "NO") << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) a[i] = in();
    FOR(i,k,n-1){
        cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 4840
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

template<int N, int M>
class ModFact {
    int inv[N+1];
    int fact[N+1];
public:
    constexpr ModFact() : fact() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < N; i++) {
            f = f*(i+1)%M;
            fact[i+1] = f;
        }
        f = power(f, M-2);
        for (int i = N-1; i >= 0; i--) {
            inv[i] = fact[i] * f % M;
            f = f * (i+1) % M;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}

	int getfact(int n) {
		return fact[n];
	}
    
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int MOD = 1000000007;

ModFact<100000, MOD> fact;

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        ans += a * d % MOD;
    }
    printf("%lld\n", ((ans%MOD)*fact.getfact(N-1))%MOD);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int s,a;
int main()
{
    cin>>s;
    while (s>0)
    {
        if (s%10==9) 
        {
            cout<<"Yes";
            return 0;
        }
        s/=10;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// Aizu Vol-1 0125: Day Count
// 2017.8.1

#include <stdio.h>
#include <stdlib.h>

int ut2jd(int year, int month, int day)
{
	int j;

	if (month <= 2) year--, month += 12;
	j = year / 4 + 3 - year / 100 + year / 400;
	j += 1720994L + year * 365 + (month + 1) * 30 + (month + 1) * 3 / 5 + day;
	return j;
}

int main()
{
	int y1, m1, d1, y2, m2, d2;

	while (1) {
		scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
		if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;
		printf("%d\n", ut2jd(y2, m2, d2) - ut2jd(y1, m1, d1));
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

int main() {
	int n,num,b;
	int a=1;
	std::cin >> n;
	b=n;
	int list[n];
	while(a<=n){
		std::cin >> num;
		list[a]=num;
		a++;
	}
	while(a>=n && b>=2){
		std::cout << list[b] << " ";
		b=b-1;
	}
	if(b==1){
		std::cout << list[1] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3080
import sys
import Queue

n = int(raw_input())

graph = dict()
color = [-1 for i in range(0, n)]
for i in range(0, n - 1):
    u, v, w = map(int, raw_input().split(" "))
    if (u - 1) in graph:
        graph[u - 1].append((v-1, w))
    else:
        graph[u - 1] = [(v-1, w)]

    if (v - 1) in graph:
        graph[v - 1].append((u - 1, w))
    else:
        graph[v - 1] = [(u - 1, w)]

# for start, value_list in graph.items():
#     for end, weight in value_list:
#         print("%s -> %d (%d)" % (start, end, weight))

queue = Queue.Queue()
sum = 0
next_check = 0

while True:
    if sum >= n:
        break

    for i in range(next_check, n):
        if color[i] < 0:
            queue.put(i)
            color[i] = 0
            sum += 1
            next_check = i
            break

    while True:
        if queue.empty():
            break

        current_node = queue.get()
        if current_node in graph:
            for end, weight in graph[current_node]:
                if color[end] < 0:
                    color[end] = (color[current_node] + weight % 2) % 2
                    queue.put(end)
                    sum += 1

for node in range(0, n):
    print(color[node])


Measured memory_bytes: 49172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=pow(2,60);
using vec = vector<vector<int>>;

bool chmax(in &a,in b){if(a<b){a=b;return 1;}return 0;}

int main(){
in n,w;
  cin>>n>>w;
 vector<in> s(n);
  vector<in> t(n);
  rep(i,n){cin>>s[i]>>t[i];}
  
  in dp[110][100010];
  rep(i,110)rep(j,100010) dp[i][j]=0ll;
  
  rep(i,100010) dp[0][i]=0;
  bool x;
  
  for(in i=1ll;i<=n;i++){
     rep(j,w+1ll){
        x=chmax(dp[i][j],dp[i-1][j]);
       if(j-s[i-1]>=0ll) x=chmax(dp[i][j],dp[i-1][j-s[i-1]]+t[i-1]);
     }
  }
  cout<<dp[n][w];
}


Measured memory_bytes: 86144