akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;
    int count;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
        count = n;
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;
        --count;

        return true;
    }
};



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

    int N, M, K; cin >> N >> M >> K;
    vector<int> friends(N, 0);
    vector<int> ans(N, 0);

    UnionFind uni(N);
    rep(i, M) {
        int a, b; cin >> a >> b; --a; --b;
        uni.connect(a, b);
        friends[a]++; friends[b]++;
    }

    rep(i, N) ans[i] = uni.size(i) - friends[i];
    
    rep(i, K) {
        int a, b; cin >> a >> b; --a; --b;
        if(uni.root(a) != uni.root(b)) continue;
        ans[a]--; ans[b]--;
    }
    
    for(int i=0; i<N; ++i) {
        if(i) cout << " ";
        cout << ans[i]-1;
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin >> n>>m;

    char  a[50][50],b[50][50];

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    int flag,i,j;
    for(i=0;i<=n-m;i++){
        for(j=0;j<=n-m;j++){
            flag = 0;
            for(int l=0;l<m;l++){
                for(int k=0;k<m;k++){
                    if(a[i+l][j+k] != b[l][k]){
                        flag = 1;
                        break;
                    }
                }
                if(flag)
                    break;
            }
            if(!flag){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

const int N = 305, mod = 1e9 + 7, inv2 = 500000004;
typedef long long ll;
ll n, d[N], f[N][N][2], fac[N], inv[N], ans, ff = 1;

void upd(ll &x, ll y) { x = (x + y) % mod; }

void init() {
    fac[0] = inv[0] = inv[1] = 1;
    rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
    rep(i, 2, n) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    rep(i, 2, n) inv[i] = inv[i] * inv[i - 1] % mod;
}

int main() {
    cin >> n;
    init();
    rep(i, 1, n) cin >> d[i], ff &= (d[i] == 2);
    if (ff) return printf("%lld\n", fac[n - 1] * inv2 % mod), 0;
    f[0][0][0] = 1;
    rep(i, 1, n) {
        rep(j, 0, i) {
            rep(k, 0, 1) {
                upd(f[i][j][k], f[i - 1][j][k] * inv[d[i] - 1] % mod);
                if (j && d[i] > 1)
                    upd(f[i][j][k], f[i - 1][j - 1][k] * inv[d[i] - 2] % mod);
                if (j && d[i] > 2 && k)
                    upd(f[i][j][1], f[i - 1][j - 1][0] * inv[d[i] - 3] % mod);
            }
        }
    }
    rep(i, 3, n - 1) upd(ans, f[n][i][1] * fac[n - i - 1] % mod * fac[i - 1] % mod * inv2 % mod);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 5116
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 220220;

string st;
int ans;

int eval(char a, char b)
{
	if (a == b)
		return 0;
	if (a == 'p')
		return -1;
	return 1;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		if (i % 2 == 0)
			ans += eval(st[i], 'g');
		else
			ans += eval(st[i], 'p');
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)



int main() {
    int h, w;
    cin >> h >> w;
    char buf[256];
    string snuke = "snuke";
    REP(j, h) REP(i , w) {
        cin >> buf;
        if (snuke == buf) {
            char col = 'A' + i;
            int row = 1 + j;
            cout << col << row << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
/*

T(i, j) 面临 [i, j] 的局面，当前玩家可获得的最大分数
则最终答案 taro 获得分数，T(0, n-1)，jiro 获得分数 
如果 taro 第一步选择 a_0，T(1, n-1) 
如果 taro 第一步选择 a_n-1，T(0, n-2) 

T(i, j) = max{ a_i + T(afterBestChoice(i+1, j)), a_j + T(afterBestChoice(i, j-1)) }

其中，afterBestChoice(i, j) 为处在 [i, j] 局面的人做完最优选择后剩下的局面

边界：
T(i, i) = a_i
bestChoice(i, i) = i
afterBestChoice(i, i) = i+1, i

*/

package main

import "fmt"

const N = 3005
var a [N]int
var T [N][N]int
var best [N][N]int

func afterBestChoice(i, j int) int {
  pick := best[i][j]
  if pick == i {
    return T[i+1][j]
  } else {
    return T[i][j-1]
  }
}

func umax(current *int, val int, i, j, choice int) {
  if val > *current {
    *current = val
    best[i][j] = choice
  }
}

func main() {
  var n int
  fmt.Scanf("%d", &n)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &a[i])
  }
  for i := 0; i < n; i++ {
    for j := i; j < n; j++ {
      T[i][j] = 0
    }
  }
  for i := 0; i < n; i++ {
    T[i][i] = a[i]
    best[i][i] = i
  }
  for i := n-1; i >= 0; i-- {
    for j := i+1 ; j < n; j++ {
      v := &T[i][j]
      umax(v, a[i] + afterBestChoice(i+1, j), i, j, i)
      umax(v, a[j] + afterBestChoice(i, j-1), i, j, j)
    }
  }
  X, Y := T[0][n-1], afterBestChoice(0, n-1)
  fmt.Println(X-Y)
}


Measured memory_bytes: 94416
# -*- coding: utf-8 -*-
import traceback


def main():
    def _check(y,x,h,w,_list,count):
        if x >= 0 and y >= 0 and x < w and y < h:
            if _list[y][x] == '#':
                count += 1

        return count


    h,w = map(int,raw_input().split())
    S = [list(raw_input()) for i in range(h)]
    ans = S

    for i,line in enumerate(S):
        for j,val in enumerate(line):
            count = 0
            if val == '.':
                count = _check(i-1,j-1,h,w,S,count)
                count = _check(i-1,j,h,w,S,count)
                count = _check(i-1,j+1,h,w,S,count)
                count = _check(i,j-1,h,w,S,count)
                count = _check(i,j,h,w,S,count)
                count = _check(i,j+1,h,w,S,count)
                count = _check(i+1,j-1,h,w,S,count)
                count = _check(i+1,j,h,w,S,count)
                count = _check(i+1,j+1,h,w,S,count)

                ans[i][j] = str(count)

    for line in ans:
        print ''.join(line)

main()


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

int main() {
    string s,ans = "",anss = "";
    cin >> s;
    int N = s.size();
    for(int i=0;i<N;i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(ans == "") continue;
        else {
            for(int j=0;j<ans.size()-1;j++){
                anss += ans.at(j);
            }
            ans = anss;
            anss = "";
        }
    }

    cout << ans << endl;
 }

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

int main(){

    int h,n;
    int a;

    cin>>h;
    cin>>n;


   for(int i=0; i<n; i++){
    cin>>a;
    h=h-a;
   }
if(h>0)
    cout<<"No";
else
    cout<<"Yes";
    return 0;


}


Measured memory_bytes: 3568
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, c, i, count=0;
    scanf("%d %d %d", &a, &b, &c);
    for(i = a; i<=b; i++){
        if(c%i == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>) {
    var s = readLine()!!

    val list = listOf("dream", "dreamer", "erase", "eraser")

    while (s.isNotEmpty()) {
        var found = false
        for (word in list) {
            if (s.endsWith(word)) {
                s = s.take(s.length - word.length)
                found = true
            }
        }
        if (!found) {
            println("NO")
            return
        }
        found = false
    }

    println("YES")
}

Measured memory_bytes: 119760
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxnn=2e5+7;
const ll mod=4294967296;
const int inf=1e9+7;
ll a[maxnn];
ll b[maxnn];
ll sg[maxnn];
ll xg[maxnn];
priority_queue<pair<ll,ll>> que;
int main()
{
    ll n;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&b[i]);
        que.push(make_pair(b[i],i));
        xg[i]=i+1ll;
        sg[i]=i-1ll;
    }
    sg[1]=n;
    xg[n]=1;
    ll flag=0ll;
    ll cnt=0ll;
    while(!que.empty())
    {
        int x=que.top().second;
        que.pop();
        if(b[x]==a[x])
            continue;
        int y=sg[x];
        int z=xg[x];
        if(b[x]-b[y]-b[z]<a[x])
        {
            printf("-1\n");
            return 0;
        }
        int k=b[x]-a[x];
        int temp=k/(b[y]+b[z]);
        b[x]=(k%(b[y]+b[z]))+a[x];
        cnt+=temp;
        if(b[x]!=a[x])
           que.push(make_pair(b[x],x));

    }
    printf("%lld\n",cnt);
    return 0;
}



Measured memory_bytes: 12144
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

const ll mod = 1e9 + 7;

void solve() {
	ll n, i, j, k, ii, jj, kk, ans=0;
	string s;
	cin>>n>>s;
	fo(ii,10) {
		fo(jj,10) {
			fo(kk,10) {
				ll find = 0;
				fo(i,n) {
					if(find==0 and s[i]-48==ii)find=1;
					else if(find==1 and s[i]-48==jj)find=2;
					else if(find==2 and s[i]-48==kk)find=3;
				}
				if(find==3)ans++;
			}
		}
	}
	cout<<ans<<endl;
}

int main()
{
    fastIO;ll t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 384
#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;

void solve_case()
{
    int x,y,i,j;
    cin >> x >> y;
    for(i=0; i<102; i++)
    {
        for(j=0; j<102; j++)
        {
            if(2*i + 4*j==y && i+j==x)
            {
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int T = 1;
    //cin >> T;
    while(T--)
    {
        solve_case();
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
# ifdef DEB
# define debug(...) fprintf(stderr, __VA_ARGS__)
# else
# define debug(...)
#endif
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define pb pop_back
#define VI vector<int> 
#define VPI vector<PII> 
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define ALL(x) (x).begin(), (x).end()
#define siz(V) ((int)V.size())
const int M =100005;

int n, T[M];
LL res;
LL dp[M][2], P[M];

int main()
{
  //ios_base::sync_with_stdio(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", T + i);
    P[i] = T[i];
    if (i > 0)
    {
      P[i] += P[i - 1];
    }
  }
  LL r = 0, added = 0;
  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0)
    {
      if (P[i] + added <= 0)
      {
        r += -(P[i] + added) + 1;
        added += -(P[i] + added) + 1;
      }
    }
    else
    {
      if (P[i] + added >= 0)
      {
        r += P[i] + added + 1;
        added -= P[i] + added + 1;
      }
    }
  }
  res = r;
  r = 0;
  added = 0;
  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 1)
    {
      if (P[i] + added <= 0)
      {
        r += -(P[i] + added) + 1;
        added += -(P[i] + added) + 1;
      }
    }
    else
    {
      if (P[i] + added >= 0)
      {
        r += P[i] + added + 1;
        added -= P[i] + added + 1;
      }
    }
  }
  res = min(res, r);
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
long long INF=99999999999;

long long n,k[200005],l[200005],sum,mon=INF;
int main(){
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i]>>l[i];
    sum+=k[i];
    if(k[i]>l[i]){mon=min(mon,l[i]);}
  }
  if(mon==INF){
    cout<<0<<endl;
    return 0;
  }
  cout<<sum-mon<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int N, M, R;
lli a, b, c;

int main() {
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++)cin >> r[i];
	lli wf[210][210];
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++)wf[i][j] = 1e15;
		wf[i][i] = 0;
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		wf[a][b] = wf[b][a] = c;
	}
	for (int t = 0; t <= N; t++)
		for (int s = 0; s <= N; s++)
			for (int g = 0; g <= N; g++)
				wf[s][g] = min(wf[s][g], wf[s][t] + wf[t][g]);
	lli ans = inf;
	sort(r.begin(), r.end());
	do {
		lli val = 0;
		for (int i = 1; i < R; i++)val += wf[r[i - 1]][r[i]];
		ans = min(ans, val);
	} while (next_permutation(r.begin(), r.end()));
	cout << ans << endl;
}


Measured memory_bytes: 640
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var c = Array.ConvertAll(line, int.Parse);
        var ans = b.Sum();
        for (int i = 0; i < n - 1; i++)
            if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
def palindrome?(word)
    word = word.to_s
    size = word.length / 2
    return ( word[0..size] == word.reverse[0..size] )
end

hantei = 1
string = gets.chomp

unless palindrome?(string) then
    hantei = 0
end

stringArr = string.chars
wordsize = stringArr.size
mae = stringArr.slice(0..((wordsize - 1)/2)-1 ).join

unless palindrome?(mae) then
    hantei = 0 
end
ato = stringArr.slice(((wordsize + 3)/2)-1 .. -1 ).join
unless palindrome?(ato) then
    hantei = 0 
end

if hantei == 1  
  puts "Yes"
  else
  puts "No"
end

Measured memory_bytes: 1788
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b; cin >> a >> b;
  if (a*b%2==0){cout << "Even";}
  else {cout << "Odd";}

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{

	int cnt = 0;
	string s;
	cin >> s;


	while(1)
	{

		int i;
		int s_s = s.size();
		for (i=0; i<s_s-1; i++) {
			if (s[i] != s[i+1]) {
				s = s.substr(0,i) + s.substr(i+2,s.size());
				cnt+=2;
				break;
			}
		}

		if (s_s == s.size()) {
			break;
		}
		
	}

	cout << cnt << endl;
	
}
	



Measured memory_bytes: 1236
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;


int main() {
    while(true){
        int N,K;
        cin >> N >> K;
        if(N == 0 && K == 0)break;
        vector<int> a(N);
        vector<int> wa(N+1);
        wa.at(0) = 0;
        for(int i = 0; i < N; i++){
            cin >> a.at(i);
            wa.at(i+1) = a.at(i) + wa.at(i);
        }
        int ANS = -INF;
        for(int i = 0; i < N - K +1; i++){
            int ans = wa.at(i+K) - wa.at(i);
            ANS = max(ANS, ans);
        }
        cout << ANS << endl;
    }
    
    
    
    
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define for(i, a, b) for(int i=a; i<b; ++i)

int main(){
	int n; cin>>n;
	int max=0, ans=0;
	for(i, 0, n){
		int m; cin>>m;
		if (m>=max) max=m, ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
ans = [-1] * n

if n == 1:
    if m == 0:
        print(0)
        exit()
    for i in range(m):
        s = sc[i][0]
        c = sc[i][1]
        if ans[s-1] != -1 and ans[s-1] != c:
            print(-1)
            exit()
        else:
            ans[s-1] = c
    print(ans[0])
else:
    if m == 0:
        print('1' + str('0' * (n-1)))
        exit()
    for i in range(m):
        s = sc[i][0]
        c = sc[i][1]
        if ans[s-1] != -1 and ans[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            ans[s-1] = c
    for i in range(n):
        if i == 0 and ans[i] == -1:
            ans[i] = 1
        elif i != 0 and ans[i] == -1:
            ans[i] = 0
    print(''.join(map(str, ans)))


Measured memory_bytes: 3064
N,K = map(int,input().split())

ans = 0
mi = 0
ma = 0
mod = 10**9+7
for i in range(N+2):

    if i >= K:
        ans += ma - mi + 1
        ans %= mod

    mi += i
    ma += N-i
    mi %= mod
    ma %= mod

print (ans)


Measured memory_bytes: 64828
N = int(input())

T = 0 #現在時間
X = 0 #現在位置X
Y = 0 #現在位置Y
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    a = abs(X-x) + abs(Y-y) #次の位置までの距離
    if a <= t-T and ((t-T)-a)%2 == 0:
        T = t
        X = x
        Y = y
    else:
        flag = False

if flag:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
    if (x) cout<<"YES";
    else cout<<"NO";
}
ll gcd (ll a, ll b)
{
    if (b == 0) return a;
    return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
    ll t = a;
    a = b;
    b = t;
}
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
// ----- code here ----- //
void solve()
{
    char a[200001], b[200001];
    cin>>a>>b;
    ll x = strlen(a), c = 0;
    f(i, 0, x)
    if (a[i] - b[i]) c++;
    cout<<c;
}
// ----- code here ----- //

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    // for checking the execution time
    #endif
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
        cout<<endl;
    }
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec";
    #endif
}

Measured memory_bytes: 4028
n = int(input())
possible = [1]
i=1
while i <= 100000:
  i = i*6
  possible+=[i]
i=1
while i <= 100000:
  i = i*9
  possible+=[i]
possible.sort(reverse =1)
ans = 0
table = set([n])
while True:
  if 0 in table:
    print(ans)
    break
  ans+=1
  nexttable = set()
  for num in table:
    for p in possible:
      if num - p >= 0:
        nexttable.add(num-p)
  table =nexttable

Measured memory_bytes: 74956
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    scanf("%lld",&n);
    ll a[n],z=1,x=1;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]%2==0)
            x=x*2;
        z=z*3;
    }
    printf("%lld\n",z-x);
}
 

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

