akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >>p.second ;
    return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
    rep(i, v.size()) {
        is >> v[i];
    }
    return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int q;
    int ans=0;
    cin >>q;
	int l, r;
	vector<bool> dis(100010,false);
	dis[0] = true;
	dis[1] = true;
	Vi sum(100010, 0);
    rep(i,100010){
        if(dis[i]){
			continue;
		}
	//	clog << i << endl;
		for (int j = i* 2; j < 100010;j+=i){
			dis[j] = true;
		}
    }
	for (int i = 0; i < 100010;i++){
        if(i%2==1){
            if(dis[i]==false and dis[(i+1)/2]==false){
				sum[i]++;
			}
        }
        if(i!=0){
			sum[i] += sum[i - 1];
		}
    } 
    rep(i, q) {
			cin >> l >> r;
		    cout << sum[r] - sum[l-1] << endl;
		//    for (int j = l - 1; j < r + 1;j++){
		//	    clog << sum[j] << " ";
		  //  }
	//	    clog << endl;
	}
//	cout<<ans<<endl;
}

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

int index(char c){
	return (int)c - 48;
}

int num(vector<int> v){
	int total = 0;
	int n = 1;
	for(vector<int>::const_iterator iter = v.begin();
		iter != v.end(); iter++)
	{
		total += *iter * n;
		n = n * 10;
	}
	return total;
}

int rnum(vector<int> v){
	int total = 0;
	int n = 1;
	for(vector<int>::const_reverse_iterator iter = v.rbegin();
		iter != v.rend(); iter++)
	{
		total += *iter * n;
		n = n*10;
	}
	return total;
}
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		vector<int> vi;
		char c;
		for(int j = 0; j < 8; j++){
			cin >> c;
			vi.push_back(index(c));
		}
		sort(vi.begin(), vi.end());
		int max;
		int min;
		max = num(vi);
		min = rnum(vi);
		cout << max - min << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = gets.to_i
a = gets.chomp.split(" ", n).map(&:to_i)

b = a.group_by{|i| i}.
  map{|j| [j[0], j[1].length]}.to_h

combi = Hash.new
b.each do |k, v|
  if !combi.has_key? v
    combi[v] = v * (v - 1) / 2
  end
  if !combi.has_key? v - 1
    combi[v-1] = (v - 1) * (v - 2) / 2
  end
end

max = 0
b.each do |_, v|
  max += combi[v]
end

ans = a.map do |i|
  max - combi[b[i]] + combi[b[i] - 1]
end

print "#{ans.join("\n")}\n"

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,w;
	cin>>n>>w;
	vector<pair<ll,ll>>v(n+2);
	vector<vector<ll>> dp(n+2,vector<ll>(w+2));
	for(ll i=1;i<n+1;i++) {
		cin>>v.at(i).first>>v.at(i).second;
	}
	for(ll i=0;i<n+1;i++){
		for(ll j=0;j<w+1;j++){
			if(i==0){
				dp[i][j]=0;
			}else{
				if( j>=v.at(i).first ){
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-v.at(i).first]+v.at(i).second);
				}else {
					dp[i][j]=dp[i-1][j];
				}
			}
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}


Measured memory_bytes: 81024
A = []
for i in range(5):
    A.append(int(input()))
k = int(input())
flag = 0
for i in range(5):
    for j in range(i+1 ,5):
        if abs(A[i]- A[j]) > k:
            flag = 1

if flag == 0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

