akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  ll numl=0;
  res=1;
  rep(i,0,2*n){
    if(s[i]=='B'){
      if(numl%2==0){
        numl++;
      }
      else{
        qmod(res,numl);
        numl--;     
      }
    }
    else{
      if(numl%2==1){
        numl++;
      }
      else{
        qmod(res,numl);
        numl--;      
      }
    }
    if(numl<0){
      judge=false;
      break;
    }
  }
  //cout<<judge spa numl<<endl;
  if(numl!=0)judge=false;
  rep(i,0,n)qmod(res,i+1);
  ans(judge,res,0);
  return 0;
}

Measured memory_bytes: 720
#include<iostream>

using namespace std;

int count;
int W = 0, H = 0;
char tyle[22][22];


void check(int x, int y);


int main(){

	int i, j;
	int startH, startW;


	while(1){

		count = 0;

		cin >> W >> H;

		if(W != 0 && H != 0){

			for(i = 0; i <= W; i++){
				tyle[i][0] = '#';
				tyle[i][H+1] = '#';
			}

			for(i = 0; i <= H; i++){
				tyle[0][i] = '#';
				tyle[W+1][i] = '#';
			}

			for(i = 1; i <= H; i++){
				for(j = 1; j <= W; j++){
					cin >> tyle[j][i];
					if(tyle[j][i] == '@'){
						startH = i;
						startW = j;
					}
				}
			}


			check(startW, startH);

			cout << count << endl;

		}

		else{break;}

	}

	return 0;
}




void check(int x, int y){

	count++;

	tyle[x][y] = '#';

	if(tyle[x][y-1] == '.'){
		check(x, y-1);
	}
	if(tyle[x-1][y] == '.'){
		check(x-1, y);
	}
	if(tyle[x][y+1] == '.'){
		check(x, y+1);
	}
	if(tyle[x+1][y] == '.'){
		check(x+1, y);
	}
}

Measured memory_bytes: 1188
#include<cstdio>
int main()
{
	int n,x,s=0,ss=0,min=0x3f3f3f3f;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x%10==0) {ss+=x;continue;}
		s+=x;
		if(x<min) min=x;
	}
	if(s) s=s%10==0?s-min+ss:s+ss;
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K, N = mapint()
As = list(mapint())

lis = []
for i in range(1, N):
    lis.append(As[i]-As[i-1])
lis.append(As[0]+(K-As[-1]))
print(K-max(lis))

Measured memory_bytes: 102360
/* ex4_1
    riverstone*/

#include<stdio.h>
#include<math.h>  //math.h を include する。


int main(void){

    //りんごの個数と監視の幅を入力
    double apple,range;
    scanf("%lf  %lf",&apple,&range); 

    //1人の監視員は(監視の幅)×2+１のりんごを監視できるので、りんごの数をそれで割ったあと切り上げる
    int num_watchmen = ceil(apple / (range*2 + 1)); 
    printf("%d",num_watchmen); //監視員の人数を出力
    return 0;

}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

