akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  int ans = a[0] - 1, res = 2;
  for(int i = 1; i < n; i++){
    ans += (a[i] - 1) / res;
    if(res == a[i]) res++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, K;
    cin >> N >> K;
    cout << (N % K == 0 ? 0 : 1) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
  char s[200000];
  int i,c = 1;
  char *a,*z;
  scanf("%s",s);
  a = strchr(s, 'A');
  z = strrchr(s, 'Z');
  while (a != z) {
    c++;
    a++;
  }
  printf("%d\n",c);

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int Comeback(int, int);

int n, search;
int N[21];

int main(){

  int i, q, ans;

  scanf("%d", &n);

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

  scanf("%d", &q);

  for(i = 0; i < q; i++){

    scanf("%d", &search);
    
    ans = Comeback(0,0);

    if(ans == 1)
      printf("yes\n");
    else
      printf("no\n");

  }

  return 0;

}

int Comeback(int i, int sum){
  
  if(sum == search)
    return 1;

  if(i == n)
    return 0;

  if(Comeback((i + 1), N[i] + sum) == 1)
     return 1;

  if(Comeback((i + 1), sum) == 1)
    return 1;

  return 0;  

}

Measured memory_bytes: 580
#include<iostream>
int main() {
	int n;
	std::cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)std::cin >> a[i];
	int count = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == count) {
			count++;
		}
	}
	count--;
	int ans = n - count;
	if (ans == n)ans = -1;
	printf("%d\n", ans);
}

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

ll a[200005],cs[N];

