akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		sc.close();
		System.out.println(lcm(n,a));
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static long arrayMax(long[] array) {
		long ans = Long.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}

	public static String[] arrayString(Scanner sc, int n) {
		String[] array = new String[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.next();
		}
		return array;
	}
	static String nextPermutation (String s) {

	ArrayList<Character> list = new ArrayList<>();
	for (int i=0; i<s.length(); i++) list.add(s.charAt(i));

	int pivotPos = -1;
	char pivot = 0;
	for (int i=list.size()-2; i>=0; i--) {
		if (list.get(i) < list.get(i+1)) {
			pivotPos = i;
			pivot = list.get(i);
			break;
		}
	}

	if (pivotPos==-1 && pivot==0) return "Final";

	int L = pivotPos+1, R = list.size()-1;
	int minPos = -1;
	char min = Character.MAX_VALUE;
	for (int i=R; i>=L; i--) {
		if (pivot < list.get(i)) {
			if (list.get(i) < min) {
				min = list.get(i);
				minPos = i;
			}
		}
	}

	Collections.swap(list, pivotPos, minPos);
	Collections.sort(list.subList(L, R+1));

	StringBuilder sb = new StringBuilder();
	for (int i=0; i<list.size(); i++) sb.append(list.get(i));

	return sb.toString();
}

			public static long gcd(final long[] param) {
			final int len = param.length;
			long g = gcd(param[0], param[1]);
			for (int i = 1; i < len - 1; i++) {
			g = gcd(g, param[i + 1]);
			}
			return g;
			}
			
			public static long gcd(long a, long b) {
			// a > b にする(swap)
			if (a < b) {
			a = a ^ b;
			b = a ^ b;
			a = a ^ b;
			}
			// ユークリッドの互除法
			long r = -1;
			while (r != 0) {
			r = a % b;
			a = b;
			b = r;
			}
			
			return a; // b には r=0 の値が入るため、a を返す
			}
			
			
			public static long lcm(long m, long n) {
			return m * n / gcd(m, n);
			}
}


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

using namespace std;

#define ll long long

const int N = (int)1005;

ll a[N], t[N];

main () {
  int n; scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", &t[i], &a[i]);
  }
  ll s1 = t[1];
  ll s2 = a[1];
  for (int i = 2; i <= n; i++) {
    if (t[i] < s1 || a[i] < s2) {
      ll mult = (s1 - 1) / t[i] + 1;
      ll mult1 = (s2 - 1) / a[i] + 1;
      mult = max(mult, mult1);
      t[i] *= mult;
      a[i] *= mult;
//      cout << t[i] << ' ' << a[i] << endl;
      s1 = t[i];
      s2 = a[i];
    } else {
      s1 = t[i];
      s2 = a[i];
    }
  }
  cout << s1 + s2;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[60],b[4]="ABC";
    int k=0,i,j,n;
    scanf("%d",&n);
    getchar();
    gets(a);
    for(i=0;i<n;i++)
      {
           for(j=0;j<3;j++)
            if(b[j]!=a[i+j])
                break;
        if(j==3)
            k++;
      }
    printf("%d",k);
    return 0;
}


Measured memory_bytes: 128
S = input()
L = ["A", "C", "G", "T"]

max_ = 0
cnt = 0
f = False
for n in range(len(S)):
    if (not f) and S[n] in L:
       cnt = 1
       f = True
    elif not f:
        pass
    elif f and S[n] in L:
        cnt += 1
    else:
        max_ = max(max_, cnt)
        cnt = 0
        f = False

print (max(max_, cnt))


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

int n,k;

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

	cin>>n>>k;
	int sum=0;
	REP(i,n) {
		int x; cin>>x;
		sum+=min(x,k-x)*2;
	}
	cout<<sum<<endl;

	return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