int main(){
    fast;
    
    string s, t;
    cin>>s>>t;
    
    ll n = s.length();
    ll m = t.length();
    
    ll ans = inf;
    
    for(ll i=0;i<=n-m;i++){
        ll cnt = 0;
        for(ll j=0;j<m;j++){
            if(s[i+j]!=t[j])
                cnt++;
        }
        
        ans = min(ans , cnt);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {

  int N, X, m;
  cin >> N >> X;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> m;
    v.at(i) = m;
  }
  
  int diff = X - accumulate(v.begin(), v.end(), 0);
  int min = *min_element(v.begin(), v.end());
  int ans = diff / min + N;
  cout << ans << endl;

  return 0;
}




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

int main() {
	int N;
	long long T, sum = 0;
	cin >> N >> T;
	vector<long long> t(N, 0);
	sum = N * T;
	rep(i, N) {
		cin >> t[i];
		if (i != 0)
			if ((t[i] - t[i - 1]) < T)
				sum -= T - (t[i] - t[i - 1]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void) {
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	int xmax = -10000;
	for (int i = 0; i < N; ++i) {
		int temp;
		cin >> temp;
		xmax = max(xmax,temp);
	}
	int ymin = 10000;
	for (int i = 0; i < M; ++i) {
		int temp;
		cin >> temp;
		ymin = min(ymin,temp);
	}

	if ((xmax < ymin)&&(X < ymin)&&(Y > xmax)) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int tempN = N;
		int fct = 0;
		
		while(tempN > 0) {
			fct += tempN%10;
			tempN /= 10;
		}
		
		if(N%fct == 0) System.out.println("Yes");
		else System.out.println("No");
	}

}


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

int n;
int a[101010];
int b[101010];
int c[101010];

int ab[101010];

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

    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);


    long long ans = 0;
    
    int x = 0;
    for(int i=0;i<n;i++){
        while(a[x] < b[i] && x < n)x++;
        ab[i] = x;
    }
    x = 0;
    long long s = 0;
    for(int i=0;i<n;i++){
        while(b[x] < c[i] && x < n){
            s += ab[x];
            x++;
        }
        ans += s;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
const int N = 1e5 + 10;
int x[N];
int main()
{
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 1; i <= k; i++)
        x[i] = s;
    for (int i = k + 1; i <= n; i++)
    {
        if (s - 1 >= 1)
            x[i] = s - 1;
        else
            x[i] = s + 1;
    }
    for (int i = 1; i <= n; i++)
        cout << x[i] << " ";
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
	int n, k, ans = 0; cin >> n >> k;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		if(x >= k) ans++;
	}
	cout << ans << endl;
}

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

