akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdint.h>

using namespace std;


#define MOD 1000000007
#define ll long long int
#define ff first
#define ss second
#define N 100001


template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.ff<<", "<<a.ss<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}
    
vector<int> adj[N];
int vis[N];
int dp[N];

int dfs(int u)
{
	if(dp[u])
		return dp[u];
	for(int v:adj[u])
		dp[u]=max(dp[u],1+dfs(v));

	return dp[u];
}

void solve()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			ans=max(ans,dfs(i));
	}
	cout<<ans<<"\n";
}
	


int32_t main()
{
 
    //your code goes here...
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }    
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int a, b, h;

int main() {
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 14
#define S 21
#define INF (1e9)
using namespace std;

int n,cnt,memo[N][N],dp[(1<<N)][N],ans;
bool t[N];
string is[N],s[N];

bool check(string a,string b){
  int alen=a.size(),blen=b.size();
  for(int i=0;i<=blen-alen;i++)
    if(a==b.substr(i,alen))return true;
  return false;
}

int check2(string a,string b){
  int alen=a.size(),blen=b.size();
  for(int i=blen-1;i>=1;i--){
    if(alen-i<0)continue;
    string s1=a.substr(alen-i,i);
    string s2=b.substr(0,i);
    if(s1==s2)return blen-i;
  }
  return blen;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++)cin>>is[i];
    memset(t,0,sizeof(t));
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	int ilen=is[i].size();
	int jlen=is[j].size();
	if(ilen>=jlen&&check(is[j],is[i]))t[j]=true;
	if(ilen<jlen&&check(is[i],is[j]))t[i]=true;
      }
    cnt=0;
    for(int i=0;i<n;i++)
      if(!t[i])s[cnt]=is[i],cnt++;
    n=cnt;
    memset(memo,0,sizeof(memo));
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	if(i==j)continue;
	memo[i][j]=check2(s[i],s[j]);
      }
    for(int i=0;i<(1<<n);i++)
      for(int j=0;j<n;j++)dp[i][j]=INF;
    for(int i=0;i<n;i++)dp[(1<<i)][i]=s[i].size();
    for(int i=0;i<(1<<n);i++)
      for(int j=0;j<n;j++){
	if(dp[i][j]==INF)continue;
	for(int k=0;k<n;k++){
	  if(!(i&(1<<k)))
	    dp[(i|(1<<k))][k]=min(dp[(i|(1<<k))][k],dp[i][j]+memo[j][k]);
	}
      }
    ans=INF;
    for(int i=0;i<n;i++)ans=min(ans,dp[((1<<n)-1)][i]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2116
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

int main(void) {

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

	const long double PI = 3.14159265358979;

		long double a; cin >> a;
	cout << a * 2 * PI << endl;





	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

int L=1e6;

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

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  int g=A[0];
  rep(i,N) g=gcd(g,A[i]);
  if(g!=1){
    cout<<"not coprime"<<endl;
    return 0;
  }

  vector<int> num(L+1,0);
  rep(i,N) num[A[i]]++;
  vector<int> prime(L+1,1);
  prime[1]=0;
  for(int i=2;i<=L;i++){
    if(prime[i]==0) continue;
    for(int j=2;i*j<=L;j++) prime[i*j]=0;
  }

  for(int i=1;i<=L;i++){
    if(prime[i]==0) continue;
    int res=0;
    for(int j=1;i*j<=L;j++){
      res+=num[i*j];
    }
    if(res>=2){
      cout<<"setwise coprime"<<endl;
      return 0;
    }
  }

  cout<<"pairwise coprime"<<endl;

  return 0;
}


Measured memory_bytes: 18768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
  int x, t;
  cin >> x >> t;
  if(x - t<= 0) cout << 0 << endl;
  else cout << x-t << endl;
}

Measured memory_bytes: 256
//2019/12/8
//bit全探索.
//Refering to exp.
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef vector<int>  vi;
typedef vector<vi >  vvi;
typedef vector<vvi > vvvi;