int k;
set<string> st;
void solve(){
	cin >> s;
	cin >> k;
	int n = s.size();
	
	for(int i = 0; i < n; i++){
		for(int j = 1; j+i <= n && j <= k; j++){
			st.insert(s.substr(i,j));
		}
	}
	auto ans = st.begin();
	for(int i = 1; i < k; i++){
		ans++;
	}
	cout << *ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1664
n,w=map(int,raw_input().split())
vw=[map(int,raw_input().split()) for _ in xrange(n)]
dp=[[0]*(w+1) for _ in xrange(2)]
for i in xrange(n):
    for j in xrange(w+1):
        if j<vw[i][1]:
            dp[(i+1)&1][j]=dp[i&1][j]
        else:
            dp[(i+1)&1][j]=max(dp[i&1][j],dp[i&1][j-vw[i][1]]+vw[i][0])
print(dp[n&1][w])

Measured memory_bytes: 6880
S = input().rstrip()
T = input().rstrip()

dic_s = {}
dic_t = {}

for i in range(len(S)):
    if not S[i] in dic_s.keys():
        dic_s[S[i]] = T[i]
    if not T[i] in dic_t.keys():
        dic_t[T[i]] = S[i]
    if dic_s[S[i]] != T[i] or dic_t[T[i]] != S[i]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define N 100000
int main(){
  int n,m,h[N],ma[N];
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    cin >> h[i];
    ma[i]=0;
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=h[i]>ma[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"Yes"<<ENDL;
#define sayn cout<<"No"<<ENDL;
#define sayY cout<<"YES"<<ENDL;
#define sayN cout<<"NO"<<ENDL;

typedef long long ll;
using namespace std;

int main(){
    io

    ll n; cin >> n;
 
    vector<ll> a(n+1),b(n+1),c(n+1);

    for(int i(1); i<=n; i++){
        ll x,y,z;
        cin >> x >> y >> z;
        a[i] = x;
        b[i] = y;
        c[i] = z;
    }

    vector<vector<int>> dp(n+1);
    for(int i(1); i<=n; i++){
        dp[i].resize(4);
    }

    dp[1][1] = max(a[1], max(b[1], c[1]));
    dp[1][2] = max(a[1], max(b[1], c[1]));
    dp[1][3] = max(a[1], max(b[1], c[1]));

    for(int i(2); i<=n; ++i){
        dp[i][1] = max(dp[i-1][2] + b[i], dp[i-1][3] + c[i]);
        dp[i][2] = max(dp[i-1][1] + a[i], dp[i-1][3] + c[i]);
        dp[i][3] = max(dp[i-1][1] + a[i], dp[i-1][2] + b[i]);
    }

    ll ans = max(dp[n][1], max(dp[n][2], dp[n][3]));
    cout << ans << ENDL;

    return 0;
}

Measured memory_bytes: 10984
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), a, ans = 0, tmp[] = new int[9];
		for (int i = 0; i < N; ++i) {
			a = sc.nextInt();
			if (a >= 3200) ++tmp[8];
			else ++tmp[a / 400];
		}
		sc.close();
		for (int i = 0; i < 8; ++i) {
			if (tmp[i] > 0) ++ans;
		}
		if (ans == 0) System.out.print(1);
		else System.out.print(ans);
		System.out.print(" " + (ans + tmp[8]));
	}
}

Measured memory_bytes: 25172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;