void countup(unordered_map<ll, vector<ll>>& tree, vector<ll>& counter, ll prev, ll next)
{
    counter[next] += counter[prev];
    for(auto elem:tree[next])
    {
		if(elem==prev)continue;
		countup(tree, counter, next, elem);
	}
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N,Q;
    cin >> N >> Q;
    unordered_map<ll, vector<ll>> tree;
    vector<ll> counter(N+1);

    for(size_t i=1;i<=N-1; i++)
    {
        ll a,b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    for(size_t i=0;i<Q; i++)
    {
        long p, x;
        cin >> p >> x;
        counter[p] += x;
    }
    countup(tree, counter, 0L, 1L);
    for(size_t i=1;i<=N; i++)
    {
        cout << counter[i] << " ";
    }
    cout << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 34120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		long s=0;
		for(int i=1; i<=N; i++) {
			if(i%3==0 && i%5==0) continue;
			if(i%3==0) continue;
			if(i%5==0) continue;
			s+=i;
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 35804
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#define EQ(x,y) (abs((x)-(y))<EPS)
#define LE(x,y) ((x)-(y) < +EPS)

#include <complex>
typedef complex<double> P;
typedef vector<P> vp;

P rotate(P t, P p, double r) {
	double ta = cos(r)*(t.real()-p.real())-sin(r)*(t.imag()-p.imag())+p.real();
	double tb = sin(r)*(t.real()-p.real())+cos(r)*(t.imag()-p.imag())+p.imag();
	return P(ta, tb);
}

double to_radian(double degree) {
	return degree*PI/180;
}

int main() {
	int N;
	while(cin >> N, N) {
		vp points(N);
		double X, Y;
		REP(i, N) {
			cin >> X >> Y;
			points[i] = P(X, Y);
		}

		int ans = 0;
		REP(i, N) {
			FOR(j, i+1, N-1) {
				P a = points[i], b = points[j];
				if(LE(abs(a-b), 2.0)) {
					P m = P((a.real()+b.real())/2, (a.imag()+b.imag())/2);
					double l = abs(a-m);
					double d = sqrt(1-l*l);
					double c = l-d;
					P t = P((d*a.real()+c*m.real())/(c+d), (d*a.imag()+c*m.imag())/(c+d));
					P p1 = rotate(t, m, to_radian(90));
					int tmp1 = 0;
					REP(k, N) {
						if(LE(abs(p1-points[k]), 1.0)) {
							tmp1++;
						}
					}
					ans = max(ans, tmp1);
					P p2 = rotate(t, m, to_radian(-90));
					int tmp2 = 0;
					REP(k, N) {
						if(LE(abs(p2-points[k]), 1.0)) {
							tmp2++;
						}
					}
					ans = max(ans, tmp2);
				}
			}
		}

		if(N <= 2 && ans == 0) {
			cout << 1 << endl;	
		} else {
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;

double get_percent(int water, int sugar){
  return (100.0*sugar)/(water+sugar);
}
int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  // percent is maximized + keeps ratio + under f
  double max = -1;
  pair<int, int> max_pair;
  for (int i=0; i*a*100<=f; i++){
    for (int j=0; i*a*100+j*b*100<=f; j++){
      for (int k=0; i*a*100+j*b*100+k*c<=f; k++){
        for (int l=0; i*a*100+j*b*100+k*c+l*d<=f; l++){
          int water = a*i+b*j;
          int sugar = c*k+d*l;
          int result = water*100+sugar;
          if (result > f){
            continue;
          }
          if (sugar > e*water){
            continue;
          }
          double ratio = get_percent(water*100, sugar);
          if (ratio > max){
            max = ratio;
            max_pair = make_pair(result, sugar);
          }
        }
      }
    }
  }
  cout << max_pair.first << " " << max_pair.second;
  return 0;
}

Measured memory_bytes: 256
S = input()

L = 0
R = 0
p = 0
ans = [0 for _ in range(len(S))]

for p in range(len(S)):
    if L > 0 and S[p] == 'R':
        tmp = (R + L) // 2
        if (R + L) % 2 == 0:
            ans[p - L - 1] = tmp
            ans[p - L] = tmp
        else:
            if R % 2 == 0:
                ans[p - L - 1] = tmp
                ans[p - L] = tmp + 1
            else:
                ans[p - L - 1] = tmp + 1
                ans[p - L] = tmp
        R = 0
        L = 0
    if S[p] == 'R':
        R += 1
    else:
        L += 1

p = len(S)
tmp = (R + L) // 2
if (R + L) % 2 == 0:
    ans[p - L - 1] = tmp
    ans[p - L] = tmp
else:
    if R % 2 == 0:
        ans[p - L - 1] = tmp
        ans[p - L] = tmp + 1
    else:
        ans[p - L - 1] = tmp + 1
        ans[p - L] = tmp

for a in ans:
    print(a, end= ' ')
print()


Measured memory_bytes: 4876
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
ll qry(ll x)
{
	cout<<"? "<<x<<endl;
	string g; cin>>g;
	return g[0]=='Y';
}
int main()
{
	int s=qry(1e9);
	if(s)
		for(int i=2;;i*=10)
			if(qry(i))
			{
				cout<<"! "<<i/2<<endl;
				return 0;
			}
	ll p;
	for(ll g=0,s=1;;s*=10,++g)
		if(!qry(s)) {p=s/10; break;}
	ll l=p,r=p*10-1;
	while(l<r)
	{
		ll m=(l+r)>>1;
		if(!qry(m*10)) l=m+1; else r=m;
	}
	cout<<"! "<<l<<endl;
}


Measured memory_bytes: 596
local n, m = io.read("*n", "*n")
local parent = {}
for i = 1, n do
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local a, b = io.read("*n", "*n")
  local ra, rb = uf_findroot(a), uf_findroot(b)
  parent[rb], parent[b] = ra, ra
end
local groups = {}
local g1 = uf_findroot(1)
local g2 = uf_findroot(2)
groups[g1] = 1
groups[g2] = 1
for i = 3, n do
  local g = uf_findroot(i)
  if not groups[g] then groups[g] = 1
  else groups[g] = groups[g] + 1
  end
end
local c1, c2 = groups[g1], groups[g2]
local rem = 0
for k, v in pairs(groups) do
  if k ~= g1 and k ~= g2 then
    rem = rem + v
  end
end
if c1 < c2 then
  c2 = c2 + rem
else
  c1 = c1 + rem
end
print(math.floor(c1 * (c1 - 1) / 2) + math.floor(c2 * (c2 - 1) / 2) - m)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,M;
  cin>>N>>M;
  vector<int>x(M),y(M);
  for(int i=0;i<M;i++)cin>>x[i]>>y[i],x[i]--,y[i]--;

  vector<bool>red(N,false);
  red[0]=true;
  vector<int>ball(N,1);

  for(int i=0;i<M;i++){
    if(red[x[i]])red[y[i]]=true;
    ball[x[i]]--;
    ball[y[i]]++;
    if(ball[x[i]]==0)red[x[i]]=false;
  }

  int ans=0;
  for(auto it:red)ans+=it;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1408
/*
**    A fish with his mouth closed never gets caught.
**    -- Tony Accardo
**
**    Author : Dhiraj Govindvira
**      Date : 05-Sep-2020 ~ Saturday
**      Time : 06:41:16 PM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin >> n;
    
    ll sm = 0;
    map<ll, ll> fre;
    loop(n)
    {
        ll x;
        cin >> x;
        fre[x]++;
        sm += x;
    }

    ll q;
    cin >> q;
    loop(q)
    {
        ll x, y;
        cin >> x >> y;
        fre[y] += fre[x];
        sm -= fre[x] * (x - y);
        fre[x] = 0;
        cout << sm << endl;
    }
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 9424
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))

# ===CODE===
tMOD = 998244353


def main():
    n = ni()
    dic = {chr(i): INF for i in range(97, 97 + 26 )}
    for _ in range(n):
        s = list(input())
        c = collections.Counter(s)
        for k, v in dic.items():
            if k in c.keys():
                dic[k] = min(dic[k], c[k])
            else:
                dic[k] = 0

    word = list(dic.items())
    word.sort()

    ans = ""
    for k, v in word:
        if v < INF:
            ans += k * v

    print(ans)

    tmp = 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include<iostream>
#include<vector>
#include<string>
using namespace std;
// Problem https://atcoder.jp/contests/abc088/tasks/abc088_c
// Referrence https://img.atcoder.jp/abc088/editorial.pdf

string solver(vector<vector<int>> infoGrid){
    string result="No";
    int a0,a1,a2,b0,b1,b2;// a0を固定して得られると予測される値
    int c11eq,c12eq,c21eq,c22eq;// 上記値とinfogridの差分
    a0=0;
    b0=infoGrid.at(0).at(0)-a0;
    b1=infoGrid.at(0).at(1)-a0;
    b2=infoGrid.at(0).at(2)-a0;
    a1=infoGrid.at(1).at(0)-b0;
    a2=infoGrid.at(2).at(0)-b0;
    c11eq=infoGrid.at(1).at(1)-(a1+b1);
    c12eq=infoGrid.at(1).at(2)-(a1+b2);
    c21eq=infoGrid.at(2).at(1)-(a2+b1);
    c22eq=infoGrid.at(2).at(2)-(a2+b2);
    if(c11eq == 0 and c12eq == 0 and c21eq == 0 and c22eq == 0){
        result="Yes";
    }

    return result;
}

int main(void){
    string answer;
    vector<vector<int>> cij(3,vector<int>(3,0));

    for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
            cin >> cij.at(j).at(k);
        }
    }
    answer = solver(cij);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

ans = 0

for i in range(1, n+1):
    if i % 2 == 0:
        continue
    yakusuu = 0
    for j in range(1, i+1):
        if i % j == 0:
            yakusuu += 1
    if yakusuu == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for (i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int j, i, v;
  for (i=1; i<N; i++){
    v = A[i];
    j = i-1;
    while (j>=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A,N);
  }
}

int main(){
  int N,i,j;
  int A[100];

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

  trace(A,N);
  insertionSort(A,N);

  return 0;
}

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

int main() {
  int N;
    cin >> N;
  vector<long long> vec(N + 1, 0);
  vec.at(0) = 2;
    vec.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    vec.at(i) = vec.at(i - 1) + vec.at(i - 2);
  }
  cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int n, o;
	char string[255];
	int character[6]={0};
	scanf("%d", &n);
	for(int i = 0; i<n; i++){
		scanf("%s", &string);
		if(o=strcmp (string, "AC")==0){
			++character[1];
		}
		if(o=strcmp (string, "WA")==0){
			++character[2];
		}
		if(o=strcmp (string, "TLE")==0){
			++character[3];
		}	
		if(o=strcmp (string, "RE")==0){
			++character[4];
		}
	}
	printf("AC x %d\n", character[1]);
	printf("WA x %d\n", character[2]);
	printf("TLE x %d\n", character[3]);
	printf("RE x %d\n", character[4]);
	return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x=0; char ch=gc(); bool positive=1;
	for (;!isdigit(ch);ch=gc())if(ch=='-')positive=0;
	for (;isdigit(ch);ch=gc())x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(int a){
    if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	if(a<0){
		a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=3,mod=1000000007;
struct matrix{
	int a[N][N];
	inline int* operator [] (int x){
        return a[x];
    }
	void clear(){
    	memset(a,0,sizeof(a));
	}
}zs,ans,md;
matrix operator *(matrix a,matrix b){
	matrix tmp; tmp.clear();
	for(int k=0;k<3;k++){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				tmp[i][j]=(tmp[i][j]+(ll)a[i][k]*b[k][j])%mod;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix zs,int k){
	matrix ans; ans.clear(); for(int i=0;i<3;i++)ans[i][i]=1;
	for(;k;k>>=1){
		if(k&1)ans=ans*zs;
		zs=zs*zs;
	}
	return ans;
}
int n,m,a[100005];
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++)a[i]=read()+1;
	zs[0][0]=1; zs[0][1]=2;
	zs[0][2]=1; zs[1][1]=1; zs[1][2]=1;
	zs[2][0]=1; zs[2][1]=2; zs[2][2]=2;
	md=zs; md[2][0]=md[2][1]=0; md[2][2]=1;
	for(int i=0;i<3;i++)ans[i][i]=1;
	for(int i=1;i<=m;i++){
		ans=ans*ksm(zs,a[i]-a[i-1]-1);
		ans=ans*md;
	}
	//cout<<ans[0][0]<<" "<<ans[0][1]<<" "<<ans[0][2]<<endl;
	ans=ans*ksm(zs,n-a[m]);
	cout<<ans[0][2]<<endl;
}


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

typedef long long int llint;

int solve(int now, int pnt, int bit);

int d, g;
int p[11], c[11];

int main()
{
  cin>> d >> g;

  for(int i = 0; i < d; i++) cin>> p[i] >> c[i];

  cout<< solve(0, 0, 0) <<endl;
  
  return 0;
}

int solve(int now, int pnt, int bit)
{
  if(pnt >= g) return 0;
  
  int rec = 10000000;

  for(int i = d - 1; i >= 0; i--) {
    if(bit & (1 << i)) continue;
    for(int j = 1; j <= p[i]; j++) {
      if(pnt + (i + 1) * 100 * j >= g) {
	rec = j;
	break;
      }
    }
    break;
  }
  
  if(now < d) {
    rec = min(rec,
	      min(solve(now + 1, pnt + c[now] + (now + 1) * p[now] * 100, bit | (1 << now)) + p[now],
		  solve(now + 1, pnt, bit)));
  }
  
  return rec;
}


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

using namespace std;

int main() {
  int a,b,c; cin >> a >> b >>c;
  long long cnt=0,ans=0;
  while(cnt<c){
    ans++;
    cnt+=a;
    if(ans%7==0) cnt+=b;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {

  static int calc(int a, int b) {
    if(a == b)
      return 1;
    else
      return 0;
  }

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(calc(a, b) == 1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    
    string s,t;
    uint64_t max,temp;
    max = 0;
    temp = 0;
    cin >> s >> t;
    for(uint64_t i=0; i < (s.size()-t.size()+1); i++){
        for(uint64_t j=0; j < t.size();j++){
            if(s[i+j]==t[j]){
                temp++;
            }
        }
        if(temp>max){
            max = temp;
        }
        temp = 0;
    }
    
    cout << (t.size() - max) << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int N, K;
vector<int> G[2010];

int dfs(int u, int p, int d) {
    int ret = 1;
    if (d != K/2) {
        for (int v: G[u]) {
            if (v == p) continue;
            ret += dfs(v, u, d+1);
        }
    }
    return ret;
}

int solve() {
    int ret = 0;
    if (K % 2 == 0) {
        for (int u = 1; u <= N; u++)
            ret = max(ret, dfs(u, -1, 0));
    } else {
        for (int u = 1; u <= N; u++) {
            for (int v: G[u])
                ret = max(ret, dfs(u, v, 0)+dfs(v, u, 0));
        }
    }
    return N-ret;
}

int main() {
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N-1; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    int ans = solve();
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[n/2] - d[(n-1)/2] << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

c = 0
for i in range(N):
    s = min(B[i],A[i])
    c += s
    B[i] = B[i]-s
    A[i] = A[i]-s
    t = min(B[i], A[i+1])
    c += t
    B[i] = B[i]-t
    A[i+1] = A[i+1]-t

print(c)

Measured memory_bytes: 18624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 
int main(){
    string s;
    cin >> s;

    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else if(s == "Rainy"){
        cout << "Sunny" << endl;
    }
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> G(N + 10,0);
  int r,l;
  for(int i=0;i<M;i++){
    cin>>r>>l;
    G[r]++;
    G[l+1]--;
  }
  int cnt=0;
  for(int i=0;i<N+1;i++){
    G[i+1]+=G[i];
    if(G[i]==M)
      cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

count = 0
edge = []

i = 0
for _ in range(n-1):
    if a[i] == a[i+1]:
        count = count + 1
        edge.append(a[i])
        i = i + 1
        if count == 2:
            break
    i = i + 1

s = edge[0]*edge[1] if count == 2 else 0
print(s)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int searchY [] = {-1,-1,0,1,1,1,0,-1};
    int searchX [] = {0,1,1,1,0,-1,-1,-1};
    int h,w;
    cin >> h >> w;
    string S;
    string squares [h][w];
    for(int i = 0;i < h;i++){
        cin >> S;
        for(int j = 0;j < w;j++){
            squares[i][j] = S[j];
        }
    }
    string ans;
    for(int i = 0;i < h;i++){
        ans = "";
        for(int j = 0;j < w;j++){
            if(squares[i][j] == "."){
                int cnt = 0;
                for(int k = 0;k < 8;k++){
                    if(i+searchY[k] >= 0 && i + searchY[k] < h && j + searchX[k] >= 0 && j + searchX[k] < w){
                        if(squares[i+searchY[k]][j+searchX[k]] == "#"){
                            cnt++;
                        }
                    }
                }
                ans += to_string(cnt);
            }else{
                ans += "#";
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<utility>
#include<vector>
#include<stack>
#include<algorithm>
#include<cmath>
#include<stdio.h>


using namespace std;

int main(){


	int N,T,c[1010],t[1010];
	int ans=100000;

	cin >>N>>T;

	for(int i=0; i<N;i++){

		cin >> c[i]>>t[i];



		if( t[i] <=T ){
			ans=min(ans,c[i]);
		}
		//cout <<t[i] <<" " <<c[i] <<" " <<ans<<endl;
	}


	
	if(ans==100000)cout <<"TLE" <<endl;
	else cout <<ans<<endl;


}

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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    int n;
    cin>>n;
    int count=0;
    while(n)
    {
        n=n/2;
        count++;
    }
    int sum=std::pow(2,count)-1;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
  n <- readLn
  [xs, ys] <- transpose . map (map read . words) <$> replicateM n getLine
  let
    a = sum $ map (solve xs ys) $ permutations [0..n-1]
    b = fromIntegral $ product [1..n]
  print (a / b :: Double)

solve :: [Double] -> [Double] -> [Int] -> Double
solve _ _ [_] = 0
solve xs ys (i:j:ps) = sqrt ((xs!!i - xs!!j)^2 + (ys!!i - ys!!j)^2) + solve xs ys (j:ps)


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll H, W;
ll res = 1e18;

void check(ll H, ll W) {
	ll Sa = 0, Sb = 0, Sc = 0;
	rep(h, 1, H) {
		Sa = h * W;
		ll w = W / 2;
		Sb = (H - h) * w;
		Sc = (H - h) * (W - w);
		ll max_v = max(Sa, max(Sb, Sc));
		ll min_v = min(Sa, min(Sb, Sc));
		res = min(res, max_v - min_v);
	}

	rep(h, 1, H) {
		Sa = h * W;
		ll hb = (H - h) / 2;
		Sb = hb * W;
		Sc = (H - h - hb) * W;
		ll max_v = max(Sa, max(Sb, Sc));
		ll min_v = min(Sa, min(Sb, Sc));
		res = min(res, max_v - min_v);
	}

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

	cin >> H >> W;

	check(H, W);
	check(W, H);

	cout << res << endl;


}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int c=0,a=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
           {
               c++;
                a=max(a,c);
           }
        else
           c=0;
    }
cout<<max(a,c)<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        vector<pair<int,int> > v;
        for(int i = 0; i < 2; ++i) {
            int N;
            cin >> N;
            if(!N) goto end;
            while(N--) {
                int H, R;
                cin >> H >> R;
                v.push_back(make_pair(H, R));
            }
        }
        sort(v.begin(), v.end());
        const int N = v.size();
        int ans = 1;
        vector<int> dp(N, 1);
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < i; ++j) {
                if(v[j].first < v[i].first && v[j].second < v[i].second) {
                    dp[i] = max(dp[i], dp[j]+1);
                }
            }
            ans = max(ans, dp[i]);
        }
        cout << ans << endl;
    }
end:
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> tree(n);
  for (int i=0; i<n; ++ i) cin >> tree[i];
  sort(tree.begin(),tree.end());
  int ans = tree[n-1];
  for(int j=0; j<=n-k; j++){
    ans = min(ans,tree[j+k-1]-tree[j]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
d=int(input())
C=[int(i) for i in input().split()]
s=[[int(i) for i in input().split()] for q in range(d)]

sco=0
L=[0 for i in range(26)]
ans=[]

#calc
for i in range(d):
    mayou=0
    est=s[i][0]+C[0]*(i+1-L[0])
    for p in range(1,26):
        if s[i][p]+C[p]*(i+1-L[p]) > est:
            mayou=p
            est=s[i][p]+C[p]*(i+1-L[p])
    ans.append(mayou)
    print(mayou+1) #output

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> v;
    int i, j, cnt = 0, ch = 0;
    for(i = 0; i < n; i++) {
        if(s[i] == '1') {
            if(i == 0 || s[i - 1] == s[i])
                cnt++;
            else {
                v.push_back(cnt);
                cnt = 1;
            }
        } else {
            if(i == 0 || s[i - 1] == s[i])
                cnt++;
            else {
                v.push_back(cnt);
                cnt = 1;
                ch++;
            }
        }
    }
    v.push_back(cnt);
    if(s.back() == '0') ch++;
    int one = 0;
    if(s[0] == '0') one = 1;
    vector<int> sum;
    sum.push_back(0);
    for(i = 0; i < v.size(); i++) {
        sum.push_back(sum[i] + v[i]);
    }
    int ret = 0;
    for(i = 0; 2 * k + i < sum.size(); i++) {
        if(one) {
            if(i % 2 == 0) {
                ret = max(sum[2 * k + i] - sum[i], ret);
            } else {
                ret = max(sum[min(2 * k + i + 1, (int)sum.size() - 1)] - sum[i], ret);
            }
        } else {
            if(i % 2 == 1) {
                ret = max(sum[2 * k + i] - sum[i], ret);
            } else {
                ret = max(sum[min(2 * k + i + 1, (int)sum.size() - 1)] - sum[i], ret);
            }
        }
    }
    if(ch <= k) ret = sum.back();
    cout << ret << endl;
    /*for(int x : sum) {
        cout << x << " ";
    }
    cout << endl;*/
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <climits>
using namespace std;
using ll = long long;
static const ll RADIX = 'z' - 'a' + 1;

string dog_name(ll n) {
    if (n < RADIX) return string(1, static_cast<char>('a' + n));

    return dog_name(n / RADIX - 1) +
           string(1, static_cast<char>('a' + (n % RADIX)));
}

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

    ll n;
    cin >> n;
    cout << dog_name(n - 1) << '\n';

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>                                         
using namespace std;
int main(){
    int i,j,H,W;

    while(cin>>H>>W&&!(H==0&&W==0)){
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                cout<<((i==0||i==H-1||j==0||j==W-1)?"#":".");      
            }
            cout<<"\n";
        }
        cout<<"\n";
    }   

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string w[n+1];
	w[0]="";
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
		
	}
	for(int i=1;i<=n;i++)
	{
		if(i!=1)
		{
			if(w[i][0]!=w[i-1][w[i-1].size()-1])
			{
				cout<<"No"<<endl;
				return 0;
			}
			for(int j=1;j<i;j++)
			   if(w[j]==w[i])
			   {
			   	  cout<<"No"<<endl;
				  return 0;
			   }
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> //cout
#include <cstring> //c
#include <vector> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
    long A, B, C, K;
    cin >> A >> B >> C >> K;

    if(A >= K){//A
        cout << K << endl;
    }
    else if(A + B >= K){//A+B
        cout << A << endl;
    }
    else{//a+B+C
        cout << A - (K - A - B) << endl;
    }
}


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;
int n, a[N], dp[100][100], was[100][100];
int get(int i,int j){
	if(was[i][j])
		return dp[i][j];
	was[i][j] = 1;
	if(a[i] <= j){
		dp[i][j] = 1;
		return dp[i][j];
	}
	if(i > 0)
		get(i - 1, j);
	get(i, j + 1);	
	if(i > 0 && dp[i - 1][j] == 0)
		dp[i][j] = 1;
	if(dp[i][j + 1] == 0)
		dp[i][j] = 1;
	return dp[i][j];
}
int main(){
	srand(time(0));

	n = 6;

	cin >> n;
	
	for(int i = 1; i <= n; i++)
		//a[i] = rand()%10 + 1 ;
		cin >> a[i];

	sort(a + 1, a + n + 1);
	
	int ans = 0;
	for(int i = n; i >= 0; i--){
		int x = n - i;
        if(x < a[i]){
			ans = a[i] - x + 1;
			//cerr << i << " " << x << " "<< a[i] << endl;
		}
        if(x == a[i]){
			int z = 0;
			for(int j = 0; j <= i; j++)
            	if(a[j] == a[i])
          	       	z++;
			if( (z % 2 == 0) && a[i] < a[i + 1] ){
				if( (a[i + 1] - a[i])&1 )
					ans = z + 1;
				else
					ans = z;		 
			}else
				ans = z;

		}
	}
	ans&=1;
	
	//cout << ans << endl;
    
    if(ans == 1)                    
		cout << "First" << endl;
    else
    	cout << "Second" << endl;
	
	return 0;
	cout << get(n,0) << endl;
	//return 0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= 20; j++){
			if(a[i] == j)
				cout<<"%";
            else
            	cout<<get(i,j);
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

int
cmp(const void *a, const void *b)
{
    return *(long *)a - *(long *)b;
}

void
solver(long n, long *a)
{
    long i;
    long p;

    qsort(a, n, sizeof(long), cmp);

    p = a[0];
    for(i = 1; i < n; i++) {
        if(p == a[i]) {
            printf("NO\n");
            return;
        }
        p = a[i];
    }
    printf("YES\n");
}

int
main(int argc, char *argv[])
{
    long N;
    long A[200000];
    long i;
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    scanf("%ld", &N);
    for(i = 0; i < N; i++)
        scanf("%ld", A + i);
    solver(N, A);
    return 0;
}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,pow2=0,sum=0,res=(1<<29);
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		pow2+=x*x;
		sum+=x;
	}
	for(int i=0;i<=100;i++)res=min(res,pow2-2*i*sum+i*i*n);
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    string s;cin>>s;

    int ans=0;
    for(int i=1;i<n;i++){
        int cnt=0;
        for(char c='a';c<='z';c++){
            bool left=false,right=false;
            for(int j=0;j<i;j++){
                if(s[j]==c) left = true;
            }
            for(int j=i;j<n;j++){
                if(s[j]==c) right = true;
            }
            if(left&&right) cnt++;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
    int ue, shita , migi, hidari, oku, temae;
    int men[7];
}Dice;

Dice initialization(Dice);
Dice North(Dice);
Dice East(Dice);
Dice South(Dice);
Dice West(Dice);
Dice TurnDice(Dice);
int CheckDice(Dice, Dice); //ある面でサイコロが同じかどうか
int Allsurface(Dice, Dice); //全ての面でチェック


int main() {
    int i, j, n, check = 0, flag = 0;
    Dice d[100];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        d[i] =  initialization(d[i]);
        for (j = 1; j <= 6; j++) {
            scanf("%d", &d[i].men[j]);
        }
    }

    for (i = 0; i < n-1; i++) {
        if (flag == 1) break;

        for (j = i+1; j < n; j++) {
            flag = Allsurface(d[i], d[j]);
            if (flag == 1) break;
        }
    }
    
    if (flag == 1) printf("No\n");
    else if (flag == 0) printf("Yes\n");
    

    return 0;
}


Dice initialization(Dice d) {
    d.ue = 1;
    d.temae = 2;
    d.migi = 3;
    d.hidari = 4;
    d.oku = 5;
    d.shita = 6;

    return d;
}

Dice North(Dice d) {
    int temp;

    temp = d.ue;
    d.ue = d.temae;
    d.temae = d.shita;
    d.shita = d.oku;
    d.oku = temp;

    return d;
}

Dice East(Dice d) {
    int temp;

    temp = d.ue;
    d.ue = d.hidari;
    d.hidari = d.shita;
    d.shita = d.migi;
    d.migi = temp;

    return d;
}

Dice South(Dice d) {
    int temp;

    temp = d.ue;
    d.ue = d.oku;
    d.oku = d.shita;
    d.shita = d.temae;
    d.temae = temp;

    return d;
}

Dice West(Dice d) {
    int temp;

    temp = d.ue;
    d.ue = d.migi;
    d.migi = d.shita;
    d.shita = d.hidari;
    d.hidari = temp;

    return d;
}

Dice TurnDice(Dice d) {
    int temp;

    temp = d.temae;
    d.temae = d.migi;
    d.migi = d.oku;
    d.oku = d.hidari;
    d.hidari = temp;
    
    return d;
}

int CheckDice(Dice d1, Dice d2) {
    int i, count = 0;

    if (d1.men[d1.ue] != d2.men[d2.ue]\
     || d1.men[d1.shita] != d2.men[d2.shita]) return 0;

    while(1) {
        if (count == 4) {
            return 0;
        }

        if (d1.men[d1.temae] == d2.men[d2.temae]\
        && d1.men[d1.migi] == d2.men[d2.migi]\
        && d1.men[d1.oku] == d2.men[d2.oku]\
        && d1.men[d1.hidari] == d2.men[d2.hidari]) {
            return 1;
        }

        d1 = TurnDice(d1);

        count++;
    }
}

int Allsurface(Dice d1, Dice d2) {
    int flag = 0;

    if (flag == 0) {
        d1 = North(d1);
        flag = CheckDice(d1, d2);
    }

    if (flag == 0) {
        d1 = initialization(d1);
        d1 = East(d1);
        flag = CheckDice(d1, d2);
    }

    if (flag == 0) {
        d1 = initialization(d1);
        d1 = South(d1);
        flag = CheckDice(d1, d2);
    }

    if (flag == 0) {
        d1 = initialization(d1);
        d1 = West(d1);
        flag = CheckDice(d1, d2);
    }

    if (flag == 0) {
        d1 = initialization(d1);
        d1 = North(d1);
        d1 = North(d1);
        flag = CheckDice(d1, d2);
    }
    return flag;
}



Measured memory_bytes: 2148
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n,m,s,t = map(int,input().split())
pathy = [{} for _ in range(n)]
paths = [{} for _ in range(n)]

import heapq
def Dijkstra(edge,start,v):
    d = [float('inf')]*v
    d[start] = 0
    pq = [(0,start)]
    heapq.heapify(pq)
    while pq:
        dist,p = heapq.heappop(pq)
        if dist > d[p]:continue
        for to,cost in edge[p].items():
            if d[to] <= dist + cost:continue
            d[to] = dist + cost
            heapq.heappush(pq, (d[to], to))
    return d

for _ in range(m):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    pathy[u][v] = a
    pathy[v][u] = a
    paths[u][v] = b
    paths[v][u] = b

dy = Dijkstra(pathy,s-1,n)
ds = Dijkstra(paths,t-1,n)
ans = [0]*n
for i in range(n)[::-1]:
    if i == n-1:
        ans[i] = dy[i] + ds[i]
    else:
        ans[i] = min(ans[i+1], dy[i]+ds[i])
print('\n'.join(str(10**15 - i) for i in ans))


Measured memory_bytes: 100220
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int X = s.nextInt();
        int N = s.nextInt();
        int P[] = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = s.nextInt();
        }
        int Q[] = new int[102];
        Arrays.sort(P);
        int p = 0;
        for (int i = 0; i <= 101; i++) {
            if (p < N) {
                if (P[p] == i) {
                    p++;
                } else {
                    Q[i] = i;
                }
            } else {
                Q[i] = i;
            }
        }
        int ans = 0;
        int d = 200;
        int d_tmp = 0;
        for (int i = 0; i <= 101; i++) {
            d_tmp = X - Q[i];
            if (d_tmp < 0) {
                d_tmp *= -1;
            }
            if (d > d_tmp) {
                d = d_tmp;
                ans = Q[i];
            }
        }
        System.out.println(ans);
        s.close();
    }
}

Measured memory_bytes: 35848
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  int64_t n,d;
  cin >> n >> d;
  if (n % (2*d +1) == 0){
    cout << n / (2*d +1) << endl;
  }else{
    cout << n / (2*d +1) +1 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
# A
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


A,B,C = na()


if A+B >= C-1:
    print(B+C)
else:
    print(B+B+A+1)








Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define x             first
#define y             second
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define PI            3.14159265358979
#define N             200005

int solve(){
    int n,k; cin>>n>>k;
    int ans=0;
    int p[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    for (int i = 0; i < k; ++i)
    {
        ans+=p[i];
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  vector<int> suretu(32);
  suretu={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; cin >> K;
  cout << suretu.at(K-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void y(){
	cout<<"yes";
}
void Y(){
	cout<<"Yes";
}
void n(){
	cout<<"no";
}
void N(){
	cout<<"No";
}
int main() {
	int num=0,max=1000000;
	char c[3];
	c[2]='0';
	cin>>c[0]>>c[1]>>c[2];
	if(c[2]!='0')
	cout<<c[2]<<c[1]<<c[0];
	else cout<<c[0]<<c[1];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int n, m, a,aa=0;
	cin >> n >> m;
	rep(i, m) {
		cin >> a;
		aa = aa + a;
	}
	aa = n -aa;
	if (aa < -1)aa = -1;
	cout << aa << endl;
	return 0;

}

Measured memory_bytes: 3632