using namespace std;

int n,m;
int p[200010];
int sz[200010];

int fifa(int x)
{
    if(p[x]==x) return x;
    return p[x]=fifa(p[x]);
}

void join(int x,int y)
{
    int px=fifa(x),py=fifa(y);
    if(px!=py)
    {
        p[px]=py;
        sz[py]+=sz[px];
        sz[px]=0;
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) p[i]=i,sz[i]=1;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        join(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,sz[i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 5364
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int N;
	int i,j,k,temp;
	int *data;
	int count=0;
	
	scanf("%d",&N);
	data=(int *)malloc(sizeof(int)*N);
	for(i=0;i<N;i++)scanf("%d",&data[i]);
	
	for(i=0;i<N;i++)
	{
		k=-1;
		int min=data[i];
		for(j=i;j<N;j++)
		{
			if(data[j]<min)
			{
				k=j;
				min=data[j];
			}
		}
		if(k!=-1)
		{
			count++;
			temp=data[k];
			data[k]=data[i];
			data[i]=temp;
		}
	}
	
	for(i=0;i<N-1;i++)printf("%d ",data[i]);
	printf("%d\n",data[N-1]);printf("%d\n",count);
	
	free(data);
	return 0;
}

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

int main() {
	// your code goes here
	int a,b,i;
	bool ans=true;
	char s[15];
	cin >> a >> b >> s;
	for(i=0;i<a;i++) if(s[i]=='-') ans=false;
	if(s[a]!='-') ans=false;
	for(i=a+1;i<=a+b;i++) if(s[i]=='-') ans=false;
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100

bool solve(){
  int n;
  pair<int,int> p[30];
  cin >> n;

  if(n==0) return false;
  
  for(int i=0;i<n;i++){
    int a, b;
    cin >> a >> b;
    p[i] = {b, a};
  }
  
  sort(p, p+n);

  int sum = 0;
  
  for(int i=0;i<n;i++){
    sum += p[i].second;
    if(sum > p[i].first){
      puts("No");
      return true;
    }
  }

  puts("Yes");
  
  return true;
}

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



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  int cnt = 0;
  bool flag[4] = {false};
  rep(i, s.size()) {
    if(s[i] == 'N' && !flag[0]) {
      cnt += 1;
      flag[0] = true;
    }
    if(s[i] == 'S' && !flag[1]) {
      cnt += 2;
      flag[1] = true;
    }
    if(s[i] == 'W' && !flag[2]) {
      cnt += 4;
      flag[2] = true;
    }
    if(s[i] == 'E' && !flag[3]) {
      cnt += 8;
      flag[3] = true;
    }
  }
  if(cnt == 3 || cnt == 12 || cnt == 15) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
WA = [0 for i in range(N+1)]
AC = [0 for i in range(N+1)]
for i in range(M):
  p, q = input().split()
  p = int(p)
  if q == "AC":
    AC[p] = 1
  else:
    if AC[p] == 0:
      WA[p] += 1
ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
print(sum(AC), ans_WA)

Measured memory_bytes: 10528
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a[3][3],b[3][3],n,x,flg,flg2,sum,sum2;
	int i,j,k;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			cin>>a[i][j];
			b[i][j]=0;
		}
	}
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				if(a[j][k]==x){
					b[j][k]=1;
				}
			}
		}
	}
	flg=0;
	sum2=0;
	for(i=0;i<3;i++){
		sum=0;
		for(j=0;j<3;j++){
			sum+=b[i][j];
			if(i==j){
				sum2+=b[i][j];
			}
		}
		if(sum==3)	flg=1;
	}
	if(sum2==3) flg=1;
	for(i=0;i<3;i++){
		sum=0;
		for(j=0;j<3;j++){
			sum+=b[j][i];
		}
		if(sum==3)	flg=1;
	}
	sum=b[1][1]+b[0][2]+b[2][0];
	if(sum==3)	flg=1;
	if(flg==1)	cout<<"Yes"<<endl;
	else		cout<<"No"<<endl;
	return 0;
}
	
	
	
	
	

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