int main()
{

    int n;

    cin >> n;

    string s;

    cin >> s;

  for(int i=0;i<s.size();i++)
  {
      char ch = ((s[i]-'A') + n)%26;
      ch += 'A';
      printf("%c",ch);
  }

    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

const int IINF = 2002002002;
const ll LINF = 9009009009009009009LL;

//===


Vl num, pa;



ll dfs(int level, ll pos)
{
	if (level == 0) {
		return 1;
	}

	ll res = 0;
	if (pos == 0) {
		res = 0;
	}
	else if (pos <= num[level - 1]) {
		res = dfs(level - 1, pos - 1);
	}
	else if (pos == num[level - 1] + 1) {
		res = dfs(level - 1, pos - 1) + 1;
	}
	else if (pos <= num[level - 1] * 2 + 1) {
		res = dfs(level - 1, pos - num[level - 1] - 2) + pa[level - 1] + 1;
	}
	else {
		res = pa[level];
	}

	return res;
}





int main()
{
	int N;
	ll X;
	cin >> N >> X;

	num.resize(N + 1);
	pa.resize(N + 1);

	num[0] = 1;
	pa[0] = 1;
	for (int i = 0; i < N; ++i) {
		num[i + 1] = num[i] * 2 + 3;
		pa[i + 1] = pa[i] * 2 + 1;
	}


	ll ans = dfs(N, X - 1);

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

    
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    if(a + b == 15) print('+');
    else if(a * b == 15) print('*');
    else print('x');
}


Measured memory_bytes: 256
from collections import defaultdict
def resolve():
    n = int(input())
    dict = defaultdict(lambda: [0, 0])
    for _ in range(n):
        dict[input()][0] += 1

    m = int(input())
    for _ in range(m):
        dict[input()][1] += 1

    ans = 0
    for blue, red in dict.values():
        ans = max(ans, blue - red)

    print(ans)

resolve()

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long r = count(begin(s), end(s), 'R');
  long long g = count(begin(s), end(s), 'G');
  long long b = count(begin(s), end(s), 'B');
  auto res = r * g * b;
  for (int j = 1; j < n; ++j) {
    for (int i = 0; i < j; ++i) {
      int k = 2 * j - i;
      if (k < n) {
        res -= s[i] != s[j] and s[j] != s[k] and s[k] != s[i];
      }
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(a) (a).begin(),(a).end()

using namespace std;

const int inf = 1e9 ;

signed main(){
	IOS;
	int n ;
	cin>>n;
	int arr[n];
	for(int& i : arr) cin>>i;
	vector<int>two;
	vector<pair<int,int>>three;
	map<int,int>mp;
	for(int i:arr){
		mp[i]++;
	}
	for(int i:arr){
		if(mp[i]==2){
			two.push_back(i);
		}else if(mp[i]>2){
			three.push_back(make_pair(i,mp[i]));
		}
	}
	sort(all(two)) ;
	sort(all(three)) ;
	two.resize(unique(all(two))-two.begin()) ;
	three.resize(unique(all(three))-three.begin());
	vector<int>ncr;
	for(auto p : three){
		int x = (p.second*(p.second-1))/2 ;
		ncr.push_back(x);
	}
	int sum_ncr = accumulate(all(ncr),0ll) ; 
	
/*
	cout << sum_ncr << endl ;
	for(int i : two ) cout << i << ' ' ; 
	cout << endl; 
	for(auto i : three) cout << i.first << ':' << i.second << ' ' ;
	cout << endl; 
*/
	for(int i=0;i<n;i++){
		int x = arr[i];
	       	if(mp[x] == 1){
			cout << sum_ncr + (int)two.size() << endl ;
		}else if(mp[x] == 2){
			cout << sum_ncr + (int)two.size() - 1 << endl ;
		}else{
			int index = lower_bound(all(three),make_pair(x,-inf)) - three.begin() ; 
			int new_ncr = (three[index].second*(three[index].second-1))/2 ; 
			int ans = sum_ncr - new_ncr ;
			ans += ((three[index].second-2)*(three[index].second-1))/2 ;
		       	cout << ans + (int)two.size() << endl ;
		}
	}	

	return 0;
}


Measured memory_bytes: 12736
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int abs(int x){
    if (x > 0) {
        return x;
    }else{
        return -x;
    }
    
}

int main(){
    string s;
    cin >> s;
    const int C = 753;
    int a[s.size()];
    for(int i = 0; i < s.size(); i++){
        a[i] = s[i] - '0';
    }
    int mn = 1000;
    for(int i = 0; i < s.size() - 2; i++){
        int num;
        num = 100 * a[i] + 10 * a[i+1] + a[i+2];
        if (mn > abs(C - num)) {
            mn = abs(C - num);
        }
    }
    cout << mn << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),i,t;
		double a1,a2,x[]=new double[6],y[]=new double[6];
		while(true){
			if(n<=0) break;
			for(i=0;i<4;i++){
				x[i]=s.nextDouble();
				y[i]=s.nextDouble();
			}
			x[4]=x[0]-x[1];
			x[5]=x[2]-x[3];
			y[4]=y[0]-y[1];
			y[5]=y[2]-y[3];
			a1=y[4]/x[4];
			a2=y[5]/x[5];
			if(a1==a2){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
			n--;
		}
	}

}

Measured memory_bytes: 12000
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/lazysegtree>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
//string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);
template <long long mod > class modint{
public:
    ll x;
    const static unsigned long long mod_plus = (LLONG_MAX / mod) * mod;
    constexpr modint(){x = 0;}
    constexpr modint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){
    }
    constexpr modint operator-(){
        return x == 0 ? 0 : mod - x;
    }
    constexpr modint& operator+=(const modint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr modint operator+(const modint& a) const{
        return modint(*this) += a;
    }
    constexpr modint& operator-=(const modint& a){
        if((x -= a.x) < 0) x += mod;
        return *this;
    }
    constexpr modint operator-(const modint& a) const{
        return modint(*this) -= a;
    }
    constexpr modint& operator*=(const modint& a){
        (x *= a.x)%=mod;
        return *this;
    }
    constexpr modint operator*(const modint& a) const{
        return modint(*this) *= a;
    }
    constexpr modint pow(unsigned long long pw) const{
        modint res(1), comp(*this);
        while(pw){
            if(pw&1) res *= comp;
            comp *= comp;
            pw >>= 1;
        }
        return res;
    }
    //以下、modが素数のときのみ
    constexpr modint inv() const{
        return modint(*this).pow(mod - 2);
    }
    constexpr modint& operator/=(const modint &a){
        (x *= a.inv().x)%=mod;
        return *this;
    }
    constexpr modint operator/(const modint &a) const{
        return modint(*this) /= a;
    }
};
#define mod1 998244353
using mint = modint<mod1>;

ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
using vm = vector<mint>;

struct S {
	mint x;
	int n;
	S(mint _x = 0, int _n = 0) : x(_x), n(_n){}
};

struct F {
	mint a, b;
	F(mint _a = 1, mint _b = 0) : a(_a), b(_b){}
};

S op(S s, S t){
	return S(s.x + t.x, s.n + t.n);
}

S e(){ return S(); }

S mapping(F f, S s){
	return S(f.a * s.x + f.b * s.n, s.n);
}

F composition(F f, F g){
	return F(f.a * g.a, f.a * g.b + f.b);
}

F id(){ return F(); }

int main() {
	cin>>N>>Q;
	vector<S> a(N);
	rep(i, N){
		scanf("%lld", &A);
		a[i] = S(A, 1);
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	rep(_, Q){
		int t, l, r, b, c;
		scanf("%d%d%d", &t, &l, &r);
		if(t == 0){
			scanf("%d%d", &b, &c);
			seg.apply(l, r, F(b, c));
		}else{
			printf("%lld\n", seg.prod(l, r).x.x);
		}
	}
}

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

int main() {
  long long a, b, c, k;

  cin >> a >> b >> c >> k;

  if (k % 2 == 1 && b - a < 1e18)
    cout << b - a;
  else if (a - b < 1e18)
    cout << a - b;
  else
    cout << "Unfair";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		for(int i=0; i<N; i++)
			d[i] = sc.nextInt();
		Arrays.sort(d);

		System.out.println(d[N/2]-d[N/2-1]);
		
		sc.close();
	}
}


Measured memory_bytes: 50348
#include<stdio.h>


#include<queue>



using namespace std ;



struct NoeSis
{
	int x ;
	int y ;
} Sis ;



int mx[] = { 0 ,1 } ;
int my[] = { 1 ,0 } ;


int ans ;




int over_check( int ,int ,int ) ;



int main()
{
	int i ,j ;


	int w ,h ;

	int n ;

	int stop_x ,stop_y ;

	while( scanf( "%d %d" ,&w ,&h ) ,w | h )
	{
		NoeSis Noe = { 1 ,1 } ;


		bool map[ 16 + 1 ][ 16 + 1 ] = { false } ;


		ans = 0 ;


		scanf( "%d" ,&n ) ;


		for( i = 0 ; i < n ; ++i )
		{
			scanf( "%d %d" ,&stop_x ,&stop_y ) ;


			map[ stop_y ][ stop_x ] = true ;
		}



		queue< NoeSis > que ;


		que.push( Noe ) ;



		while( ! que.empty() )
		{
			Sis = que.front() ;

			que.pop() ;


			if( Sis.x == w && Sis.y == h )
			{
				++ans ;
			}


			else
			{
				for( i = 0 ; i < 2 ; ++i )
				{
					if( over_check( w ,h ,i ) & map[ Sis.y + my[ i ] ][ Sis.x + mx[ i ] ] == false )
					{
						Noe = Sis ;

						Noe.x += mx[ i ] ;
						Noe.y += my[ i ] ;


						que.push( Noe ) ;
					}
				}
			}
		}



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



	return 0 ;
}





int over_check( int w ,int h ,int i )
{
	++w ;
	++h ;

	return ( ( Sis.x + mx[ i ] < w ) + ( Sis.y + my[ i ] < h ) ) / 2 ;
}

Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=(LL)1e18;
int n,a[200005];
vector < int > vec;
bool got[200005];
LL m;
 
int stt,lft,nx[60][200005],pr[200005];
LL ds[60][200005];
void getper(){
	int i,j,k;
	for(i=n-1;i>=0;--i) pr[a[i]]=i;
	for(i=n-1;i>=0;--i){
		nx[0][i]=pr[a[i]];
		if(nx[0][i]<=i)
			ds[0][i]=(LL)(n+nx[0][i]-i);
		else
			ds[0][i]=(LL)(nx[0][i]-i);
		++ds[0][i];
		nx[0][i]=(nx[0][i]+1)%n;
//		printf("ds %d %d = %d nx=%d\n",0,i,ds[0][i],(int)nx[0][i]);
		pr[a[i]]=i;
	}
	for(i=1;i<60;++i){
		for(j=0;j<n;++j){
			nx[i][j]=nx[i-1][nx[i-1][j]];
			ds[i][j]=ds[i-1][j]+ds[i-1][nx[i-1][j]];
			ds[i][j]=min(ds[i][j],inf);
//			if(i<3) printf("ds %d %d = %d nx=%d\n",i,j,(int)ds[i][j],nx[i][j]);
		}
	}
	stt=0;
	LL lf=m*(LL)n;
	for(i=59;i>=0;--i){
		if(lf>=ds[i][stt]){
			lf-=ds[i][stt];
			stt=nx[i][stt];
		}
	}
	assert(stt<n);
	if(lft>n+1) exit(0);
	lft=(int)lf;
}
 
int main(){
	int i,j,k;
	scanf("%d%lld",&n,&m);
	for(i=0;i<n;++i) scanf("%d",a+i);
	for(i=0;i<n;++i) if(a[i]<0 || a[i]>200000) exit(0);
	getper();
	memset(got,0,sizeof(got));
	vec.clear();
	for(i=0;i<lft;++i){
		int d=(stt+i)%n,v=a[d];
		if(!got[v]){
			vec.push_back(v);
			got[v]=1;
		}
		else{
			got[v]=0;
				if(vec.empty()) return 0;
			while(vec.back()!=v){
				got[vec.back()]=0;
				vec.pop_back();
				if(vec.empty()) return 0;
			}
			if(vec.empty()) return 0;
			vec.pop_back();
		}
	}
	for(i=0;i<(int)vec.size();++i)
		printf("%d ",vec[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 144756
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> dx={1,0,-1,0},dy={0,-1,0,1};
map<P,P> mp;
int main(){
    set<int> s;
    s.insert(1);s.insert(2);s.insert(3);
    int a,b;
    cin>>a>>b;
    s.erase(a);s.erase(b);
    cout<<*s.begin()<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int head,nu,out,near,i,j;
  int graph_s[100][100];

  scanf("%d",&head);

  for(i=0;i<head;i++){
    for(j=0;j<head;j++){
      graph_s[i][j]=0;
    }
  }


  for(i=0;i<head;i++){
    scanf("%d%d",&nu,&out);
    for(j=0;j<out;j++){
      scanf("%d",&near);
      graph_s[nu-1][near-1]=1;
    }
  }

  
  for(i=0;i<head;i++){
    for(j=0;j<head;j++){
      if(j>0) printf(" ");
      printf("%d",graph_s[i][j]);
    }
    printf("\n");
  }

  return 0;
}
    



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, k, s;
	cin >> n >> k >> s;
	//int x = 1; vi v;
	if(s<1e9)
	{
		zip(i, 0, k)
		{
			cout << s << " ";
		}
		int x = n - k;
		zip(i, 0, x)
		{
			cout << s + 1 << " ";
		}
		cout << en;
	}
	else
	{
		zip(i, 0, k)
		{
			cout << s << " ";
		}
		int x = n - k;
		zip(i,0,x)
		{
			cout<<1<<" ";
		}
	}


	return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int ms = 10;
int visit[ms];
vector<int> g[ms];
int n,m;

int dfs(int node, int p){
	visit[node] = 1;
	bool f = 0;
  for(int i = 1;i<=n;i++){
  	if(!visit[i])
      	f = 1;
  }
  if(!f)
    	return 1;
 	int ans = 0;
  for(auto it : g[node]){
  		if(it==p)
          	continue;
   		if(!visit[it]){
        	ans += dfs(it,node);
          visit[it] = 0;
        }
  
  }
  return ans;
  

}

int main(){
	int a,b;
	cin >> n >> m;
  for(int i = 0;i<m;i++){
  	cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout<<dfs(1,-1);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    ll sol = (x / 11) * 2;
    x %= 11;
    cout << sol + (x > 6) + (x != 0);
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100

void Bsort(int a[], int n);

int main(void) {
  int A[MAX];
  int N;
  scanf("%d", &N);

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

  Bsort(A, N);

  return 0;
}

void Bsort(int a[], int n) {
  int tmp, j;
  int c = 0;
  int flag = 1;
  int i = 0;

  while(flag) {
    flag = 0;
    for(j=n-1; j>=i+1; --j) {
      if(a[j] < a[j-1]) {
        tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;

        c++;
        flag = 1;
      }
    }
    ++i;
  }

  for(j=0; j<n; ++j) {
    if(j != n-1) {
      printf("%d ", a[j]);
    }
    else printf("%d\n", a[j]);
  }
  printf("%d\n", c);

}



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct SegTree {
	std::vector<int> data;
	std::vector<bool> clear;
	int n;
	SegTree (int n_) {
		for (n = 1; n < n_; n <<= 1);
		data.resize(n << 1);
		clear.resize(n << 1);
	}
	void flush(int i) {
		if (clear[i]) {
			if (i < n) {
				clear[i << 1] = true;
				clear[i << 1 | 1] = true;
			}
			data[i] = 0;
			clear[i] = false;
		}
	}
	int get(int i, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (node_l == node_r - 1) return data[node];
		int m = node_l + (node_r - node_l) / 2;
		if (i < m) return get(i, node << 1, node_l, m);
		else return get(i, node << 1 | 1, m, node_r);
	}
	void set(int i, int val, int node = 1, int node_l = 0, int node_r = 0) {
		if (!node_r) node_r = n;
		flush(node);
		if (node_l == node_r - 1) {
			data[node] = val;
		} else {
			int m = node_l + (node_r - node_l) / 2;
			if (i < m) return set(i, val, node << 1, node_l, m);
			else return set(i, val, node << 1 | 1, m, node_r);
		}
	}
	void zero_clear() {
		clear[1] = true;
	}
	int operator[] (int i) {
		return get(i);
	}
};

#define MOD 1000000007
int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	std::vector<SegTree> dp(3, SegTree(100001));
	if (a[0] != 0) {
		std::cout << 0 << std::endl;
		return 0;
	}
	dp[0].set(0, 1);
	dp[1].set(0, 1);
	dp[2].set(0, 1);
	for (int i = 1; i < n; i++) {
		int prim = a[i - 1];
		std::vector<std::pair<std::pair<int, int>, int> > add_list;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				bool new_primary = !k || (!j && k == 1);
				bool old_primary = !j || (!k && j == 1);
				if (!new_primary && i - a[i - 1] - 1 - a[i] < 0) continue;
				if (!old_primary && i - a[i] - a[i - 1] - 1 < 0) continue;
				int add_num = dp[j][new_primary ? a[i] : i - a[i - 1] - 1 - a[i]];
				add_list.push_back({{k, old_primary ? a[i - 1] + 1 : i - a[i - 1] - a[i] - 1}, add_num});
			}
		}
		if (a[i] != a[i - 1] + 1) {
			for (int j = 0; j < 3; j++) {
				dp[j].zero_clear();
			}
		}
		for (auto &i : add_list) {
			int val = dp[i.first.first][i.first.second];
			val += i.second;
			if (val >= MOD) val -= MOD;
			dp[i.first.first].set(i.first.second, val);
		}
	}
	int res = 0;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <= 100000; j++) {
			res += dp[i][j];
			if (res >= MOD) res -= MOD;
		}
	}
	std::cout << res << std::endl;
	return 0;
}


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


int main(){

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

  int max= -999999999;
  int minr=r[0];
  for(int i=0;i<n;i++){
    if(r[i]<=minr){
      for(int j=i+1;j<n;j++){
	if(max<r[j]-r[i])
	  max=r[j]-r[i];
      }
      minr=r[i];
    }
  }
  
  cout << max << endl;

}

Measured memory_bytes: 1940
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    xor = 0

    for ai in a:
        xor ^= ai

    tmp = xor
    ans = list()

    for ai in a:
        xor ^= ai
        ans.append(xor)
        xor = tmp

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 124052
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}


int main(){
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;

}


Measured memory_bytes: 81204
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll D, T, S;
	cin >> D >> T >> S;

	string ans;

	if (T * S >= D) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
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; }
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    rep(i, 0, M) {
        cin >> a[i] >> b[i];
        int bit = 0;
        rep(j, 0, b[i]) {
            int t; cin >> t;
            t--;
            bit |= (1 << t);
        }
        c[i] = bit;
    }
    vector<int> dp((1 << N) + 1, INF);
    dp[0] = 0;
    rep(i, 0, M) rep(bit, 0, (1 << N))  {
        chmin(dp[bit | c[i]], dp[bit] + a[i]);
    }
    int ans = dp[(1 << N) - 1];
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
denger = [False] * (n + 1)
for i in range(m):
    denger[int(input())] = True

DP = [0] * (n + 1)
DP[0] = 1
for i in range(n):
    if not denger[i + 1]:
        DP[i + 1] += DP[i]
    if i + 2 <= n and not denger[i + 2]:
        DP[i + 2] += DP[i]

print(DP[-1] % 1000000007)

Measured memory_bytes: 468884
from collections import deque

S = input()
pre, post = deque(), deque()
Q = int(input())
reversed = False
for _ in range(Q):
  query = input().split()
  if query[0] == '1':
    reversed = not reversed
    pre, post = post, pre
  else:  # query[0] == 2
    F, C = query[1:]
    if F == '1':
      if reversed:
        pre.append(C)
      else:
        pre.appendleft(C)
    else:  # F == '2'
      if reversed:
        post.appendleft(C)
      else:
      	post.append(C)
if reversed:
  print(''.join(pre)[::-1] + S[::-1] + ''.join(post)[::-1])
else:
  print(''.join(pre) + S + ''.join(post))

Measured memory_bytes: 6508
#include<cstdio>

using namespace std;
int main(void)
{
	int a,b;
	while(scanf("%d",&a))
	{
		if(a == 0) break;
		int c = 0;
		for(int i = 1;i < 10;i++)
		{
			scanf("%d",&b);
			c += b;
		}
		c = a - c;
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
//const int PI = acos(-1);
int main(){
	int n;cin>>n;
	int a =0,b=0,ab=0,same=0;
	rep(i,n){
		string s;
		cin>>s;
		rep(j,s.length()-1){
			if(s[j]=='A'&&s[j+1]=='B')ab++;
		}
		if(s[0]=='B')b++;
		if(s[s.length()-1]=='A')a++;
		if(s[s.length()-1]=='A'&&s[0]=='B')same++;
	}
	int ans = ab+min(a,b);
	if(same==a&&same==b&&same!=0)ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

class Node
{
public:
	int location;
	int p,l,r;
	Node(){}
};

class Point
{
public:
	int id,x,y;
	Point(){}
	Point(int id,int x,int y):id(id),x(x),y(y){}
	bool operator<(const Point &p)const
	{
		return id<p.id;
	}
	
	void print()
	{
		printf("%d\n",id);
	}
};

static const int MAX=1000000;
static const int NIL=-1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}

int makekDTree(int l,int r,int depth)
{
	if(!(l<r))return NIL;
	int mid=(l+r)/2;
	int t=np++;
	if(depth%2==0)
	{
		sort(P+l,P+r,lessX);
	}
	else
	{
		sort(P+l,P+r,lessY);
	}
	T[t].location=mid;
	T[t].l=makekDTree(l,mid,depth+1);
	T[t].r=makekDTree(mid+1,r,depth+1);
	
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans)
{
	int x=P[T[v].location].x;
	int y=P[T[v].location].y;
	
	if(sx<=x&&x<=tx&&sy<=y&&y<=ty)
	{
		ans.push_back(P[T[v].location]);
	}
	
	if(depth%2==0)
	{
		if(T[v].l!=NIL)
		{
			if(sx<=x)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL)
		{
			if(x<=tx)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
	else
	{
		if(T[v].l!=NIL)
		{
			if(sy<=y)find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL)
		{
			if(y<=ty)find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
}

int main()
{
	int x,y;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l=T[i].r=T[i].p=NIL;
	}
	np=0;
	int root=makekDTree(0,N,0);
	
	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i=0;i<q;i++)
	{
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j=0;j<ans.size();j++)
		{
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 15868
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ld pi=2.0*acos(0.0);
ll arr[MAX][3];
ll dp[MAX][3];
ll n;
ll solve(int p,int v)
{
	if(p>n)
	return 0;
	if(dp[p][v]!=-1)
	return dp[p][v];
	dp[p][v]=-1;
	for(int i=0;i<3;i++)
	{
		if(i==v)
		continue;
		dp[p][v]=max(dp[p][v],solve(p+1,i));
	}
	return dp[p][v]+=arr[p][v];
}
int main() {
	fastIO
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	for(int i=0;i<=n;i++)
	for(int j=0;j<3;j++)
	dp[i][j]=-1;
	ll ans =-1;
	for(int i=0;i<3;i++)
	ans = max(solve(1,i),ans);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14720
import java.util.*;

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

		int N = stdIn.nextInt();
		int[] numbers = new int[N];

		for (int i = 0; i < N; i++) {
			numbers[i] = stdIn.nextInt();
		}

		int sortCounter = 0;

		/*?????????????????¬???*/
		for (int i = 0; i < N; i++) {
			int min = numbers[i];
			int minIndex = i;

			/*??´?????????????????????????????§????°????????????????*/
			for (int j = i + 1; j < N; j++) {
				if (min > numbers[j]) {
					min = numbers[j];
					minIndex = j;
				}
			}

			/*??\???????????????????????????????????????*/
			if (minIndex != i) {
				/*??´????????????????????????????????¨????°?????????´????????\????????????*/
				int tmp = numbers[i];
				numbers[i] = numbers[minIndex];
				numbers[minIndex] = tmp;
				sortCounter++;
			}
		}

		/*????????????*/
		for (int i = 0; i < N - 1; i++) {
			System.out.print(numbers[i] + " ");
		}
		System.out.println(numbers[N - 1]);
		System.out.println(sortCounter);
	}
}

Measured memory_bytes: 26360
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<string> s(N);rep(i,N)cin >> s[i];
    vector<map<char,int>> vm(N);

    rep(i,N){
        if(i == 0){
            rep(j,s[i].size())vm[i][s[i][j]]++;
        }
        else{
            rep(j,s[i].size()){
                if(vm[0][s[i][j]] > vm[i][s[i][j]])vm[i][s[i][j]]++;
            }
        }
    }

    map<char,int> m2;
    rep(i,N){
        for(auto t : vm[i]){
            int tmp = t.S;
            char a = t.F;
            rep(k,N){
                chmin(tmp,vm[k][a]);
            }
            m2[a] = tmp;
        }
    }

    for(auto t : m2){
        cout << string(t.S,t.F); 
    }
    cout << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)


def initRMQ(n):
    n_ = 1

    while n_ < n:
        n_ *= 2

    D = []
    for _ in range(2*n_ - 1):
        D.append(0)

    return n_, D


def update(k, a):
    k += n_ - 1
    D[k] += a
    while k > 0:
        k = int((k - 1) / 2)
        D[k] = D[k*2 + 1] + D[k*2 + 2]


def findSum(a, b):
    return query(a, b + 1, 0, 0, n_)


def query(a, b, k, l, r):
    #print('q', a, b, k, l, r)
    if r <= a or b <= l:
        return 0

    if a <= l and r <= b:
        return D[k]

    vl = query(a, b, k*2 + 1, l, int((l + r)/2))
    vr = query(a, b, k*2 + 2, int((l + r)/2), r)

    return vl + vr


if __name__ == '__main__':
    n, q = map(int, input().split())

    n_, D = initRMQ(n)

    for _ in range(q):
        #print(D)
        c, x, y = map(int, input().split())

        if c == 0:
            update(x - 1, y)

        else :
            print(findSum(x - 1, y - 1))



Measured memory_bytes: 10864
n,k=gets.split
n=n.to_i
k=k.to_i

b=k+1
ans=0
key=1
aa=0
bb=0

if k==0
    puts n**2
    exit
end
(n-b+1).times{
    
    aa=n/b

ans+=key*aa
 bb=b*aa+k
 
 ans+=[n-bb+1,0].max
   
   key+=1
   b+=1
   
}



puts ans

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

int main(){
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << "7" << endl;
  }
  else if(S == "MON"){
    cout << "6" << endl;
  }
  else if(S == "TUE"){
    cout << "5" << endl;
  }
  else if(S == "WED"){
    cout << "4" << endl;
  }
  else if(S == "THU"){
    cout << "3" << endl;
  }
  else if(S == "FRI"){
    cout << "2" << endl;
  }
  else if(S == "SAT"){
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    
    while(true){
      int n = sc.nextInt();
      int m = sc.nextInt();
      if (n == 0 && m == 0) return;
      int a[] = new int[n];
      int b[] = new int[m];
      int sumA = 0;
      int sumB = 0;
      for (int i = 0; i < n; i++) {
        a[i] = sc.nextInt();
        sumA += a[i];
      }
      for (int i = 0; i < m; i++) {
        b[i] = sc.nextInt();
        sumB += b[i];
      }
      
      int minsum = 100000;
      int mini = -1, minj = -1;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if ( (sumA - a[i] + b[j]) == (sumB - b[j] + a[i]) ) {
            if ( (a[i] + b[j]) < minsum) {
              minsum = a[i] + b[j];
              mini = i;
              minj = j;
            }
          }
        }
      }
      
      if (mini == -1)
        System.out.println("-1");
      else
        System.out.println(a[mini] + " " + b[minj]);
    }
  }
}


Measured memory_bytes: 29556
#include <stdio.h>
 
int main(){
  int N, A, B;
  1 <= N <= 20;
  1 <= A <= 50;
  1 <= B <= 50;
  int NA;

  
  	
  scanf("%d %d %d", &N, &A, &B);
  NA = N * A;
  
  
  if(NA <= B){
    printf("%d", NA);
  }else if(B < NA){
    printf("%d", B);
  }
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n, m, x;
vi c;
vvi a;
int ans = INT_MAX;

void dfs(int cnt = -1, int sum = 0, vi US = vi(m, 0), int choice = -1){
    if(cnt == n){
        bool ok = true;
        rep(i, m) if(US[i] < x) ok = false;
        if(ok) ans = min(ans, sum);
        return;
    }
    else{
        if(choice == 1){
            sum += c[cnt];
            rep(i, m) US[i] += a[cnt][i];
        }
        cnt++;
        dfs(cnt, sum, US, 0);
        dfs(cnt, sum, US, 1);
    }
}

void Main(){
    cin >> n >> m >> x;
    c = vi(n);
    a = vvi(n, vi(m));

    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    
    // dfs で 2^n 通りを全探索
    dfs();
    if(ans == INT_MAX) cout << -1 << endl;
    else cout << ans << endl;
    return;
}

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

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

const int maxn = 2e5+5;
int N;
vector<int> adj[maxn];

int maxdist = 0, u = -1;
void DFS(int i, int d, int p) {
    if (d >= maxdist) {
        maxdist = d;
        u = i;
    }
    for (int j: adj[i]) {
        if (j == p) continue;
        DFS(j,d+1,i);
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    DFS(1,0,1);
    DFS(u,0,u);
    int diam = maxdist;
    cout << (diam%3 == 1 ? "Second" : "First") << '\n';
}



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

int main()
{
    int n;
    cin >> n;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (i - minj) cnt++;
        swap(a[i], a[minj]);
    }

    for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? "" : " ");
    cout << endl << cnt << endl;

    return 0;
}



Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=[int(input()) for i in range(N)]
    sorted_A=list(sorted(A))
    d={x:i for i,x in enumerate(sorted_A)}
    ans=0
    for i in range(N):
        if d[A[i]]%2!=i%2:
            ans+=1
    ans//=2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 56924
solver::Int->Bool
solver n = let ls = [i*4+j*7|i<-[0..div n 4],j<-[0..div n 7]] in
           elem n ls

main::IO()
main=do
  nc<-getLine
  let n = read nc
  putStr (if solver n then "Yes\n" else "No\n")


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

int a,b,c,d;
int temp;
std::cin >> a>>b>>c>>d;
int min[2]={a,b};
int big[2]={c,d};


if(a>c){min[0]=c;min[1]=d;big[0]=a;big[1]=b;}
int ans=min[1]-big[0];
if(big[1]<min[1])ans=big[1]-big[0];
if(ans<0)ans=0;
std::cout << ans << '\n';


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	dunk(n % 2 == 0 ? n / 2 : n / 2 + 1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(n == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;

namespace ITP1_9_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            var result = new List<string>();

            while ((input = Console.ReadLine()) != "-")
            {
                Deck deck = new Deck(input);
                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++)
                    deck.Shuffle(int.Parse(Console.ReadLine()));
                result.Add(deck.Cards);
            }
            foreach (var r in result) Console.WriteLine(r);
        }
    }
    class Deck
    {
        public string Cards { set; get; }

        public Deck(string cards) { Cards = cards; }

        public void Shuffle(int h)
        {
            Cards = Cards.Substring(h) + Cards.Substring(0, h);
        }

    }
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> c(n);
  bool f = false;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    if (x == y && f) {
      f = true;
      c[i] = c[i - 1] + 1;
    } else if (x == y) {
      f = true;
      c[i] = 1;
    } else {
      f = false;
    }
  }
  bool good = false;
  for (int i = 0; i < n; i++) {
    if (c[i] == 3) good = true;
  }
  if (good) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3652
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll mm=998244353;
ll fact[2*100002];