signed main(void) {
  int i,j,k,l;
  int n,w;
  cin>>n>>w;
  vi w0,w1,w2,w3;
  pii p[100];
  rep(i,n)cin>>p[i].first>>p[i].second;
  sort(p,p+n);

  rep(i,n){
    if(p[i].first-p[0].first==0)
      w0.push_back(p[i].second);
    if(p[i].first-p[0].first==1)
      w1.push_back(p[i].second);
    if(p[i].first-p[0].first==2)
      w2.push_back(p[i].second);
    if(p[i].first-p[0].first==3)
      w3.push_back(p[i].second);
  }
  w0.push_back(0);
  w1.push_back(0);
  w2.push_back(0);
  w3.push_back(0);

  sort(all(w0));
  sort(all(w1));
  sort(all(w2));
  sort(all(w3));

  if(w0.size())
    rep(i,w0.size()-1)w0[i+1]+=w0[i];
  if(w1.size())
    rep(i,w1.size()-1)w1[i+1]+=w1[i];
  if(w2.size())
    rep(i,w2.size()-1)w2[i+1]+=w2[i];
  if(w3.size())
    rep(i,w3.size()-1)w3[i+1]+=w3[i];

  ll ans=0;
  rep(i,w0.size()){
    ll sum0=w0[w0.size()-1]-w0[w0.size()-1-i];
    if(i*p[0].first>w)break;
    ans=max(ans,sum0);
    rep(j,w1.size()){
      ll sum1=w1[w1.size()-1]-w1[w1.size()-1-j];
      if(i*p[0].first+j*(p[0].first+1)>w)break;
      ans=max(ans,sum0+sum1);
      rep(k,w2.size()){
	ll sum2=w2[w2.size()-1]-w2[w2.size()-1-k];
	if(i*p[0].first+j*(p[0].first+1)+k*(p[0].first+2)>w)break;
	ans=max(ans,sum0+sum1+sum2);
	rep(l,w3.size()){
	  ll sum3=w3[w3.size()-1]-w3[w3.size()-1-l];
	  if(i*p[0].first+j*(p[0].first+1)+k*(p[0].first+2)+l*(p[0].first+3)>w)break;
	  ans=max(ans,sum0+sum1+sum2+sum3);
	}
      }
    }
  }
  cout<<ans<<endl;
}


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

int main()
{
  char ch;
  int a[26]={}, i;

  while(cin >> ch)
    {
      
      if(isalpha(ch))
	{
	  ch = tolower(ch);
	  a[ch-'a'] += 1;
	}
    }

  for(i=0;i<26;i++)
    printf("%c : %d\n", 'a'+i, a[i]);
}

Measured memory_bytes: 1128
N = int(input())
A_list = list(map(int,input().split()))

iter_num_list = []
for a in A_list:
    count = 0
    while a%2 == 0:
        a = a/2
        count += 1
    iter_num_list.append(count)
ans = sorted(iter_num_list)[0]
print(ans)

Measured memory_bytes: 3060
# 2019-11-23 01:09:31(JST)
import sys
import itertools



def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    
    b = list(itertools.accumulate(a))

    count = 1
    for i in range(n-1, 0, -1):
        if a[i] <= b[i-1] * 2:
            count += 1
        else:
            break
    
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14484
S = list(input())

lenS = len(S)
ans = 0

for i in range(1, lenS+1):
    for j in range(lenS-i+1):
        tmp = S[j:j+i]
        if set(tmp).issubset(['A', 'C', 'G', 'T']):
            #print(tmp)
            ans = max(len(tmp), ans)

print(ans)


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr ll INF = TEN(18);

int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];

    ll ans = -INF;

    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;

        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }

        ll path = 0;
        int cnt = 0;

        while (true) {
            cnt++;
            path += C[v];

            if (cnt > K) break;

            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);

            v = P[v];
            if (v == i) break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int a, b; scanf("%d%d", &a, &b);
	int n; scanf("%d", &n);
	std::vector<int> latte(1000, 0);
	while(n--) {
		int l, r; scanf("%d%d", &l, &r);
		
		for(int i = l; i < r; i++) latte[i] = 1;
	}
	
	bool ans = false;
	for(int i = a; i < b; i++) ans |= latte[i];
	printf("%d\n", ans);	
	return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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

	int Q; cin >> Q;
	while (Q--) {
		int K; cin >> K;
		ll ans = 0ll;

		ll mnum = 0, cnum = 0, pot = 0;
		for (int i = 0; i < K; i++) {
			if (S[i] == 'M') mnum++;
			if (S[i] == 'C') pot += mnum, cnum++;
		}
		for (int i = 0; i < N; i++) {
			if (S[i] == 'D') ans += pot;
			if (S[i] == 'M') pot -= cnum, mnum--;
			if (S[i] == 'C') cnum--;
			if (i >= N - K) continue;
			if (S[i+K] == 'M') mnum++;
			if (S[i+K] == 'C') pot += mnum, cnum++;
		}

		cout << ans << el;
	}
	
	return (0);
}

