akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; ++i){
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main(){
    ll n, p;
    cin >> n >> p;
    vector<pair<ll, int>> res = factorize(p);
    ll ans = 1;
    rep(i, res.size()){
        while(res[i].second >= n){
            ans *= res[i].first;
            res[i].second -= n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9+7;

int dp[10005][2][101];

int main(){
  string s;
  cin >> s;
  int d;
  cin >> d;
  int n = s.size();
  dp[0][0][0] = 1;
  rep(i,n) {
    const int P = s[i] - '0';
    rep(j,2) {
      rep(k,d) {
        for (int p = 0; p <= (j ? 9 : P); p++) {
          (dp[i+1][j || (p<P)][(k+p)%d] += dp[i][j][k]) %= mod;
        }
      }
    }
  }
  int res = (dp[n][0][0] + dp[n][1][0] - 1 + mod)%mod;
  cout << res << endl;//0の場合を引く
  return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define inf 1000000000
#define ll long long
using namespace std;
int v[205],d[205],flag=1;
int n,f[205][205],ans=0;
char a[205][205];
void dfs(int x,int dis)
{
    if(v[x])
    {
        if((dis-d[x])%2)
            flag=0;
        return ;
    }
    v[x]=1,d[x]=dis;
    for(int i=1; i<=n; i++)
    {
        if(f[x][i]==1)
            dfs(i,dis+1);
        if(!flag)
            return ;
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%s",a[i]+1);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            f[i][j]=(a[i][j]=='1'?1:inf);
    for(int i=1; i<=n; i++)
        f[i][i]=0;
    for(int i=1; i<=n; i++)
    {
        memset(v,0,sizeof(v));
        memset(d,0,sizeof(d));
        dfs(i,0);
    }
    if(!flag)
    {
        printf("-1");
        return 0;
    }
    for(int k=1; k<=n; k++)
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(f[i][j]!=inf)
                ans=max(ans,f[i][j]);
    printf("%d",ans+1);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

ll frac[100000];
ll inv_frac[100000];

ll binary_method(ll a,ll b){
    if(b==0) return (ll)1;
    ll temp = binary_method(a,b>>1);
    if(b%2) return (((temp*temp)%mod)*a)%mod;
    else return (temp*temp)%mod;
}
ll inv(ll a){
    return binary_method(a,mod-2);
}


ll dfs(vector<int> *edge, int N,ll K,int pos,int parent){
    if(edge[pos].size()==1 && parent != -1) return (ll) 1;
    int child_num ;
    ll ans;
    if(parent==-1){
        child_num = edge[pos].size();
        ans = (frac[K-1]*inv_frac[K-1-child_num])%mod;
    } 
    else {
        child_num = edge[pos].size()-1;
        ans = (frac[K-2]*inv_frac[K-2-child_num])%mod;
    }
    // cout<<ans<<endl;
    rep(i,edge[pos].size()){
        int now_pos = edge[pos][i];
        if(now_pos == parent) continue;
        ans = (ans * dfs(edge,N,K,now_pos,pos)) % mod;
    }
    // cout<<pos<<" "<<ans<<endl;
    return ans;
}

int main(){
    int N;
    ll K;
    cin>>N>>K;
    vector<int> edge[100000];
    int a,b;
    rep(i,N-1){
        cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    if(K==1){
        if(N!=1) cout<<0<<endl;
        else cout<<1<<endl;
        return 0;
    }
    int max_deg = 0;
    rep(i,N) max_deg = max(max_deg,(int)edge[i].size()+1);
    if(max_deg>K) {cout<<0<<endl; return 0;}

    frac[0] = 1;
    Rep(i,1,K-1) frac[i] = frac[i-1]*i %mod;
    rep(i,K) inv_frac[i] = inv(frac[i]); 
    ll ans = dfs(edge,N,K,0,-1);
    ans = (ans*K)%mod;

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

Measured memory_bytes: 12800
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

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

	if(n == 0) {
		cout << 1 << endl;
	} else if(n == 1) {
		cout << 2 << endl;
	} else if(n == 2) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
class PriorityQueue

  def initialize(&compare)
    @items = []
    if block_given?
      @compare_proc = compare
    else
      @compare_proc = Proc.new { |a, b| a > b }
    end
  end
  
  def push(x)
    n = @items.size
    @items << x
    while n != 0
      p = (n - 1) / 2
      if @compare_proc.call(@items[n], @items[p])
        @items[p], @items[n] = @items[n], @items[p]
      end
      n = p
    end
  end
  
  def pop
    result = @items[0]
    @items[0] = @items[-1]
    @items.delete_at(-1)

    n = 0
    loop do
      left = 2 * n + 1
      break if left >= @items.size

      right = left + 1
      if (right < @items.size) && @compare_proc.call(@items[right], @items[left])
        c = right
      else
        c = left
      end
      
      break unless @compare_proc.call(@items[c], @items[n])

      @items[n], @items[c] = @items[c], @items[n]
      n = c
    end
    result
  end

  def empty?
    @items.empty?
  end
  
  def size
    @items.size
  end
end

n, m = gets.split.map(&:to_i)
rewards = (m + 1).times.map{Array.new}
n.times do
  a, b = gets.split.map(&:to_i)
  rewards[a] << b if a <= m
end

ans = 0
reward = PriorityQueue.new
1.upto(m) do |i|
  rewards[i].each do |b|
    reward.push(b)
  end
  unless reward.empty?
    ans += reward.pop
  end
end

puts ans


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

int n,m,r;
int R[9];
long long fw[201][201], ans=100000000;

void per(int x[], int i){
	long long tmp=0;
	if(i==r){
		for(int k=1;k<r;k++){
			tmp+=fw[x[k]][x[k+1]];
		}
		ans=min(ans,tmp);
	}else{
		for(int j=i;j<=r;j++){
			int tt=x[i];
			x[i]=x[j];
			x[j]=tt;
			per(x,i+1);
			x[j]=x[i];
			x[i]=tt;
		}
	}
}

int main(){
	cin>>n>>m>>r;
	for(int i=1;i<=r;i++){
		cin>>R[i];
	}
	for(int i=1;i<=200;i++){
		for(int j=1;j<=200;j++){
			fw[i][j]=100000000;
		}
	}
	int a,b,c;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		fw[a][b]=c;
		fw[b][a]=c;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				fw[i][j]=min(fw[i][j],fw[i][k]+fw[k][j]);
			}
		}
	}
	per(R,1);
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
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...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	char ch;
	cin>>ch;
	++ch;
	cout<<ch;
	return 0;
}




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

int main() {
    long long n;
    scanf("%lld",&n);
    long long ans = 0;
    long long x = (long long)sqrt(n+1);
    for(long long z=1; z<x; z++) {
        if(n%z==0) {
            long long p = n/z;
            ans += (p-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let res = match input.trim() {
        "3" => "YES",
        "5" => "YES",
        "7" => "YES",
        _ => "NO"
    };
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

bool check[200];

int main() {
  int x, n;
  cin >> x >> n;
  rep(i,n) {
    int p;
    cin >> p;
    check[p] = true;
  }
  if(!check[x]) {
    cout << x << endl;
    return 0;
  }
  for(int i = 1; i<=200; i++) {
    if(x-i<=0) {
      cout << x-i << endl;
      break;
    }
    else if(!check[x-i]) {
      cout << x-i << endl;
      break;
    }
    else if(!check[x+i]) {
      cout << x+i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int area(int x,int y)
{   if(x<1||y>100)
    return 0;
    else
    return x*y;}
int perimeter(int x,int y)
{   if(x<1||y>100)
    return 0;
    else
    return 2*x+2*y;}
int main()
{    int a,b;
     cin>>a>>b;
    cout<<area(a,b)<<" "<<perimeter(a,b)<<endl;
    return 0; 
    
    
}


Measured memory_bytes: 3092
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

  if (a + b == c || b + c == a || a + c == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace IO{
	const int maxn(1<<21|1);
	char ibuf[maxn],*iS,*iT,obuf[maxn],*oS=obuf,*oT=obuf+maxn-1,_c,_st[55];
	int _f,tp;
	char Getc(){return (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,maxn,stdin),(iS==iT?EOF:*iS++)):*iS++);}
	void Flush(){fwrite(obuf,1,oS-obuf,stdout);oS=obuf;}
	void Putc(char x){*oS++=x;if(oS==oT)Flush();}
	template<class Int>void Input(Int &x){
		for(_f=0,_c=Getc();_c<'0'||_c>'9';_c=Getc())_f=_c=='-';
		for(x=0;_c<='9'&&_c>='0';_c=Getc())x=(x<<3)+(x<<1)+(_c^48);
		if(_f)x=-x;
	}
	template<class Int>void Print(Int x){
		if(!x)Putc('0');
		if(x<0)Putc('-'),x=-x;
		while(x)_st[++tp]=x%10+'0',x/=10;
		while(tp)Putc(_st[tp--]);
	}
}
using namespace IO;
using namespace std;
const int _=1e6+5;
int f[_],A[_],B[_],W[_],fa[_],n,m;
int cmp(int x,int y){return W[x]<W[y];}
vector<int>fz;int x,y=2e9;
int fi(int x){return fa[x]?fa[x]=fi(fa[x]):x;}
int main(){
	Input(n);Input(m);memset(f,63,sizeof(f));
	for(int i=1;i<=m;++i){
		Input(A[i]);Input(B[i]);Input(W[i]);++A[i];++B[i];
		f[A[i]]=min(f[A[i]],W[i]+1);f[B[i]]=min(f[B[i]],W[i]+2);
		if(f[A[i]]<y)x=A[i],y=f[x];
		if(f[B[i]]<y)x=B[i],y=f[x];
	}
	for(int i=x;i<=n;++i)f[i]=min(f[i],f[i-1]+2);f[1]=min(f[1],f[n]+2);
	for(int i=2;i<=x;++i)f[i]=min(f[i],f[i-1]+2);
	for(int i=1;i<=n;++i)A[++m]=i,B[m]=i%n+1,W[m]=f[i];
	for(int i=1;i<=m;++i)fz.push_back(i);
	sort(fz.begin(),fz.end(),cmp);
	long long ans=0;
	for(int i:fz){
		int fx=fi(A[i]),fy=fi(B[i]);
		if(fx!=fy)fa[fx]=fy,ans+=W[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 27376
def main():
    n = int(input())
    a = list(map(int, input().split()))
    dp = []
    now = 1
    ans = 0
    for i in range(n+1):
        if a[i] > now:
            print(-1)
            return
        else:
            dp.append(now)
            now -= a[i]
            now *= 2
    now = 0
    for i in range(n, -1, -1):
        now += a[i]
        ans += min(now, dp[i])
    print(ans)


main()


Measured memory_bytes: 674452
import math


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h
# print(a)
for i in range(h):
    a[i] = input()
# print(a)
x = [None]*h
y = [None]*w
# print(x)
# print(y)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            x[i] = True
            y[j] = True
# print(x)
# print(y)
for i in range(h):
    if x[i] == True:
        for j in range(w):
            if y[j] == True:
                print(a[i][j], end="")
        print()


Measured memory_bytes: 4468
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, X, m;
    
    cin >> N >> X;
    
    int minPiece = 10000;
    for(int i=0; i<N; ++i){
        cin >> m;
        X -= m;
        if(minPiece > m) minPiece = m;
    }
    
    cout << (N + X/minPiece);
    
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string.h>

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

void solve()
{
	int N;
	cin >> N;
	vector<int> C(N - 1);
	vector<int> S(N - 1);
	vector<int> F(N - 1);
	for (int i = 0; i < N - 1; ++i)
	{
		cin >> C[i] >> S[i] >> F[i];
	}

	for (int i = 0; i < N - 1; ++i)
	{
		int cur = S[i] + C[i];
		for (int j = i + 1; j < N - 1; ++j)
		{
			if (cur < S[j])
			{
				cur = S[j] + C[j];
			}
			else
			{
				int temp = S[j] + (cur - S[j]) / F[j] * F[j];
				while (temp < cur)
				{
					temp += F[j];
				}
				cur = temp + C[j];
			}
		}
		cout << cur << endl;
	}
	cout << 0 << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#ifdef LL
const ll inf = 1e9;
#else 
const ll inf = 1e18;
#endif

const int mod = 1e9 + 7;
const int mod2 = 998244353;

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

// lower bound returns first element greater than the value

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ transform(s.begin(), s.end(), s.begin(), ::toupper); return s; }
template <typename T>
T to_lower(T s){ transform(s.begin(), s.end(), s.begin(), ::tolower); return s; }

int n;
#define rep(i,n) for(int i=0;i<n;i++)

struct Matrix
{
    vvi a = vvi(n,vi(n));
    Matrix operator *(const Matrix& other)
    {
        Matrix product;
        rep(i,n)rep(j,n)rep(k,n)
        {
            product.a[i][k] = (product.a[i][k] + a[i][j]*other.a[j][k])%mod;
        }
        return product;
    }
};

Matrix ExpoPower(Matrix m, ll k)
{
    Matrix res;
    rep(i,n)res.a[i][i]=1;
    while(k>0)
    {
        if(k&1) res = res*m;
        m = m*m;
        k>>=1;
    }
    return res;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    ll k;
    cin>>n>>k;

    Matrix single;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>single.a[i][j];
        }
    }

    Matrix total = ExpoPower(single, k);
    ll ans=0;
    rep(i,n)rep(j,n) ans = (ans+total.a[i][j])%mod;

    cout<<ans<<endl;

    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int f(int n)
{
    int ret = 0;
    while (n % 2 == 0)
    {
        n /= 2;
        ++ret;
    }
    return ret;
}

void Main()
{
    int n = in();
    vint a = in(n);
    int ans = INF;
    rep(i, n)
    {
        ans = min(ans, f(a[i]));
    }
    cout << ans << 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: 256
#include <iostream>

using namespace std;

int main() {
  long long int A, B, K;

  cin >> A >> B >> K;

  cout << ((A>K) ? A-K : 0) << " " << ((K-A>B) ? 0 : ((K-A>0) ? B-K+A : B)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(q,p,k) for(int k = q; k < p; k++)
#define it(q) for(auto j = q.begin(); j != q.end(); j++)
#define s string 
#define vi vector<int>
#define vs vector<string>
#define pb push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long int ll;

int main(){
	ll t;
	cin >> t;
	string ans = "";
	rp(0, t, i){
		ans+="ACL"; 
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
const ll mod = 1e9+7;
const ll maxn = 100005;
char k[maxn];
string s;
ll D;
ll add(ll a, ll b){
	return (a%mod+b%mod+mod)%mod;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> s;
	cin >> D;
	for (ll i = 0; i < s.length(); i++)k[i] = s[i];
	vector<vector<ll>> dp(D, vector<ll>(2));
	dp[0][0] = 1;
	for (ll where = 0; where < s.length(); where++){ //each digit
		vector<vector<ll>> new_dp(D, vector<ll>(2));
		for (ll sum = 0; sum < D; sum++){ //each possible modulo
			for (ll i = 0; i < 2; i++){ 
				for (ll digit = 0; digit < 10; digit++){
					if (digit > k[where]-'0' && i == 0)break;
					bool check = 0;
					if (i == 1)check = 1;
					new_dp[(sum+digit)%D][check || (digit < k[where]-'0')] = add(new_dp[(sum+digit)%D][check || (digit < k[where]-'0')], dp[sum][i]);
				}
			}
		}
		dp = new_dp;
	}
	ll ans = (dp[0][0] + dp[0][1])%mod;
	ans = add(ans, -1);
	cout << ans;
	
}	


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = 0; i + 1 < S.size(); i++)
    {
        if(S[i] == S[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }

        if(i + 2 < S.size() && S[i] == S[i + 2])
        {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }

    cout << "-1 -1";
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
	String ans = "No";
    for(int i = 0;i < str1.length();i++){
      str1 = str1.substring(1,str1.length())+str1.charAt(0);
      if(str1.equals(str2)){
        ans="Yes";
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, n;std::cin >> x >> n;
  vll a(n);
  re(i, n) std::cin >> a[i];
  ll sa = 10000000000, ans = -1;

  for(int i=-100;i<=101;i++){
    bool f = true;
    for(int j=0;j<n;j++) if(a[j]==i) f = false;
    if(!f) continue;
    if(abs(x-i)<sa) sa = abs(x-i), ans = i;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  string a, b; cin >> a >> b;
  int x = stoi(a+b);

  for (int i=1;i<=(int)sqrt(x);i++){
    if (i*i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
b = input().split()
B = []
for i in range(N-1):
  B.append(int(b[i]))

A = []
A.append(B[0])
for i in range(1,N-1):
  A.append(min(B[i-1],B[i]))
A.append(B[N-2])
Asum = 0
for i in range(N):
  Asum += A[i]
print(Asum)

Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d%d", $n, $k);
for($i = 1; $i <= $n; $i++){
  $G[$i] = [];
}

for($i = 0; $i < $n-1; $i++){
  fscanf(STDIN, "%d%d", $a, $b);
  $G[$a][] = $b;
  $G[$b][] = $a;
  $C[] = [$a, $b];
}

$max = 0;
if($k % 2 == 0){
  //偶数の場合は頂点からの距離が$k/2になればよい
  for($i = 1; $i <= $n; $i++){
    $max = max($max, dfs(0, $i, $k/2));
  }
}else{
  //奇数の場合は辺の両端からの距離が[$k/2]になればよい
  foreach($C as list($d, $e)){
    $max = max($max, dfs($d, $e, floor($k/2)) + dfs($e, $d, floor($k/2)));
  }
}
echo $n - $max;

function dfs($from, $current, $left){
  global $G;
  if(!$left)return 1;
  $sum = 1;
  foreach($G[$current] as $to){
    if($to != $from){
      $sum+=dfs($current, $to, $left - 1);
    }
  }
  return $sum;
}

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


int main()
{
  int a,b,c,n1=0,n2=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(a*a+b*b==c*c)
      n1++;
    if(a==b)
      n2++;
  }
  printf("%d\n%d\n",n1,n2);

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> v(n),c(n);
	for (int i=0; i<n; i++)
		cin>>v[i];
	for (int i=0; i<n; i++)
		cin>>c[i];
	int ret=0;
	for (int i=0; i<n; i++)
		ret+=max(0,v[i]-c[i]);
	cout<<ret<<endl;	
	return 0;
}


Measured memory_bytes: 3540
n ,m,x = map(int,input().split())
fee_list = list(map(int,input().split()))

pay_list= [0,0]

for i in range(x,n+1):
    if i in fee_list:
        pay_list[0] += 1

for j in range(x):
    if j in fee_list:
        pay_list[1] += 1

if pay_list[0] < pay_list[1]:
    print(pay_list[0])
else:
    print(pay_list[1])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if (a==1)
	{
		cout<<"Hello World"<<endl;
		return 0;
	}
	else
	{
		int n,m;
		cin>>n>>m;
		cout<<n+m<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#0オリジンで行うので注意
import sys
input = sys.stdin.buffer.readline

INF = 10 ** 9


#隣接行列
n = int(input())
G = []
for _ in range(n):
    G.append(list(map(int, input().split())))
for i in range(n):
    for j in range(n):
        if G[i][j] == -1:
            G[i][j] = INF

#到着してない：white,　到着後:gray, 確定:black
white, gray, black = 1, 2, 3
color = [white] * n #初期条件

d = [INF] * n #d[m]にTに属する頂点とT-Vに属する頂点を繋ぐ辺の中で重みが最小の物を記録
p = [INF] * n #p[m]にMSTにおける頂点mの親を記録


def prim():
    d[0] = 0
    p[0] = -1
    
    while True:
        mincost = INF
        for i in range(n):
            if color[i] != black and d[i] < mincost:
                mincost = d[i]
                u = i #次に伸ばす頂点の候補として記録
                
                
        if mincost == INF: #次の頂点がなかったらbreak
            break
                
        color[u] = black #最小全域木の頂点として決定
            
        for v in range(n):
            if color[v] != black and G[u][v] != INF:
                if G[u][v] < d[v]:
                    d[v] = G[u][v] #d[n]を更新を更新する
                    p[v] = u #uをvの親候補として記録
                    color[v] = gray
    
    S = 0#合計
    for i in range(n):
        if p[i] != -1:
            S += G[i][p[i]]
    return S

print(prim())
            
            



Measured memory_bytes: 5836
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

		
#階乗#
lim = 2*10**5   #必要そうな階乗の限界を入力
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod

S = INT()
ans = 0
for i in range(1, S//3+1):
	left = S - 3*i
	ans += C(left+i-1, i-1)
	ans %= mod

print(ans)


Measured memory_bytes: 25580
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <algorithm> // std::sort(begin,end)
#include <utility> // std::swap, std::pair
#include <assert.h>

using namespace std;



long long  num[100000] = {0};
long long  parent[100000] = {0};

long long  get_root(long long  i){
  if(parent[i] != i)
    parent[i] = get_root(parent[i]); 
  return parent[i];
}

long long  merge(long long  i, long long  j){
  assert(i == parent[i]); 
  assert(j == parent[j]); 
  assert(num[i] != 0); 
  assert(num[j] != 0); 

  if(i == j)
    return i;
  if(num[j] > num[i])
    swap(i,j);
 
  num[i] += num[j];
  parent[j] = i;
  num[j] = 0;

  return i;
}

int main(int  argc, char const* argv[])
{
  long long  n, m;
  cin >> n >> m;

  for (long long  i = 0; i < n; i++) {
    num[i] = 1;
    parent[i] = i;
  }

  stack<pair<long long ,long long >> edges;
  stack<long long > score;
  long long  a,b;
  for (long long  i = 0; i < m; i++) {
    cin >> a >> b;
    edges.push(make_pair(a-1,b-1));
  }

  score.push(n * (n-1) / 2 );
  while(!edges.empty()){
    pair<long long ,long long > p = edges.top();  

    p.first = get_root(p.first);
    p.second = get_root(p.second);

    if(p.first != p.second){
      long long  tmp = score.top() - num[p.first] * num[p.second];
      
      //cerr  << "(" << p.first << "," << p.second << "):" <<  tmp << endl;
      score.push(tmp);
      merge(p.first, p.second);
    }else{
      score.push(score.top());
    }
    edges.pop();
  }

  assert(score.top() == 0);
  score.pop();


  while(!score.empty()){
    cout << score.top() << endl;
    score.pop();
  }

  return 0;
}


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

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

sort(a,a+n);
int ans=0;
for(int i=0;i<k;i++)
ans+=a[i];

cout <<ans;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
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=1LL<<60;

int n;
string s;

int main(){
    cin>>n>>s;
    int cnt=0;
    rep(i,0,n-1){
        if(s[i+1]!=s[i]) cnt++;
    }
    cnt++;
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 3712
def Msol_B_():
    a,b,c = list(map(int,input().split()))
    K = int(input())

    for i in range(8):
        if K==0:
            print('No')
            return 
        if a >= b:
            b *= 2
            K -= 1
        if a < b:
            break
    for i in range(8):
        if  K ==0:
            print('No')
            return
        if b >= c:
            c *= 2
            K -= 1
        if b < c:
            print('Yes')
            return
    print('No')



Msol_B_()


Measured memory_bytes: 9200
N,M=map(int, input().split())

checked = [0] * 8
path = [[] for _ in range(8)]

for i in range(M):
  a,b=map(int, input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)

ans = 0

def dfs(place):
  checked[place] = 1
  if sum(checked) == N:
    return 1
  ret = 0
  for i in path[place]:
    if checked[i] == 1:
      continue
    ret += dfs(i)
    checked[i] = 0
  return ret

print(dfs(0))

Measured memory_bytes: 9016
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
using namespace std;

int main(void){
  int N,M;
  cin >> N >> M;
  vector<bitset<10>> lights;
  for(int i=0;i<M;i++){
    int k;
    cin >> k;
    bitset<10> switches;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      switches |= (1 << (tmp-1));
    }
    lights.push_back(switches);
  }
  vector<int> answers;
  for(int i=0;i<M;i++){
    int tmp;
    cin >> tmp;
    answers.push_back(tmp);
  }
  
  int count = 0;
  for(int bit=0;bit<(1<<N);bit++){
    bitset<10> curbit(bit);
    bool ok = true;
    for(int i=0;i<M;i++){
      if((lights[i] & curbit).count() %2 != answers[i]){
        ok = false;
        break;
      }
    }
    
    if(ok){ count++; }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
class Comb{
    public:
    vector<lint> fac,ifac;
    lint M=1000000;
    Comb(){
        fac.resize(M+1);
        ifac.resize(M+1);
        fac[0] = 1;
        ifac[0] = 1;
        rep(i,M){
            fac[i+1] = fac[i]*(i+1) % MOD;
            ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
        }
    }
    lint mpow(lint x, lint n){
        lint ans = 1;
        while(n != 0){
            if(n&1) ans = ans*x % MOD;
            x = x*x % MOD;
            n = n >> 1;
        }
        return ans;
    }
    lint comb(lint a, lint b){
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        lint tmp = ifac[a-b]* ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};
int main(){
    lint w,h,n;
    cin>>w>>h>>n;
    vec x(n),y(n),a(n);
    rep(i,n)cin>>x[i]>>y[i]>>a[i];
    lint s=0,t=0,u=w,r=h;
    rep(i,n){
        if(a[i]==1)s=max(s,x[i]);
        if(a[i]==2)u=min(u,x[i]);
        if(a[i]==3)t=max(t,y[i]);
        if(a[i]==4)r=min(r,y[i]);
    }
    cout<<max(0LL,u-s)*max(0LL,r-t);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc128/tasks/abc128_c

int main() {
    int N, M; cin >> N >> M;
    int s[M][10];
    int K[M];
    REP(i, M) {
        int k; cin >> k;
        K[i] = k;
        REP(j, k) {
            cin >> s[i][j];
        }
    }
    int p[M]; REP(i, M) cin >> p[i];


    int ans = 0;
    for (int msk = 0; msk < 1<<N; msk++) {
        bool can = true;
        REP(i, M) {
            int oncnt = 0;
            for (int j = 0; j < K[i]; j++) {
                if (msk & 1<< (s[i][j]-1)) oncnt++;
            }
            if (oncnt%2 != p[i]) can = false;
        }
        if (can) ans++;
    }

    cout << ans << "\n";


    return 0;
}

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

const int MOD = 1000000007;
const int MAXN = 3005;

void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }

int dp[2][MAXN];

char A[MAXN];

int N, Ans;

int main() {
	scanf("%d %s", &N, A+2);
	dp[0][1] = 1;
	for(int i = 2; i <= N; i++) {
		if('<' == A[i]) {
			dp[1][1] = 0;
			for(int j = 2, s = 0; j <= i; j++) {
				add(s, dp[0][j-1]);
				dp[1][j] = s;
			}
		} else {
			for(int j = i-1, s = 0; j; j--) {
				add(s, dp[0][j]);
				dp[1][j] = s;
			}
		}
		memcpy(dp[0], dp[1], (i+1) * sizeof(int));
	}
	for(int i = 1; i <= N; i++) add(Ans, dp[0][i]);
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	double a,b,c,d;
	cin >> a >> b >> c >> d;
	cout  << fixed << setprecision(8) << sqrt((a - c) * (a - c) + (b - d) * (b - d)) << endl;
	cin >> a;
}


Measured memory_bytes: 3288
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    string s;
    cin >> s;
    if (s == "RRS" || s == "SRR")
    {
        cout << 2 << endl;
        return 0;
    }
    else if (s == "RRR")
    {
        cout << 3 << endl;
        return 0;
    }
    else if (s == "RSR" || s == "SRS" || s == "SSR" || s == "RSS")
    {
        cout << 1 << endl;
        return 0;
    }
    else
    {
        cout << 0 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
h = list(map(int, input().split()))
inf = 10**4 +1
dp = [inf]* N

dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2,N):
    dp[i] = min(dp[i-1] + abs(h[i]- h[i-1]), dp[i-2] + abs(h[i-2] - h[i]))

print(dp[N-1])


Measured memory_bytes: 13980
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,t,y=100000000000,m;
cin>>n;
ll a[n],b[n],c[n];
for(i=0;i<n;i++)
cin>>a[i]>>b[i]>>c[i];
 ll dp1[n];
 ll dp2[n];
 ll dp3[n];
 dp1[0]=a[0];
 dp2[0]=b[0];
 dp3[0]=c[0];
 for(i=1;i<n;i++)
 {
 	dp1[i]=max(dp2[i-1]+a[i],dp3[i-1]+a[i]);
 	dp2[i]=max(dp1[i-1]+b[i],dp3[i-1]+b[i]);
 	dp3[i]=max(dp1[i-1]+c[i],dp2[i-1]+c[i]);
 }
 cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 8276
using System;

class ABC_135_C
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        string[] input = Console.ReadLine().Split(' ');
        int[] A = new int[N+1];
        for (int i = 0; i < N+1; i++)
        {
            A[i] = int.Parse(input[i]);
        }

        string[] input2 = Console.ReadLine().Split(' ');
        int[] B = new int[N];
        for (int i = 0; i < N; i++)
        {
            B[i] = int.Parse(input2[i]);
        }

        long count = 0;

        for (int i = 0; i < N; i++)
        {
            if (A[i] <= B[i])
            {
                count += A[i];
                B[i] -= A[i];
                A[i] = 0;
            }
            else
            {
                count += B[i];
                A[i] -= B[i];
                B[i] = 0;
            }

            if(A[i+1] <= B[i])
            {
                count += A[i+1];
                B[i] -= A[i+1];
                A[i+1] = 0;
            }
            else
            {
                count += B[i];
                A[i+1] -= B[i];
                B[i] = 0;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 35236
n = int(input())
p = list(map(int, input().split()))
for i in range(n):
    if p[i] != i+1:
        x = p.index(i+1)
        p[i], p[x] = p[x], p[i]
        break
ok = True
for i in range(n):
    if p[i] == i+1:
        continue
    ok = False
    break
if ok:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
// Problem B

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

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

int K;
char S[1000];

int main() {
  cin >> K;
  cin >> S;
  if ((int)strlen(S) <= K) cout << S << endl;
  else {
    for (int i=0; i<K; i++) cout << S[i];
    cout << "...\n";
  }
  
  return 0;
}


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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=0; i<k; i++){
        if(i%2==0){
            if(a%2==1)a--;
            b+=a/2;
            a/=2;
        }
        else{
            if(b%2==1)b--;
            a+=b/2;
            b/=2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256