int main() {
	long S;
	cin >> S;
	long X1 = (S + 999999999) / 1000000000, X2 = X1 * 1000000000 - S;
	cout << X1 << " 1 " << X2 << " 1000000000 0 0";
}

Measured memory_bytes: 256
import numpy as np

# 入力
N,M = map(int,input().split())

Check_AC = np.zeros(N)
WA_Counter = np.zeros(N)

for i in range(M):
    pi,Si = input().split()
    pi = int(pi)
    # まだ正解していない問題
    if Check_AC[pi-1] == 0:
        if Si == "AC":
            Check_AC[pi-1] = 1
        else:
            WA_Counter[pi-1] += 1
    
print(str(int(sum(Check_AC))) + " " + str(int(np.dot(Check_AC,WA_Counter))))

Measured memory_bytes: 13908
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    char prev, cur;
    cin >> prev;
    int cnt = 1;
    for (int i = 1; i < n; ++ i) {
        cin >> cur;
        if (cur == prev) continue;
        cnt ++;
        prev = cur;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>

int main() {
  intmax_t X, Y;
  scanf("%jd %jd", &X, &Y);

  intmax_t res=0;
  for (intmax_t i=X; i<=Y; i<<=1)
    ++res;

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


Measured memory_bytes: 128
from itertools import permutations, combinations

n = int(input())
p_array = [int(x) for x in input().split()]
q_array = [int(x) for x in input().split()]
comb = sorted(permutations(p_array, n))
d = {comb[x]: x + 1 for x in range(len(comb))}
print(abs(d[tuple(p_array)]- d[tuple(q_array)]))


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

int main() {
	int H, W;

	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if(i%2 == 0) {
				    if(j%2 == 0) printf("#");
				    else printf(".");
				} else {
				    if(j%2 == 0) printf(".");
				    else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

const int N = 2e5 + 5, M = 1e9 + 7;
int n, f[N], cnt[N], fac[N];
vector<int> g[N];

constexpr long long inv(long long x, long long m) {
  return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x;
}

void dfs1(int u, int p) {
  cnt[u] = 1, f[u] = 1;
  for (auto v: g[u]) {
    if (v == p) continue;
    dfs1(v, u);
    cnt[u] += cnt[v];
    f[u] = 1ll * f[u] * f[v] % M * inv(fac[cnt[v]], M) % M;
  }
  f[u] = 1ll * f[u] * fac[cnt[u] - 1] % M;
}

void dfs2(int u, int p) {
  if (u != p) {
    f[u] = 1ll * f[p] * cnt[u] % M * inv(n - cnt[u], M) % M;
  }  
  for (auto v: g[u]) {
    if (v == p) continue;
    dfs2(v, u);
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % M; 
  dfs1(1, 1);
  dfs2(1, 1);
  for (int i = 1; i <= n; ++i) printf("%d\n", f[i]);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int resxor = 0;
  for (int &i : a) {
    cin >> i;
    resxor ^= i;
  }
  for (int i = 0; i < n; i++) {
    int ans = resxor ^ a[i];
    if (i != n - 1)
      cout << ans << " ";
    else
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol ans=0;
  cin >>n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++){
    cin >>a[i];
    if(i&1){
      if(a[i]&1) ans++;
    }
  }
  cout <<ans<<'\n';
  return(0);
}

Measured memory_bytes: 3608
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--,b--,c--,d--;
    string s;
    cin>>s;
    auto connect=[&](int l,int r){
        for(int i=l;i<r;i++){
            if(s[i]=='#' && s[i+1]=='#') return false;
        }
        return true;
    };

    if(d<c){
        bool isok1=(connect(a,c) && connect(b,d));
        bool isok2=false;
        for(int i=b;i<=d;i++){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') isok2=true;
        }
        cout<<((isok1 && isok2) ? "Yes" : "No")<<endl;
    }
    else{
        cout<<((connect(a,c) && connect(b,d)) ? "Yes" : "No")<<endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc016.contest.atcoder.jp/tasks/agc016_a>
問題文============================================================
 すぬけ君は、次のルールに従い、長さ N の文字列 t を長さ N−1 の文字列 t' へ変えることができます。
 
 各 i (1≤i≤N−1) について、t' の i 文字目は t の i, i+1 文字目のどちらかである。
 
 英小文字のみからなる文字列 s があります。
 すぬけ君の目標は、s に上記の操作を繰り返し行い、s が単一の文字のみからなるようにすることです。
 目標を達成するために必要な操作回数の最小値を求めてください。

=================================================================

解説=============================================================

 最終的な単一文字が実際に何にするかを最初に決めておいて、あとはその文字になるように
 （できるだけその文字が多くなるように）シミュレーションすれば良い
 
================================================================
*/

int ans = INF;
void dfs(string s,int dep,char c){
    string tmp = s;
    tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
    if(tmp.length() == 1){
        ans = min(ans,dep);
        return ;
    }
    for(int i = 0; i < (int)s.length() - 1;i++){
        if(s[i] == c || s[i+1] == c){
            s[i] = c;
        }
    }
    s.pop_back();
    dfs(s,dep+1,c);
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    bool alpha[26] = {false};
    for(auto c:s) alpha[c-'a'] = true;
    for(int i = 0; i < 26;i++){
        if(alpha[i]){
            dfs(s,0,'a'+i);
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=3e3+5;
const ll p=998244353;

ll read()
{
	ll s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(ll x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(ll x,char c='\n')
{
	write(x);
	putchar(c);
}
ll dp[N][N];

int main()
{
	memset(dp,0,sizeof(dp));
	ll a=read(),b=read(),c=read(),d=read();
	dp[a][b]=1;
	for (ll i=a;i<=c;i++)
	for (ll j=b;j<=d;j++)
	if (i>a||j>b) dp[i][j]=((dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%p+p)%p;
	print(dp[c][d]);

	return 0;
}

Measured memory_bytes: 74180
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n, t, ans = 1 << 30;
	bool tle = true;
	cin >> n >> t;
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		if (b <= t) {
			ans = min(ans, a);
			tle = false;
		}
	}
	if (tle) {
		cout << "TLE" << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    long long a, b;
    
    scanf("%lld %lld", &a, &b);
    
    if (a == b) {
        puts("1");
    } else {
        int c, i;
        long long ans;
        
        for (i = 60; i >= 0; i--) {
            if (((a >> i) & 1) != ((b >> i) & 1)) break;
            
            if ((a >> i) & 1) {
                a ^= 1LL << i;
                b ^= 1LL << i;
            }
        }
        
        for (c = i - 1; c >= 0; c--) {
            if ((b >> c) & 1) break;
        }
        
        if (a == 0) {
            ans = 1LL << (i + 1);
        } else if (c == -1) {
            ans = (b - a) * 2 + 1;
        } else if ((1LL << (c + 1)) < a) {
            ans = (1LL << i) - a + (1LL << (c + 1)) + (1LL << i) - a;
        } else {
            ans = (1LL << (i + 1)) - a;
        }
        
        printf("%lld\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
vector<pair<pair<string, ll>, ll>> vp; // <<Si, Pi>, index>
int main() {
    cin>>n;
    REP(i, 0, n){
        string s;
        ll p;
        cin>>s>>p;
        vp.emplace_back(make_pair(make_pair(s, -p), i+1));
    }

    sort(vp.begin(), vp.end());

    REP(i, 0, vp.size()){
        cout<<vp[i].second<<endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    vector<vector<int>> left(h, vector<int>(w, 0)), right(h, vector<int>(w, 0)), up(h, vector<int>(w, 0)), down(h, vector<int>(w, 0));
    for (int i = 0; i < h; i++)
    {
        if (s[i][0] != '#')
            left[i][0] = 1;
        for (int j = 1; j < w; j++)
        {
            if (s[i][j] != '#')
                left[i][j] = left[i][j - 1] + 1;
        }
        if (s[i][w - 1] != '#')
            right[i][w - 1] = 1;
        for (int j = w - 2; j >= 0; j--)
        {
            if (s[i][j] != '#')
                right[i][j] = right[i][j + 1] + 1;
        }
    }
    for (int j = 0; j < w; j++)
    {
        if (s[0][j] != '#')
            up[0][j] = 1;
        for (int i = 1; i < h; i++)
        {
            if (s[i][j] != '#')
                up[i][j] = up[i - 1][j] + 1;
        }
        if (s[0][j] != '#')
            down[h - 1][j] = 1;
        for (int i = h - 2; i >= 0; i--)
        {
            if (s[i][j] != '#')
                down[i][j] = down[i + 1][j] + 1;
        }
    }
    int ret = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
                continue;
            ret = max(ret, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 69376
import sys
sys.setrecursionlimit(10**7)
def input():
	return sys.stdin.buffer.readline()[:-1]

class SCC():
	def __init__(self, adj):
		self.n = len(adj)
		self.adj = adj
		self.post_order = []
		self.visited = [False for _ in range(self.n)]
		self.dag_v_to_num = [-1 for _ in range(self.n)]
		self.dag_num_to_v = []
		self.inv = [[] for _ in range(self.n)]
		for i, l in enumerate(self.adj):
			for j in l:
				self.inv[j].append(i)
		return

	def dfs1(self, i):
		for j in adj[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs1(j)
		self.post_order.append(i)
		return

	def dfs2(self, i, num):
		self.dag_num_to_v[-1].append(i)
		self.dag_v_to_num[i] = num
		for j in self.inv[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs2(j, num)
		return

	def make_scc(self):
		for i in range(self.n):
			if not self.visited[i]:
				self.visited[i] = True
				self.dfs1(i)

		self.visited = [False for _ in range(self.n)]
		num = 0
		for i in range(self.n-1, -1, -1):
			if not self.visited[self.post_order[i]]:
				self.visited[self.post_order[i]] = True
				self.dag_num_to_v.append(list())
				self.dfs2(self.post_order[i], num)
				num += 1

		return self.dag_v_to_num, self.dag_num_to_v

n, m = map(int, input().split())
adj = [set() for _ in range(n)]
for _ in range(m):
	u, v = map(int, input().split())
	if u != v:
		adj[u].add(v)
adj = [list(x) for x in adj]
scc = SCC(adj)
v_to_num, num_to_v = scc.make_scc()
print(len(num_to_v))
for x in num_to_v:
	print(len(x), end=" ")
	print(*x)

Measured memory_bytes: 329856
<?php

fscanf(STDIN,"%d %d %d",$a,$b,$x);
$a_mod_x = $a % $x;
$left = $a;
if($a_mod_x != 0)
{
	$left = $a - $a_mod_x + $x;
}
$right = $b - $b % $x;

$ans = ($right - $left) / $x + 1;

echo $ans, "\n";

Measured memory_bytes: 4728
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int main(){
    ll a, b, v, w, t;
    scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
    ll d = abs(a - b);
    ll dd = (v - w ) * t;
    puts(d <= dd ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 1652
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    seq_min = 1e9
    ans = -1
    for j in range(m):
        seq = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if seq_min > seq:
            seq_min = seq
            ans = j
    print(ans + 1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	bool aa = 0 < a && a <= 12;
	bool bb = 0 < b && b <= 12;
	if (aa && bb) cout << "AMBIGUOUS\n";
	else if (aa) cout << "MMYY\n";
	else if (bb) cout << "YYMM\n";
	else cout << "NA\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    if(k<(1<<n)){ 
        if(n==1 && k){
            printf("-1\n");
            return 0;
        }
        else if(n==1 && !k){
            printf("0 0 1 1\n");
            return 0;
        }
        printf("%d",k);
        for(int i = 0; i < (1<<n); i++){
            if(i!=k) printf(" %d",i);
        }
        printf(" %d",k);
        for(int i = (1<<n)-1; i >= 0; i--){
            if(i!=k) printf(" %d",i);
        }
        printf("\n");
    }
    else printf("-1\n");
  
    return 0;
}

Measured memory_bytes: 1792
import sys
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
result=[]
for i in range(n):
  result.append((Arr[i],i+1))
result.sort()
ans=[]
for i in result:
  ans.append(i[1])
print(*ans)

Measured memory_bytes: 20520
N = int(input())
A = list(map(int, input().split()))

d = [1] * (N+1)
d[0] -= A[0]
for i in range(N):
    d[i+1] = d[i] * 2 - A[i+1]

if d[-1] < 0:
    print(-1)
    exit()
else:
    d[-1] = A[-1]
for i in range(N, 0, -1):
    x = d[i]
    x += A[i-1]
    d[i-1] = min(x, d[i-1]+A[i-1])
print(sum(d))


Measured memory_bytes: 668704
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  vector<int> p(N, 0);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a]++;
    p[b]++;
  }

  int cnt = 0;
  rep(i, N) { cnt += p[i] % 2; }

  cout << (cnt <= 1 ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<ll> x(n);

    for (auto &&i : x)
    {
        cin >> i;
    }

    ll ans = INF;

    for (int i = k - 1; i < n; i++)
    {
        ans = min(ans, x[i] - x[i - k + 1] + min(abs(x[i]), abs(x[i - k + 1])));
    }

    cout << ans << endl;
}


Measured memory_bytes: 4016
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D&lang=jp*/
#include <iostream>
#include <algorithm>

using namespace std;

void insertionSort(int *a,int n,int g,int *cnt){
    for(int i=g;i<n;i++){
        int v=a[i];
        int j=i-g;
        while(-1<j && v<a[j]){
            a[j+g]=a[j];
            j-=g;
            (*cnt)++;
        }
        a[j+g]=v;
    }
}

void shellSort(int *a,int n){
    int cnt=0;
    vector<int> g(1,1);

    while(3*g.back()+1<=n){
        g.push_back(3*g.back()+1);
    }
    reverse(begin(g),end(g));
    cout<<g.size()<<endl;
    vector<int>::iterator it=g.begin();
    cout<<*it;
    it++;
    while(it!=g.end()){
        cout<<" "<<*it;
        it++;
    }
    cout<<endl;
    for(int i:g){
        insertionSort(a,n,i,&cnt);
    }
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<a[i]<<endl;
    }
}

int main(){
    int n;
    int a[1000000];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    shellSort(a,n);
    return 0;
}

Measured memory_bytes: 5116
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);

    for (int a=1; a<=9; a++) {
        for (int b=1; b<=9; b++) {
            if (a*b==n) {
                printf("Yes");
                return 0;
            }
        }
    }

    printf("No");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
 {
	//code
	int d,t,s; cin>>d>>t>>s;
    int y=(float) t;
	float x=(float)d/(float)s;
	//cout<<y<<x<<endl;
	if(y<x) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3644