akhauriyash/Code-Regression huggingface dataset:
S=str(input())
s=list(S)
x,y=map(int,input().split())
fora=0
side=[]
updw=[]
while s[0]=="F":
  fora+=1
  s.pop(0)
  if len(s)==0:break
flag=1#1のとき横向き、-1のときたて向き
step=0
while s:
  if s[0]=="T":
    s.pop(0)
    if step:
      if flag==-1: updw+=[step]
      else: side+=[step]
    flag=flag*(-1)
    step=0
  elif s[0]=="F":
    s.pop(0)
    step+=1
    if len(s)==0:
      if flag==-1: updw+=[step]
      else: side+=[step]
  else: break
ypossi=len(side)
tpossi=len(updw)
X=sum(side)+fora+abs(x)
Y=sum(updw)+abs(y)
xdp=[[0 for i in range(2*X+1)] for j in range(ypossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
xdp[0][fora+X]=1 
for i in range(ypossi):
  for j in range(2*X+1):
    if j-side[i]>=0:
      if xdp[i][j-side[i]]==1:xdp[i+1][j]=1
    if j+side[i]<2*X+1:
      if xdp[i][j+side[i]]==1:xdp[i+1][j]=1

ydp=[[0 for i in range(2*Y+1)] for j in range(tpossi+1)]
#dp[i][j] i個文字使ったときにj+len(s)は達成できるか
ydp[0][Y]=1 
for i in range(tpossi):
  for j in range(2*Y+1):
    if j-updw[i]>=0:
      if ydp[i][j-updw[i]]==1:ydp[i+1][j]=1
    if j+updw[i]<2*Y+1:
      if ydp[i][j+updw[i]]==1:ydp[i+1][j]=1
if xdp[ypossi][x+X]==1 and ydp[tpossi][y+Y]==1:
  print("Yes")
else: print("No")

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

using lli = long long int;

using namespace std;

constexpr lli INF = 1ll << 60;
constexpr lli MAX_V = 100100;

int main() {
    lli N, W;
    cin >> N >> W;

    std::vector<lli> w(N + 1), v(N + 1);
    for (lli i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    std::vector<std::vector<lli>> dp(N + 1, std::vector<lli>(MAX_V, INF));

    dp[0][0] = 0;

    for (lli i = 0; i < N; ++i) {
        for (lli dpv = 0; dpv < MAX_V; ++dpv) {

            if (dpv - v[i] >= 0) {
                dp[i + 1][dpv] = std::min(dp[i + 1][dpv], dp[i][dpv - v[i]] + w[i]);
            }

            dp[i + 1][dpv] = std::min(dp[i + 1][dpv], dp[i][dpv]);
        }
    }

    lli ans = 0;
    for (int i = 0; i < MAX_V; ++i) {
        if (dp[N][i] <= W) { ans = i; }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int main(){
	int x=read();
	for(int i=1;i;i++){
		if(i*(i+1)>=(2*x)){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll cnt[10][10];

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        cnt[s[0]-'0'][s[s.size()-1]-'0']++;
    }

    ll ans=0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }

    cout<<ans<<endl;
}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

int main(){
	ll n;
	cin >> n;
	string ans = "";
	while(n > 0){
	    n--;
	    ans += 'a' + n%26;
	    n /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3656
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
M = 1500000
l = [1]*(M+1)
p = 2
prime = []
while p <= M:
    while p <= M and not l[p]:
        p += 1
    j = p
    while j <= M:
        l[j] = 0
        j += p
    prime.append(p)
    
def solve(k):
    i = bisect.bisect_left(prime,k)
    if prime[i] == k:
        print(0)
    else:
        print(prime[i] - prime[i-1])
    return

#Solve
if __name__ == "__main__":
    while 1:
        k = I()
        if k == 0:
            break
        solve(k)



Measured memory_bytes: 24620
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    cin>>n>>m>>p;
   q=m/n;
   if(m%n!=0&&q==(p/n))
   cout<<"NG"<<endl;
   else
   cout<<"OK"<<endl;
   
}


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

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

    if (M == 1 || N >= M) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> X(M);
    rep(i, M) cin >> X[i];
    sort(all(X));
    vector<int> diff(M - 1);
    rep(i, M - 1) {
        diff[i] = X[i + 1] - X[i];
    }
    sort(all(diff));

    int ans = accumulate(all(diff), 0);
    rep(i, N - 1) {
        if (diff.size() - 1 > i) {
            ans -= diff[M - 2 - i];
        };
    }
    cout << ans << endl;
}

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

int main(){
  char a,c[128];
  cin >> a;
  c['A'] = 'T';
  c['T'] = 'A';
  c['C'] = 'G';
  c['G'] = 'C';
  cout << c[(int)a] << endl;
}


Measured memory_bytes: 256
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define isko_lga_dala_to_life_jhinga_la_la ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define pld pair<long double,long double>
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define inv(v) for(auto&i:v) in(i)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpl vector<pair<ll,ll>>
#define INF 0x3f3f3f3f

template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<t.first<<" "<<t.second; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }

int main() {
        ll n,a,b;
        in3(n,a,b);
        ll y= min(a,b);
        ll t= max(a,b);
        ll ans = min(t-1,n-y);
        if((t-y)%2==0) ans = min(ans,(t-y)/2);
        else {
            ans = min(ans, (t+y-1)/2);
            ans=min(ans,((2*n)-t-y+1)/2);
        }
        cout<<ans<<endl;   
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int n, m;


int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  vvi graph (n+1);
  for (int i = 0; i < m; ++i) {
    int a, b; cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<bool> visited(n+1,false);
  vector<int> ans(n+1,0);
  visited[1] = true;

  int C = 0;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    queue<int> nq;
    while (!q.empty()) {
      auto nde = q.front(); q.pop();
      for (auto u : graph[nde]) {
        if (visited[u]) continue;
        visited[u] = true;
        ans[u] = nde;
        C += 1;
        nq.push(u);
      }
    }
    swap(q, nq);
  }

  if (C < n-1) {
    cout << "No\n";
    return 0;
  }


  cout << "Yes\n";
  for (int i = 2; i <= n; ++i) {
    cout << ans[i] << endl;
  }
  cout << endl;
  

  return 0;
}



Measured memory_bytes: 10384
n, k = map(int, input().split())
d = []
A = [A for A in range(1, n+1)]
ans = []
for i in range(k):
  d.append(int(input()))
  al = list(map(int, input().split()))
  for j in range(len(al)):
    if not(al[j] in ans):
      ans.append(al[j])
print(len(list(set(A)-set(ans))))


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

int main() {
    int n, c, k;
    cin >> n >> c >> k;

    priority_queue<int, vector<int>, greater<int>> que;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        que.push(t);
    }

    int ans = 0;
    while (!que.empty()) {
        int first = que.top(),
            member = 0;
        while (!que.empty() && member < c && que.top() <= first + k) {
            que.pop();
            member++;
        }
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 892
<?php

$number = explode(" ", trim(fgets(STDIN)));

$tmp = $number[0];
$number[0] = $number[1];
$number[1] = $tmp;

$tmp = $number[0];
$number[0] = $number[2];
$number[2] = $tmp;

echo $number[0]." ".$number[1]." ".$number[2]."\n";

Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	if (a>b) cout<<0<<endl;
	else if (n==1)
	{
		if (a==b) cout<<1<<endl;
		else cout<<0<<endl;
	}
	else if (n==2)
	{
		cout<<2<<endl;
	}
	else cout<<((n-1)*b+a)-((n-1)*a+b)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200000;

int main() {
	int n;cin>>n;
	int a[N];
	rep(i,n) cin>>a[i];
	int r=0,s=a[0];
	ll ans=0LL;
	for(int l=0;l<n;l++){
		while(r<n-1&&s+a[r+1]==(s^a[r+1])){
			s+=a[r+1];
			r++;
		}
		ans+=r-l+1;
		if(r<n-1&&l==r){
			s+=a[r+1];
			r++;
		}
		s-=a[l];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=3010;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
char str[N];
pair<int,int>p[N*2];
#define l first
#define r second
inline bool cmp (const pair<int,int> &a,const pair<int,int> &b) { return a.l==b.l?a.r>b.r:a.l<b.l; }
int f[N][N],sum[N];
const int mod=1e9+7;
inline void inc(int &x,int y) { (x+=y)>=mod?x-=mod:0; }
int main()
{
	int n=gi(),m=gi(),i,j,t,d;
	scanf("%s",str+1);
	for (i=1;i<=n+1;i++) sum[i]=sum[i-1]+(str[i]=='1');
	for (i=1;i<=n;i++) p[i].l=p[i].r=i;
	for (i=n+1,m+=n;i<=m;i++) p[i].l=gi(),p[i].r=gi();
	sort(p+1,p+1+m,cmp);
	for (i=1,t=m,m=0;i<=t;i++) if (p[i].r>p[m].r) p[++m]=p[i];
	p[m+1]=make_pair(n+1,n+1);
	f[1][sum[p[1].r]-sum[p[1].l-1]]=1;
	for (i=t=1;i<=n;i++) {
		if (p[t+1].l<=i) t++;
		for (j=0;j<=n;j++)
			if (f[i][j]) {
				d=p[t+1].l==i+1?sum[p[t+1].r]-sum[p[t].r]:0;
				if (j) inc(f[i+1][j-1+d],f[i][j]);
				if (j!=p[t].r-i+1) inc(f[i+1][j+d],f[i][j]);
			}
	}
	printf("%d\n",f[n+1][0]);
	return 0;
}


Measured memory_bytes: 34048
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  string s1, s2, s3;
  while (cin >> s1 >> s2 >> s3){
    cout << s1[0] << s2[1] << s3[2] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
    #pragma GCC target("sse,sse2,avx,avx2,popcnt,tune=native")
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(auto i=x;i<=y;i++)
    #define Fdr(i,x,y) for(auto i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 100003
char s[N];
int main(){
    in>>s;
    int ans=inf,t=0,k=0,n=strlen(s);
    Fur(i,0,n-1){
        if(s[i]-48!=k)t++;
        k^=1;
    }
    ans=MIN(ans,t);
    t=0;k=1;
    Fur(i,0,n-1){
        if(s[i]-48!=k)t++;
        k^=1;
    }
    ans=MIN(ans,t);
    out<<ans<<ln;
}

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

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

    ll res=LLONG_MAX;
    for(ll i=0;i<S.size()-T.size()+1;i++)
    {
        ll sum = 0;
        for(ll j=0;j<T.size();j++) 
        {
            if(T[j]!=S[i+j])sum++;
        }
        res = min(sum,res);
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;
int A[100010], B[100010];
vector<int> G[100010];
int indeg[100010];
int par[100010];

void dfs(int v) {
  vector<int> p;
  for (int nv : G[v]) {
    if (indeg[nv] == 1) p.PB(nv);
    indeg[nv]--;
  }
  for (int nv : p) {
    par[nv] = v;
    dfs(nv);
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  REP(i, N-1+M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    G[A[i]].EMPB(B[i]);
    indeg[B[i]]++;
  }

  REP(i, N) if (indeg[i] == 0) {
    par[i] = -1;
    dfs(i);
    break;
  }

  REP(i, N) {
    cout << par[i]+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 21888
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const long long Mod=1000000007;
int n,m;
long long f[310][310][310];
int cnt,head[310],to[310],nxt[310],w[310];
void add(int x,int y,int z)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
	w[cnt]=z;
} 
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		add(y,x,z);
		if (y==1 && z!=1)
		{
			puts("0");
			return 0;
		}
	}
	f[1][0][0]=1;
	for (int i=1;i<n;i++)
	{
		for (int j=0;j<i;j++)
		{
			for (int k=j;k<i;k++)
			{
				if (!f[i][j][k])
				{
					continue;
				}
				int tmp=f[i][j][k];
				f[i+1][j][k]=(f[i+1][j][k]+tmp)%Mod;
				if (j || k)
				{
					f[i+1][j][i]=(f[i+1][j][i]+tmp)%Mod;
					f[i+1][k][i]=(f[i+1][k][i]+tmp)%Mod;
				}
				else
				{
					f[i+1][0][i]=(f[i+1][0][i]+tmp)%Mod;
				}
			}
		}
		for (int j=head[i+1];j;j=nxt[j])
		{
			int l=to[j];
			int r=i+1;
			int x=w[j];
			for (int k=0;k<=i;k++)
			{
				for (int h=k;h<=i;h++)
				{
					int now=1;
					if (k>=l)
					{
						now++;
					}
					if (h>=l)
					{
						now++;				
					}
					if (now!=x)
					{
						f[i+1][k][h]=0;
					}
				}
			}
		}
	}
	long long ans=0;
	for (int i=0;i<n;i++)
	{
		for (int j=i;j<n;j++)
		{
			int now=1;
			if (i)
			{
				now++;
			}
			if (j)
			{
				now++;
			}
			if (now==1)
			{
				ans=(ans+f[n][i][j]*3%Mod)%Mod;
			}
			else
			{
				ans=(ans+f[n][i][j]*6%Mod)%Mod;
			}
		}
	}
	printf("%lld\n",ans);
    return 0;
}
//你如果认识从前的我，也许你会原谅现在的我。

Measured memory_bytes: 225536
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int x,l=1,p=3,maxv=0;
	cin>>x;
	int n=sqrt(x);
	int q=n*n;
	maxv=q;
	int b=n;
	while(b>1){
		l=1;
		for(int j=1;j<=p;j++){
			l*=b;
		}
		if(l<=x){
			p++;
			if(l>maxv){
				maxv=l;
			}
		}
		else{
			b--;
		}
	}
	cout<<maxv;
	return 0;
}

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

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    double max = 0;
    int max_water = 0, max_sugar = 0;
    for(int i = 0; 100*a*i <= f ; ++i) {
        for(int j = 0; 100*a*i + 100*b*j <= f; ++j) {
            double water = 100*a*i + 100*b*j;
            double sugar_limit = min(f - water, e * water/100);
            
            for(int p = 0; c*p <= sugar_limit; ++p) {
                for(int q = 0; c*p + d*q <= sugar_limit; ++q) {
                    double sugar = c*p + d*q;
                    if(max <= sugar/(sugar + water)) {
                        max = sugar/(sugar + water);
                        max_water = water;
                        max_sugar = sugar;
                    }
                }
            }
        }
    }
    
    cout << max_water + max_sugar << " " << max_sugar << endl;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

ll calc(ll A, ll B){
    return A*A*A*A + A*A*A*B + A*A*B*B + A*B*B*B + B*B*B*B;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll X; cin >> X;
    ll ulim = sqrt(X);
    vector<ll> yakusuu;
    for(ll i = 1; i <= ulim; i++){
        if(X % i == 0){
            yakusuu.push_back(i);
            yakusuu.push_back(X/i);
        }
    }
    for(ll A = -1000; A <= 1000; A++){
        ll va = A;
        rep(i, 4) va *= A;
        for(ll b = 0; b <= 1000; b++){
            ll vb = b;
            rep(i, 4) vb *= b;
            if(va + vb == X){
                cout << A << " " << -b << endl;
                return 0;
            }
        }
    }

    for(ll A = -1000; A <= 1000; A++){
        for(ll B = 1000; B <= 1000; B++){
            ll val = calc(A, B);
            if((A-B)*val == X){
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double p[n+1],ans=0.0;
	for(int i=1;i<=n;i++)
	cin>>p[i];
	double dp[n+1][n+1];
	dp[0][0]=0;
	dp[1][0]=1-p[1];
	for(int i=2;i<=n;i++)
	dp[i][0]=dp[i-1][0]*(1-p[i]);
	dp[1][1]=p[1];
	for(int i=2;i<=n;i++)
	dp[i][i]=dp[i-1][i-1]*p[i];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<i;j++)
		{
			dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	for(int i=n/2+1;i<=n;i++)
	{	ans+=dp[n][i];}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int a;
	string s;
	cin >> a >> s;

	long long int b = 0;
	b = 100 * (s[0] - '0') + 10 * (s[2] - '0') + (s[3] - '0');

	cout << (long long int)(a * b) / 100;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
  string S;
  cin >> S;
  int cnt = 0;
  for (auto ch : S) {
    if (ch == '+') ++cnt;
    else --cnt;
  }
  cout << cnt << endl;
  return 0;
}


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

string s;
int l, q, t, f;
char c;
bool ord;   // T:normal, F:reverse

int main(){
    cin >> s >> q;
    ord = true;
    for (int i = 0; i < q; ++i){
        cin >> t;
        if (t == 1) ord = !ord;
        else{
            cin >> f >> c;
            if ((f == 1 && ord) || (f == 2 && !ord)) s.insert(0, 1, c);
            else s.push_back(c);
        }
    }
    if (ord) cout << s;
    else{
        for (auto iter=s.rbegin(); iter != s.rend(); ++iter) cout << (*iter);
    }
}


Measured memory_bytes: 900
#include<stdio.h>
#include<string.h>
#define LIM 100

int main()
{
  char s[LIM], p[LIM], s2[200];

  scanf("%s", &s);
  scanf("%s",&p);

  strncat(s2,s,LIM);

  strncat(s2, s,LIM);

  if(strstr(s2,p)!= NULL){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

  return 0;
}

Measured memory_bytes: 532
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String S = sc.next();
   String Ss = S.substring(0,4)+S.substring(5,7)+S.substring(8,10);
   int day = Integer.parseInt(Ss);
   if(day<=20190430) System.out.println("Heisei");
   else System.out.println("TBD");
 }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define NUMBER 1000
void print_array(int v[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", v[i]);
    }
    printf("%d\n", v[n - 1]);
}
void swap(int *a, int *b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}
int main(void)
{
    int n;
    int v[NUMBER];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &v[i]);
    }
    int q;
    scanf("%d", &q);
    while (q)
    {
        int b, e, t;
        scanf("%d %d %d", &b, &e, &t);
        for (int k = 0; k < (e - b); k++)
        {
            swap(&v[b + k], &v[t + k]);
        }
        q--;
    }
    print_array(v, n);

    return 0;
}


Measured memory_bytes: 2700
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<iomanip>
#include<map>
using namespace std;

int main(){
	long long n,x;
	cin >> n;
	vector<long long> a(100000,0);
	long long cnt=0;
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	map<long long,long long> b;
	
	for(int i=0;i<n;i++){
		b[a[i]]++;
	}

	for(auto mp:b){
		long long x=mp.first;
		long long y=mp.second;
		if(y<x)cnt+=y;
		else cnt+=y-x;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 7040
use std::io::stdin;

fn main() {

let mut scan = std::io::stdin();

let mut line = String::new();


let _ = scan.read_line(&mut line);

let vec: Vec<&str> = line.split_whitespace().collect();


let n: i32 = vec[0].parse().unwrap_or(0);
let m: i32 = vec[1].parse().unwrap_or(0);

let menseki = n*m;
let shuu = 2*(n+m);

println!("{} {}", menseki, shuu)
}


Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  double a,b,h,m;cin>>a>>b>>h>>m;
  double pi=3.14159265358979;
  double s,t;
  s=(h+m/60)*pi/6;
  t=m/60*pi*2;
  double x=abs(a*cos(s)-b*cos(t));
  double y=abs(a*sin(s)-b*sin(t));
  cout << fixed << setprecision(10);
  cout<<sqrt(x*x+y*y);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	int A, B;
	cin >> A >> B;

	co(max(A - B, 0));

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}
typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

ll findSumOfDigits(ll n)
{
    ll digit = 0;
    while (n > 0)
    {
        digit++;
        n /= 10;
    }
    return digit;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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


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

#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define all(vec) vec.begin(), vec.end()
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
//#define int long long
#define endl "\n"
typedef long long ll;

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

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

  ll a, b, x; cin >> a >> b >> x;

  cout << func(b, x) - func(a-1, x) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdlib>
#include <cmath>
#include <string.h>
#include <memory.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <bitset>

#define F first
#define S second
#define MP make_pair

typedef long long ll;

using namespace std;

double const PI = acos(-1);
int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };
// int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
// int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };

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

long long lcm(long long a, long long b) {
	return a * (b / gcd(a, b));
}

int const N = 1e5 + 1;
int freq[N];

int main() {
	int n, m;
	cin >> n >> m;
	
	int a, b;
	for(int i = 0; i < m; ++i) {
	  cin >> a >> b;
	  ++freq[--a];
	  ++freq[--b];
	}
	
	for(int i = 0; i < n; ++i)
	  if(freq[i] % 2 != 0) {
	    cout << "NO" << endl;
	    return 0;
	  }
	
	cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int ans = max<int>({ 10 * a + b + c,a + 10 * b + c,a + b + 10 * c });

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
w_cnt=[0]*(n+1)
e_cnt=[0]*(n+1)
s.insert(0,"G")
for i in range(1,n+1):
    if s[i]=="W":
        w_cnt[i]=w_cnt[i-1]+1
    else:
        w_cnt[i]=w_cnt[i-1]
s.reverse()
s.pop(n)
s.insert(0,"G")
for i in range(1,n+1):
    if s[i]=="E":
        e_cnt[i]=e_cnt[i-1]+1
    else:
        e_cnt[i]=e_cnt[i-1]
ans=float("inf")
for i in range(n):
    temp=w_cnt[i]+e_cnt[n-1-i]
    if temp<=ans:
        ans=temp
print(ans)


Measured memory_bytes: 19948
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define ten(n) (1e##n)
#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

int
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    map<int, int> A;
    cin >> N;
    for (int i = 0; i < N; ++i) {
      int tmp;
      cin >> tmp;
      if (A.find(tmp) == A.end()) {
	A.insert(make_pair(tmp, 0));
      }
      A[tmp] += 1;
    }

    int total = 0;
    for (auto iter: A) {
      total += iter.second - 1;
    }

    if (total & 1) {
      cout << A.size() - 1 << endl;
    } else {
      cout << A.size() << endl;;
    }

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, k, d, temp, ans = 0;
	cin >> n >> k;
	vector<bool>z(n, false);
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> temp;
			z[temp - 1] = true;
		}
	}
	for (auto i : z) {
		if (!i) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

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

int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int g = gcd(i, j);
      for (int k = 1; k <= n; k++) {
        ans += gcd(g, k);
      }
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1736
// D - Lucky PIN

#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(){
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	for (int d0=0; d0<=9; d0++) {
		for (int d1=0; d1<=9; d1++) {
			for (int d2=0; d2<=9; d2++) {
				char c[3];
				c[0] = '0' + d0;
				c[1] = '0' + d1;
				c[2] = '0' + d2;

				int i=0;
				for (int j=0; j<N; j++) {
					if (S[j] == c[i]) {
						i++;
						if (i == 3) {
							ans++;
							break;
						}
					}
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    string s;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1];
    return 0;
    }
    

Measured memory_bytes: 3632
#include <stdio.h>
 
#define N 200000
 
long a[N+1];
 
int main(void){
    long n;
    scanf("%ld", &n);
    a[0] = -1;
    for(long i=1; i<=n; i++){
        scanf("%ld", a+i);
    }
    long count=-1;
    for(long i=1; i<=n; i++){
        long d = a[i]-a[i-1];
        if(d>=2){
            puts("-1");
            return 0;
        }else if(d==1){
            count++;
        }else{
            count += a[i];
        }
    }
    printf("%ld\n", count);
    return 0;
}
 

Measured memory_bytes: 1664
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define ll long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12




int main(void)
{
	//変数の宣言
	int n;
	int s[110];
	static int dp[100][10010];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	
	
	//データの読み込み
	scanf("%d",&n);
//	scanf_s("%d",&n);

	fr(i,0,n){
		scanf("%d",&s[i]);
//		scanf_s("%d",&s[i]);
	}

	fr(i,0,n){
		fr(j,0,10010){
			dp[i][j]=0;
		}
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	dp[0][0]=1;
	dp[0][s[0]]=1;

	fr(i,1,n){
		fr(j,0,10010){
			if(j>=s[i]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-s[i]]);
			if(j<s[i])  dp[i][j]=dp[i-1][j];
		}
	}

	for(i=10000;i>0;i--){
		if(i%10!=0&&dp[n-1][i]!=0){
			ans=i;
			break;
		}
	}

	//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
	//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 4096
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>
using namespace std;

#define int long long
const int mod = 1e9 + 7;

int n;
vector<vector<int> > a;
vector<int> dp;
vector<int> cost;

void compute_cost(int n){
  for(int i = 0; i < (1<<n); i++){
    for(int j = 0; j < n; j++)
      for(int k = j + 1; k < n; k++)
        if((i&(1<<j)) and (i&(1<<k)))
          cost[i] += a[j][k];
  }
}

int func(int used){
  if(used == 0)
    return 0;
  if(dp[used] != -1)
    return dp[used];
  int s = used;
  while(s > 0){
    dp[used] = max(dp[used], cost[s] + func(used^s));
    s = (s - 1) & used;
  }
  return dp[used];
}

int32_t main(){
  cin >> n;
  a.resize(n, vector<int>(n));
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> a[i][j];
  dp.resize((1<<n), -1);
  cost.resize((1<<n), 0);
  compute_cost(n);
  int ans = func((1<<n) - 1);
  cout << ans << endl;

}


Measured memory_bytes: 4320
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[] = new int[N];
		int n = 0;
		int c = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		for(int j = 0; Math.pow(10, 9) > Math.pow(2, j); j++) {
			for(int k = 0; k < N; k++) {
				if(A[k] % 2 == 0) {
					A[k] = A[k]/2;
					c++;
				}
				if(c == N) {
					n++;
				}
			}
			c = 0 ;
		}
		System.out.println(n);
	}

}


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

int main(){
  int N,M;
  cin>>N>>M;
  
  int a=N*(N-1)/2;
  int b=M*(M-1)/2;
  
  if(a>0&&b>0){
    cout<<a+b<<endl;
  }
  else if(a<=0&&b>0){
    cout<<b<<endl;
  }
  else if(a<=0&&b<=0){
    cout<<0<<endl;
  }
  else if(a>0&&b<=0){
    cout<<a<<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


vector<pair<int,int>> soinsuu(int n){
    vector<pair<int,int>> ret;
    for(int i=2;i*i<=n;i++){
        if(n%i !=0) continue;
        int ex=0;
        while(n%i ==0){
            ex++;
            n /= i; //n変更することで、それ以降の約数で割り切れることはない
        }
        ret.push_back(make_pair(i,ex));
    }
    //nが素数だった場合
    if(n!=1) ret.push_back(make_pair(n,1));
    return ret;
}

int mod=998244353;

signed main(){ 
    int a;
    string s;
    cin>>a>>s;
    int n=s.size();
    char b100[n-1];
    for(int i=0;i<n-2;i++){
        b100[i]=s[i];
    }

    b100[n-3]=s[n-2];
    b100[n-2]=s[n-1];

    int b=stoi(b100);
    cout<<(a*b)/100<<endl;
    
}  

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

int main()
{
  ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
  int n, m, sum = 0, p, x;
  cin >> n;
  vector<int> t(n);
  
  for(int i = 0; i < n; i++)
  {
    cin >> t[i];
    sum += t[i];
  }
  
  cin >> m;
  while(m--)
  {
    cin >> p >> x;
    cout << sum-t[p-1]+x << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,mina=1e9;
	long long sum=0;
	bool par=false;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=abs(a[i]);
		mina=min(mina,abs(a[i]));
		par^=signbit(a[i]);
	}
	cout<<(par?sum-mina*2:sum)<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

/**
 * Description ：
 *
 * @author poyun
 * @version V1.0.0
 * @since 1.0
 * date 2020/5/10
 */
public class Main {

    public static void main(String[]args){
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        String t = input.nextLine();
        System.out.println(compare(s,t));
    }


    public static String compare(String S , String T){
        char[] chars1 = S.toCharArray();
        char[] chars2 = T.toCharArray();
        if(chars1.length>=chars2.length) return "No";
        for (int i = 0; i < chars1.length; i++) {
            if(chars1[i]!=chars2[i]) return "No";
        }
        return "Yes";
    }
}


Measured memory_bytes: 35700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x, y := scanInt(), scanInt()
	fmt.Fprintln(wr, x+y/2)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,k;
    cin>>n>>k;
    vector<ll>a(n), pref(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pref[i+1] = mod( pref[i] + a[i], k );
    }

    for(int i=1;i<=n;i++)
    {
        pref[i] = mod( pref[i]-i, k);
    }

    map<ll,ll>fr;
    ll cur = 0;
    ll ans = 0;
    for(int i=n;i>=0;i--)
    {
        ans += fr[pref[i]];

        fr[pref[i]]++;
        cur++;
        while( cur >= k )
        {
            fr[pref[i+k-1]]--;
            cur--;
        }
    }
    cout<<ans,nl;

    return 0;
}


Measured memory_bytes: 18736
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

int main()
{
	int N = 0, L = 0, ans  = 0;
	std::cin >> N >> L;
	
	int A = 0, L_begin, L_end;

	L_begin = L;
	L_end = L + N - 1;
	if (L_begin >= 0){
		A = L_begin;
	}
	else if(L_end < 0){
		A = L_end;
	}
	else{
		A = 0;
	}

	for (int i = 0; i < N; i++){
		ans += L + i;
		
	}
	ans -= A;
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 384
N = int(input())
H = [int(x) for x in input().split()]
last = H[-1]
for i in H[::-1]:
    if(i>last):
        if(i!=last+1):
            print('No')
            break
        else:
            last = i-1
    else:
        last = i
else:
    print('Yes')


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

	while (1){

		cin >> H >> W;

		for (int i = 0; i < H; i++){
			if (i % 2 == 0){
				for (int i = 0; i < W / 2; i++){
					cout << "#" << ".";
				}
				if ((W + 1) % 2 == 0){
					cout << "#";
				}
				cout << endl;
			}
			if (i % 2 != 0){
				for (int i = 0; i < W / 2; i++){
					cout << "." << "#";
				}
				if ((W + 1) % 2 == 0){
					cout << ".";
				}
				cout << endl;
			}
		}

		if (H == 0 && W == 0){
			break;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

def single_mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    if r > n - r:
        r = n - r
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD
    return ret

n, a, b = [int(item) for item in input().split()]
total = pow(2, n, MOD) - 1
pata = single_mod_nCr(n, a)
patb = single_mod_nCr(n, b)
ans = ((total - pata - patb) % MOD + MOD) % MOD
print(ans)

Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;



int main(){

    int n;
    cin>> n;
    vector<double> v(n,0);
    for(int i =0; i< n; i++){
        cin >>v.at(i);
    }
    

    double result = 0;
    for(int i = n-1; i > 0; i--){
        sort(v.rbegin(),v.rend());
        result = v.at(i)+v.at(i-1);
        result/=2.0;

        v.pop_back();
        v.pop_back();
        v.push_back(result);

        
    }

    cout << setprecision(6) << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main(void){
  int A,B;
  cin >>A>>B;
  if (B%A==0){
    cout << A+B<<endl;
  }else{
    cout << B-A<<endl;
  }
}

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

int n,m,x,ans=1e9+7;
int c[105],a[105][105],pos[105];

signed main() {
	cin>>n>>m>>x;

	for (int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1; j<=m; j++)  
            cin>>a[i][j];
	}
	
	while (pos[0]==0) {
		int in[105]= {0},money=0;
		for (int i=1; i<=n; i++) {
			if (pos[i]==1) {
				money+=c[i];
				for (int j=1; j<=m; j++)  in[j]+=a[i][j];
			}
		}
		int flag=1;
		for (int i=1; i<=m; i++) {
			if (in[i]<x) {
				flag=0;
				break;
			}
		}
		if (flag==1)  ans=min(ans,money);

		for (int i=n; i>=0; i--) {
			if (pos[i]==1)  pos[i]=0;
			else {
				pos[i]=1;
				break;
			}
		}
	}
	if (ans!=1e9+7)  cout<<ans<<endl;
	else cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 3620