akhauriyash/Code-Regression huggingface dataset:
local zeroes, ones = 0, 0
while true do
    local c = io.read(1)
    if c == '0' then
        zeroes = zeroes + 1
    elseif c == '1' then
        ones = ones + 1
    elseif c == '\n' then
        break
    end
end
print(math.min(zeroes, ones) * 2)

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main () {
 
    int a[3];
    for (int i=0; i<3; ++i) {
	cin >> a[i];
    }
    sort(a,a+3);
    if(a[0] == 5 and a[1] == 5 and a[2] == 7)
	cout << "YES" << endl;
    else
	cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e5 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**
贪心
1 4
2 5
把数据经过排序之后形成东西走向有序的岛屿
如果第二组数据的左端点大于等于上一个数据的右端点
说明两个区间不存在相交的区间
也就是说明两个区间都要切断一座桥
即ans++ 
**/
struct node
{
	int l;
	int r;
}a[maxn];

bool cmp(node x,node y)
{
	if(x.r == y.r)	return x.l < y.l;//右端点相同的话按照左端点升序排列
	return x.r < y.r;//否则就按照右端点升序排列 
}

int n,m,ans;
int main()
{
	n = read();	m = read();
	for(int i=0;i<m;i++)
		cin >> a[i].l >> a[i].r;
	sort(a,a+m,cmp);
	int t = a[0].r;	
	ans = 1;
	for(int i=1;i<m;i++)
	{
		if(a[i].l >= t) 
		{
			ans++;
			t = a[i].r;
			//如果这一个左端点大于上一个右端点，切断桥数+1，更新t 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/* h-ex7_1
   Ohshima */

#include <stdio.h>

//頂点を表す構造体
typedef struct point{
  int x_elem;
  int y_elem;
}point;

//ある頂点についてx軸、y軸について移動させた頂点を返す関数, 座標成分はすべて整数なので変化量も整数
point shift_point(point pnt, int x_shift, int y_shift){
  pnt.x_elem += x_shift;
  pnt.y_elem += y_shift;
  return pnt;
}

int main(void){
  int x1, y1, x2, y2;
  point pnt1, pnt2, pnt3, pnt4;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  //頂点pnt1, pnt2にそれぞれ成分を代入
  pnt1.x_elem = x1;
  pnt1.y_elem = y1;
  pnt2.x_elem = x2;
  pnt2.y_elem = y2;
  //pnt3はpnt2をx軸方向に(y1-y2), y軸方向に(x2-x1)だけ平行移動させた頂点 (複素数平面などを用いて示せる)
  pnt3 = shift_point(pnt2, pnt1.y_elem - pnt2.y_elem, pnt2.x_elem - pnt1.x_elem);
  //pnt4もpnt3と同様に平行移動させればよい
  pnt4 = shift_point(pnt3, pnt2.y_elem - pnt3.y_elem, pnt3.x_elem - pnt2.x_elem);
  printf("%d %d %d %d\n", pnt3.x_elem, pnt3.y_elem, pnt4.x_elem, pnt4.y_elem);
  return 0;
}


Measured memory_bytes: 1736
import sys
anw = {}
for line in sys.stdin.readlines():
    for _ in line:
        if _.lower() in anw:
            anw[_.lower()] += 1
        else:
            anw[_.lower()] = 1

for _ in 'abcdefghijklmnopqrstuvwxyz':
    if _ not in anw:
        print(_,":","0")
    else:
        print(_,":",anw[_])


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
const int N = 2e5 + 7;
vector<ll> vout;
vector<vector<int>> vnodes;

void dfs(int node, int prev, ll val){
  vout[node] += val;
  auto nodes = vnodes[node];
  for(int i=0;i<nodes.size();++i){
    if(nodes[i] == prev) continue;
    dfs(nodes[i], node, vout[node]);
  }
}

int main() {
  int n,q;cin >>n >>q;
  vnodes.resize(n);
  vout.resize(n,0LL);
  for(int i=0;i<n-1;++i){
    int a,b;cin>> a>>b;
    vnodes[a-1].push_back(b-1);
    vnodes[b-1].push_back(a-1);
  }
  for(int i=0;i<q;++i){
    int p,x;cin>> p>>x;
    vout[p-1] += x;
  }

  ll tmp = vout[0];
  vout[0] = 0;
  dfs(0, -1,tmp);

  for(int i=0;i<n;++i){
    cout << vout[i] << " ";
  }

  return 0;
}


Measured memory_bytes: 33664
N, M =map(int, input().split())
ab = list(list(map(int ,input().split())) for _ in range(N))
cd = list(list(map(int ,input().split())) for _ in range(M))

lst = [ [0] * M for _ in range(N)] 
for i in range(N):
    for j in range(M):
        lst[i][j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for i in range(N):
    print(lst[i].index(min(lst[i])) + 1)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int[] array = {Integer.parseInt(sc.nextLine()),
                        Integer.parseInt(sc.nextLine()),
                        Integer.parseInt(sc.nextLine()),
                        Integer.parseInt(sc.nextLine()),
                        Integer.parseInt(sc.nextLine())};
        int k = Integer.parseInt(sc.nextLine());
        
        boolean flag = false;
        
        for(int i = 0; i < array.length - 1; i++){
            for(int j = i + 1; j < array.length; j++){
                if(Math.abs(array[i] - array[j]) > k){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
        }
        
        if(!flag){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");
        }
        
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[300000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n;cin>>n;
  REP(i,n){
    cin>>a[i];
  }
  ll sum=0;
  ll ans=0;
  for(ll l=0,r=0;l<n;l++){
    while(r<n && (sum^a[r])==(sum+a[r])){
      sum^=a[r];
      r++;
    }
    ans+=r-l;
    sum^=a[l];
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 1792
import math
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


count2=0
mod=1000000007
X,Y=map(int,input().split())
flag=0
count=0
for i in range(min(X,Y)//3):
    if min(X,Y)*2==max(X,Y):
        flag=1
        count2=min(X,Y)
        break
    X-=3
    Y-=3
    count+=1
    #print(X,Y)

if min(X,Y)*2==max(X,Y):
    flag=1

if flag==0:
    print('0')
    exit(0)

print(cmb(count*2+count2,count)%mod)



Measured memory_bytes: 102376
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll inf = 1 << 30;
const ll mod = 1000000000 + 7;

ll f(ll x)
{
	ll y = x + 1;
	ll r = 0;
	if (y % 2 == 0)
	{
		r = ((y / 2) % 2 == 0) ? 0 : 1;
	}
	else
	{
		r = ((y / 2) % 2 == 0) ? 0 : 1;
		r ^= x;
	}

	return r;
}

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

	cout << (f(b) ^ f(a - 1)) << endl;
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 100000;

int n;
ll c, ans;
ll x[N + 5], v[N + 5];
ll t0[N + 5], t1[N + 5];
ll pre[N + 5], suf[N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(c);
    for(int i = 1; i <= n; ++i) { read(x[i]), read(v[i]); }
    for(int i = 1; i <= n; ++i) {
        pre[i] = pre[i-1] + v[i];
        chkmax(ans, pre[i] - x[i]);
        t0[i] = std::max(t0[i-1], pre[i] - 2 * x[i]);
    }
    for(int i = n; i >= 1; --i) {
        suf[i] = suf[i+1] + v[i];
        chkmax(ans, suf[i] - (c - x[i]));
        t1[i] = std::max(t1[i+1], suf[i] - 2 * (c - x[i]));
    }

    for(int i = 1; i <= n; ++i) {
        chkmax(ans, pre[i] + t1[i + 1] - x[i]);
        chkmax(ans, suf[i] + t0[i - 1] - (c - x[i]));
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,c;
    while(cin>>a>>b>>c)
    {
        set<ll> st;
        st.insert(a);
        st.insert(b);
        st.insert(c);
        if(st.size()==2) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int d,sum=0,t;
	while(scanf("%d",&d) !=EOF)
	{
		sum=0;
		t=d;
		for(t;t<600;t+=d)
		{
			sum+=t*t*d;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
  long long n,ans=1;
  scanf("%lld",&n);
  long long arr[n+5],maks=1000000000000000000;
  for(long long i=1;i<=n;i++){
      scanf("%lld",&arr[i]);}
  
  for(int i=1;i<=n;i++){
    if(arr[i]==0){
        printf("0");
        return 0;
    }
  }
  
  for(long long i=1;i<=n;i++){
    if(maks/ans<arr[i]){
        printf("-1");
        return 0;
    }
    
    ans*=arr[i];
  }
  
  printf("%lld",ans);
}

Measured memory_bytes: 2476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
  public static void main(String[] args) throws IOException {
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      String line = br.readLine();
      int n = Integer.parseInt(line);
      n = (int) Math.pow(n, 3);
      System.out.println(n);
    }
  }
}


Measured memory_bytes: 24256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}



void solve()
{ 
string s;
    cin>>s;
    ll sum=0;
    for(char c:s)
    {
     sum+=(c-'0');   
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;
   
    
     int t=1;
  //  cin>>t;
     while(t--)
    	solve();
    return 0;
}



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

const int N = 200000 + 7;
int n;
int t[2*N];

void build(){
	for(int i = n-1;i > 0;--i) t[i] = max(t[i<<1],t[i<<1|1]);
}

int query(int l,int r){
	int res = -INT_MAX;

	for(l += n, r += n; l < r; l >>= 1, r >>= 1){
		if(l&1) res = max(res, t[l++]);
		if(r&1) res = max(res, t[--r]);
	}

	return res;

}

int main(){
	scanf("%d",&n);
	for(int i = 0;i < n;i++) scanf("%d", t + n + i);
	build();

	for(int i = 0;i < n;i++){
		int res = -INT_MAX;
		if(i > 0) res = max(res, query(0,i));
		if(i < n-1) res = max(res, query(i+1,n)); 
		

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

}


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

int main(void){

    int N; cin>>N;
    int tmp = N;
    int fx;
    while(tmp>0){
        fx += tmp%10;
        tmp /= 10;
    }
    if(N%fx==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second

typedef pair<int,int> ii;
typedef pair<int,ii> iii;

class UnionFindDS{
private:
	vector<int> p, h, sz;	// parent, height (rank), size
	int num;
public:
	UnionFindDS(int N){
		p.assign(N,0); for (int i=0; i<N; i++) p[i] = i;
		h.assign(N,0); sz.assign(N,1);
		num = N;
	}
	int numSets(){ return num; }
	int findSet(int i){ return p[i] == i ? i : p[i] = findSet(p[i]); }
	int sizeSet(int i){ return sz[findSet(i)]; }
	bool isSameSet(int i, int j){ return findSet(i) == findSet(j); }
	void unionSet(int i, int j){
		int x = findSet(i), y = findSet(j);
		if (x == y) return;
		
		num--;
		if (h[x] > h[y]){ p[y] = x; sz[x] += sz[y]; }
		else			{ p[x] = y; sz[y] += sz[x]; h[y] += (h[y] == h[x]); }
	}
};

priority_queue< iii,vector<iii>,greater<iii> > pq;

int main(){

	ios_base::sync_with_stdio(0);

	int V, E;
	cin >> V >> E;

	int u, v, w;
	for (int i=0; i<E; i++){
		cin >> u >> v >> w;

		pq.push(iii(w,ii(u,v)));
	}

	UnionFindDS uf(V);

	int sum = 0;
	while (uf.numSets() > 1 && !pq.empty()){
		iii front = pq.top(); pq.pop();

		u = front.se.fi; v = front.se.se; w = front.fi;

		if (uf.isSameSet(u,v)) continue;

		uf.unionSet(u,v); sum += w;
	}

	if (uf.numSets() > 1) cout << -1  << endl;		// impossible to form spanning tree
	else 				  cout << sum << endl;

	return 0;
}

Measured memory_bytes: 2720
// https://atcoder.jp/contests/abc101/tasks/arc099_a

#include <bits/stdc++.h>
#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, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, K, A;

int main()
{
  cin >> N >> K;
  REP(i, N)
  {
    cin >> A;
  }

  cout << (N + K - 3) / (K - 1) << '\n';

  return 0;
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using v = vector<T>;
using P = pair<int, int>;

/*
 *  */

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

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

  v<int> cnt(101010);
  rep(i, 0, n) cnt[a[i]]++;

  int ans = 0, tmp = 0;
  rep(i, 0, 101010){
    if(cnt[i]%2) ans++;
    if(cnt[i] and cnt[i]%2 == 0){
      if(tmp) ans += 2, tmp = 0;
      else tmp = 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

const int mod = 1e9+7;
int n, a[100001], b[100001], cnt[100001];
int FF(int start, int num){
    return max(num-(start+1)/2, 0);
}

bool meet(int p1, int p2, int num){
    return (p2-2*(num-1)) <= (p1+1);
}

struct Elem{
    int place, num;
    Elem(int place, int num){
		this->place=place;
		this->num=num;
	}
};

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);

	vector<Elem> V;
	V.push_back(Elem(a[1], 1));

	for(int i=2; i<=n; i++){
		V.push_back(Elem(a[i], 1));
		while(V.size()>=2){
			unsigned int p=V.size()-2;
			unsigned int q=V.size()-1;

			if(meet(V[p].place, V[q].place, V[q].num)){
				V[p].place=V[q].place;
				V[p].num+=V[q].num;
				V.pop_back();
			}
			else break;
		}
		/*for(const Elem &e:V){
			printf("(%d, %d)\n", e.place, e.num);
		}*/
		b[i]=FF(V[0].place, V[0].num);
		//printf("b[%d]:%d\n\n", i, b[i]);

	}

	cnt[1]++;
	for(int i=2; i<=n; i++)
		cnt[b[i-1]+1]++;

	long long ans = 1;
	int sum=0;
	for(int i=1; i<=n; i++){
		sum+=cnt[i];
		ans=ans*sum%mod;
		sum--;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    long n;
    cin >> n;
    long perm[n];
    for (long i=0; i<n; i++) {
        int a;
        cin >> a; a--;
        perm[a] = i;
    }
    set<long> used;
    used.insert(-1);
    used.insert(n);
    long sum = 0;
    for (long i=0; i<n; i++) {
        long p = perm[i];
        auto itr1 = used.upper_bound(p), itr2 = itr1;
        itr1--;
        sum += (*itr2 - p) * (p - *itr1) * (i + 1);
        used.insert(p);
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  for(int i=1; i<=2000; ++i) {
    if(floor(i * 0.08) == A && floor(i*0.1) == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
// AtCoder ABC135: D - Digits Parade
// 2019.8.26 bal4u

#include <stdio.h>

//// 高速入力
#define gc() getchar_unlocked()

int ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

#define MOD 1000000007
char S[100005]; int w;
int dp[100005][13];
#define PERIOD 6
int tbl[] = {1,10,9,12,3,4};

inline static void chmod(int *a, int b) { *a += b; if (*a >= MOD) *a -= MOD; }

int main()
{
	int i, j, k, x, t;
	
	w = ins(S+1);
	t = (w-1) % PERIOD, dp[0][0] = 1;
	for (i = 1; i <= w; i++) {
		for (j = 0; j < 13; j++) if (dp[i-1][j]) {	
			if (S[i] == '?') {
				for (k = 0; k < 10; k++) chmod(&dp[i][(j + k * tbl[t]) % 13], dp[i-1][j]); 
			} else chmod(&dp[i][(j + (S[i] & 0xf)*tbl[t]) % 13], dp[i-1][j]); 
		}
		if (t == 0) t = PERIOD;
		t--;
	}
	printf("%d\n", dp[w][5]);
	return 0;
}

Measured memory_bytes: 5376
import math

a,b,h,m = map(int, input().split())

degree = abs(30*h+0.5*m) - (6*m)

if degree >= 180:
    degree = 360 - degree

radians = math.pi*degree/180
length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(radians))
print(length)


Measured memory_bytes: 9520
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

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

	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	// 累積和でいいじゃん
	vector<vector<int>> sumh(h + 1, vector<int>(w + 1, 0));
	vector<vector<int>> sumw(w + 1, vector<int>(h + 1, 0));

	rep(i, h) {
		Rep(j, 1, w + 1) {
			if (s[i][j-1] == '.') {
				sumh[i][j] = sumh[i][j - 1] + 1;
			}
			else {
				sumh[i][j] = 0;
			}
		}
	}

	rep(j, w) {
		Rep(i, 1, h + 1) {
			if (s[i-1][j] == '.') {
				sumw[j][i] = sumw[j][i - 1] + 1;
			}
			else {
				sumw[j][i] = 0;
			}
		}
	}
	//cout << "a" << endl;
	//戻してあげる
	rep(i, h) {
		for (int j = w; j > 0; j--) {
			if (sumh[i][j] == 0) continue;
			if (sumh[i][j - 1] == 0)continue;
			sumh[i][j - 1] = sumh[i][j];
		}
	}

	rep(j, w) {
		for (int i = h; i > 0; i--) {
			if (sumw[j][i] == 0) continue;
			if (sumw[j][i - 1] == 0)continue;
			sumw[j][i - 1] = sumw[j][i];
		}
	}

	int ans = 0;

	//全探索
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') continue;
			int tmp = 0;
			tmp = sumh[i][j + 1] + sumw[j][i + 1] - 1;
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}


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

string s;
int x, y;
vector<int> xs, ys;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> s >> x >> y;
    int T = 0, cnt = 0;
    rep(i, s.size()) {
        if (s[i]=='F') cnt++;
        else {
            if (T%2==0) xs.pb(cnt);
            else ys.pb(cnt);
            T++;
            cnt = 0;
        }
    }
    if (T%2==0) xs.pb(cnt);
    else ys.pb(cnt);
    set<int> dpx = {0};
    rep(i, xs.size()) {
        set<int> ndpx = {};
        for (auto it=dpx.begin(); it!=dpx.end(); it++) {
            if (i==0) ndpx.insert(*it+xs[i]);
            else {
                ndpx.insert(*it+xs[i]);
                ndpx.insert(*it-xs[i]);
            }
        }
        swap(dpx, ndpx);
    }
    set<int> dpy = {0};
    rep(i, ys.size()) {
        set<int> ndpy = {};
        for (auto it=dpy.begin(); it!=dpy.end(); it++) {
            ndpy.insert(*it+ys[i]);
            ndpy.insert(*it-ys[i]);
        }
        swap(dpy, ndpy);
    }
    if (dpx.find(x)!=dpx.end() && dpy.find(y)!=dpy.end()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, A;

ll dp[51][2505];

int main() {
    cin >> N >> A;
    vector<ll> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x.at(i);
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = i; j >= 0; j--) {
            for (int c = 0; c < 2501; c++) {
                if (c + x[i] <= 2500) dp[j + 1][c + x[i]] += dp[j][c];
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += dp[i + 1][A * (i + 1)];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main() {
    int a,b,c,min,max;
    cin >> a >> b >> c;
    min = a;
    max = a;
    if (min > b) {
        min = b;
    }
    if (max < b) {
        max = b;
    }
    if (min > c) {
        min = c;
    }
    if (max < c) {
        max = c;
    }
    cout << min << " " << a + b + c - min - max << " " << max << endl;
}


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

#define FasterIO  ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;

template <typename T> T Sqr(T x) { 
    T n = x * x ; 
    return n ;
}
template <typename T> T Pow(T B,T P){
    if(P == 0) return 1;
    if(P & 1) return B*Pow(B,P-1);
    else return Sqr(Pow(B,P/2));
}
int main() {
    long long n , ans = 1 ;
    cin >> n ;
    long long cnt = 0  ;
    while(n) {
        n /= 2LL ;
        cnt++ ;
    }
    cout << Pow(2LL , cnt) - 1LL << "\n" ;
    return 0 ;
}

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

struct StTrgLen
{
  StTrgLen() : m_nLenA(0), m_nLenB(0), m_nLenC(0) { }

  int m_nLenA;
  int m_nLenB;
  int m_nLenC;
};

struct StMatrl
{
  StMatrl() : m_nNumA(0), m_nLenA(0), 
               m_nNumB(0), m_nLenB(0),
               m_nNumC(0), m_nLenC(0) { }
  int m_nNumA;
  int m_nLenA;
  int m_nNumB;
  int m_nLenB;
  int m_nNumC;
  int m_nLenC;
};

void fnInput(StTrgLen& roTrgLen, vector<int>& rvnMatLen)
{
  int nMatLenSiz;
  cin >> nMatLenSiz >> roTrgLen.m_nLenA >> roTrgLen.m_nLenB >> roTrgLen.m_nLenC;
  rvnMatLen.resize(nMatLenSiz);

  for (int& rnMatLen : rvnMatLen)
    cin >> rnMatLen;
}

int fnDfs(int nPos, StTrgLen oTrgLen, StMatrl& roMatrl, const vector<int>& cnrvnMatLen)
{
  if (nPos == cnrvnMatLen.size())
    if ( roMatrl.m_nNumA && roMatrl.m_nNumB && roMatrl.m_nNumC )
      return  abs(oTrgLen.m_nLenA - roMatrl.m_nLenA)
            + abs(oTrgLen.m_nLenB - roMatrl.m_nLenB) 
            + abs(oTrgLen.m_nLenC - roMatrl.m_nLenC);
    else
      return 1 << 30; 

  int nMinMp = 0; 
  int nAddMp;

  StMatrl oMatrlA(roMatrl);
  nAddMp = oMatrlA.m_nNumA ? 10 : 0;
  oMatrlA.m_nNumA++;
  oMatrlA.m_nLenA += cnrvnMatLen[nPos];
  nMinMp = fnDfs(nPos + 1, oTrgLen, oMatrlA, cnrvnMatLen) + nAddMp;

  StMatrl oMatrlB(roMatrl);
  nAddMp = oMatrlB.m_nNumB ? 10 : 0;
  oMatrlB.m_nNumB++;
  oMatrlB.m_nLenB += cnrvnMatLen[nPos];
  nMinMp = min(nMinMp, fnDfs(nPos + 1, oTrgLen, oMatrlB, cnrvnMatLen) + nAddMp);

  StMatrl oMatrlC(roMatrl);
  nAddMp = oMatrlC.m_nNumC ? 10 : 0;
  oMatrlC.m_nNumC++;
  oMatrlC.m_nLenC += cnrvnMatLen[nPos];
  nMinMp = min(nMinMp, fnDfs(nPos + 1, oTrgLen, oMatrlC, cnrvnMatLen) + nAddMp);

  nMinMp = min(nMinMp, fnDfs(nPos + 1, oTrgLen, roMatrl, cnrvnMatLen));

  return nMinMp;
}

int fnMinCostTrgLen(StTrgLen oTrgLen, const vector<int>& cnrvnMatLen)
{
  StMatrl oMatrl;

  return fnDfs(0, oTrgLen, oMatrl, cnrvnMatLen);
}
 
int main()
{
  StTrgLen oTrgLen;
  vector<int> vnMatLen;

  fnInput(oTrgLen, vnMatLen);
  cout << fnMinCostTrgLen(oTrgLen, vnMatLen) << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    ll A;
    double B;
    cin >> A >> B;
    ll nB = B * 1000;
    ll n2B = B * 100;
    cout << max(A*nB/1000,A*n2B/100)<< endl;
}

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

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  int cost[n]={0};
  cost[0]=0;
  cost[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++){
     int prev=INT_MAX;
    for(int j=1;j<=min(i,k);j++){
      prev=min(prev,cost[i-j]+abs(arr[i]-arr[i-j]));
      cost[i]=prev;
    }
}
    cout<<cost[n-1];
  return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

int main()
{
	puts(abs(read()-read())<=1?"Brown":"Alice");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args:Array[String]):Unit = {
    val sc = new Scanner(System.in)
    val r, g, b = sc.nextInt()

    if ((g * 10 + b) % 4 == 0) {
      println("YES")
    } else {
      println("NO")
    }
  }
}

Measured memory_bytes: 25424
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	vector<int> t(3);
	int ans = 0;
	rep(i,3) cin >> t[i];
	sort(all(t));
	if((t[1]-t[0])%2 != 0){
		t[2]++;
		t[0]++;
		ans++;
	}
	ans+=(t[2]-t[1]);
	ans+=(t[1]-t[0])/2;
	cout << ans << endl;
	return 0;
}

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


int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
    ll x,y;
    cin>>x;
    cin>>y;
    if(abs(x-y)<=1)
    {
        cout<<"Brown"<<endl;
    }
    else{
        cout<<"Alice"<<endl;
    }

    
    return 0;
}

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

int HM[358623],*END=HM+358621;

bool insert(int a){
    int *p=HM+a%358621;
    while(*p){
        if(*p==a) return true;
        if(++p==END) p=HM;
    }
    *p=a;
    return false;
}

int main(){
    int n{},a,c;
    while((c=getchar_unlocked()-'0')>=0) n*=10,n+=c;
    fr(i,n){
        a=0;
        while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
        if(insert(a)){
            putchar_unlocked('N');
            putchar_unlocked('O');
            putchar_unlocked('\n');
            return 0;
        }
    }
    putchar_unlocked('Y');
    putchar_unlocked('E');
    putchar_unlocked('S');
    putchar_unlocked('\n');
}


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


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

    //Insert code
    
    ll n,res=0;
    cin>>n;
    ll a[2205];
    cin>>a[0];
    cin>>a[1];
    for (int i=2;i<n;i++){
        cin>>a[i];
        if (min(a[i],a[i-2])<a[i-1]&& a[i-1]<max(a[i],a[i-2]) ) {
            //cout<<min(a[i],a[i-2])<<" "<<a[i-1]<<" "<<max(a[i],a[i-2])<<endl;
            //cout<<a[i]<<endl;
            res++;
        }
    }
    
    cout<<res;
    
    //End code

    cerr << "\nTime elapsed: " << 1000*clock() / CLOCKS_PER_SEC << "ms\n";
    
}   

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    vector<string> v;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v.pb(s);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout<<v[i];
    }
    return 0;
}


Measured memory_bytes: 256
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int n=Integer.parseInt(br.readLine());
            HashSet<String> set=new HashSet<>();
            for(int j=0;j<n;j++){
                set.add(br.readLine());
            }
            System.out.println(set.size());
        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}

Measured memory_bytes: 66008
#include <cstdio>
int n;
int a[200005];
int box[200005];
int ans[200005];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	for (int i = n; i >= 1; i--) {
		int sum = 0;
		for (int j = 2 * i; j <= n; j += i) {
			sum += box[j];
		}
		box[i] = (a[i] - sum % 2) % 2;
	}
	
	int m = 0;
	for (int i = 1; i <= n; i++) {
		if (box[i]) {
			ans[m++] = i; // not ans[m++] = 1
		}
	}
	
	printf("%d\n", m);
	for (int i = 0; i < m; i++) {
		printf("%d ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ll N,A; cin >> N;
    ll sum = 0;
    vector<ll> array;
    for(ll i = 0;i < N*3;i++){
        cin >> A;
        array.push_back(A);
    }
    
    sort(array.rbegin(),array.rend());
    
    for(int i = 1; i < 2*N+1; i += 2) sum += array[i];
    
    cout << sum << endl;
}


Measured memory_bytes: 6256
N = int(input())
S = list(input())
s = list(set(S))
L = [0 for i in range(len(s))]
for i in range(len(s)):
    L[i] = S.count(s[i]) + 1
a = 1
for i in range(len(s)):
    a *= L[i]
print((a - 1) % (10 ** 9 + 7))


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int X, Y;
    cin >> X >> Y;
    bool check = false;
    for (int i = 0; i <= X; i++) {
        int temp = i * 2 + (X - i) * 4;
        if (temp == Y) check = true;
    }
    cout << (check ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline

n = int(input())
t0,x0,y0 = 0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    d = abs(x-x0) + abs(y-y0)
    dd = (t-t0) - d
    if dd < 0 or dd % 2 != 0:
        print("No")
        exit()
    t0,x0,y0 = t,x,y
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include<queue>
#include<cstring>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;
typedef pair<int,int> P;
int ans[105][105];
int a[10005];
int x[4]={0,1,-1,0};
int y[4]={1,0,0,-1};
bool used[105][105];
int H,W,N;
int main()
{

    while(cin>>H>>W>>N)
    {

        for(int i=1;i<=N;i++)
        {
           cin>>a[i];
        }

        int x=0;
        int y=0;

        for(int i=1;i<=N;i++)
        {
            while(a[i]--)
            {
                ans[y][x]=i;
                if(y==H-1&&!(x&1))
                    {
                        x++;
                    }

                else if(y==0&&(x&1))
                   x++;
                else if(!(x&1))
                    y++;
                else
                    y--;
            }
        }
         for(int i=0;i<H;i++)
        {
            cout<<ans[i][0];
            for(int j=1;j<W;j++)
            {
               cout<<' '<<ans[i][j];
            }
            cout<<endl;
        }



    }
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		while (scanner.hasNext()) {

			double x1 = input();
			double y1 = input();
			double x2 = input();
			double y2 = input();
			double x3 = input();
			double y3 = input();
			double xp = input();
			double yp = input();

			double area1 = getArea(x1, y1, x2, y2, xp, yp);
			double area2 = getArea(x1, y1, x3, y3, xp, yp);
			double area3 = getArea(x2, y2, x3, y3, xp, yp);
			double area4 = area1 + area2 + area3;
			double area5 = getArea(x1, y1, x2, y2, x3, y3);

			if (area4 - area5 < 0.001) {

				System.out.println("YES");

			} else {

				System.out.println("NO");

			}
		}

		close();

	}

	public static double getDistance(double x1, double y1, double x2, double y2) {

		return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));

	}

	public static double getArea(double x1, double y1, double x2, double y2, double x3, double y3) {

		double a = getDistance(x1, y1, x2, y2);
		double b = getDistance(x1, y1, x3, y3);
		double c = getDistance(x2, y2, x3, y3);
		double s = (a + b + c) / 2;

		return Math.sqrt(s * (s - a) * (s - b) * (s - c));

	}

	public static double input() {

		return scanner.nextDouble();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 31516
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int k, n;
  cin >> k >> n;

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

  int max = 0;
  for(int i=1; i<n+1; i++) {
    if(max < a[i] - a[i - 1]) {
      max = a[i] - a[i - 1];
    }
  }

  cout << k - max << endl;
}

Measured memory_bytes: 4056
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    cnt=0
    for i in range(1,36):
        d=2**i
        for Ai in A:
            if Ai%d!=0:
                print(cnt)
                exit()
        cnt+=1
    print(cnt)
    
    
    
if __name__=="__main__":
    main()


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

struct robo{
  ll s,t;

  bool operator<(const robo& r) const { 
    return t == r.t ? s < r.s : t < r.t;
  }
};

int main(){
  ll n;
  cin>>n;
  vector<ll> x(n),l(n);
  vector<robo> a(n);
  for(ll i=0;i<n;i++){
    cin>>x[i]>>l[i];
    a[i].s=x[i]-l[i];
    a[i].t=x[i]+l[i];
  }
  sort(a.begin(),a.end());
  ll ans=n;
  ll minv=a[0].t;
  for(ll i=1;i<n;i++){
    if(minv>a[i].s){
      ans--;
    }else{
      minv=max(minv,a[i].t);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define in insert
#define sort(v) sort(v.begin(),v.end())
int main()
{ 
ll a,b,c,d,e,f,i,j,k,l=0;
cin>>a;
cout<<a+(a*a)+(a*a*a);
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
mod=10**9+7
fact=[1]*(m+1)
inv=[1]*(m+1)
for i in range(2,m+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(m,1,-1):
    inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
def p(x,y):return fact[x]*inv[x-y]%mod if x>=y>=0 else 0
ans=p(m,n)**2%mod
a=-1
for i in range(1,n+1):
    ans=(ans+a*(p(m,i)*comb(n,i)*p(m-i,n-i)**2%mod))%mod
    a*=-1
print(ans)

Measured memory_bytes: 48356
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> face_east(n+2, 0);
    vector<int> face_west(n+2, 0);
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        face_east[i] = face_east[i-1] + (s[i-1] == 'E');
    }
    for(int i = n; i >= 1; i--) {
        face_west[i] = face_west[i+1] + (s[i-1] == 'W');
    }
    for(int i = 1; i <= n; i++) {
        ans = max(ans, face_east[i-1]+face_west[i+1]);
    }
    cout << n - 1 - ans << endl;
    return 0;
}




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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue

int n, res;

bool big(pii a, pii b){
    if(a.fi >= b.fi && a.se >= b.se){
        return 1;
    }
    return 0;
}

pii a[maxn], b[maxn];
vector < int > g[maxn];
int p[maxn];
bool used[maxn];
int get_kuhn(int v){
    if(used[v]) { return false; }
    used[v] = true;
    for(int i : g[v]){
        if(p[i] == -1 || get_kuhn(p[i])){
            p[i] = v;
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i].fi >> a[i].se;
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i].fi >> b[i].se;
        p[i] = -1;
    }
    for(int i = n; i <= n + n; i++){
        p[i] = -1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(big(b[i], a[j])){
                g[i].push_back(j + n);
            }
        }
    }
    for(int i = 1; i <= n; i++){
        memset(used, 0, sizeof(used));
        get_kuhn(i);
    }
    for(int i = 1; i <= n + n; i++){
        if(p[i] != -1){
            res++;
        }
    }
    cout << res;
}


Measured memory_bytes: 11392
from bisect import bisect_left

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

m = 30
d = []
# d[i] = 1<<i
for i in range(m+1):
    d.append(1<<i)

c = [[] for i in range(m)]
for bi in b:
    for i in range(m):
        c[i].append(bi&(d[i+1]-1))
for i in range(m):
    c[i].sort()

keta = [0]*m

# しゃくとりするなら桁ごとにやるしか無い
for i in range(m):
    aa = [ai&(d[i+1]-1) for ai in a]
    aa.sort()
    a0 = aa[0]

    i1 = d[i]
    i2 = d[i+1]
    i3 = i2+i1
    b1 = bisect_left(c[i], i1-a0)
    b2 = bisect_left(c[i], i2-a0)
    b3 = bisect_left(c[i], i3-a0)

    for ai in aa:
        # 尺取
        # aiは大きくなる→境界は小さくなる
        # 引いたあとのindexが0以上であることも必要
        while b1-1 >= 0 and c[i][b1-1] >= i1-ai:
            b1 -= 1
        while b2-1 >= 0 and c[i][b2-1] >= i2-ai:
            b2 -= 1
        while b3-1 >= 0 and c[i][b3-1] >= i3-ai:
            b3 -= 1
        keta[i] += b2-b1 + n-b3
    keta[i] %= 2

#print(keta)

ans = 0
for i in range(m):
    ans += keta[i]*(1<<i)

print(ans)

Measured memory_bytes: 145276
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll int n,i,a[60],sum=0,j,t,s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            s=a[i]*a[j];
            sum=sum+s;
        }
    }
   cout<<sum<<endl;
return 0;
}

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


int main(){    
    int a,b,c,d ;
    cin >> a >> b >> c >> d ;
    while (1)
    {
        c -= b ;
        if(c <= 0){
            cout << "Yes" << endl ;
            return 0 ;
        }
        a -= d ;
        if (a <= 0)
        {
            cout << "No" << endl ;
            return 0 ;
        }
        
    }
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define S second
#define F first
#define ll long long
using namespace std;

main(){
    long long n,m;
    cin >> n >> m;
    if (n == 1 && m == 1) cout << 1 << endl;
    else if(n == 1) cout << m-2 << endl;
    else if(m == 1) cout << n-2 << endl;
    else cout << (m-2) *(n-2)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool f=0;
  if(s[0]==s[1]) f=1;
  if(s[2]==s[1]) f=1;
  if(s[2]==s[3]) f=1;
  if(f) cout<<"Bad";
  else cout<<"Good";
}

Measured memory_bytes: 256