template<class Type> int counter_bit(Type x){return (x==0)?0:counter_bit(x>>1)+(x&1);}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	vvvi v(n);
	REP(i,n){
		cin>>a[i];
		v[i].resize(a[i],vi(2));
		REP(j,a[i])REP(k,2) cin>>v[i][j][k];
	}
	
	int ans=0;
	REP(i,(1<<n)){//point.
		bool flag=true;
		REP(j,n){
			if((i>>j) & 1){
				REP(k,a[j]){
					if(!(((i>>(v[j][k][0]-1)) & 1) ^ v[j][k][1])){}
					else{
						flag=false;
						break;//REP(k).
					}
				}
			}
			if(!flag) break;//REP(j).
		}
		if(flag) ans=max(ans,counter_bit(i));
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

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

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		ll N; input_returnner(ll N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(ll N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---


signed main(void) {
	SETUP;
	solve();
	return 0;
}

// x^n % mod
// O(log n)
template<typename T>
T mod_pow(T x, T n, T mod) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x*x %mod;
		n >>= 1;
	}
	return res;
}


void solve() {
	int N = in();
	vector<int> check(N);

	REP(i, N) {
		int a; cin >> a;
		if ((N & 1) == (a & 1)) {
			cout << 0 << endl;
			return;
		}
		check[a]++;
	}
	if (check[0] != (N&1)) {
		cout << 0 << endl;
		return;
	}
	for (int i = (N & 1)+1; i < N; i+=2) {
		if (check[i] != 2) {
			cout << 0 << endl;
			return;
		}
	}

	cout << mod_pow<ll>(2, N/2, 1e9+7) << endl;;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <set>
//反向bfs
using namespace std;
map<string ,int> t;
int num;
int mv[]={-4,4,1,-1};//上下右左
void bfs(string st)
{
    queue<string> q;
    t[st]=1;
    q.push(st);
    while(!q.empty())
    {

       st=q.front(),q.pop();
        int num=st.find('0');
        for(int i=0;i<4;++i)
//        {
//            int tn=num+mv[i];
//            if(tn<0||tn>7||tn==3&&mv[i]==1||tn==4&&mv[i]==-1)
//                continue;
//                string tp=st;
//            swap(tp[num],tp[num+mv[i]]);
//            if(!t[tp])
//            {
//                    q.push(tp);
//                    t[tp]=t[st]+1;
//            }
//
//
//        }
//        }
//

   // t[st]=1;q.push(st); //起始状?
  //  while(!q.empty())
  //  {
        //st=q.front();q.pop();
      //  int num=st.find('0');//找到空格位置
    //    for(int i=0;i<4;++i)
        {
            int tn=num+mv[i];//可能??的数?
            if(tn<0||tn>7||num==3&&mv[i]==1||num==4&&mv[i]==-1)
            //空格在3的?候，4不能??，因?3 4 不相?，反之同理
            {
                continue;
            }
            string tp=st;
            swap(tp[num],tp[num+mv[i]]);//移?物?
            if(!t[tp])//未出??的状?
            {
                q.push(tp);
                t[tp]=t[st]+1;
            }
        }
    }
}

int main()
{
    string st="01234567";
    bfs(st);
    while(scanf("%d",&num)!=EOF)
    {
        st[0]=num+'0';
        for(int i=1;i<8;i++)
        {
            scanf("%d",&num);
            st[i]=num+'0';
        }
        cout<<t[st]-1<<endl;
    }

}

Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    map<ll, ll> mp;
    mp[n-a[n-1]]++;
    ll ans = 0;
    for(int i = n-2; i >= 0; i--){
        ans += mp[i+1+a[i]];
        mp[i+1-a[i]]++;
    }
    cout << ans << endl;
}  


Measured memory_bytes: 26668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll n,k; cin >> n >> k;
  ll h[n];
  FOR(i,0,n-1) cin >> h[i];
  ll ans = 0;

  sort(h,h+n,greater<ll>());
  FOR(i,0,n-1){
    if(k>0){
      --k;
    } else {
      ans += h[i];
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 1920
s = sorted(input())
t = sorted(input(),reverse=True)
ans = ""
def check_dict():
  for i in range(min(len(s),len(t))):
    if s[i] < t[i]:
      ans = "Yes"
      return ans
    elif s[i] > t[i]:
      ans = "No"
      return ans
  return ""
if len(s) < len(t):
  ans = check_dict()
  if ans == "":
    ans = "Yes"
  print(ans)
else:
  ans = check_dict()
  if ans == "":
    ans = "No"
  print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

char a[20] = "CODEFESTIVAL2016";
char b[20];

int main() {
	scanf("%s", b);
	int cnt = 0;
	for (int i = 0; i < 16; i++) if (b[i] != a[i]) cnt++;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
from fractions import gcd
from functools import reduce

N, M = map(int, input().split())
*a, = map(int, input().split())
lcm = reduce(lambda x,y:x*y//gcd(x,y), a)

for i in map(lambda x:lcm//x, a):
    if i%2==0:
        print(0)
        break
else:
    start = lcm//2
    print((M-start)//lcm+1)

Measured memory_bytes: 16236
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	int i,p,c=0,f=0,j,k;
	cin>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=='C') c=1;
		if(c==1&&s[i]=='F') f=1; 
		if(f==1&&c==1){
			cout<<"Yes";//<<endl;
			break;
		}
	}
	if(f!=1||c!=1){
		cout<<"No";//<<endl;
	}
//	cout<<c<<"   "<<f;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {


  def exec(w:String):Unit =  {
    val len = w.length

    def shuffle(i:Int, cnt:Int):String =
      if(i == 0) (w drop (cnt%len))+(w take (cnt%len)) else { val m = readInt;shuffle(i-1, cnt+m) }

    if(w=="-") return else { val n = readInt;println(shuffle(n,0));exec(readLine) }

  }
  exec(readLine)
}

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

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

    uint64_t a = N / (A + B);
    uint64_t d = N % (A + B);

    uint64_t ans = a * A;
    if (d >= A) {  
        ans += A;
    } else {
        ans += d;
    }

    std::printf("%lu\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

using namespace std;

int main()
{
	int H, W;
	string s;
	vector<vector<int>> map;

	cin >> H >> W;

	map.resize(H);
	rep(i, H)
	{
		map[i].resize(W);
	}

	rep(i, H)
	{
		cin >> s;
		rep(j, W)
		{
			if (s.at(j) == '#')
			{
				map[i][j] = -1;

				if(i > 0)
				{
					if (j > 0 && map[i - 1][j - 1] != -1) { map[i - 1][j - 1] += 1; }
					if (map[i - 1][j] != -1) { map[i - 1][j] += 1; }
					if (j < (W - 1) && map[i - 1][j + 1] != -1) { map[i - 1][j + 1] += 1; }
				}

				if (j > 0 && map[i][j - 1] != -1) { map[i][j - 1] += 1; }
				if (j < (W - 1) && map[i][j + 1] != -1) { map[i][j + 1] += 1; }

				if (i < (H - 1))
				{
					if (j > 0 && map[i + 1][j - 1] != -1) { map[i + 1][j - 1] += 1; }
					if (map[i + 1][j] != -1) { map[i + 1][j] += 1; }
					if (j < (W - 1) && map[i + 1][j + 1] != -1) { map[i + 1][j + 1] += 1; }
				}
			}
		}
	}

	rep(i, H)
	{
		rep(j, W)
		{
			if (map[i][j] == -1)
			{
				cout << "#";
			}
			else
			{
				cout << map[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s; cin >> s;
    int flag = 1;
    if (s[0] != 'A') flag = 0;
    int cnt = 0, idx;
    for (int i = 2; i < s.size() - 1; i++) {
        if (s[i] == 'C') { idx = i; cnt++;}
    }
    if (cnt != 1) flag = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i != 0 && i != idx && isupper(s[i])) flag = 0;
    }
    if (flag) puts("AC");
    else puts("WA");
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> X(N), Y(N), H(N);
    int x, y, h;
    REP(i, N) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > 0) {
            x = X[i], y = Y[i], h = H[i];
        }
    }
    REP(cx, 101) {
        REP(cy, 101) {
            bool f = true;
            int A = h + abs(x - cx) + abs(y - cy);
            REP(i, N) {
                int d = abs(X[i] - cx) + abs(Y[i] - cy);
                if (H[i] > 0) {
                    if (H[i] + d != A) {
                        f = false;
                    }
                } else {
                    if (A - d > 0) {
                        f = false;
                    }
                }
            }
            if (f) {
                cout << cx << " " << cy << " " << A << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

typedef long long ll;

const int MAX_N = 100050;
int prime[MAX_N]; //素数が入っている
bool is_prime[MAX_N+1];

void sieve(int n){
    int p = 0;
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=n;i++) is_prime[i] = true;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i) is_prime[j] = false; 
        }
    }
}

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

    int q; cin >> q;
    sieve(100000);
    int cnt[MAX_N] = {0};
    bool ok[MAX_N];
    memset(ok,0,sizeof(ok));
    for(int i=3;i<=100000;i+=2){
        if(is_prime[i] && is_prime[(i+1)/2]) ok[i] = true;
    }
    for(int i=3;i<=100000;i++){
        if(ok[i]) cnt[i]++;
    }
    for(int i=2;i<100000;i++){
        cnt[i+1] += cnt[i];
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        cout << cnt[r]-cnt[l-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func main() {
	var h, w, k int64
	const m = 1000*1000*1000 + 7
	fmt.Scan(&h, &w, &k)

	if w == 1 {
		if k == 1 {
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}
		return
	}
	var z [9][2]int64
	z[0][0] = 1
	z[0][1] = 1
	z[1][0] = 1
	z[1][1] = 1
	for i := range iter(2, 9) {
		z[i][0] = z[i-1][0] + z[i-1][1]
		z[i][1] = z[i-1][0]
	}

	var dp [101][8]int64
	dp[0][0] = 1
	for i := range iter(1, h+1) {
		for j := range iter(0, w) {
			l := z[j][0]
			r := z[w-j-1][0]
			dp[i][j] = (dp[i-1][j] * (l * r)) % m
		}
		for j := range iter(0, w-1) {
			l := z[j][0]
			r := z[w-j-2][0]
			dp[i][j] = (dp[i][j] + (l*r)*dp[i-1][j+1]) % m
			dp[i][j+1] = (dp[i][j+1] + (l*r)*dp[i-1][j]) % m
		}
	}
	fmt.Println(dp[h][k-1])
}

func iter(l int64, r int64) chan int64 {
	var i int64 = l
	c := make(chan int64)
	run := func() {
		for i < r {
			c <- i
			i += 1
		}
		close(c)
	}
	go run()
	return c
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return a % b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	// 尺取り法
	// 区間内に「同じビットが2度出現しない」というルールを設けます。
	// そのルールが成立するのと等号が成立するのは同値です。
	int r = 0;
	ll ret = 0;
	int base = 0;
	rep(l, n) {
		while (r < n && (base&a[r]) == 0) {
			base |= a[r++];
		}
		ret += r - l;
		base ^= a[l];
	}
	cout << ret << endl;
	return 0;
}

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

int main(void){
    ll n,m,k;cin >> n >> m >> k;
    ll a[n],b[m];
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    
    ll N[n+1],M[m+1];
    N[0] = 0,M[0] = 0;
    for(int i = 1;i <= n;i++)N[i] = N[i-1] + a[i-1];
    for(int i = 1;i <= m;i++)M[i] = M[i-1] + b[i-1];
    
    int alina = 0,gray = n;
    for(int i = 0;i <= m;i++){
        while(gray > 0 && N[gray] + M[i] > k)gray--;
        if(N[gray]+M[i] <= k)alina = max(alina,gray+i);
    }
    cout << alina;
}

Measured memory_bytes: 9876
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int N=100010;
int a[N];
int n;
ll work(){
    int i;
    ll sum=0,ans=0;
    for(i=1;i<=n;i++){
        sum+=a[i];
        if((i&1)&&sum>=0) ans+=sum+1,sum=-1;
        if((i&1)==0&&sum<=0) ans+=-sum+1,sum=1;
    }
    return ans;
}
int main(){
    int i;ll ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    ans=work();
    for(i=1;i<=n;i++) a[i]=-a[i];
    ans=min(ans,work());
    cout<<ans;
    return 0;
}


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

const int AtoZ = 'Z'-'A'+1;
struct limbox{
    int u,d,l,r;
    limbox():u(100),d(-1),l(100),r(-1){}
};

vector<vector<bool> > o;
vector<bool> s;
vector<bool> c;

bool check(int k){
    if(s[k]) return true;
    if(c[k]) return false;
    c[k] = true;
    for(int i=0; i<AtoZ; i++){
        if(o[k][i] && !check(i)){
            return false;
        }
    }
    c[k] = false;
    s[k] = true;
    return true;
}
            

int main(){
    int n;
    cin >> n;
    
    for(int rep=0; rep<n; rep++){
        int h,w;
        cin >> h >> w;
        vector<vector<char> > mat(h, vector<char>(w));
        vector<limbox> dom(AtoZ);
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin >> mat[i][j];
                if(mat[i][j]!='.'){
                    int c = mat[i][j] - 'A';
                    dom[c].u = min(dom[c].u, i);
                    dom[c].d = max(dom[c].d, i);
                    dom[c].l = min(dom[c].l, j);
                    dom[c].r = max(dom[c].r, j);
                }
            }
        }

        vector<vector<bool> > ovl(AtoZ, vector<bool>(AtoZ, false));
        vector<bool> safe(AtoZ, true);
        bool suspicious = false;
        for(int k=0; k<AtoZ; k++){
            for(int i=dom[k].u; i<=dom[k].d; i++){
                for(int j=dom[k].l; j<=dom[k].r; j++){
                    if(mat[i][j]=='.'){
                        suspicious = true;
                        safe[k] = false;
                    }else if(mat[i][j] != 'A'+k){
                        ovl[k][mat[i][j]-'A'] = true;
                        safe[k] = false;
                    }
                }
            }
        }
        if(suspicious){
            cout << "SUSPICIOUS" << endl;
            continue;
        }

        vector<bool> checking(AtoZ, false);
        o = ovl;
        s = safe;
        c = checking;
        for(int i=0; i<AtoZ; i++){
            if(!check(i)){
                suspicious = true;
            }
        }
        if(!suspicious){
            cout << "SAFE" << endl;
        }else{
            cout << "SUSPICIOUS" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3124
#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<i64>();
    let k = sc.value::<i64>();

    let ans = if k % 2 != 0 {
        let m = n / k;
        m*m*m
    }
    else {
        let m1 = n / k;
        let m2 = n / (k/2) - m1;
        m1*m1*m1 + m2*m2*m2
    };

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


int32_t main()
{
	IOS
	int n,ans=1e18;cin>>n;
	string s;cin>>s;
	vector<int>B(n+2),W(n+2);
	for(int i=0;i<n;i++)
	{
		B[i+1]+=(s[i]=='#')+B[i];
		W[i+1]+=(s[i]=='.')+W[i];
	}
	B[n+1]+=B[n];
	W[n+1]+=W[n];
	//for(int i=0;i<=n+1;i++)
	//cout<<B[i]<<" "<<W[i]<<endl;
	for(int i=1;i<=n+1;i++)
	{
		ans=min(ans,W[n]-W[i-1]+B[i-1]);
	}
	cout<<ans<<endl;
		
}
				
			
	

	
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 3732
/**
 *  author: mahfuzz
 *  created: 13.04.2020
**/
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define trace(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, a, b;
    cin >> n >> a >> b;
    
    string s; cin >> s;
    
    int cnt = 0, overses = 0;
    for(int i = 1; i <= n; i++){
        if(s[i - 1] == 'a' && cnt < a + b){
            cout << "Yes\n";
            ++cnt;
        }
        else if(s[i - 1] == 'b' && cnt < a + b && overses < b){
            cout << "Yes\n";
            ++overses;
            ++cnt;
        }else{
            cout << "No\n";
        }
            
    }

    return 0;
}



Measured memory_bytes: 848
n, m = gets.split(/ /).map(&:to_i)
h = gets.split(/ /).map(&:to_i)
ab_s = Array.new(m) { gets.split(/ /).map(&:to_i) }

class Observatory
  def initialize(index, height)
    @index = index
    @height = height

    @connected_observatories = []
  end

  attr_reader :height, :connected_observatories

  def connect_to(observatory)
    connected_observatories.push(observatory)
  end

  def good?
    connected_observatories.empty? || connected_observatories.all? { |observatory| height > observatory.height }
  end
end

observatories = h.map.with_index(1) { |height, i| Observatory.new(i, height) }

ab_s.each do |ab|
  a, b = ab

  observatory_a = observatories[a - 1]
  observatory_b = observatories[b - 1]

  observatory_a.connect_to(observatory_b)
  observatory_b.connect_to(observatory_a)
end

puts observatories.select(&:good?).size


Measured memory_bytes: 31636
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll SOLVE(){
    ll n,s;cin>>n>>s;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n+1][s+1];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,0,n-1){
        rep(j,0,s){
            Add(dp[i+1][j],dp[i][j]*2);
            if(j+a[i]<=s)Add(dp[i+1][j+a[i]],dp[i][j]);
        }
    }
    cout<<mod(dp[n][s])<<endl;
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}



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

int main(){

  int n,p,i,o,k;
  char str[16];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      o=0;
      p=0;
      k=0;
      while(o<3)
	{
	  scanf("%s",str);
	  if(strcmp(str,"OUT")==0)
	     o++;
	  else if(strcmp(str,"HOMERUN")==0)
	       {
		 p=p+1+k%4;
		 k=0;
	       }
	  else if(strcmp(str,"HIT")==0)
	       {
		 k++;
		 if(k%4==0)
		   {
		     p++;
		     k--;
		   }
	       }
	}
      printf("%d\n",p);
    }
  return 0;
}

	     

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main()
{
  int A, B, C;
  
  cin >> A >> B >> C;
  
  if( (A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 && B==5 && C==5) )
     cout << "YES" << endl;
  
  else
     cout << "NO" << endl;
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << ' ' << i;
			continue;
		}
		for (int x = i; x > 0; x /= 10)
			if (x % 10 == 3) {
				cout << ' ' << i;
				break;
			}
	}
	cout << endl;
}

Measured memory_bytes: 1164
/**
 *    author:  FromDihPout
 *    created: 2020-07-29
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int sum = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    vector<bool> score(sum+1);
    score[0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = sum - a[i]; j >= 0; j--) {
            if (score[j]) {
                score[j + a[i]] = true;
            }
        }
    }
    
    for (int i = sum; i >= 0; i--) {
        if (score[i] && i % 10 != 0) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << 0 << '\n';
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            List<calc> calcs = new List<calc>();
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ');
                if (inputs[1] == "?")
                {
                    break;
                }
                calcs.Add(new calc(int.Parse(inputs[0]), int.Parse(inputs[2]), inputs[1]));
            }
            foreach (var i in calcs)
                Console.WriteLine(i.ans());
        }
    }


    public class calc
    {
        int a;
        int b;
        string op;
        public calc(int a, int b, string op)
        {
            this.a = a;
            this.b = b;
            this.op = op;
        }
        public int ans()
        {
            switch (op)
            {
                case "+":
                    return a + b;
                case "-":
                    return a - b;
                case "/":
                    return a / b;
                case "*":
                    return a * b;
                default:
                    throw new NotSupportedException();
            }
        }
    }
}
    

Measured memory_bytes: 5772
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cout<<"# "<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
struct node{
	int c0,c1,p;
	friend bool operator < (node a,node b){
		ll A=(ll)a.c1*b.c0,B=(ll)a.c0*b.c1;
		if(A!=B)return A<B;
		if(a.c1!=b.c1)return a.c1<b.c1;
		if(a.c0!=b.c0)return a.c0>b.c0;
		return a.p<b.p;
	}
}a[N];
int pa[N],fa[N],v[N],n;
set<node> s;
ll res;

int getpa(int x){
	return pa[x]==x?x:pa[x]=getpa(pa[x]);
}

int main(){
	read(n);
	rep(i,2,n)read(fa[i]);
	rep(i,1,n){
		read(v[i]),pa[i]=i;
		if(v[i])a[i].c1=1;
		else a[i].c0=1;
		a[i].p=i;
		pa[i]=i;
		if(i>=2)s.insert(a[i]);
	}
	while(s.size()){
		auto x=*s.begin();
		s.erase(s.begin());
		int u=x.p,v=getpa(fa[u]);
		if(v>=2)s.erase(a[v]);
		res+=(ll)a[v].c1*a[u].c0;
		a[v].c1+=a[u].c1,a[v].c0+=a[u].c0;
		pa[u]=v;
		if(v>=2)s.insert(a[v]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map <pair <pair <int, int>, pair <ll, ll>>, ll> mem;

  function <ll(int, int, ll, ll)> rec = [&] (int l, int r, ll c1, ll c2) {
    if (l > r) return 0LL;
    if (mem.count({{l, r}, {c1, c2}})) return mem[{{l, r}, {c1, c2}}];
    ll &res = mem[{{l, r}, {c1, c2}}];
    res = 1e18;
    for (int i = l; i <= r; ++i) {
      ll cur = (ll)a[i] * (c1 + c2) + rec(l, i - 1, c1, c1 + c2) + rec(i + 1, r, c1 + c2, c2);
      res = min(cur, res);
    } 
    return res;
  };
  cout << a[0] + a[n - 1] + rec(1, n - 2, 1, 1) << '\n';
}



Measured memory_bytes: 20608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long M = sc.nextInt();
		sc.close();
		if(N > M) {
			long t = M;
			M = N;
			N = t;
		}
		if(N == 1 && M == 1) {
			System.out.println(1);
		}else if(N == 1) {
			System.out.println(M - 2);
		}else if(N == 2) {
			System.out.println(0);
		}else {
			long t = N * M - 2 * M - 2 * (N - 2);
			System.out.println(t);
		}
	}
}

Measured memory_bytes: 22996
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
a = [0]*3
b = [0]*3
for i in range(3):
    b[i] = c[0][i]
for i in range(3):
    a[i] = c[i][0] - b[0]

ans = 'Yes'
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            ans = 'No'
# print(c)
# print(a)
# print(b)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ll a;
  string b;
  cin >> a >> b;
  ll b_sub = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  cout << a * b_sub / 100 << endl;
}


Measured memory_bytes: 3476
x,n = map(int,input().split())
li1 = list(map(int,input().split()))
if n == 0:
    print(x)
    exit()
b=100
c=0
li = []
li = list(range(min(li1)-1,max(li1)+2))
for ii in range(n):
    if li1[ii] in li:
        li.remove(li1[ii])
for i in range(len(li)):
    a=li[i]
    if a<=x:
        if b>x-a:
            b=x-a
            c=a
    else:
        if b>a-x:
            b=a-x
            c=a
print(c)

Measured memory_bytes: 61924
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
Ls = list(map(int, input().split()))
sorted_ = sorted(Ls)
list_ = []
for i, x in enumerate(sorted_):
    if i % 2 == 0:
        list_.append(x)
sum_ = sum(list_)
print(sum_)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
int main()
{
   ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;

  vector<int> cnt(n), paisi(n);
  for (int i = 0; i < m; i++){
    int p;
    string vr;
    cin >> p >> vr;
    if(vr=="AC"){
      paisi[p - 1] = 1;
    }
    else if(vr=="WA"){
      if(paisi[p-1] == 0){
        cnt[p - 1]++;
      }
    }
    else
      assert(false);
  }
  int ac = 0, pnl = 0;
  for (int i = 0; i < n; i++){
    if(paisi[i]){
      ++ac;
      pnl += cnt[i];
    }
  }
  cout << ac << " " << pnl << endl;
  return 0;
}




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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int32_t main(){
  int n,k,cnt=0;  cin>>n>>k;
  vector<int>A(n);  fr(i,0,n) cin>>A[i];
  for(auto x:A)
  if(x >= k)  cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 1024
def heho(n):
    for i in range(1,n+1):
        if i*i==n:
            return True

n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]
cnt=0

if d!=1:
    for i in range(n-1):
        for j in range(i+1,n):
            z=0
            for k in range(d):
                z+=abs(x[i][k]-x[j][k])**2
            if heho(z):
                cnt+=1
else:
    for i in range(n-1):
        for j in range(i+1,n):
            v=0
            v+=abs(x[i][0]-x[j][0])**2
            if heho(v):
                cnt+=1

print(cnt)

Measured memory_bytes: 3064
<?php

function get_input_num(){
	$input_num = (int) fgets(STDIN);
	return $input_num;
}

function make_score_list($judge_num){
	$score_list = [];
	for($i=0;$i<$judge_num;$i++){
		$score_list[] = get_input_num();
	}
	return $score_list;
}

function calculate_adjusted_ave_score($judge_num, $score_list){
	$max_num = max($score_list);
	//echo $max_num;
	$min_num = min($score_list);
	//echo $min_num;
	$score_sum = array_sum($score_list) - $max_num - $min_num;
	$adjusted_ave_score = $score_sum / ($judge_num - 2);
	return $adjusted_ave_score;
}

while(True){
	$judge_num = get_input_num();
	if ($judge_num === 0){
		break;
	}
	//echo $judge_num;
	$score_list = make_score_list($judge_num);
	//var_export($score_list);
	$adjusted_ave_score = calculate_adjusted_ave_score($judge_num, $score_list);
	$adjusted_ave_score = floor($adjusted_ave_score);
	echo $adjusted_ave_score . PHP_EOL;
}



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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int x, y; cin >> x >> y;
    string ans;
    if (y > 4 * x) ans = "No";
    else {
        bool ok = false;
        for (int num2 = 0; num2 <= x; ++num2) {
            if (num2 * 2 + (x - num2) * 4 == y) {
                ok = true;
                break;
            }
        }
        if (ok) ans = "Yes";
        else ans = "No";
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 3652
# coding: utf-8
# Your code here!
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n #各要素の親要素の番号を格納するリスト

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]

    def union(self,x,y): #要素xが属するグループと要素yが属するグループとを併合する
        x=self.find(x)
        y=self.find(y)

        if x==y:
            return

        if self.parents[x]>self.parents[y]:
            x,y=y,x

        self.parents[x]+=self.parents[y]
        self.parents[y]=x

    def size(self,x): #要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self,x,y): #要素x, yが同じグループに属するかどうかを返す
        return self.find(x)==self.find(y)

    def members(self,x): #要素xが属するグループに属する要素をリストで返す
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self): #すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x<0]

    def group_count(self): #グループの数を返す
        return len(self.roots())

    def all_group_members(self): #{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
now=0
ans=0
for _ in range(m):
    uf=UnionFind(n)
    for ind,aa in enumerate(a):
        if ind!=now:
            uf.union(aa[0]-1,aa[1]-1)
    if uf.group_count()!=1:
        ans+=1
    now+=1
print(ans)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k;
ll fx(ll x,vector<ll> &a)
{
	ll sum=0;
	for(ll i=0;i<(ll)a.size();i++)
	sum+=a[i]^x;
	return sum;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	vector<int> bit_nums(64);
	vector<int> x_vec(64);
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(ll i=0;i<ll(a.size());i++)
	{
		ll t=0;
		for(ll j=0;j<64;j++)
		{
			t=a[i]>>j;
			bit_nums[j]+=(int)(t&ll(1));
		}
	}
	for(int i=0;i<64;i++)
	{
		if(n%2!=0)
		{
			if(bit_nums[i]>(n/2)) x_vec[i]=0; else x_vec[i]=1;
		}
		else
		{
			if(bit_nums[i]>=(n/2)) x_vec[i]=0; else x_vec[i]=1;
		}
	}
	ll x=0;
	for(int i=62;i>=0;i--)
	{
		ll temp=x;
		temp+=x_vec[i]*((ll)1<<i);
		if (temp>k) continue; else x=temp;
	}
	ll ans=fx(x,a);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n = 0, awia = 100000;
    
    scanf("%d", &n);
    while (--n >= 0){
        awia += awia * 0.05;
        if (awia % 1000)
            awia = (awia / 1000 * 1000) + 1000;
    }
    printf("%d\n", awia );
    return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n, i, j, num[], count = 0;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		num = new int[n];
		for (i = 0; i < n; ++i) {
			num[i] = sc.nextInt();
		}
		sc.close();
		i = 1;
		while (i != 0) {
			i = 0;
			for (j = n - 1; j > 0; --j) {
				if (num[j - 1] > num[j]) {
					int tmp = num[j];
					num[j] = num[j - 1];
					num[j - 1] = tmp;
					i = 1;
					++count;
				}
			}
		}
		for (i = 0; i < n; ++i) {
			System.out.print(num[i]);
			if (i != n - 1) {
				System.out.print(" ");
			}
		}
		System.out.print("\n");
		System.out.println(count);
	}
}



Measured memory_bytes: 26424
# Buffet
import numpy as np

# input
N = int(input())
A = [e - 1 for e in list(map(int, input().split()))]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# solve
res = 0
for i in range(len(A)):
    res += B[i]
    if i != 0 and A[i-1] + 1 == A[i]:
        res += C[A[i-1]]

# output
print(res)


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

vector<int> grundy(100005, -1);

int getMax(set<int> s)
{
	int max = 0;
	while(s.find(max) != s.end())
		max++;
	return max;
}

int getGrundy(int pos, int *a, int n)
{
	if(grundy[pos] != -1)
		return grundy[pos];
	set<int> s;
	for(int i = 0; i < n; i++)
	{
		if(a[i] > pos)
		break;
		int res = getGrundy(pos - a[i], a, n);
		s.insert(res);
	}
	return grundy[pos] = getMax(s);
}

int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	grundy[0] = 0;
	grundy[k] = getGrundy(k, a, n);
	if(grundy[k])
	cout << "First\n";
	else
	cout << "Second\n";
	
	return 0;
}

Measured memory_bytes: 20992