akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  string str;
  cin>>str;
  int SIZE = str.size();
  SIZE--;
  for (int i = 0; i < str.size(); i++)
  {
    // DEBUG(SIZE);
    if(SIZE %2 == 0){
    int F = SIZE/2;
    string str1 = str.substr(0,F);
    string str2 = str.substr(F,F);
    // DEBUG(str1,str2,"\n");
    if(str1 == str2)
    {
      cout<<SIZE<<endl;
      return;
    }
    }
    SIZE--;
  }
  
  return;
}




int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := map[string]int{}

	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		m[s[:1]]++
	}

	march := []string{"M", "A", "R", "C", "H"}

	ans := 0
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			for k := j + 1; k < 5; k++ {
				ans += m[march[i]] * m[march[j]] * m[march[k]]
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split();

        Console.WriteLine(string.Join("", a[0].Zip(a[1], (x, y) => $"{x}{y}")));
    }
}

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

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

    int ans = 10000;
    for (int i = 0; i + 3 <= s.length(); i++) {
        int k = stoi(s.substr(i, 3));
        ans = min(ans, abs(753 - k));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def crane_and_title(animals: int, foot: int) -> bool:
    if foot % 2:
        return False
    if foot < 2 * animals or 4 * animals < foot:
        return False
    return True


if __name__ == "__main__":
    X, Y = map(int, input().split())
    yes = crane_and_title(X, Y)
    print("Yes" if yes else "No")


Measured memory_bytes: 9164
using System;
using System.Collections.Generic;

class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int sum = 0;

            string[] s = (Console.ReadLine()).Split(' ');
            int[] elm = new int[num];

            for (int i = 0; i < num; i++)
            {
                sum += int.Parse(s[i]);
                elm[i] = int.Parse(s[i]);
            }

            int half = sum / 2;
            int res = sum;
            int tmp = 0;
            for (int i = 0; i < num; i++)
            {
                tmp += elm[i];
                int abs = Math.Abs(sum - tmp - tmp);
                res = Math.Min(res, abs);
                if (tmp > half) break;
            }
            Console.WriteLine(res);
        }
    }

Measured memory_bytes: 11092
import numpy as np
n=int(input())
A=np.array(list(map(int, input().split(" "))))

me=A.mean()
min_diff=99999999999999999999999999999999999
for num,i in enumerate(A):
    diff=abs(me-i)
    if diff<min_diff:
        out=num
        min_diff=diff

print(out)

Measured memory_bytes: 21644
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n, a[N], A, B;

void win()
{
	puts("Hanako");
}
void lose()
{
	puts("Jiro");
}

int main()
{
	scanf("%d%d%d",&n,&A,&B);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	
	int sg = 0, cnt = 0;
	for(int i = 1; i <= n; i++) 
	{
		sg ^= a[i] % (min(A, B) + 1);
		if(a[i] > min(A, B)) cnt++;
	}
	
	if(A == B)
	{
		sg ? win() : lose();
	}
	else if(A > B)
	{
		if(sg) win();
		else if(cnt) win();
		else lose();
	}
	else // A < B
	{
		if(!sg) lose();
		else // win ?
		{
			if(cnt == 0) win();
			else if(cnt > 1) lose();
			else // cnt = 1
			{
				int i = 0; for(i = 1; i <= n; i++) if(a[i] > A) break; // i
				
				int new_ai_sg = (a[i] % (A + 1)) ^ sg;
				
				if(new_ai_sg >= A + 1) lose();
				else
				{
					int fetch = a[i] % (A + 1) - new_ai_sg; 
					while(fetch <= 0) fetch += A + 1;
					if(fetch >= a[i]) lose();
					else if(a[i] - fetch <= A) win();
					else lose();
				}
			}
		}
	}
	
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,l;
  cin >> n >> l;
  int total=0,mi=IINF,val;
  for(int i=0;i<n;i++){
    total+=l+i;
    if(mi>abs(l+i)){
      mi=abs(l+i);
      val=l+i;
    }
  }
  cout << total-val << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 2e5 + 10;

vector<vector<int> > es;
int n, m;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  es = vector<vector<int> >(n + m);
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) {
      int x;
      scanf("%d", &x);
      --x;
      int s = i, t = x + n;
      es[s].pb(t), es[t].pb(s);
    }
  }
  return 1;
}

int used[maxn];

void dfs(int v) {
  used[v] = 1;
  for (int u : es[v]) {
    if (used[u]) {
      continue;
    }
    dfs(u);
  }
}