ll fpow(ll aa,ll power){
    if(power==0) return(1);
    ll b=fpow(aa,power/2);
    if(power%2==0) return((b*b)%mm);
    else return((((b*b)%mm)*aa)%mm);
}

int main(){
    ll n,m,k,ans=0;
    cin>>n>>m>>k;

    fact[0]=1;
    for1(i,n) fact[i]=(i*fact[i-1])%mm;
    //cout<<fpow(2,3);
    forn(i,k+1){
        ll p=(fact[n-1]*fpow(fact[i],mm-2))%mm;
        p=(p*fpow(fact[n-1-i],mm-2))%mm;
        p=(p*m)%mm;
        p=(p*fpow(m-1,n-i-1))%mm;
        ans=(ans+p)%mm;
    }
    cout<<ans;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
using vec_ll = vector<ll>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    ll N, K; cin>>N>>K;
    vec_ll A(N), F(N);
    rep(i,N)cin>>A.at(i);
    rep(i,N)cin>>F.at(i);

    sort(A.begin(),A.end());
    sort(F.begin(),F.end());

    //よし、二分探索だ
    ll left = -1;
    ll right = pow(10,18); 

    while(right>left+1){
        ll comp = (left+right)/2;
//        cout<<right<<" "<<left<<" "<<comp<<endl;

        //compのスコアを達成できるかをチェックする
        ll used_K = 0;
        int flag = 0;
        rep(i,N){
            if(F.at(N-1-i)*A.at(i)>comp){
                used_K+=(F.at(N-1-i)*A.at(i)-comp)/F.at(N-1-i);
                if((F.at(N-1-i)*A.at(i)-comp)%F.at(N-1-i)!=0)used_K++;
            }
            if(used_K>K){
                flag=1;
                break;
            }
        }
        //flag=1の時にはスコアを達成できなかった
        if(flag==1){
            left = comp; 
        }else{
            right = comp;
        }
    }
    cout<<right<<endl;


    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

#define pi 3.1415926535897932384

main()
{
        int n; cin>>n;
        string a,b,c; cin>>a>>b>>c;

        int ans=0;

        rep(i,n)
        {
                set<char> s;
                s.insert(a[i]);
                s.insert(b[i]);
                s.insert(c[i]);

                if(s.size()==2)ans++;
                if(s.size()==3)ans+=2;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256