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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

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

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

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









    int main(){
        string S;
        cin >> S;
        ll n = S.length();
        ll ans = 0;
        for(ll i = n - 1; i >= 0; i--){
          int target = S.at(i) - '0';
          if((i > 0 && target == 5 && S.at(i - 1) - '0' >= 5) || target > 5) {
            ans += 10 - target;
            if(i > 0) S.at(i - 1)++;
            else ans++;
          }else ans += target;
        }
          print(ans);
          return 0;
    }

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

void Main() {
    int64_t n, k, x, r = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        r += min(x, k-x);
    }
    cout << r * 2 << endl;
}

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


Measured memory_bytes: 3616
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out))
        {
            final int X = in.nextInt();
            final int Y = in.nextInt();

            out.println(X + (Y >> 1));
        }
    }
}


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

struct Node{
	int index;
	int number;
};

Node a[1000000];

bool cmp(Node a,Node b){
	return a.number<b.number;
}
int main(void){
	int n;
	cin>>n;

	for(int i=1 ; i<=n ; i++){
		cin>>a[i].number;
		a[i].index=i;
	}
	sort(a+1,a+1+n,cmp);

	for(int i=1 ; i<=n ; i++){
		cout<<a[i].index<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main (){
	int angka;
	scanf("%d", &angka);
	
	char kata[angka+1];
	scanf("%s", kata);
	
	if(angka % 2 != 0){
		puts("No");
	}
	
	else {
		int tanda = 1;
		for (int i =0; i < angka/2; i++){
			if (kata[i] != kata[i+ angka/2]){
				tanda = 0;
			}
		}
		
		if (tanda == 1){
			puts("Yes");
		}
		else {
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>
#include <string.h>

#define N 100

int main() {
	static char s[N + 1], t[N + 1];
	int n, i, j, yes;
	char c;

	scanf("%s%s", s, t);
	n = strlen(s);
	yes = 0;
	for (i = 0; i < n; i++) {
		if (strcmp(s, t) == 0) {
			printf("Yes\n");
			return 0;
		}
		c = s[n - 1];
		for (j = n - 2; j >= 0; j--)
			s[j + 1] = s[j];
		s[0] = c;
	}
	printf("No\n");
	return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
long long n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	long long cur = 1ll , ans = 0ll ;
	while(n > 0)
	{
		ans += cur ;
		n /= 2ll ;
		cur *= 2ll ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n,p,a,o,e;
long long ans;

long long combination(int n,int k){
    long long r=1;
    k=min(k,n-k);
    for(int i=0;i<k;i++){
        r*=(n-i);
        r/=(i+1);
    }
    return r;
}

int main(){
    cin>>n>>p;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2) o++;
        else e++;
    }
    for(int i=p;i<=o;i+=2){
        ans+=combination(o,i);
    }
    for(int i=0;i<e;i++){
        ans*=2;
    }
    cout<<ans;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val n = readLine.trim.toInt
  val room = readLine.trim.split(' ').map(_.toInt)
  var stack: List[Int] = List(0)
  var count = 0
  for (length ← room){
    if (stack.head > length){
      stack = stack.dropWhile(len ⇒ len > length)
    }
    if (stack.head != length) {
      count += 1
      stack ::= length
    }
  }
  println(
    count
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 91332
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
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 * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	ll X;cin >> X;
	bool ok = false;
	vector<ll> a(120);
	for (ll i = 0;i <= 120;i++) {
		a[i] = i*i*i*i*i;
	}
	//for (int i = 0;i < 120; i++)cout << a[i] << endl;
	for (ll i = 0;i<120;i++) {
		for (ll j = i;j<120;j++) {
			if (a[j]+a[i]==X) {
				cout << j << " " << -i << endl;
				ok = true;
				break;
			}
			if (a[j]-a[i]==X) {
				cout << j << " " << i << endl;
				ok = true;
				break;
			}
		}
		if (ok) break;
	}
}


Measured memory_bytes: 3644
#coding:utf-8

while True:
    try:
        a, b = map(int, raw_input(). split())
        x = a * b
        while True:
            c = a % b
            a = b
            b = c
            if b == 0:
                break
        x = x / a
        print("%d %d" % (a, x))
    except:
        break

Measured memory_bytes: 6384
#include<cstdio>
using namespace std;
 
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)
 
int sum[100010];
 
int main() {
  int n,k,t,zero;
  while(scanf("%d %d", &n, &k), n|k) {
    rep(i,n+1) sum[i] = 1; sum[0] = 0;
    zero = 0;
    rep(i,k) {
      scanf("%d", &t);
      if(t == 0) zero++;
      else sum[t] = 0;
    }
 
    rep(i,n) sum[i+1] += sum[i];
 
    int res = 0,start = 0,end = 0;
    while(end <= n) {
      if(sum[end]-sum[start] > zero) start++;
      if(end - start > res) res = end - start;
      end++;
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1416
n=int(input())
a=list(map(int,input().split()))
a.sort()
e=[]
b=[]
turn=1
for i in range(n):
    if turn==1:
        e.append(a.pop(-1))
        turn-=1
    else:
        b.append(a.pop(-1))
        turn+=1
print(sum(e)-sum(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;

int a[MAX_N];
int b[MAX_N+1];

int main()
{
	int n;
	int t=0;
	scanf("%d",&n);
	fill(b,b+n,0);
	rep(i,n){
		scanf("%d",&a[i]);
		b[a[i]]++;
		t = max(t,a[i]);
	}
	int sum = 0; //1枚しかないカードの枚数
	int buff0 = 0;
	int buff1 = 0;
	for(int i=1;i<=t;i++){
		if(b[i] == 1){
			sum++;
		}
		if(b[i] > 1 && b[i] % 2 == 0){
			buff0++;
		}
		if(b[i] > 1 && b[i] % 2 == 1){
			buff1++;
		}
	}
	if(buff0 % 2 == 0){
		cout << sum+buff0+buff1;
	}else{
		cout << sum+buff0+buff1-1;
	}
}

Measured memory_bytes: 1024
//Copied: https://www.codechef.com/viewsolution/21764904
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
void pre(){
 
 
}
vector<pii> g[100009];
int ans[100009];
int deg[100009];
bool vis[100009];
void dfs(int v,int pr=-1){
	vis[v] = 1;
	trav(i,g[v]){
		if(!vis[i.fst]){
			dfs(i.fst,i.snd);
			if(deg[i.fst]%2) {
				if(i.snd<0) {
					ans[-i.snd] = 1;
					deg[i.fst]++;
					deg[v]--;
				}
				else{
					ans[i.snd]=1;
					deg[i.fst]--;
					deg[v]++;
				}
			}
		}
	}
}
 
int stu[100005], stv[100005];
 
void solve(){
	int n,m;cin>>n>>m;
	repA(i,1,n) g[i].clear();
	fill(ans);fill(deg);fill(vis);
	repA(i,1,m){
		int u,v;cin>>u>>v;
		stu[i] = u;
		stv[i] = v;
		g[u].pb(mp(v,i));
		deg[v]++;
		g[v].pb(mp(u,-i));
	}
	if(m%2) cout<<-1;
	else {
		dfs(1);
		repA(i,1,m) 
			if(ans[i])
				cout << stu[i] << ' ' << stv[i] << endl;
			else
				cout << stv[i] << " " << stu[i] << endl;
	}
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	pre();
	int n;
	n = 1;
	rep(i,n) solve(),cout<<'\n';;	
	
	
	
	
	return 0;
}

Measured memory_bytes: 11136
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define LL long long
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,cnt,tmp,tot,two=1,first[N],id[N];
struct edge{int to,next;}e[N];
struct node{int f[3];node(){f[0]=f[1]=f[2]=0;}};
deque<node>q[N];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void print(int x)
{
	printf("[%d]\n",x);
	for(deque<node>::iterator it=q[id[x]].begin();it!=q[id[x]].end();it++)printf("%d %d %d\n",(*it).f[0],(*it).f[1],(*it).f[2]);
}
void ins(int u,int v){e[++cnt]=(edge){v,first[u]};first[u]=cnt;}
void merge(int x,int y)
{
//	printf("[x]%d id:%d sz:%d [y]%d id:%d sz:%d\n",x,id[x],q[id[x]].size(),y,id[y],q[id[y]].size());
	for(deque<node>::iterator xi=q[id[x]].begin(),yi=q[id[y]].begin();xi!=q[id[x]].end();xi++,yi++)
	{
		node temp;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
			{
				tmp=min(i+j,2);
				temp.f[tmp]=(temp.f[tmp]+1ll*(*xi).f[i]*(*yi).f[j]%mod)%mod;
			}
		(*yi)=temp;
	}
}
void dfs(int x)
{
	id[x]=++tot;int mx=0;
	for(int i=first[x];i;i=e[i].next)
	{
		int to=e[i].to;dfs(to);
		if(q[id[x]].size()<q[id[to]].size())merge(x,to),mx=max(mx,(int)q[id[x]].size()),id[x]=id[to];
		else merge(to,x),mx=max(mx,(int)q[id[to]].size());
	}
	for(deque<node>::iterator it=q[id[x]].begin();mx;it++,mx--)
		(*it).f[0]=((*it).f[0]+(*it).f[2])%mod,(*it).f[2]=0;
	node temp;temp.f[0]=temp.f[1]=(mod+1)>>1;q[id[x]].push_front(temp);
//	print(x);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)tmp=read(),ins(tmp,i);
	for(int i=1;i<=n+1;i++)two=(two<<1)%mod;
	dfs(0);int ans=0;
	while(!q[id[0]].empty())ans=(ans+q[id[0]].front().f[1])%mod,q[id[0]].pop_front();
	printf("%lld",1ll*ans*two%mod);
	return 0;
}

Measured memory_bytes: 234240
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

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

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

double eps = 0.0001;
int main()
{
    long long n; cin>>n;

    double x = ceil(n/(1.08));
    double n_new = floor(x*1.08);


    if(n_new==n)
    {
        cout<<x<<endl;
    }
    else
    {
        cout<<":("<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n,k,d,temp,ans=0;
    cin>>n>>k;
    vector<bool> a(n,true);
    rep(i,k) {
        cin>>d;
        rep(j,d) {
            cin>>temp;
            temp--;
            a[temp]=false;
        }
    }
    rep(i,n) {
        if (a[i]) ans++;
    }
    cout<<ans<<endl;
}   


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

ll digitSum(string &k, int s){

    int n = k.size();
    if(n == 1){
        int ans = 0;
        for(int i=1; i<=k[0]-'0'; i++)
            if(i%s == 0)
                ans++;
        return ans;
    }
    vector<vector<ll>> dp(n, vector<ll>(s, 0));
    // dp[i][j] stores the number of integers having 'i' digits and
    // having remainder as 'j' when sum of digits is divided by 's'

    for(int d=1; d<=9; d++){
        int rem = d%s;
        dp[1][rem]++;
    }

    dp[0][0] = 1;
    for(int i=2; i<=n-1; i++){
        for(int j=0; j<s; j++){
            // Find number of integers having number of digits as 'i'
            // and remainder as 'j'
            // At this place we can append any of the 10 digits
            for(int d=0; d<=9; d++){
                ll req = ((j-d)%s+s)%s;
                dp[i][j] = (dp[i][j] + dp[i-1][req])%M;
            }
        }
    }

    // Now find number of required integers with exactly 'n' digits
    ll ans = 0, sum = 0;
    vector<ll> cnt(s, 0);
    for(int i=0; i<=n-1; i++)
        for(int j=0; j<s; j++)
            cnt[j] = (cnt[j] + dp[i][j])%M;

    for(int i=0; i<n; i++){
        int d = k[i]-'0';
        int st = 0;
        if(i == 0)
            st++;
        for(int w=st; w<d; w++){
            int newSum = sum + w;
            int req = (-newSum%s + s)%s;
            ans = (ans + cnt[req])%M;
        }
        for(int j=0; j<s; j++)
            cnt[j] = ((cnt[j] - dp[n-i-1][j])%M + M)%M;

        sum += d;
    }
    // If the number 'k' itself has sum of digits as multiple of 's'
    if(sum%s == 0)
        ans = (ans + 1)%M;

    for(int i=1; i<=n-1; i++)
        ans = (ans + dp[i][0])%M;

    return ans;
}

int main()
{
 string k;
 cin>>k;
 int s;
 cin>>s;
 ll ans = digitSum(k, s);
 cout<<ans;
 return 0;
}



Measured memory_bytes: 11260
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {
	int a[3];
	int k;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}

	scanf("%d", &k);

	sort(a, a + 3);

	for (int i = 0; i < k; i++) {
		a[2] = a[2]*2;
	}

	printf("%d\n", a[0] + a[1] + a[2]);
  
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int k,n,ans=INF;
    cin>>k>>n;
    VI a(n+1);
    rep(i,1,n+1)
        cin>>a[i];
    rep(i,2,n+1)ans=min(ans,k-a[i]+a[i-1]);
    ans=min(ans,k-(k+a[1]-a[n]));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define lcm(a,b) (((a)/gcd(a,b))*(b))
ll log_two(int n){
  if(n==0 || n%2==1) return 0;
  else return log_two(n/2)+1;
}
int main(){
  ll n,m,k,i,j,result=0,t;
  int a[200010];
  cin >> n >> m;
  t=1;
  rep(i,n){
    cin >> a[i];
    if(i==0){
      k = log_two(a[i]);
      t = a[i]/2;
    }else if(t==0 || k != log_two(a[i])){
      t=0;
    }else{
      a[i] /= 2;
      t = lcm(a[i],t);
    }
    //cout << t << endl;
  }
  if(t==0) cout << 0 << endl;
  else cout << (m/t-m/(2*t)) << endl;
  
  return 0;
}

Measured memory_bytes: 3860
#include<iostream>

using namespace std;

bool isprime(int x) {
	if (x <= 1) {
		return false;
	}
	for (int i = 2; i * i <= x; i++){
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x;
	cin >> x;
	int ans = x;
	while (!isprime(ans)) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}

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

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

    for(int i = a; i <= b; i++){
        if(c % i == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}





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

int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  while (a > 0) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
 
using namespace std;
 
template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}
 
template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}
 
bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
 
u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}
 
u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
 
  return b ? gcd(b, a % b) : a;
}
 
u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }
 
int main() {
  u32 N;
  cin >> N;
  set<u32> S;
  for (u32 i = 0; i < N; ++i) {
    u32 tmp;
    cin >> tmp;
    S.insert(tmp);
  }
  cout << ((S.size() == N) ? "YES" : "NO") << endl;
 
  return 0;
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int a,b,c;
  a=x+y;
  b=x-y;
  c=x*y;
  if(a>=b&&a>=c){
    cout<<a;
  }else if(b>=a&&b>=c){
    cout<<b;
  }else if(c>=a&&c>=b){
    cout<<c;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll q[50],k;
  char c[1000000];
  rep(i,26)q[i]=0;
  string s;
  cin >> s;
  k=s.length();
  rep(i,k)c[i]=s[i];
  rep(i,26){
    rep(j,k){
      if('a'+i==c[j])q[i]++;
    }
  }
  rep(i,26)if(q[i]==0){
    c[i]='a'+i;
    printf("%c",c[i]);
    return 0;
  }
  printf("None");
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 100001;
const ll mod = 1e9+7;
int r,c,n;
struct point{
  int id;
  int val;
};
vector<point> v1;
vector<point> v2;
vector<point> v3;
vector<point> v4;
bool check(int x, int y){
  if(x == 0 || x == r || y == 0 || y == c) return true;
  return false;

}
void push(int id, int x, int y){
  if(x == 0) v1.pb({id, y});
  else if(y == c) v2.pb({id, x});
  else if(x == r) v3.pb({id, y});
  else if(y == 0) v4.pb({id, x});
}
bool cmp1(point a, point b){
  return a.val < b.val;
}
bool cmp2(point a, point b){
  return a.val > b.val;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  cin >> r >> c >> n;
  int x1,x2,y1,y2;
  for(int i = 1; i <= n; i++){
    cin >> x1 >> y1 >> x2 >> y2;
    if(check(x1,y1) && check(x2,y2))
      push(i,x1,y1),push(i,x2,y2);
  }
  sort(v1.begin(), v1.end(),cmp1);
  sort(v2.begin(), v2.end(),cmp1);
  sort(v3.begin(), v3.end(),cmp2);
  sort(v4.begin(), v4.end(),cmp2);
  stack<int> s;
  for(int i = 0; i < v1.size(); i++){
    if(s.size() == 0) {s.push(v1[i].id); continue;}
    if(s.top() == v1[i].id) s.pop();
    else s.push(v1[i].id);
  }
  for(int i = 0; i < v2.size(); i++){
    if(s.size() == 0) {s.push(v2[i].id); continue;}
    if(s.top() == v2[i].id) s.pop();
    else s.push(v2[i].id);
  }
  for(int i = 0; i < v3.size(); i++){
    if(s.size() == 0) {s.push(v3[i].id); continue;}
    if(s.top() == v3[i].id) s.pop();
    else s.push(v3[i].id);
  }
  for(int i = 0; i < v4.size(); i++){
    if(s.size() == 0) {s.push(v4[i].id); continue;}
    if(s.top() == v4[i].id) s.pop();
    else s.push(v4[i].id);
  }
  cout << (s.empty() ? "YES" : "NO" )<< endl;
  return 0;
}






Measured memory_bytes: 2520
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

struct Edge {
    int from, to, cost;
    Edge(int _from, int _to, int _cost) : from(_from), to(_to), cost(_cost){};
    Edge(){};
};

Edge es[2005];

int d[1005];
int V, E;

bool shortest_path(int s) {
    REPS(i, V) d[i] = INF;
    d[s] = 0;

    int loop = 0;
    while (true) {
        ++loop;
        bool update = false;
        REP(i, E) {
            Edge& e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (loop >= V && e.to == V) {
                    // find negative loop
                    return false;
                }
                if (loop >= V * 2) {
                    return true;
                }
                update = true;
            }
        }
        if (!update) break;
    }
    return true;
}

signed main() {
    cin >> V >> E;
    REP(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        Edge e(a, b, -c);
        es[i] = e;
    }
    if (shortest_path(1)) {
        cout << -d[V] << endl;
    } else {
        cout << "inf" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int numOfCanDivide(int x) {
    int count = 0;
    while (x % 100 == 0) {
        x /= 100;
        count++;
    }
    return count;
}

int main() {
    int D, N;
    cin >> D >> N;

    int MAX_VAL = 1010000;

    int count = 1;
    int ans = 0;
    for (int i = 1; i <= MAX_VAL; i++) {
        if(numOfCanDivide(i) == D) {
            if (count == N) ans = i;
            count++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
a, b, h, m = map(int, input().split())


from math import pi
from math import sqrt
from math import cos
from math import radians
# angle
angle = abs(30 * (h + m / 60) - 6 * m)
c = sqrt(a**2 + b**2 - 2*a*b*cos(radians(angle)))
print(c)

Measured memory_bytes: 62284
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        if(input[0] == input[1] && input[1] == input[2])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }

}


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

#define ll long long
#define rep(i,N) for(ll i=1; i<=N; i++)
const int mx = 2e5;

int main(void){

  ll K, ans=0;
  cin >> K;
  
  rep(a,K){
    rep(b,K){
      rep(c,K){
        ans += gcd(a,gcd(b,c));/*
        ll first,second;
        first=gcd(a,b);
        second=gcd(b,c);
        if(first==1 || second==1 || first==second){
          ans += 1;
        }else{
          ans += gcd(a,second);
        }*/
      }
    }
  }
  
  cout << ans;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {

    int N;
    int cnt = 0;
    float r;

    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        if ((i+1) % 2 == 0)
        {
            continue;
        }
        cnt++;
    }
    r = (float)cnt / N;

    cout << r << endl;

}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n, m;
struct event {
	ll x, op, i;
	bool operator < (const event &e) const {
		return pi(x, op) < pi(e.x, e.op);
	}
};
struct node {
	int s,e,m;
	ll v,add;
	node *l,*r;
	node(ll _S,ll _E){
		s=_S,e=_E,m=(s+e)>>1;
		v=0, add=0;
		if(s^e){
			l=new node(s,m);
			r=new node(m+1,e);
		}
	}
	void update(ll x,ll y,ll nval) {
		if(s==x&&e==y) { add += nval; return; }
		if(x>m) r->update(x,y,nval);
		else if(y<=m) l->update(x,y,nval);
		else l->update(x,m,nval), r->update(m+1,y,nval);
		v=max(l->value(),r->value());
	}
	ll value() {
		v+=add;
		if(s^e){
			l->add+=add;
			r->add+=add;
		}
		add=0;
		return v;
	}
}*seg;
int main()
{
	FAST
	cin>>n>>m;
	vector<spi> A(m);
	FOR(i,0,m-1) cin>>A[i].s.f>>A[i].s.s>>A[i].f;
	vector<event> v;
	FOR(i,0,m-1) v.pb({A[i].s.f, 0, i}), v.pb({A[i].s.s, 1, i});
	sort(all(v)); reverse(all(v));
	ll sum=0;
	vector<ll> dp(n+1, 0); seg=new node(1,n);
	FOR(i,1,n) {
		while(v.size() && v.back().x == i && v.back().op == 0) {
			sum += A[v.back().i].f;
			v.pop_back();
		}
		dp[i]=max(0ll, seg->value()) + sum;
		seg->update(i, i, dp[i] - sum);
		while(v.size() && v.back().x == i && v.back().op == 1) {
			seg->update(A[v.back().i].s.f,A[v.back().i].s.s,A[v.back().i].f);
			sum -= A[v.back().i].f;
			v.pop_back();
		}
	}
	cout<<*max_element(all(dp))<<'\n';
}


Measured memory_bytes: 42856
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else if(a + b > c + d){
		cout << "Left" << endl;
	}
	else {
		cout << "Right" << endl;

	}
	
}

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

using namespace std;

int main (){

    int n, sum = 0, digit = 0;
    cin >> n;

    digit = (int)log10(n)+1;

    int unti = n;
    while(digit){
        digit = unti%10;
        sum += digit;
        unti /= 10;
    }

    if(n%sum == 0) cout << "Yes";
    else cout << "No";

    return 0;
}


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


    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int n;
        cin>>n;
        vector<long long>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        unsigned long long ans=1;
        for(int i=0;i<n;i++){
            if(a[i]==0){
                cout<<0;
                return;
            }
        }
        for(int i=0;i<n;i++){
            ans*=(unsigned long long)(a[i]);
            unsigned long long k=((unsigned long long)(1e18))/ans;
            if(i+1<n && a[i+1]>k){
                cout<<-1;
                return;
            }
        }
        cout<<ans;
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main(){
	int N;
	cin >> N;
	if (N > 999) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #t=int(input())
    t=1
    for _ in range(t):
        n=int(input())
        num=7
        ans=0
        ls={}
        while 1:
            if num%n==0:
                ans+=1
                break
            else:
                if num%n in ls:
                    ans=-1
                    break
                ls[num%n]=1
                st=num%n
                st=str(st)+"7"
                #print(st)
                ans+=1
                num=int(st)
        print(ans)






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()


Measured memory_bytes: 160032
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>199
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
const long int MAXN = 2e5+100;
#define PI 3.14159265358979323846264338327950

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

// vector<li> v[MAXN];
// li ances[MAXN];
// bool visited[MAXN];
// li n,m;

// void bfs(li node)
// { 
//    queue <li> q;
//    q.push(node);

//    visited[node] = true;
//    n-=1;
   
//    while (!q.empty()) 
//    {
//       li u = q.front(); 
//       q.pop();
//       for(li j = 0;j < (li)size(v[u]);j++) 
//       {
//          li nodes = v[u][j];
         
//          if (!visited[nodes]) 
//          {
//             n-=1;
//             ances[nodes] = u;
//             q.push(nodes);
//             visited[nodes] = true;
//          }
//       }
//    }
// }

void solve()
{
   li n,k;
   cin>>n>>k;
   vli v(n);

   rep(i,0,n)
   cin>>v[i];

   vli dp(n+1,INF);

   dp[0] = 0;

   dp[1] = abs(v[1]-v[0]);

   for(li i=2;i<n;i++)
   {
      for(li j=1;j<=min(i,k);j++)
      {
        dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j]));
      }
   }

   cout<<dp[n-1]<<'\n';

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

Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int MAX = 31;

typedef long long ll;

int main()
{
	int N,M;
	while( cin >> N && N )
	{
		ll dp[N][MAX]; //i番目の人がj日目までに集められる最大値(bitで表現)
		bool is_ok[N][MAX]; //その人の都合を表す配列
		fill_n((int *)dp, sizeof(dp) / sizeof(int), 0);
		fill_n((bool *)is_ok, sizeof(is_ok) / sizeof(bool), false);

		int f;
		rep(i,N)
		{
			cin >> M;
			rep(m,M){
				cin >> f;
				is_ok[i][f] = true;
			}	
		}
		
		REP( i, 0, N ){
			dp[i][0] |= 1LL<<i;
		}

		const ll COMP = (1LL<<N)-1;
		int ans=-1;
		REP( j, 1, MAX ){
			REP( i, 0, N ){
				if(is_ok[i][j]){
					REP( k, 0, N ){
						if(is_ok[k][j]){
							dp[i][j] |= dp[k][j-1];
						}
					}
				}else{
					dp[i][j] |= dp[i][j-1];
				}
	
				if(dp[i][j] == COMP){ ans=j; goto end; }
			}
		}
end:
		cout << ( (ans==-1) ? -1 : ans ) << endl;  
	}
	return 0;
}


Measured memory_bytes: 2992
import heapq

n = int(input())
A = list(map(int, input().split()))
A_rev = [-x for x in A[::-1]]


def get_sum_list(A):
    h = []
    result = []
    current_sum = 0
    for i, a in enumerate(A[:2 * n]):
        heapq.heappush(h, a)
        current_sum += a
        if i >= n:  # 配列の個数がn+1になってしまっているので引き算が必要
            m = heapq.heappop(h)
            current_sum -= m
        if i >= n - 1:  # 配列の長さがnになっているのでresultに記録する
            result.append(current_sum)
    return result


from_left = get_sum_list(A)
from_right = get_sum_list(A_rev)[::-1]

ans = -float('inf')
for i in range(n + 1):
    score = from_left[i] + from_right[i]
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 38776
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    bool alph[26] = {};
    for(auto c: s) {
        alph[c-'a']=true;
    }
    char c='!';
    for(int i=0; i<26; ++i) {
        if(!alph[i]) {
           c = (char)('a'+i);
           cout<<c<<'\n';
           return 0;
        }
    }
    cout<<"None"<<'\n';
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if(a <= 5) {
    cout << 0 << endl;
  } else if(a >= 6 && a <=12) {
    cout << b / 2 <<endl;
  }else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {
  int n, a[200001] = {0};
  int buka[200001] = {0};
  cin >> n;
  for (int i = 1; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    buka[a[i] - 1]++;
  }
  for (int i = 0; i < n; i++) cout << buka[i] << endl;
  return 0;
}

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

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a))
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T=long long>
inline T IN(){T x; cin>>x; return(x);}
inline void CIN(){}
template <class Head,class... Tail>
inline void CIN(Head&& head,Tail&&... tail){
    cin>>head;
    CIN(move(tail)...);
}
#define CINT(...) int __VA_ARGS__;CIN(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CIN(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CIN(__VA_ARGS__)
#define Yes(a) cout<<(a?"Yes":"No")<<"\n"
#define YES(a) cout<<(a?"YES":"NO")<<"\n"
 
typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int,V,greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N;
vector<int> A,B,C;

int main(){
	cin>>N;
	A.resize(N); B.resize(N); C.resize(N);
	REP(i,N) A[i]=IN();
	REP(i,N) B[i]=IN();
	REP(i,N) C[i]=IN();
	sort(All(A)); sort(All(C));
	ll res=0;
	FOREACH(b,B){
		ll tmp=1;
		tmp*=lower_bound(All(A),b)-A.begin();
		tmp*=C.end()-upper_bound(All(C),b);
		res+=tmp;
	}
	cout<<res<<"\n";
	return 0;
}

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

int h[100010];
vector<int> edges[100010];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)
		scanf("%d", h + i);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b); a--, b--;
		if(h[a] < h[b]) edges[a].push_back(b);
		else if(h[a] > h[b]) edges[b].push_back(a);
		else{
			edges[a].push_back(b);
			edges[b].push_back(a);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(edges[i].size() == 0)
			ans++;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 8368
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    if n == 1 {
        println!("1");
        return;
    } else if n == 2 {
        println!("5");
        return;
    } else if n == 3 {
        println!("11");
        return;
    }

    let mut array = vec![1; n+1];
    array[1] = 1;
    array[2] = 2;
    array[3] = 2;

    let m = (n as f64).sqrt() as usize;
    let mut sieve = vec![true; n+1];
    sieve[0] = false;
    sieve[1] = false;
    let mut d = 2;
    while d <= m {
        let mut t = 2 * d;
        while t <= n {
            sieve[t] = false;
            t += d;
        }

        let mut i = d+1;
        let mut flag = false;
        while i <= m+1 {
            if sieve[i] {
                d = i;
                flag = true;
                break;
            }
            i += 1;
        }
        if !flag {
            break;
        }
    }

    let mut primes = Vec::with_capacity(n+1);
    for i in 0..=n {
        if sieve[i] {
            primes.push(i);
        }
    }

    for d in primes.into_iter() {
        array[d] = 2;
        let mut t = 2 * d;
        while t <= n {
            let mut num = 1;
            let mut u = t;
            while u % d == 0 {
                num += 1;
                u /= d;
            }
            array[t] *= num;
            t += d;
        }
    }

    let res: usize = array
        .into_iter()
        .enumerate()
        .map(|(i, v)| {
            i * v
        }).sum();

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


Measured memory_bytes: 94848
n, a, b = map(int, input().split())


if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    test = (b - a) // 2
    left = a - 1
    right = n - b
    if left >= right:
        print(n - a - test)
    else:
        print(b - 1 - test)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
 
    
    
int main(){
     
  long int a,b,c,t;
  cin>>a>>b>>c;

  t=4*a*b-(c-a-b)*(c-a-b);
  if ((t<0)&&(c-a-b>0))
  {
    cout<<"Yes"<<endl;
  }
  
  else
  {
    cout<<"No"<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


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 up(int a, int b) {
    return (a + a % b) / b;
}

void swap(string s) {
    int low = 0;
    int high = s.length() - 1;
    while (low < high) {
        char tmp = s[low];
        s[low] = s[high];
        s[high] = tmp;
        low++;
        high--;
    }
}

template<class T>  T gcd(T a, T b) {
    while (a % b != 0) {
        T tmp = b;
        b = a % b;
        a = tmp;
    }
    return b;
}

template<class T> T lcm(T a, T b) {
    if (a == b) return b;
    T g = gcd(a, b);
    return (a / g) * b;
}


int main() {
    int n, m;
    int a[100000];
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        n -= a;
    }
    if (n >= 0) {
        cout << n << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636