template <class Abel>
struct BIT
{
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0; // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n)
    {
        for (int iter = 0; iter < 2; ++iter)
            dat[iter].assign(n + 1, UNITY_SUM);
    }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x)
    {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x)
    {
        sub_add(0, a, x * -(a - 1));
        sub_add(1, a, x);
        sub_add(0, b, x * (b - 1));
        sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a)
    {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b)
    {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print()
    {
        for (int i = 1; i < (int)dat[0].size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    int Q;
    cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i)
    {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) { return rights[i] < rights[j]; });

    BIT<int> bit(N + 5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids)
    {
        for (; r < rights[i]; ++r)
        {
            bit.add(prev[a[r]] + 2, r + 2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i] + 1, lefts[i] + 2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i)
        cout << res[i] << endl;
}

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

int main(){
    
    int n,x;
    cin >> n >> x;
    int sum = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        sum += l;
        if(sum <= x){
            cnt ++;
        }
    }
    cout << cnt+1 << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m;
pii arr[100009],segtree[500005];

void build(int node,int si,int ei)
{
    if (si>ei)return;
    if (si==ei)
    {
        segtree[node]={si,si};
        return;
    }

    int mid=(si+ei)/2;

    build(2*node,si,mid);build(2*node+1,mid+1,ei);

    segtree[node]=max(segtree[2*node],segtree[2*node+1]);
}

void update(int node,int si,int ei,int idx,int val)
{
    if (si==ei)
    {
        segtree[node].ff=val;
        return;
    }

    int mid=(si+ei)/2;

    if (idx<=mid)
    {
        update(2*node,si,mid,idx,val);
    }
    else
    {
        update(2*node+1,mid+1,ei,idx,val);
    }

    segtree[node]=max(segtree[2*node],segtree[2*node+1]);
}

pii query(int node,int si,int ei,int l,int r)
{
    if (si>r || ei<l)
        return {-1,-1};

    if (si>=l && ei<=r)
        return segtree[node];

    int mid=(si+ei)/2;
    return max(query(2*node,si,mid,l,r),query(2*node+1,mid+1,ei,l,r));
}



void solve()
{
	cin>>n>>m;
	rep(i,0,n)
	{
		cin>>arr[i].ss>>arr[i].ff;
	}
	
	build(1,0,100005);
	sort(arr,arr+n,greater<pii>());
	
	int lim=m,ans=0;
	
	rep(i,0,n)
	{
		int pos=lim-arr[i].ss;
		pii where=query(1,0,100005,0,pos);
		if (where.ff==-1)continue;
		else 
		{
			update(1,0,100005,where.ss,-1);
			ans+=arr[i].ff;
		}
	}
	cout<<ans<<"\n";
	
	
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    ///cin>>t;
    
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
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; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

int main() {
	ll n;
  	ll a[10001000];
  
  	cin>>n;
  	rep(i,n){
    cin>>a[i];
    }
  
  	ll ans=0;
  	ll high=a[0];
  
  	for(int i=1;i<n;i++){
    	if(high>a[i]){
        	ans+=high-a[i];
        }
      
      	else if(high<a[i]){
        	high=a[i];
        }
    }
  
  cout<<ans<<endl;

}

Measured memory_bytes: 5120
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let a = Int(split[0])!
let b = Int(split[1])!
let c = Int(split[2])!

if (a <= b * c) {
  print("Yes")
}else{
  print("No")
}

Measured memory_bytes: 14076
X = int(input())
a = [100, 101, 102, 103, 104, 105]
dp = [[False]*100010 for _ in range(10)]
dp[0][0] = True

for i in range(6):
    for j in range(X+1):
        dp[i+1][j] |= dp[i][j]
        if j >= a[i]:
            dp[i+1][j] |= dp[i][j-a[i]]
            dp[i+1][j] |= dp[i+1][j-a[i]]
if dp[6][X]:
    print(1)
else:
    print(0)

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = head[b]; a; a= edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

int n;
double a[55];

void _main () {
	scanf ("%d", &n);

	REP (i, 1, n) {
		scanf ("%lf", &a[i]);
	}

	sort(a + 1, a + n + 1);
	double b = a[1];

	REP (i, 2, n) {
		b = (a[i] + b) / 2;
	}

	cout << b << endl;

}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
import sys
input = sys.stdin.buffer.readline

def f(x):
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1
    return cnt

n, m = map(int, input().split())
a = list(set([int(i) // 2 for i in input().split()]))

b = f(a[0])
for i in a:
    if f(i) != b:
        print(0)
        exit()

l = 1
for i in a:
    l = l * i // gcd(l, i)

print((m // l + 1) // 2)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 066_arc_a / Link: https://arc066.contest.atcoder.jp/tasks/arc066_a?lang=en ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(N);
	int ok = 1;
	ans = 1;
	if (N % 2 == 1) {
		FOR(i, 0, N) { // even only
			int v; cin >> v;
			if (v % 2 == 1)ok = 0;
			a[v]++;
			if (a[0] > 1)ok = 0;
		}
		FOR(i, 0, N/2) {
			ans *= 2;
			ans %= MOD;
		}
	}
	else {
		FOR(i, 0, N) { // odd only
			int v; cin >> v;
			if (v % 2 == 0)ok = 0;
			a[v]++;
		}
		FOR(i, 0, N/2) {
			ans *= 2;
			ans %= MOD;
		}
	}

	if (ok == 0)ans = 0;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, m = MI()
    A = LI()

    s = sum(A)
    print(max(n - s, -1))


if __name__ == '__main__':
    solve()


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int num1 = stoi(S.substr(0, 2)), num2 = stoi(S.substr(2, 2));
    bool is_yymm = false, is_mmyy = false;
    if (num1 <= 12 && num1 > 0) is_mmyy = true;
    if (num2 <= 12 && num2 > 0) is_yymm = true;
    if (is_mmyy && !is_yymm) cout << "MMYY" << endl;
    else if (!is_mmyy && is_yymm) cout << "YYMM" << endl;
    else if (is_mmyy && is_yymm) cout << "AMBIGUOUS" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> H >> W;
  vs s(H);
  rep(i,H) cin >> s[i];
  vector<vector<pii>> hw(H,vector<pii>(W,pii(0,0)));

  rep(i,H){
    int cnt = 0;
    vi chk;
    rep(j,W){
      if(s[i][j]=='.'){
        cnt++;
        chk.push_back(j);
      }
      if(s[i][j]=='#' || j== W-1){
        if(cnt == 0) continue;
        rep(k,chk.size()){
          hw[i][chk[k]].second = cnt;
        }
        chk.clear();
        cnt = 0;
      }
    }
  }
  
  rep(i,W){
    int cnt = 0;
    vi chk;
    rep(j,H){
      if(s[j][i]=='.'){
        cnt++;
        chk.push_back(j);
      }
      if(s[j][i]=='#' || j== H-1){
        if(cnt == 0) continue;
        rep(k,chk.size()){
          hw[chk[k]][i].first = cnt;
        }
        chk.clear();
        cnt = 0;
      }
    }
  }
  int ans = 0;
  rep(i,H){
    rep(j,W){
      ans = max(ans, hw[i][j].first + hw[i][j].second);
    }
  }
    
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 73424
var debug = false;

//for(var i =0;i<;i++)

var dx = [-1, 1, 0, 0];
var dy = [0, 0, -1, 1];

function Main(input) {
    var isKaibun = (str) => {
        if(debug) console.log(str)
        var l = str.length;
        var len = 0;
        if (l % 2 === 0) len = l / 2;
        else len = (l - 1) / 2;
        var res = true;
        for (var i = 0; i < len; i++) {
            if (debug)
                console.log("i:" + str.charAt(i) + ", j:"+ str.charAt(l - i - 1));
            if (str.charAt(i) !== str.charAt(l - i - 1)) res = false;
        }
        return res;
    };

    var str = input.split("\n")[0];
    var len = str.length;
    var l = (len - 1) / 2;


    if (isKaibun(str) && isKaibun(str.slice(0,l)) && isKaibun(str.slice(len - l)))
        console.log("Yes")
    else
        console.log("No")
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
if (!debug)
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
else
    Main(require("fs").readFileSync("./input", "utf8"));

Measured memory_bytes: 7372
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
c = 1
count = 0
for i in a:
    if i == c:
        count += 1
    else:
        print(count)
        if i-c-1 > 0:
            for _ in range(i-c-1):
                print(0)
        c = i
        count = 1
print(count)
for _ in range(n-a[-1]):
    print(0)

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

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int count = 0;

    for (int i = 0; i < N; i++) {
        while (A[i]%2 == 0) {
            A[i] /= 2;
            count ++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
n, k = map(int, input().split())
ans = k
if n >= 2:
    ans = k * (k - 1) ** (n - 1)
print(ans)

Measured memory_bytes: 5056
#include<stdio.h>

int main(){
  long long N,K,a,b,i=0,s[100005]={0},sum=0;
  scanf("%lld %lld",&N,&K);
  for(i=0;i<N;++i){
    scanf("%lld %lld",&a,&b);
    s[a]+=b;
  }

  i=0;
  while(++i){
    sum+=s[i];
    if(sum>=K){
      printf("%lld\n",i);
      return 0;
    }
  }

}


Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var pi = Sarray();
            var rui = new long[N + 1];
            for (var i = 0; i < N; ++i)
                rui[i + 1] = rui[i] + pi[i] + 1;
            var max = 0L;
            for(var i=K;i<=N;++i)
                max = Max(max, rui[i] - rui[i - K]);
            WriteLine((double)max / 2.0);

            //Out.Flush();
        }
    }
}

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

int main() {
  
  int x; cin >> x;
  int c = 0;
  for(int i=0; i<x; i++){
    
    int p; cin >> p;
    
    while(p%2==0 && p != 0){
      p /= 2;
      c++;
    }
    
  }
  
  cout << c << endl;
  

}

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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

int main() {
    boost();
    ll n;
    ll cnt = 0;
    cin>>n;
    for (int i=1;i<=n;i++) {
        if ((to_string(i).length()%2)==1) cnt++;
    }
        cout <<cnt<<endl;
}


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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int t=1;
//    scan(t);
    while(t--){
        int n;cin>>n;
        map<int,int> mp;
        int sum=0;
        for(int i=0;i<n;i++){
            int x;cin>>x;
            sum+=x;
            mp[x]++;
        }
        int q;cin>>q;
        while(q--){
            int a,b;cin>>a>>b;
            int x=mp[a];
            sum-=(x*a);
            mp[a]=0;
            mp[b]+=x;
            sum+=(x*b);
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 9436
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = ll(1e9) + 7;

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}


const int MAXN = 25100;

int n, k, m;
int a[MAXN];

ll dp[410][MAXN];
ll dp2[410][MAXN];


ll add(ll a, ll b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
	return a;
}

map<int, int> mm;

int pr[MAXN];
int nx[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k >> m;
	for (int i = 0; i < m; ++i)
		cin >> a[i], --a[i];
	for (int i = 1; i < k; ++i)
		dp[i][0] = 1;
	for (int i = 1; i <= n; ++i) {
		ll sum = 0;
		for (int j = 1; j < k; ++j) {
			sum = add(sum, dp[j][i - 1]);
			dp[j][i] = (k - j) * dp[j + 1][i - 1] % MOD;
			dp[j][i] = add(dp[j][i], sum);
		}
	}
	for (int i = 0; i <= n; ++i) {
		ll sum = 0;
		for (int j = 1; j < k; ++j) {
			sum = add(sum, dp[j][i]);
			dp2[j][i] = sum;
		}
	}
	mm.clear();
	for (int i = 0; i < m; ++i) {
		if (mm.count(a[i])) {
			pr[i] = mm[a[i]];
		}
		else {
			pr[i] = -1;
		}
		mm[a[i]] = i;
	}
	mm.clear();
	for (int i = m - 1; i >= 0; --i) {
		if (mm.count(a[i])) {
			nx[i] = mm[a[i]];
		}
		else {
			nx[i] = m;
		}
		mm[a[i]] = i;
	}
	int cur = -1;
	int fl = 0;
	for (int i = 0; i < m; ++i) {
		cur = max(cur, pr[i]);
		if (i - cur >= k) {
			fl = 1;
			break;
		}
	}
	ll all = (n - m + 1) * pw(k, n - m) % MOD;
	if (fl) {
		cout << all << "\n";
		return 0;
	}
	fl = 0;
	int sl = 0;
	int sr = 0;
	while (sl < m && pr[sl] == -1)
		++sl;
	while (sr < m && nx[m - 1 - sr] == m)
		++sr;
	if (sl == m) {
		ll ans = 0;
		ll mul = 1;
		for (int len = m; len < k && len < n; ++len) {
			if (len > m)
				mul = (mul * (k - (len - 1))) % MOD;
			for (int sh = 0; sh + len + 1 <= n; ++sh) {
				int r = n - sh - len - 1;
				ans = (ans + mul * dp[len][sh] % MOD * dp2[len][r]) % MOD;
			}
		}
		mul = 1;
		for (int len = m; len < k && len <= n; ++len) {
			if (len > m)
				mul = (mul * (k - (len - 1))) % MOD;
			ans = (ans + mul * dp[len][n - len]) % MOD;
		}
		cout << (all - ans + MOD) % MOD;
	}
	else {
		ll ans = 0;
		for (int i = 0; i <= n - m; ++i)
			ans = add(ans, dp[sl][i] * dp[sr][n - m - i] % MOD);
		cout << (all - ans + MOD) % MOD << "\n";
	}
	return 0;
}




Measured memory_bytes: 159872
#include<stdio.h>
int main()
{
    int num[10]={0};
    int n,a,i,h,j=0,k=0,y;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a);
        if(a>=1 && a<=399)
        {
            num[1]++;
        }
        else if(a>=400 && a<=799)
        {
            num[2]++;
        }
        else if(a>=800 && a<=1199)
        {
            num[3]++;
        }
        else if(a>=1200 && a<=1599)
        {
            num[4]++;
        }
        else if(a>=1600 && a<=1999)
        {
            num[5]++;
        }
        else if(a>=2000 && a<=2399)
        {
            num[6]++;
        }
        else if(a>=2400 && a<=2799)
        {
            num[7]++;
        }
        else if(a>=2800 && a<=3199)
        {
            num[8]++;
        }
        else
        {
            j++;
        }
    }
    for(i=1; i<=8; i++)
    {
        if(num[i]>0)
        {
            k++;
        }
    }
    int x=8-k;
    if(n==1)printf("1 1\n");
    else if(k==0)
    {
        printf("%d %d\n",1,j);

    }
    else if(j==0)
    {

        printf("%d %d\n",k,k);
    }
    else
    {
          printf("%d %d\n",k,k+j);

    }



    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll T[2], A[2], B[2];
int main()
{
	cin>>T[0]>>T[1]>>A[0]>>A[1]>>B[0]>>B[1];
	if(T[0]*A[0]+T[1]*A[1] == T[0]*B[0]+T[1]*B[1]) return cout<<"infinity\n", 0; 
	if(A[0] > B[0]) swap(A[0], B[0]), swap(A[1], B[1]);
	if(A[0]==B[0]) {
		return cout<<"infinity\n", 0; 
	}
	if(T[0]*B[0]+T[1]*B[1] > T[0]*A[0]+T[1]*A[1]) return cout<<0, 0;
	ll diff=(T[0]*A[0]+T[1]*A[1])-(T[0]*B[0]+T[1]*B[1]);
	// cerr<<diff<<'\n';
	cout<<(ll)ceill(((B[0]-A[0])*T[0]+1)/(ld)diff)*2-1-(((B[0]-A[0])*T[0])%diff==0?1:0)<<'\n';
}


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

int main() {
	int K,S,count=0,x,y,z;
	cin>>K>>S;

	REP(x,K){
		REP(y,K){
			if(0<=S-x-y&&S-x-y<=K){
				count++;
			}
			else if(x+y>S) break;
		}
	}
	
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    ll a,b,c;
    cin>>a>>b>>c;
    set<ll> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
    cout<<"Yes";
    else
    cout<<"No";
}

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

int main() {
    int n, k;
    cin >> n >> k;
    k--;
    vector<int> a(n);
    for (int i=0; i<n; ++i) cin >> a[i];
    n--;
    int ans = (n+k-1)/k;
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char *argv[])
{
    string s;
    cin >> s;
    int ans = 0;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let x = read::<u32>();
    println!("{}", x * x * x);
}



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

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K-1];
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double high,low,tmp;
	
	scanf("%lf",&tmp);
	high=tmp;
	low=tmp;
	
	while( scanf(" %lf ",&tmp) != EOF ){
		if(tmp > high) high = tmp;
		if(tmp < low) low = tmp;
	}
	printf("%lf\n",high-low);
	
	return 0;
}

Measured memory_bytes: 652
def atcodeer_and_rock_paper(s: str) -> int:
    score = 0
    for i, c in enumerate(s):
        if i % 2 == 0 and c == 'p':
            score -= 1
        elif i % 2 == 1 and c == 'g':
            score += 1
    return score


if __name__ == "__main__":
    s = input()
    ans = atcodeer_and_rock_paper(s)
    print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int a[100001];
bool cmp(int a,int b)
{
	return a>b; 
}

int main()
{
	int n,s;
	cin>>n>>s;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+2+n,cmp);
	int cnt=0;
	for(int i=1;i<=s;i++)
		cnt+=a[i];
	cout<<cnt<<endl;
    return 0;
}

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

int main(){
  int d,n,ans=0;
  cin>>d>>n;
  if(d==0){
    ans=(n==100?101:n);
  }
  else if(d==1){
    ans=(n==100?100*(n+1):100*n);
  }
  else if(d==2){
    ans=(n==100?10000*(n+1):10000*n);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int N, L;

bool comp(const string& lh, const string& rh) {
	int i=0;
	while(lh[i]==rh[i] && i<L) i++;
    return (int)lh[i] - rh[i] < 0;
}

int main(){
	cin >> N >> L;
	string *str = new string[N];
	REP(i, N){
		cin >> str[i];
	}
	std::sort(str, str+N, comp);
	REP(i, N){
		cout << str[i] << flush;
	}
	cout << '\n';

	delete[] str;
	return 0;
}


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

using namespace std;

int main() {
	
	char str;
	cin >> str;

	if (str == 'A') { cout << 'T' << endl; }
	if (str == 'T') { cout << 'A' << endl; }
	if (str == 'G') { cout << 'C' << endl; }
	if (str == 'C') { cout << 'G' << endl; }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main() {
    int k;
    string s;
    cin >> k >> s;
    int size_s = s.size();
    if(size_s > k){
        rep(i,k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    else cout << s << endl;
}


Measured memory_bytes: 3636
I=input()
s=I.split()
A=int(s[0])
B=int(s[1])

M=(A+B)/2.0

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

if(is_integer_num(M)):
    print(int(M))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 3060
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int A[] = new int[N];
		final int B[] = new int[N];
		final int C[] = new int[N-1];

		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N-1;i++) {
			C[i] = sc.nextInt();
		}
		int score = B[A[0]-1];
		for(int i=1;i<N;i++) {
			score += B[A[i]-1];
			if(A[i-1]+1 == A[i]) {
				score += C[A[i-1]-1];
			}
		}

		out.println(score);
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

constexpr int MOD = 1e9+7;

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    ll ans = 1;
    For(i, n) ans = ans*(i+1) % MOD;
    Cout(ans);
    
}


Measured memory_bytes: 256
import heapq
n = int(input())
a = [int(input()) for i in range(n)]
maxa = max(a)
ma2 = heapq.nlargest(2, a)[1]
ca = a.count(maxa)
if ca >= 2:
    for i in range(n):
        print(maxa)
else:
    for i in range(n):
        if a[i] == maxa:
            print(ma2)
        else:
            print(maxa)

Measured memory_bytes: 16920
// Last Change: 06/20/2019 19:42:47.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  ll a, b;
  vector<ll> ipt(N + 3, 0);
  for (ll i = 0; i < N; ++i) {
    cin >> a >> b;
    ++ipt[min(a, N + 2)];
    --ipt[min(b + 1, N + 2)];
  }

  ll tmp = 1;
  ll ans = 1;
  for (ll i = 2; i < N + 2; ++i) {
    tmp += ipt[i];
    if (tmp >= i) {
      ans = max(ans, i);
    }
  }

  cout << ans - 1 << endl;

  //NS::LoopUntilZeroInpput();
}



Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1; 
  if (cross(b,c) < -EPS) return -1;
  if (dot(b,c)   < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;  
  return 0; 
}
P crosspointLL(P a1, P a2, P b1, P b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;
  if (EQ(d2, 0)) throw "kouten ga nai";
  return a1 + d1/d2 * (a2-a1);
}
VP convexCut(const VP& ps, P a1, P a2) {
  int n = ps.size();
  VP ret;
  rep(i,n) {
    int ccwc = ccw(a1, a2, ps[i]);
    if (ccwc != -1) ret.push_back(ps[i]);
    int ccwn = ccw(a1, a2, ps[(i + 1) % n]);
    if (ccwc * ccwn == -1) ret.push_back(crosspointLL(a1, a2, ps[i], ps[(i + 1) % n]));
  }
  return ret;
}
D area(const VP& ps) {
  D a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}
VP voronoiCell(P p, const VP& ps, const VP& outer) {
  VP cl = outer;
  rep (i, ps.size()) {
    if (abs(ps[i]-p)<EPS) continue;
    P h = (p+ps[i])*0.5;
    cl = convexCut(cl, h, h + (ps[i]-h)*P(0,1) );
  }
  return cl;
}
int n,m;
VP v1,v2;
double x,y;
int main(){
  while(cin>>n>>m,n){
    v1.clear();
    v2.clear();
    rep(i,n){
      cin>>x>>y;
      v1.push_back(P(x,y));
    }
    rep(i,m){
      cin>>x>>y;
      v2.push_back(P(x,y));
    }
    rep(i,m){
      VP t=voronoiCell(v2[i],v2,v1);
      printf("%.10f\n",area(t));
    }
  }
}

Measured memory_bytes: 3072
def e():
    import numpy as np

    N, W = map(int, input().split())

    dp = np.zeros(W+1, dtype=np.int64)

    for _ in range(N):
        w, v = map(int, input().split())
        np.maximum(dp[:-w]+v, dp[w:], out=dp[w:])

    print(dp[-1])


##########
if __name__ == "__main__":
    e()


Measured memory_bytes: 14580
#include <bits/stdc++.h>
#define PI 3.14159265359
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;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string S;
  cin >> S;

  int res = 0;
  int cur = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      ++cur;
    } else {
      chmax(res, cur);
      cur = 0;
    }
  }

  chmax(res, cur);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
const ll MOD = 1e9+7;
ll gcd(ll a,ll b){
    while(b!=0){
        a %= b;
        if(a==0) return b;
        b %= a;
    }
    return a;
}
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    int g;
    int ma=0;
    rep(i,n){
        int a; cin >> a;
        chmax(ma,a);
        if(i==0)g=a;
        else g=gcd(g,a);
    }
    if(k%g==0&&k<=ma)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}



Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int i, j, k;
		int n = sc.nextInt();
		int a[] = new int[n];
		int count = 0;
		
		for(i = 0; i < n; i++){
			a[i] = sc.nextInt();
			if(prime(a[i]) == 1) count++;
		}
		System.out.println(count);
		
		
	}
	
	public static int prime(int x){
		if(x == 2) return 1;
		if(x <= 1 || x % 2 == 0) return 0;
		int i = 3;
		
		while( i <= Math.sqrt(x)){
			if(x % i == 0) return 0;
			i = i + 2;
		}
		return 1;
	}
}


Measured memory_bytes: 41564
values = gets.split
stack = []
values.each do |v|
  if v =~ /^[0-9]+$/
    stack << v.to_i
    next
  end

  v1 = stack.pop
  v2 = stack.pop
  stack << eval("#{v2} #{v} #{v1}") if ['+', '-', '*', '/'].include?(v)
end

puts stack.pop

Measured memory_bytes: 8664
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		String s = sc.next();
		char cbefore = s.charAt(0);
		for(int i = 1;i < s.length();i ++) {
			char c = s.charAt(i);
			if(cbefore == c) {
				System.out.println("Bad");
				return;
			}
			cbefore = c;
		}
		System.out.println("Good");
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

}

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