Measured memory_bytes: 1412
import math
S = int(input())

if int(math.sqrt(S))**2 == S:
    a = d = int(math.sqrt(S))
else:
    a = d = int(math.sqrt(S)) + 1

bc = a*d - S

if bc == 0:
    b = c = 0
else:
    for i in range(int(math.sqrt(bc)),0,-1):
        if bc % i == 0:
            b = i
            c = bc//i
            break

print(0,0,a,b,c,d)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    string t = "keyence";
    int n = s.size();
    for(int i = 0; i < n-1; i++){
        for(int j = i; j < n; j++){
            string tmp = s;
            tmp.erase(tmp.begin()+i,tmp.begin()+j);
            if(t == tmp){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    [r,g,b,n] <- map read . words <$> getLine :: IO [Int]
    print . sum
        $ [ 1
          | i <- [0..(n`div`r)]
          , j <- [0..((n-r*i)`div`g)]
          , let k = n-r*i-g*j in k >= 0 && k `rem` b == 0
          ]

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    vector<pair<int, int> > rank;
    rep (i, n) {
        int a, b;
        cin >> a >> b;
        rank.push_back(make_pair(a, b));
    }
    sort(rank.begin(), rank.end());
    ans += rank[n - 1].second;
    ans += rank[0].first - 1;
    ans += rank[n - 1].first - rank[0].first + 1;
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline void LB(vector<T>& v, T& a) { return *lower_bound(ALL(v),a); }
template <typename T> inline void LBP(vector<T>& v, T& a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline void UB(vector<T>& v, T& a) { return *upper_bound(ALL(v),a); }
template <typename T> inline void UBP(vector<T>& v, T& a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template< typename T, typename V > typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) { t = v; }
template< typename T, typename V > typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

  int N;
  cin >> N;
  vector<int> a(N),b(N,0),ans;
  cin >> a;
  for (int i = N-1; i >= 0; i--) {
    int n = i+1, sum = 0;
    for (int j = 1; j * n <= N; j++) {
      sum += b[j*n-1];
    }
    sum %= 2;
    if (sum == a[i]) continue;
    b[i] = 1;
    ans.push_back(i);
  }
  for (int i = 0; i < N; i++) {
    int n = i+1, sum = 0;
    for (int j = 1; j * n <= N; j++) {
      sum += b[j*n-1];
    }
    sum %= 2;
    if (sum != a[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans.size() << endl;
  REP(i,ans.size()) cout << ans[i]+1 << " \n"[i+1==ans.size()];

  return 0;
}

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

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >>n;
  vector<int>a(n);
  for(int i=0; i<n; i++) cin >>a[i];
  sort(a.rbegin(),a.rend());
  long long sum=a[0];
  for(int i=1; i<=(n-1)/2; i++) sum+=2*a[i];
  if(n%2) sum-=a[(n-1)/2];
  cout <<sum;
return 0;}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 2e5 + 5;


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

  int a, b, c; ll k; cin >> a >> b >> c >> k;
  if(k % 2) {
    cout << b - a;
  }
  else {
    cout << a - b;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(void){
    int n;
    cin>>n;
    vector <pair<int, int> > a(n);
    rep(i, n){
        int s;
        cin>>s;
        a[i]= make_pair(s, i+1);
    }
    sort(a.begin(), a.end());
    rep(i, n){
        cout<<a[i].second<<" ";
    }
    cout<<endl;

}

Measured memory_bytes: 1664
N ,K = map(int, input().split())
S = input()

K -= 1

s=list(S)
if s[K]=="A":
    s[K]='a'
elif s[K]=='B':
    s[K]='b'
elif s[K]=='C':
    s[K]='c'

print(''.join(s))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;

const double eps = 1e-11;

int K, R, L;
double P, E, T;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

double rec(double r, double l, int k, int flag) {
  if(flag) {
    double dist = min(abs(T-r), abs(T-l));
    if(!equals(dist, E) && dist > E) return 0.0;
  }

  {
    double tr = T - E;
    double tl = T + E;
    if((equals(tr, r) || tr < r) && (equals(l, tl) || l < tl)) {
      return 1.0;
    }
  }

  if(k == 0) {
    double t = (r+l)/2.0;
    double diff = abs(T-t);
    return (equals(diff, E) || diff < E) ? 1.0 : 0.0;
  } else {
    double h = (r+l)/2.0;
    if(equals(h, T) || h > T) {
      return (1-P)*rec(r,h,k-1,0) + P*rec(h,l,k-1,1);
    } else {
      return (1-P)*rec(h,l,k-1,0) + P*rec(r,h,k-1,1);
    }
  }
}

int main() {
  cin >> K >> R >> L;
  cin >> P;
  cin >> E;
  cin >> T;
  printf("%.10f\n", rec(R, L, K, 0));
  return 0;
}

Measured memory_bytes: 1248
N,A,B,C = map(int,input().split())
l = [int(input()) for _ in range(N)]

ans = 10**9
for i in range(2**(2*len(l))):
    a = 0
    b = 0
    c = 0
    cnt = 0
    for j in range(len(l)):
        if (i>>j*2)&1 and (i>>j*2+1)&1:
            if a!=0:
                cnt +=10
            a += l[j]
        elif (i>>j*2)&1 and ~(i>>j*2+1)|0:
            if b!=0:
                cnt +=10
            b += l[j]
        elif ~(i>>j*2)|0 and (i>>j*2+1)&1:
            if c!=0:
                cnt +=10
            c += l[j]
        else:
            pass
    if all(x>0 for x in [a,b,c]):
        ans = min(ans,cnt+abs(A-a)+abs(B-b)+abs(C-c))

print(ans)

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

int h, w;
char sky[100][100];
int main()
{
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cin >> sky[i][j];
  }
  
  for(int i = 0; i < h; i++){
    int dif = -1;
    for(int j = 0; j < w; j++){
      if(sky[i][j] == 'c') dif = 0;
      else if(dif >= 0) dif++;
      cout << dif;
      if(j == w - 1) cout << endl;
      else cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1168
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    if n % 1000 == 0 {
        "0".to_string()
    } else {
        (1000 - (n % 1000)).to_string()
    }
}


Measured memory_bytes: 2172
import sys
input = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    N = int(input())
    a = make_divisors(N)
    a.sort()
    ans = 10
    for i in a:
        ans = min(ans, len(str(max(i, N/i))))

    print(ans)


if __name__ == '__main__':
    main()


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

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

  if (A * N > B) {
    cout << B << endl;
  }
  if (A * N < B) {
    cout << A * N << endl;
  }
  if (A * N == B) {
    cout << A * N << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
vll a;
lli pre = 0;
lli h,w;

int main(){
	cin >> n;
	a = vll(n);
	for(lli i = 0;i < n;i++) cin >> a[i];
	sort(a.rbegin(),a.rend());
	lli i = 0;
	for(i = 0;i < n;i++){
		if(a[i] == pre){
			h = a[i];
			break;
		}
		pre = a[i];
	}
	i++;pre = 0;
	for(;i < n;i++){
		if(a[i] == pre){
			w = a[i];
			break;
		}
		pre = a[i];
	}
	cout << h*w << endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
    }
    let mut chnums = vec![];
    let mut i = 1;
    loop {
        i = i * 2;
        if i > 100 {
            break;
        }
        chnums.push(i);
    }
    if n == 1 {
        println!("1");
        return;
    }
    chnums.reverse();
    for (idx, chnum) in chnums.iter().enumerate() {
        if (chnum <= &n) {
            println!("{}", chnum);
            break;
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 100010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void init(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    init(100000);
    ll n,k;
    cin >> n >> k;
    // vector<int> a(n);
    map<ll,ll> mp;
    // for (int i = 0;i < n;++i) cin >> a[i];
    // sort(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0,cnt = 0;
    for (auto p : mp) {
        if (cnt+p.second >= k) {
            for (int i = 1;i < min(k,p.second)+1;++i) {
                if (k-i <= cnt) (ans += p.first*combi(cnt,k-i)%mod*combi(p.second,i)%mod) %= mod;
            }
        }
        cnt += p.second;
    }
    cnt = n;
    for (auto p : mp) {
        cnt -= p.second;
        if (cnt+p.second >= k) {
            for (int i = 1;i < min(k,p.second)+1;++i) if (cnt >= k-i) {
                (ans -= p.first*combi(cnt,k-i)%mod*combi(p.second,i)%mod) %= mod;
            }
        }
    }
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 8448
use std::io;
use std::cmp;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let a: Vec<i64> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    let sum = a.iter().fold(0i64, |s, val| s + val);
    let mut res = (sum - a[0]*2).abs();
    let mut sum2 = 0i64;
    for i in 0..a.len()-1 {
        sum2 += a[i] ;
        res = cmp::min(res, (sum - sum2 * 2).abs());
    }

    println!("{}", res);
}


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

int main()
{
  int n;
  int p[105] = {0};

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

  int s = 0;
  for (int i = 100; i >= 0; i--) {
    s += p[i];
    if (s >= i) {
      cout << i << endl;
      break;
    }
  }

  return (0);
}

Measured memory_bytes: 3100
#include<stdio.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN+1];
int head = 1, tail, n;

void enqueue(P x);
P dequeue();

int main(){
    int elaps = 0, c;
    int i,q;
    P u;
    
    scanf("%d %d",&n,&q);
    
    for(i = 1;i <= n; i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    tail = n + 1;
    
    while( head != tail){
        u = dequeue();
        c = q < u.t ? q : u.t;
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n",u.name, elaps);
        }
    }
    
    return 0;
}

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
   int i = head;
    head = (head +1) % LEN;
    return Q[i];
}


Measured memory_bytes: 11852
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 10007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/

signed main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=k+1;i<=n;i++){
        int cnt=0;
        cnt+=(i-k)*(n/i);
        cnt+=max(n-(n/i*i+k)+1,(ll)0);
        if(k==0)cnt--;
        ans+=cnt;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main(){
    int k;
    cin >> k;
    for(double i=1; i<=k ; i++){
        double sum =(i*360)/k;
        int sumInt = (i*360)/k;
        if(sumInt - sum == 0) {
            cout << sum;
            break;
        }
    }
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> A, B, C;
	for(int i = 0; i < a; i++){
		int x;
		cin >> x;
		A.pb(x);
	}
	for(int i = 0; i < b; i++){
		int x;
		cin >> x;
		B.pb(x);
	}
	for(int i = 0; i < c; i++){
		int x;
		cin >> x;
		C.pb(x);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	reverse(A.begin(), A.end());
	reverse(B.begin(), B.end());
	while(A.size() > x)
		A.pop_back();
	while(B.size() > y)
		B.pop_back();
	reverse(C.begin(), C.end());
	ll ans = 0;
	multiset<int> ry;
	for(int i = 0; i < A.size(); i++)ans += A[i], ry.insert(A[i]);
	for(int i = 0; i < B.size(); i++)ans += B[i], ry.insert(B[i]);
	for(int i = 0; i < C.size(); i++){
		if(!ry.size())break;
		int x = (*ry.begin());
		//cout << x << ' ' << ry.size() << '\n';	
		if(x < C[i]){
			ry.erase(ry.find(x));
			ans += C[i] - x;
		}
	}
	cout << ans << '\n';

}

Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
const int Maxn=2005;
int n,a[Maxn];
bool vis[Maxn];
vector <int> g[Maxn],e[Maxn];
void dfs(int u)
{
	if (vis[u]) return;
	vis[u]=true;
	for (int i=0;i<g[u].size();++i)
	{
		int v=g[u][i];
		if (!vis[v])
		{
			dfs(v);
			e[u].push_back(v);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;++i) scanf("%d",a+i);
	sort(a,a+n);
	for (int i=0;i<n;++i) for (int j=0;j<n;++j)
		if (__gcd(a[i],a[j])>1) g[i].push_back(j);
	priority_queue <int> pq;
	for (int i=0;i<n;++i) if (!vis[i])
	{
		dfs(i);
		pq.push(i);
	}
	while (!pq.empty())
	{
		int u=pq.top();pq.pop();
		for (int i=0;i<e[u].size();++i) pq.push(e[u][i]);
		printf("%d ",a[u]);
	}
	return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF (1<<30)
const int N=105;
int n,m;
int adj[N][N],set[N],res,sum;
bool judge(int ind,int cnt)
{
    for(int i=0;i<cnt;i++)
    {
        if(adj[ind][set[i]]==0) return false;
    }
    return true;
}
int calu(int cnt)
{
    if(cnt<=1) return 0;
    int sum=0;
    for(int i=0;i<cnt;i++)
    {
        int imin=INF;
        for(int j=0;j<cnt;j++)
        {
            if(i==j) continue;
            imin=min(imin,adj[set[i]][set[j]]);
        }
        sum+=imin;
    }
    return sum;
}
void dfs(int ind,int cnt)
{
   // cout<<ind<<" "<<cnt<<endl;
    if(ind==n+1)
    {
        res=max(res,calu(cnt));
        return;
    }
    if(judge(ind,cnt))
    {
        set[cnt]=ind;
        dfs(ind+1,cnt+1);
    }
    dfs(ind+1,cnt);
}
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        res=sum=0;
        memset(adj,0,sizeof(adj));
        memset(set,0,sizeof(set));

        for(int i=0;i<m;i++)
        {
            int a,b,c;  scanf("%d%d%d",&a,&b,&c);
            adj[a][b]=adj[b][a]=c;
        }
        dfs(1,0);
        printf("%d\n",res);
    }
}

Measured memory_bytes: 0
#include <stdio.h>
void count_primes(int f[], int n);

int main(void) {
  int i, n, f[1000000], count;
  while (scanf("%d", &n) != EOF) {
    count = 0;
    count_primes(f, n);
    for (i = 2; i <= n; i++) count += f[i];
    printf("%d\n", count);
  }
  return 0;
}

void count_primes(int f[], int n)
{
  int i, j;
  for (i = 2; i <= n; i++) f[i] = 1;
  for (i = 2; i*i <= n; i++)
    if (f[i])
      for (j = i*2; j <= n; j += i) f[j] = 0;
}

Measured memory_bytes: 4504
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	g := [15][15]int{}
	for i := 0; i < 15; i++ {
		for j := 0; j < 15; j++ {
			g[i][j] = -1
		}
	}

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		var x, y int
		for j := 0; j < a; j++ {
			fmt.Scan(&x, &y)
			g[i][x-1] = y
		}
	}

	ans := 0
	for bits := 0; bits < 1<<uint(n); bits++ {
		ok := true
		for i := 0; i < n; i++ {
			if bits&(1<<uint(i)) == 0 {
				continue
			}
			for j := 0; j < n; j++ {
				if g[i][j] == -1 {
					continue
				}
				b := bits & (1 << uint(j))
				if b > 0 {
					b = 1
				}
				if b != g[i][j] {
					ok = false
				}
			}
		}
		if ok {
			c := count1(bits)
			if ans < c {
				ans = c
			}
		}
	}
	fmt.Println(ans)
}

func count1(a int) int {
	c := 0
	for i := 0; i < a; i++ {
		if a&(1<<uint(i)) > 0 {
			c++
		}
	}
	return c
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int a, b, coin;
    coin = 0;
    cin >> a >> b;

    for(int i = 0; i < 2; i++){
        if(a >= b){
            coin += a;
            a--;
        }else{
            coin += b;
            b--;
        }
    }
    cout << coin << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)


template<typename T>
T gcd(T n, T m){

    if(m > n)  swap(n, m);

    if(m == 0) return n;

    T r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}


int main(){

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

    ll k; cin >> k;

    ll ans = 0;
    reps(a, 1, k + 1){
        reps(b, 1, k + 1){
            reps(c, 1, k + 1){
                ans += gcd(a, gcd(b, c));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int a,b,c,n,r;

    while(cin>>a>>b>>c,a||b||c){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>r;
            if(a*a+b*b<4*r*r || a*a+c*c<4*r*r || b*b+c*c<4*r*r){
                cout<<"OK"<<endl;
            }else{
                cout<<"NA"<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

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


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

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || '9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x*f;
}

inline void chkmax(int &a,int b){if(a<b)a=b;}
inline void chkmin(int &a,int b){if(a>b)a=b;}

typedef long long ll;

const int N=100009;

int n,c,k;
int tt[N];

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();c=read();k=read();
	for(int i=1;i<=n;i++)tt[i]=read();
	sort(tt+1,tt+n+1);

	int ans=-1,cnt=0;
	for(int i=1,las=-k;i<=n;i++)
	{
		int t=tt[i];
		if(las+k<t)
			cnt=0,ans++,las=t;
		if(cnt==c)
			cnt=0,ans++,las=t;
		cnt++;
	}
	if(cnt)ans++;

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N;
ll X[1000];

int main()
{
    cin >> N;
    ll ans = INF;
    repe(i, 1, N)
    {
        cin >> X[i];
    }
    repe(i, 1, 100)
    {
        ll cost = 0;
        repe(j, 1, N)
        {
            cost += (X[j] - i) * (X[j] - i);
        }
        chmin(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    char c;
    cin >> c;
    if (c <= 'z' && c >= 'a'){
        cout  << "a" << endl;
    } else {
        cout  << "A" << endl;
    }


}



Measured memory_bytes: 3648
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = 0
    count = 0

    if N == 2:
        if H[0] >= H[1]:
            ans = 1
    elif N > 2:
        for i in range(1, N):
            j = i + 1
            if H[-i] <= H[-j]:
                count += 1
                if j == N:
                    if ans <= count:
                        ans = count
            else:
                if ans <= count:
                    ans = count
                count = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[40]={};
int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, n){
		int k; scanf("%d", &k);
		int b;
		REP(j, k) scanf("%d", &b), a[b]++;
	}
	int ans=0;
	FOR(i, 1, m+1) if(a[i]==n) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
as = M.times.map{ gets.strip.to_i }

(M-1).times do |i|
  if as[i+1] - as[i] == 1
    puts 0
    exit
  end
end

require 'set'
as = as.to_set

paths = [1]
1.upto(N) do |i|
  if as.include?(i)
    paths[i] = 0
  else
    if i == 1
      paths[i] = paths[i-1]
    else
      paths[i] = paths[i-1] + paths[i-2]
    end
  end
end

puts paths[N] % 1000000007


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

int main()
{
    i64 n, x, m;
    cin >> n >> x >> m;

    vector<i64> mod;
    int initix = 0;
    bool flag = true;
    while (flag)
    {
        mod.push_back(x);
        x = (x * x) % m;

        for (int i = 0; i < mod.size(); i++)
        {
            if (mod[i] == x)
            {
                flag = false;
                initix = i;
                break;
            }
        }
    }

    int repsize = mod.size() - initix;    

    int residueix = (n - initix) % repsize;

    i64 repsum = 0;
    for (int i = initix; i < mod.size(); i++)
    {
        repsum += mod[i];
    }

    i64 ans = 0;
    for (int i = 0; i < initix; i++)
    {
        ans += mod[i];
    }

    ans += (n - initix ) / repsize * repsum;

    for (int i = initix; i < initix + residueix; i++)
    {
        ans += mod[i];
    }

    cout << ans << endl;

    // printvec(mod);
    // debug(initix);
    // debug(residueix);

    return 0;
}

Measured memory_bytes: 3760