void solve() {
  for (int i = 0; i < n + m; ++i) {
    used[i] = 0;
  }

  dfs(0);

  if (count(used, used + n, 1) != n) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

using namespace std;

int N, M;
vector<vector<int> > adj;
vector<int> lp;
vector<bool> visited;

void dfs(const int vertex)
{
	for(const auto child : adj[vertex])
	{
		if(not visited[child])
		{
			visited[child] = true;
			dfs(child);
		}
		lp[vertex] = max(lp[vertex], lp[child] + 1);
	}
}

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

	cin >> N >> M;
	adj.resize(N);
	lp.resize(N, 0);
	visited.resize(N, false);

	for(int edge_number = 0; edge_number < M; ++edge_number)
	{
		int u, v;
		cin >> u >> v;
		--u, --v;
		adj[u].emplace_back(v);
	}

	for(int vertex = 0; vertex < N; ++vertex)
	{
		if(not visited[vertex])
		{
			visited[vertex] = true;
			dfs(vertex);
		}
	}

	int result{};
	for(const auto p : lp)
	{
		result = max(result, p);
	}

	cout << result << "\n";

	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;


int tc,n,a[N];

char s[N];

int main(){
    //IO();   
    ll n;
    ll cur = 100;
    int ans = 0;
    scanf("%lld",&n);
    while(cur < n){
        cur += cur / 100;
        ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3828
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int per(int x){
  int res = 1;
  while(x>0){
    res *= x;
    x--;
  }
  return res;
}

int main(){
  int N,cnt,keta;
  cin >> N;
  vector<int> P(N),Q(N);
  rep(i,N)cin >> P[i];
  rep(i,N)cin >> Q[i];
  int p,q;
  p=1;
  q=1;
  vector<int> use(10,0);
  keta = N;
  rep(j,N){
    cnt = 0;
    for(int i = 1;i <= N;i++){
      if(i == P[j]){
        use[i] = 1;
        p += cnt*per(keta-1);
        keta--;
        break;
      }
      if(use[i]==0)cnt++;
    }
  }
  keta = N;
  rep(i,10)use[i] = 0;
  rep(j,N){
    cnt = 0;
    for(int i = 1;i <= N;i++){
      if(i == Q[j]){
        use[i] = 1;
        q += cnt*per(keta-1);
        keta--;
        break;
      }
      if(use[i]==0)cnt++;
    }
  }
  //cout << p << " " << q << endl;
  cout  << abs(p-q) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int count[] = new int[100010];
    Arrays.fill(count, 0);
    for(int i=0; i<N; i++){
      int a = sc.nextInt();
      count[a]++;
    }
    int ans = 0;
    for(int i=0; i<count.length-2; i++){
      int tmp = count[i] + count[i+1] + count[i+2];
      ans = Math.max(ans, tmp);
    }
    out.println(ans);
  }

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

Measured memory_bytes: 51252
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(3 * n);
    rep(i, 3 * n) {
        cin >> A[i];
        A[i]--;
    }

    ll INF = 1e18;
    vector<vector<ll> > dp(n+1, vector<ll>(n+1, -INF));
    vector<ll> ma(n+1, -INF);
    dp[A[0]][A[1]] = 0;
    ma[A[0]] = 0;
    ma[A[1]] = 0;

    ll score = 0;
    rep(i, n-1) {
        sort(A.begin() + 2 + 3 * i, A.begin() + 2 + 3 * i + 3);
        ll x = A[2 + 3 * i];
        ll y = A[2 + 3 * i + 1];
        ll z = A[2 + 3 * i + 2];

        // a, b, x, y, zで並んでいる


        // x==y==z
        if (x == z) {
            score++;
            continue;
        }

        vector<vector<ll> > cand;
        // x,y,zのうち２つだけ等しい場合
        // 左ふたつのうちどちらかがそれら２つと同じであればペアを作る
        if (x == y) {
            rep(p, n) {
                cand.push_back({
                    z,
                    p,
                    // そんなx,pのペアがなければdp[x][p]は-INFになっているから問題ない
                    max(dp[x][p], dp[p][x]) + 1,
                });
            }
        }
        if (z == y) {
            rep(p, n) {
                cand.push_back({
                    x,
                    p,
                    max(dp[z][p], dp[p][z]) + 1,
                });
            }
        }

        // 5つともとくにかぶりがない
        rep(p, n) cand.push_back({ p, x, ma[p] });
        rep(p, n) cand.push_back({ p, y, ma[p] });
        rep(p, n) cand.push_back({ p, z, ma[p] });

        // 左２つがともにxyzのどれかと等しい場合
        // xxxyz, yyxyzみたいなとき
        // そんな場合がなればdp[z][z]は-INFになっているのでこれでよい
        cand.push_back({ x, y, dp[z][z] + 1});
        cand.push_back({ x, z, dp[y][y] + 1});
        cand.push_back({ y, z, dp[x][x] + 1});

        // 右3つのどれかを残す時、とにかく前回で一番成績が良いものを選ぶ
        ll tmp = -1;
        rep(p, n) tmp = max(ma[p], tmp);
        cand.push_back({ x, y, tmp});
        cand.push_back({ x, z, tmp});
        cand.push_back({ y, z, tmp});

        for (auto& c: cand) {
            dp[c[0]][c[1]] = max(dp[c[0]][c[1]], c[2]);
            ma[c[0]] = max(ma[c[0]], c[2]);
            ma[c[1]] = max(ma[c[1]], c[2]);
        }
    }

    ll res = max(0LL, *max_element(all(ma)));
    // dp[A[3 * n - 1]][A[3 * n - 1]] は、最後の3枚が同じになるように選んだ場合の最高成績
    // このときは追加で1点もらえるので特別扱い
    res = max(res, dp[A[3 * n - 1]][A[3 * n - 1]] + 1);
    res += score;

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 35512
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;

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

int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};
string g="5555555555555555";

bool in(int a,int b){
  if(a<0 || b<0 || 4<=a || 4<=b)return false;
  return true;
}

string bfs(string s,int index){
  if(s[index]=='5'){
    s[index]='1';
    return s;
  }
  s[index]++;
  if(s[index]!='5')return s;

  int d[16]={};
  queue<pii> q;
  for(int i=0;i<4;i++)q.push(mp(0,mp(index,i)));

  while(!q.empty()){
    pii u=q.front();
    q.pop();

    int ny=u.s.f/4+Y[u.s.s],nx=u.s.f%4+X[u.s.s];
    if(!in(ny,nx))continue;
    int nindex=ny*4+nx;
    if(d[nindex]==u.f+1 && s[nindex]=='5')continue;
    if(s[nindex]=='5')q.push(mp(u.f+1,mp(nindex,u.s.s)));
    else {
      s[nindex]++;
      d[nindex]=u.f+1;
      if(s[nindex]=='5'){
	for(int i=0;i<4;i++)q.push(mp(u.f+1,mp(nindex,i)));
      }
    }
  }
  return s;
}

int main()
{

  int a;
  string s;

  for(int i=0;i<16;i++){
    cin>>a;
    if(a==0)s+='5';
    else s+=(a+'0');
  }

  map<string,int> m;
  queue<string> q;
  int ans=-1;
  q.push(s);
  m[s]=0;

  while(q.size()){
    string u=q.front();
    q.pop();
    int cost=m[u];

    if(5<cost)break;

    if(u==g){
      ans=cost;
      break;
    }

    for(int i=0;i<16;i++){
      string t=u;
      //if(t[i]=='5')continue;
      t=bfs(t,i);

      if(m.find(t)==m.end()){
	m[t]=cost+1;
	q.push(t);
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 30448
#include <stdio.h>
#define N 100
void Swap(int*x,int*y){
  int temp;
  temp=*x;
  *x=*y;
  *y=temp;
}
int main(){
  int i,j,n,count=0;
  int A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){
	Swap(&A[j],&A[j-1]);
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

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

int main()
{
    /*A
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
    */
    int n;
    double m;
    cin>>n>>m;
    vector <double> a(n);
    double total = 0;
    rep(i,n)
    {
        cin>>a[i];
        total+= a[i];
    }
    
    sort(a.rbegin(),a.rend());
    bool flag = true;
    for(int i=0;i<m;i++)
    {
        if(1/(4*m)>a[i]/total)
        {
            flag = false;
            break;
        }
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long

int main(void){
	int N,id[100005];
	cin >> N;
	vector<int> vals,v;
	for(int i=0;i<N;i++){
		int a;cin >>a;
		vals.push_back(a);
		v.push_back(a);
	}
	sort(ALL(vals));
	for(int i=0;i<N;i++){
		id[i] = lower_bound(ALL(vals),v[i]) - vals.begin();
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		if(i%2==0 && id[i]%2!=0)ans++;
	}
	cout << ans << endl;
}

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

int counter( string* a , int i,int j , int h , int w)
{

    int ans =0;
    if( i-1>=0 && a[i-1][j] =='#')
    {
        ans++;
    }
    if( i+1 <h && a[i+1][j] =='#')
    {
        ans++;
    }
    if( j-1 >=0 && a[i][j-1 ] =='#')
        ans++;
    if( j+1 <w && a[i][j+1 ] =='#')
        ans++;

    if( i-1 >=0 && j-1>=0 && a[i-1][j-1] =='#' )
        ans++;
    if( i-1 >=0 && j+1 < w && a[i-1][j+1] =='#' )
        ans++;
    if( i+1 <h && j-1>=0 && a[i+1][j-1] =='#' )
        ans++;
    if( i+1 <h  && j+1 < w && a[i+1][j+1] =='#' )
        ans++;
    return ans;

}
void printer( string* a , int i , int j , int h , int w)
{
    if( a[i][j] == '#')
    {
        cout<<"#";
    } else
    {
        cout<<counter( a,i,j,h,w);
    }
}

int main()
{
  int h,w;
  cin>>h>>w;
  string *a = new string[h];
  for(int i=0;i<h;i++)
  {
      cin>>a[i];
  }
  for(int i=0;i<h;i++)
  {
      for(int j=0;j<w;j++)
      {
          printer(a,i,j,h,w);
      }
      cout<<endl;
  }
}

Measured memory_bytes: 3640
from collections import deque

N,Q = map(int,input().split())
AB = [tuple(int(i) for i in input().split()) for j in range(N-1)]
PX = [tuple(int(i) for i in input().split()) for j in range(Q)]

graph = [[] for i in range(N+1)]
for a,b in AB: 
    graph[a].append(b)
    graph[b].append(a)

value = [0]*(N+1)
for p,x in PX:
    value[p] += x 

parent = [None]*(N+1)
q = deque([1])
while q:
    i = q.popleft()
    for j in graph[i]:
        if parent[i] == j:
            continue
        else:
            q.append(j)
            value[j] += value[i]
            parent[j] = i

ans = ' '.join(map(str,value[1:]))
print(ans)


# par = [None] * (N+1)
# q = [1]
# while q:
#     x = q.pop()
#     for y in graph[x]:
#         if y == par[x]:
#             continue
#         value[y] += value[x]
#         q.append(y)
#         par[y] = x


Measured memory_bytes: 107912
#include<iostream>

using namespace std;

int main(){
	double ma=-1,mi=-1;
	double x;
	while(cin>>x){
		if(ma==-1 || ma<x)ma=x;
		if(mi==-1 || mi>x)mi=x;
	}
	
	cout<<ma-mi<<endl;
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    for (int &a : as)
        cin >> a;
    cin >> n;
    akari<int> bs(n);
    for (int &b : bs)
        cin >> b;
    cout << includes(as.begin(), as.end(), bs.begin(), bs.end()) << endl;
}

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



Measured memory_bytes: 4368
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		String ans = "War";

		int max = -101;
		int min = 100;

		for(int i = 0; i < N; i++){
			int x = sc.nextInt();
			max = Math.max(max, x);
		}

		for(int j = 0; j < M; j++){
			int y = sc.nextInt();
			min = Math.min(min, y);
		}

		int cnt = min - max;
		int Z = min;
		
		for(int j = 0; j<cnt; j++){
			Z = min - j;
		if(max<Z && min >= Z && X<Z && Y >=Z){
			ans = "No War";
		}
	}

	System.out.println(ans);


	}
}

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

int main(){
    long long n, p;
    cin >> n >> p;

    map<long long, long long> T;
    long long num = p;

    for(long long i = 2; i * i <= num; i++){
        if(num % i != 0) continue;

        while(num % i == 0){
            if(T.find(i) == T.end()){
                T[i] = 1;
                num /= i;
            }
            else{
                T[i]++;
                num /= i;
            }
        }
    }
    if(num != 1) T[num] = 1;

    map<long long, long long>::iterator it;
    long long ans = 1;
    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= n){
            long long m = it->second / n;
            for(long long i = 0; i < m; i++){
                ans *= it->first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <functional>
using namespace std;

string S;

int main() {
	cin >> S; int G = 0; if (S[0] == S[S.size() - 1]) G = 1;
	if ((S.size() + G) % 2 == 0) cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cassert>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

string s;
int K;

int main()
{
  cin >> s >> K;
  int N = s.length();           // |s|

  // sの長さKまでの部分文字列
  vector<string> vec;

  REP(j,1,K+1) {
    REP(i,0,N) {

      string t = s.substr(i,j);
      if (t.length() == j) vec.push_back(t);
      else break;               // iからj文字取れなかった

    }
  }

  sort(vec.begin(), vec.end());
  unique(vec.begin(), vec.end());

  assert(vec.size() >= K);
  cout << vec[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int n,m;
int f[12],cnt[1<<12],p[12];
int main() {
    for(int i=0;i<1<<12;i++) for(int j=0;j<12;j++) if(i>>j&1) cnt[i]++;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int k; scanf("%d",&k);
        for(int j=0;j<k;j++){
            int x; scanf("%d",&x); --x;
            f[i]|=1<<x;
        }
    }
    for(int i=0;i<m;i++) scanf("%d",&p[i]);
    int ans=0;
    for(int i=0;i<1<<n;i++){
        bool ok=1;
        for(int j=0;j<m;j++){
            if(cnt[f[j]&i]%2 != p[j]) ok=0;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(int n,int m,int s){
    int ans=0;
    REP(i,1,s-1)REP(j,1,s-1){
        if(i*(100+n)/100+j*(100+n)/100==s){
            ans=max(ans,i*(100+m)/100+j*(100+m)/100);
        }
    }
    cout<<ans<<endl;
}
int main(){
    int n,m,s;
    while(cin>>n>>m>>s,n!=0)solve(n,m,s);
    return 0;
}


Measured memory_bytes: 3084
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    int cnt = 0;
    int l = 0;
    int r = s.length-1;
    while(l<=r){
      if(s[l]==s[r]){
        l++;
        r--;
      }else if(s[l]=='x'){
        l++;
        cnt++;
      }else if(s[r]=='x'){
        r--;
        cnt++;
      }else{
        cnt = -1;
        break;
      }
    }
    System.out.println(cnt);
  }
}


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

int ng() {
    cout << "No\n";
    return 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> x(n), a(n*n, -1);
    deque<array<int, 4>> v;
    for (int i = 0; i < n; i++) {
        cin >> x[i]; a[--x[i]] = i+1;
        if (i != 0) v.push_back({0, x[i]-1, i, i+1});
        if (i != n-1) v.push_back({x[i]+1, n*n-1, n-i-1, i+1});
    }
    sort(v.begin(), v.end());
    set<array<int, 3>> s;
    for (int i = 0; i < n*n; i++) {
        while (!v.empty() && v[0][0] == i) {
            s.insert({v[0][1], v[0][2], v[0][3]});
            v.pop_front();
        }
        if (a[i] != -1) continue;
        if (s.empty()) return ng();
        auto p = *s.begin();
        s.erase(s.begin());
        if (p[0] < i) return ng();
        a[i] = p[2];
        if (--p[1]) s.emplace(p);
    }
    cout << "Yes\n";
    for (int i = 0; i < n*n; i++) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2176
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//for(int i=0;i<n;i++)cin>>hoge[i];
int n,m;
string str;
vector<pii> hoge;

int main(){
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		//a[i]--;
	}
	sort(all(a));
	a.pb(a[n-1]);
	reverse(all(a));
	a.pb(-1);
	int z;
	for(int i=0;i<a.size();i++){
		if(a[i]>=i)z=i;
	}
	
	z--;
	int u=a[z+1]-z;
	int k=z,r=0;
	while(a[k]>z){
		k++;
		r++;
	}
	//cout<<k<<endl;
	r--;
	//cout<<z<<" "<<r<<" "<<u<<endl;
	u=u%2;
	r=r%2;
	if(u==1&&r==1)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int days(int,int,int);

int main(void){
	int n,y,m,d,c;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> y >> m >> d;

		c=days(y,m,d);
		for(int j=y+1;j<1000;j++)
			c+=(j%3==0?200:195);

		cout << c << endl;
	}
}

int days(int y,int m,int d){
	int day;

	day=(y%3==0?20:(m%2==0?19:20))-d+1;
	for(int i=m+1;i<=10;i++)
		day+=(y%3==0?20:(i%2==0?19:20));

	return day;
}

Measured memory_bytes: 1160
n=int(input())
a=[]
for i in range(n):
    b=[]
    x,y=input().split()
    b.append(x)
    b.append(int(y))
    a.append(b)

x=input()
ans=0
flag=False
for i in a:
    if i[0]==x:
        flag=True
        continue
    if flag==True:
        ans+=i[1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct UnionFind{
  vector<int> par; //親
  vector<int> size; //集合の大きさ

  UnionFind(int n){
    par.resize(n);
    size.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      size[i] = 1;
    }
  }

  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }

  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }
};

const int N = 1e5;

signed main(){

  int n; cin >> n;
  UnionFind uf(N*2);
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    uf.unite(a, b + N);
  }

  vector<int> x(N*2), y(N*2);
  for(int i = 0; i < N; i++){
    x[uf.root(i)]++;
    y[uf.root(i + N)]++;
  }

  int cnt = 0;
  for(int i = 0; i < N*2; i++){
    cnt += x[i] * y[i];
  }
  cout << cnt - n << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

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

    string t;
    cin >> t;

    int count = 0;
    bool last_tile_is_changed = false;

    for (int i = 1; i < t.size(); i++)
    {
        if ((t[i] == t[i - 1]) ^ last_tile_is_changed)
        {
            last_tile_is_changed = true;
            count++;
        }
        else
        {
            last_tile_is_changed = false;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,num)for(int i=0;i<(num);++i)
#define RREP(i,num)for(int i=(num)-1;i>=0;--i)

using namespace std;
int arr[501][501];
int ans[250001][4],cnt;
int H,W;
void move(int i,int j,int i2, int j2){
    bool did=false;
    arr[i2][j2]++;
    arr[i][j]--;
    ans[cnt][0]=i+1;
    ans[cnt][1]=j+1;
    ans[cnt][2]=i2+1;
    ans[cnt][3]=j2+1;
    cnt++;
}
int main() {
    ios::sync_with_stdio(false);
    cin>>H>>W;
    REP(i,H){
        REP(j,W){
            cin>>arr[i][j];
        }
    }
    int v[501][501]={0,};
    REP(i,H){
        REP(j,W){
            if(v[i][j]!=0||arr[i][j]%2==0)continue;
            // v[i][j]=1;
            if(j<W-1)move(i,j,i,j+1);
            else if(i<H-1)move(i,j,i+1,j);
        }
    }
    // for(int i=H-1;i>=0;i--){
    //     for(int j=W-1;j>=0;j--){
    //         if(v[i][j]!=0||arr[i][j]==2)continue;
    //         v[i][j]=1;
    //         if(j>0)move(i,j,i,j-1);
    //         else if(i>0) move(i,j,i-1,j);
    //     }
    // }
    cout<<cnt<<endl;
    REP(i,cnt){
        cout<<ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<" "<<ans[i][3]<<endl;
    }
    // REP(i,H){
    //     REP(j,W){
    //         cout<<arr[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // 0 2 2
    // 0 2 2

    // 0 2 2
    // 0 0 4
// 1 1 1
// 0 0 0
// 3 3 3

    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
using namespace std ;
int main () {
int A , B , K ; cin >> A >> B >> K ;
for ( int i = min (A , B ); i >= 1; --i ) {
if ( A % i == 0 && B % i == 0) {
--K ;
if ( K == 0) {
cout << i << endl ;
return 0;
}
}
}

}

Measured memory_bytes: 256
max = 104730
prime = [2]
list = Array.new(max){|i| i}
list[0] = 0
list[1] = 0
loop do
  a = prime[-1]
  break if a >= Math.sqrt(max)
  i = a
  while i <= max
    list[i] = 0
    i += a
  end
  while list[a] == 0
    a += 1
  end
  prime << list[a]
  list[a] = 0
end
prime += list - [0]

while n = gets.to_i
  break if n == 0
  puts prime[0,n].inject(:+)
end

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

int main(){
  int n, k, m; cin>>n>>k;
  vector<int> a(n), b(n, 0);
  for (int i=0; i<n; ++i) cin>>a[i];
  b[1] = abs(a[1] - a[0]);
  for(int i=2; i<n; ++i){
      m  = 1e9;
      for (int j =i-1; j>= 0 && j >= i-k; --j) m = min(abs(a[i] - a[j]) + b[j], m);
      b[i] = m;
  }
  cout<<b[n-1];
  return 0;
      
} 


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

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

	int N;
	cin >> N;
	map<int, int64_t> freq;
	int64_t running = 0;
	for (int i = 0; i < N; ++i) {
		int num;
		cin >> num;
		freq[num]++;
		running += num;
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int64_t b, c;
		cin >> b >> c;
		running += (c-b)*freq[b];
		cout << running << endl;
		freq[c] += freq[b];
		freq[b] = 0;
	}
}

Measured memory_bytes: 9532
a,b,c,k=io.read("*n","*n","*n","*n")
if a>=k then
    print(k)
elseif a<k then
    if a+b>=k then
        print(a)
    elseif a+b<k then
        if a+b+c==k then
            print(a-c)
        elseif a+b+c>k then
            print(a-(k-a-b))
        end
    end
end


Measured memory_bytes: 2792
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

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

    int ans = 0;
    for(size_t i = 0; i < s.length() / 2; ++i){
        if(s[i] != s[s.length() - 1 - i]) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 760
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
string s;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>s;
	map<char,ll>mp;
	for(char ch: s)
	++mp[ch];
	for(char i='a'; i<='z'; i++)
	{
	    if(mp[i]&1)
	    {
	        cout<<"No";
	        return 0;
	    }
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
/* 
    AtCoder Beginner Contest 102
    B:Maximum Difference
    二重のforループを1回に削減
    AC
*/

#include <iostream>
using namespace std;

int main(void)
{
    int i;
    int length;
    cin >> length;
    int num[length];
    for (i = 0; i < length; i++)
    {
        cin >> num[i];
    }
    int max = num[0],
        min = num[0];
    for (i = 1; i < length; i++)
    {
        if(num[i] > max){
            max = num[i];
        }
        if(num[i] < min){
            min = num[i];
        }
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const long double pi = acos(-1.0);
const int s = 250000;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	vector<pair<long double,long double>>p(N);
	for (int i = 0; i < N; i++)cin >> p[i].first >> p[i].second;

	vector<int>ans(N);
	for (int i = 0; i < s; i++) {
		long double co = cos(2*pi*((long double)i/(long double)s));
		long double si = sin(2*pi*((long double)i/(long double)s));
		vector<pair<long double, int>>temp;
		for (int j = 0; j < N; j++) {
			temp.pb({p[j].first*co + p[j].second*si,j});
		}
		sort(all(temp));
		ans[temp.back().second]++;
	}

	for (int i = 0; i < N; i++) {
		cout << setprecision(20) << (long double)ans[i] / s << endl;;
	}

	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<iostream>
typedef long long LL;
using namespace std;
int main()
{
	int n,ans,h[200];
	cin>>n;ans=n;
	for(int i=1;i<=n;i++)
	cin>>h[i];
	for(int i=1;i<=n;i++)
	for(int j=1;j<i;j++)
	{
		if(h[j]>h[i])
		{
			ans--;break;
		}
	}
	cout<<ans;
}


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

int main(){
  int N; cin >> N;
  vector<long long> MY(N+1,0);
  for(int i=1;i<N+1;i++){
    cin >> MY.at(i);
  }
  vector<long long> ans(N+1,0);
  long long count=0;
  for(int i=1;i<N+1;i++){
    if(i%2!=0){
      count+=MY.at(i);
    }
    else count-=MY.at(i);
  }
  ans.at(1)=count;
  for(int i=2;i<N+1;i++){
    ans.at(i)=MY.at(i-1)*2-ans.at(i-1);
  }
  for(int i=1;i<N+1;i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 2944
iN ,iX  = [int(x) for x in input().split()]

aCum = [0]
for i in map(int,input().split()):aCum+=[aCum[-1]+i]
aCum = aCum[1:]

#aX = [int(x) for x in input().split()]
#aCum = [0]*iN
#aCum[0] = aX[0]
#for i in range(1,iN):
#   aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
    return iCost

iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iTotalCost = min(iTotalCost,fCalcCost(iN,iX,aCum,iK))
print(iTotalCost)


Measured memory_bytes: 27244
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[2005][2005];
int n,m,u[2005][2005],d[2005][2005],l[2005][2005],r[2005][2005],ans;
int main(){
    read(n),read(m);
	fr(i,1,n)cin>>s[i]+1;
	fr(i,1,n)fr(j,1,m)if(s[i][j]=='.'){
		u[i][j]=s[i-1][j]=='.'?u[i-1][j]+1:1;
		l[i][j]=s[i][j-1]=='.'?l[i][j-1]+1:1;
	} 
	rf(i,n,1)rf(j,m,1)if(s[i][j]=='.'){
		d[i][j]=s[i+1][j]=='.'?d[i+1][j]+1:1;
		r[i][j]=s[i][j+1]=='.'?r[i][j+1]+1:1;
	}
	fr(i,1,n)fr(j,1,m)ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70364
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> Z_algorithm(vector<ll> S) {
	int c = 0, n = S.size();
	vector<int> Z(n, 0);
	for (int i = 1; i < n; i++) {
		int l = i - c;
		if (i + Z[l] < c + Z[c]) {
			Z[i] = Z[l];
		} else {
			int j = max(0, c + Z[c] - i);
			while (i + j < n && S[j] == S[i + j])j++;			
			Z[i] = j;
			c = i;
		}
	}
	Z[0] = n;
	return Z;
}

int main(){
  int n;
  cin >> n;
  vector<ll> a(mx), b(mx);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  vector<ll> axor(n),bxor(n);
  rep(i,n){ axor[i]=a[i]^a[i+1]; } axor[n-1]=a[n-1]^a[0]; 
  rep(i,n){ bxor[i]=b[i]^b[i+1]; } bxor[n-1]=b[n-1]^b[0]; 
  auto tmp = bxor;
  rep(j,2)rep(i,n) tmp.emplace_back(axor[i]);

  vector<pair<int,ll>> kx;
  auto res = Z_algorithm(tmp);
  for(int i=n; i<n*2; i++)if(res[i]>=n){
    kx.push_back({i-n,b[0]^a[i-n]});
  }

  sort(kx.begin(),kx.end());
  for(auto ans:kx){
    cout << ans.F << " " << ans.S << endl;
  }
  return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
const int INF = 1000000000;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X.at(i);
    int distance;
    int sum = 0;
    int ans = INF;

    for(int i=1; i <= 100; i++){
        sum = 0;
        rep(j,N){
            distance = abs(X.at(j) - i);
            sum += distance * distance;
        }
        ans = min(sum, ans);
    }
    cout << ans << endl;
}

/*
int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int elements = 0;
    rep(i,n){
        cin >> x.at(i);
        elements += x.at(i);
    }
    int p = (elements + x.size() / 2) / x.size();
    int q = (elements - x.size() / 2)/ x.size();
    int SumofMin1 = 0;
    int SumofMin2 = 0;
    rep(i,n){
        int distance1 = abs(x.at(i) - p);
        int distance2 = abs(x.at(i) - q);
        SumofMin1 += distance1 * distance1;
        SumofMin2 += distance2 * distance2;
    }
    cout << min(SumofMin1, SumofMin2) << endl;
}
*/

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> h(n);
	rep(i,n) std::cin >> h[i];
	std::vector<int> good(n,true);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		if(h[a]==h[b]) {
			good[a]=false;
			good[b]=false;
			continue;
		}
		if(h[a]>h[b]) std::swap(a,b);
		good[a]=false;
	}
	int ans=0;
	rep(i,n) if(good[i]) ans++;
	debug(good);
	print(ans);

	return 0;
}


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

class Baseball{
private:
	//int event;
	int point_count;
	int out_count;
	int runner;

public:
	 Baseball(int p, int o, int r);
	 void singleHit();
	 void homerun();
	 void out();
	 void newInning();
	 int now_point();
	 int now_out();
	~ Baseball();
};

Baseball::Baseball(int p, int o, int r){
	point_count = p;
	out_count = o;
	runner = r;
}

Baseball::~Baseball(){	
}

void Baseball::singleHit(){
	if(runner < 3){
		++runner;
	}else if(runner == 3){
		++point_count;
	}
}

void Baseball::homerun(){
	point_count += runner+1;
	runner = 0;
}

void Baseball::out(){
	++out_count;
}

void Baseball::newInning(){
	point_count = 0;
	out_count = 0;
	runner = 0;
}

int Baseball::now_point(){
	return point_count;
}

int Baseball::now_out(){
	return out_count;
}

int main(){
	int num;
	std::string event;
	Baseball baseball(0,0,0);

	std::cin >> num;

	for(int i=0; i<num; ++i){
		baseball.newInning();

		while(baseball.now_out() < 3){
			std::cin >> event;

			if(event == "HIT"){
				baseball.singleHit();

			}else if(event == "HOMERUN"){
				baseball.homerun();

			}else if(event == "OUT"){
				baseball.out();

			}
		}

		std::cout << baseball.now_point() << std::endl;
	}
	
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)
 
typedef long long ll;
typedef pair<int, int> pii;
 
const int N = 200200;
const int mod = 1e9 + 7;
const int M = 1e8;
const double PI = acos(-1.0);
 
vector<pii> allx, ally;
ll curx, fnx, fny;
ll cury;
ll uu[N];
ll n;
ll x[N], y[N];
ll d[N];
pii a[N];
 
inline void rotate()
{
	ll xc = curx;
	curx = cury;
	cury = M - 1 - xc;
	xc = fnx;
	fnx = fny;
	fny = M - 1 - xc;
	for(ll i = 1; i <= n; ++i)
	{
		ll yc = y[i];
		y[i] = M - 1 - x[i];
		x[i] = yc;
	}
}
 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> curx >> cury >> fnx >> fny;
	cin >> n;
	for(ll i = 1; i <= n; ++i)
		cin >> x[i] >> y[i];
	while(curx > fnx || cury > fny)
		rotate();
	fo(i, n)
		a[i].F = x[i], a[i].S = y[i];
	sort( a + 1, a + n + 1);
	fo(i, n)
	{
		a[i].F -= curx;
		a[i].S -= cury;
	}
	ll p = 1;
	while(p <= n && a[p].F < 0)
		++p;
	if(p > n)
		return cout << abs(curx - fnx) + abs(cury - fny), 0;
	fnx -= curx;
	fny -= cury;
	curx = 0;
	cury = 0;
	cout.precision(15);
	d[0] = -1e9;
	fo(i, n)
		d[i] = 1e9;
	ll ans = 0;
	double res = 1e18;
	for(ll i = 1; i <= n; ++i)
	{
		if(a[i].F > fnx) break;
		if(a[i].F < curx) continue;
		if(a[i].S < cury) continue;
		if(a[i].S > fny) continue;
		ll j = upper_bound(d + 1, d + n + 1, a[i].S) - d;
		uu[i] = j;
		if(a[i].S <= fny) ans = max(ans, j);
		d[j] = a[i].S;
	}  
	fo(i,n)
	{
		if(uu[i] == ans && a[i].S <= fny)
		{
			ll j = uu[i];
			double dist = abs(curx - fnx)* 100 + abs(cury - fny) * 100 - j * 20 + PI * 5 * j;
			if(j == abs(fnx - curx) + 1 || j == abs(fny - cury) + 1)
				dist += PI * 5;
			res = min(res, dist);
		}
	}       /*
	if(curx + 1 == fnx)
	{
		ll height1 = -1e9, height2 = -1e9;
		for(int j = 1; j <= n; ++j)
			if(a[j].F == curx)
				height1 = a[j].F;
		for(int j = 1; j <= n; ++j)
			if(a[j].F == fnx)
				height2 = a[j].F;
		if(height1 != -1e9 && height2 != -1e9 && height1 < height2)
			return cout << fixed <<abs(curx - fnx)* 100 + abs(cury - fny) * 100 - 20 + PI * 5 - 20 + PI * 10, 0;

	}
	if(cury + 1 == fny)
	{  	
		ll height1 = -1e9, height2 = -1e9;
		for(int j = 1; j <= n; ++j)
			if(a[j].S == cury)
				height1 = a[j].S;
		for(int j = 1; j <= n; ++j)
			if(a[j].S == fny)
				height2 = a[j].S;
		if(height1 != -1e9 && height2 != -1e9 && height1 < height2)
			return cout << fixed <<abs(curx - fnx)* 100 + abs(cury - fny) * 100 - 20 + PI * 5 - 20 + PI * 10, 0;
	}          */
	if(res == 1e18)
		cout << fixed << min(res, abs(curx - fnx)* 100 + abs(cury - fny) * 100.0); 
	else
		cout << fixed << res;
	return 0;
}


Measured memory_bytes: 8192
l = []
cnt = 0
while 1:
    x = input()
    if x == '0 0':
        break
    l.append(x)
    cnt += 1
for i in range(cnt):
    f = list(map(int,l[i].split()))
    f.sort()
    print(f[0],f[1],sep=' ')
    del f[:]

Measured memory_bytes: 8076
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;


typedef long long ll;

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a >= 13) cout << b << endl;
  else if(a <= 5) cout << 0 << endl;
  else cout << b/2 << endl;
}


Measured memory_bytes: 256