using namespace std;

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

  int n, m;
  long long x, y;
  cin >> n >> m;

  vector<pair<long long, long long>> stud(n);
  vector<pair<long long, long long>> check(m);
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    stud[i] = {x, y};
  }
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    check[i] = {x, y};
  }
  for (int i = 0; i < n; ++i) {
    long long res = 1e18;
    long long ans = 0;
    for (int j = 0; j < m; ++j) {
      long long dist = llabs(check[j].first - stud[i].first)+
        llabs(check[j].second - stud[i].second);
      if (dist < res) {
        res = dist;
        ans = j;
      }
    }
    cout << ans+1 << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#include<queue>
#define INF 1000000009;
#define inl long long
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	int N = 0, M = 0;
	cin >> N >> M;
	vector <int>ac[100005];
	priority_queue<int, vector<int>> pq;
	inl summ = 0;
	int mem = 0, cop = 0;
	cop = M;
	for (int i = 0; i < N; i++) {
		int a = 0, b = 0;
		cin >> a >> b;
		if (a <= M) {
			ac[a].push_back(b);

			mem = max(mem, b);
		}
	}
	for (int i = M - 1; i >= 0; i--) {
		while (ac[M-i].size()) {
			pq.push(ac[M -i][0]);
			ac[M - i].erase(ac[M-i].begin());
		}
      if(pq.size()){
		summ += pq.top();
		pq.pop();
      }
	}
	cout << summ << endl;
	return 0;
}






Measured memory_bytes: 5632