akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,L;
int A[100010],B[100010];
int C[100010];
int Q;
int S[100010],T[100010];

int d1[334][334];
int d2[334][334];

signed main(){
	cin>>N>>M>>L;
	REP(i,M){
		cin>>A[i]>>B[i]>>C[i];
		A[i]--,B[i]--;
	}
	cin>>Q;
	REP(i,Q){
		cin>>S[i]>>T[i];
		S[i]--,T[i]--;
	}
	REP(i,334){
		REP(j,334){
			d1[i][j]=INF;
			d2[i][j]=INF;
		}
	}
	REP(i,334){
		d1[i][i]=0;
		d2[i][i]=0;
	}
	REP(i,M){
		d1[A[i]][B[i]]=C[i];
		d1[B[i]][A[i]]=C[i];
	}
	REP(k,N){
		REP(i,N){
			REP(j,N){
				d1[i][j]=min(d1[i][j],d1[i][k]+d1[k][j]);
			}
		}
	}
	REP(i,N){
		REP(j,N){
			if(d1[i][j]<=L){
				d2[i][j]=min(d2[i][j],1);
			}
		}
	}
	REP(k,N){
		REP(i,N){
			REP(j,N){
				d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
			}
		}
	}
	REP(i,Q){
		int d=d2[S[i]][T[i]];
		if(d==INF){
			cout<<-1<<endl;
		}
		else{
			cout<<d-1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(long long)(n);(i)++)
#define ll long long
using namespace std;

ll i,j;
const ll MOD = 1000000000 + 7;

int main(){
    int d,t,s;
    string ans="No";
    ll cnt=0;
    ll time=0;
    cin>>d>>t>>s;

    if((d+s-1)/s<=t){
        ans="Yes";
    }
   
    
    cout<<ans<<'\n';
    return 0;
}

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

from heapq import heappop, heappush
from collections import defaultdict

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

lst = []
for i in range(N):
    s, t, x = map(int, input().split())
    lst.append((t - x, 0, x)) #xで止まらなくなる
    lst.append((s - x, 1, x)) #xで止まる

for i in range(Q):
    lst.append((int(input()), 2, i))

lst.sort()
ans = [-1] * Q

#引っかかっている場所の管理
se = set()
se_hp = [] #heapで最小値を先頭に保つ

#小さい時刻から順に見ていく
for a, b, c in lst:
    if b == 0:
        se.remove(c)
    elif b == 1:
        se.add(c)
        heappush(se_hp, c)
    else:
        while se_hp and se_hp[0] not in se:
            heappop(se_hp)
        ans[c] = se_hp[0] if se_hp else -1

print ('\n'.join(map(str, ans)))

Measured memory_bytes: 106040
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int N, M;
  vector<int> T, P, X;
  cin >> N;
  rep(i, N) {
    int x;
    cin >> x;
    T.push_back(x);
  }
  cin >> M;
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    P.push_back(x - 1);
    X.push_back(y);
  }
  rep(i, M) {
    int sum = 0;
    rep(j, N) {
      if (j == P[i]) {
        sum += X[i];
      }
      else {
        sum += T[j];
      }
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n,total;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int roundrobin(int rest,int q){
	if (q < rest){
		total += q;
		rest -= q;
	}
	else{
		total += rest;
		rest = 0;
	}
	return rest;
}

int main(){
	total = 0;
	P u;
	int q;
	scanf("%d %d", &n,&q);
	for(int i=1;i<=n;i++){
		scanf("%s %d", Q[i].name, &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	while (head != tail){
		u = dequeue();
		u.t = roundrobin(u.t, q);
		if (u.t > 0){
			enqueue(u);
		}
		else{
			printf("%s %d\n", u.name, total);
		}
	}
	return 0;
}

Measured memory_bytes: 13312
H, W = map(int, input().split())

Ss = []
white_count = 0
for i in range(H):
    s = list(input())
    for masu in s:
        if masu == '.':
            white_count += 1
    Ss.append(s)

# print('white_count', white_count)


def search():
    global Ss_hosu
    #global min_hosu
    Ss_hosu[0][0] = 1
    que = [[0, 0]]
    while len(que) > 0:
        x, y = que.pop(0)
        my_value = Ss_hosu[y][x]
        for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
            if 0 <= x + dx <= W - 1 and 0 <= y + dy <= H - 1:
                if Ss[y + dy][x + dx] == '.' and Ss_hosu[y + dy][x + dx] is None:
                    Ss_hosu[y+dy][x+dx] = my_value + 1
                    que.append([x + dx, y + dy])

  
Ss_hosu = [[None for _ in range(W)] for _ in range(H)]
search()
min_hosu = Ss_hosu[H-1][W-1]

# for s in Ss_hosu:
#     print(s)

# print('min_hosu', min_hosu)

if min_hosu is None:
    print(-1)
else:
    print(white_count - min_hosu)


Measured memory_bytes: 3192
// olaf_surgut
//        _        __                             _   
//   ___ | | __ _ / _|  ___ _   _ _ __ __ _ _   _| |_ 
//  / _ \| |/ _` | |_  / __| | | | '__/ _` | | | | __|
// | (_) | | (_| |  _| \__ \ |_| | | | (_| | |_| | |_ 
//  \___/|_|\__,_|_|___|___/\__,_|_|  \__, |\__,_|\__|
//                |_____|             |___/           
//
#pragma optimize ("Ofast")
#include <bits/stdc++.h>
#define st  first
#define nd  second
#define ll  long long
#define INF 1000000005LL
using namespace std;

void solve(){
  int n;
  cin >> n;
  vector<pair<int,int>> l(n);
  for(int i = 0; i < n; i++)  cin >> l[i].st >> l[i].nd;
  sort(l.begin(), l.end());
  vector<int> x, y;
  for(int i = 0; i < n; i++)  x.push_back(l[i].st), y.push_back(l[i].nd);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  if(n & 1){
    int low = x[n / 2];
    int upp = y[n / 2];
    cout << upp - low + 1 << '\n';
  }else{
    double low = (x[n / 2 - 1] + x[n / 2]) / 2.;
    double upp = (y[n / 2] + y[n / 2 - 1]) / 2.;
    // cout << low << ' ' << upp << '\n';
    cout << fixed << setprecision(0) << (upp - low) * 2 + 1 << '\n'; 
  }
}

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  int _ = 1;
  // cin >> _;
  while(_--)solve();
}

Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll bl = 0;
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    A[i] = a + b;
    bl += b;
  }
  sort(A.begin(), A.end(), greater<ll>());
  ll ans = 0;
  REP(i, N) {if(i%2==0) ans += A[i]; }
  cout << ans - bl << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string w; cin>>w;

	map<char, int> count;
	rep(i, w.size()){
		count[w[i]]++;
	}
	bool yes = true;
	for(auto itr=count.begin(); itr!=count.end(); itr++){
		if (itr->se % 2 == 1){
			yes = false;
			break;
		}
	}
	if (yes){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int n,h,m,s;

	scanf("%d", &n);

	h = n / 3600;
	m = n % 3600 / 60;
	s = n % 3600 % 60;


	printf("%d:%d:%d\n", h, m, s);

	return(0);

}


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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (auto&& si : s) cin >> si;
	cout << string(w+2, '#') << endl;
	for (auto&& si : s) cout << "#" << si << "#" << endl;
	cout << string(w+2, '#') << endl;
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    vector<int> X(N), ans(N);
    vector<P> p(N);

    rep(i, N) {
        cin >> X[i];
        p[i].first = X[i];
        p[i].second = i;
    }

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());

    int center = N / 2;
    center--;
    rep(i, N) {
        if (i <= center) {
            ans[p[i].second] = p[center + 1].first;
        }
        else {
            ans[p[i].second] = p[center].first;
        }
    }

    rep(i, N) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

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

const ll INF=1LL << 60;
int dp[100100];

int main() {
  int n;cin >> n;
  rep(i,n+1)dp[i]=i;

  rep(i,n+1){
    reps(t,7){
      ll k=pow(6,t);
      if(i+k<100100)chmin(dp[i+k],dp[i]+1);
      ll j=pow(9,t);
      if(i+j<100100)chmin(dp[i+j],dp[i]+1);
    }
  }
  cout <<dp[n];
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;


int main() {
  string S;
  int w;

  cin >> S;
  scanf("%d", &w);

  for(int i = 0; i < S.size(); i += w){
    printf("%c", S[i]);
  }

  return 0;
}


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

typedef long long ll;
using namespace std;

ll mod=1e9+7;

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

}


int calculate(int h,int w){
    int first_cut = w/3 + w%3 - 1;
    vector<int> v;
    v.push_back(first_cut*h);
    v.push_back((h/2)*(w-first_cut));
    v.push_back(h*w - v[0] - v[1]);
    sort(v.begin(),v.end());
    return v[2]-v[0];
}
int main()
{
    io();
    int h,w,t=1;
    //cin>>t;
    while(t--){
        cin>>h>>w;
        if(h%3 == 0 || w%3 == 0){
            cout<<"0\n";
            continue;
        }
        
        int x=min({calculate(h,w),calculate(w,h),h,w});
        cout<<x<<endl;
    }


}





Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int count=1,r=0;
    for(int i=0;i<N;i++){
        if(a[i]==count){
            count++;
        }else{
            r++;
        }
    }
    if(r==N){
        cout<<-1<<endl;
        exit(0);
    }
    cout<<r<<endl;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

// vector<vector<int>> data(3, vector<int>(4));

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

  string str, str2;
  cin >> str >> str2;
  int ans = 0;
  rep(i, str.size()) {
    if (str[i] != str2[i]) ans++;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, y;
    cin >> n >> y;
    bool exist=false;
    for(int i=0; i<=n; i++){
        for(int j=0; i+j<=n; j++){
            for(int k=0; i+j+k<=n; k++){
                if(10000*i+5000*j+1000*k==y && i+j+k==n){
                    cout << i << " " << j << " " << k << endl;
                    exist = true;
                    goto loop_end;
                }
            }
        }
    }
    loop_end:
    if(!exist) cout << -1 << " " << -1 << " " << -1  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> ss(m);
    vector<int> ps(m);
    for(int i=0; i<m; ++i){
        int k; cin >> k;
        for(; k; --k){
            int s; cin >> s;
            --s;
            ss[i].push_back(s);
        }
    }
    for(int i=0; i<m; ++i){
        cin >> ps[i];
    }

    int ans=0;
    for(int mask=0; mask<(1<<n); ++mask){
        int lit=0;
        for(int i=0; i<m; ++i){
            int on=0;
            for(auto s : ss[i]){
                if((1<<s) & mask) ++on;
            }
            if(on%2==ps[i]) ++lit;
        }
        if(lit==m) ++ans;
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll>
#define pll pair<ll,ll>


int main()
{
  int t;
  t=1;
  while(t--){
  string s;
  cin>>s;
  int n=s.size();
  if(n==1){
     if(s[0]=='?')
     cout<<"D";
     else
     cout<<s;
     }
     else{

     string ans;

         for(int i=0;i<n;i++){
              if( i+1<n&&s[i]=='?'&&(s[i+1]=='D'|| s[i+1]=='?') ){
                    ans+="P";
                    s[i+1]='D';
              }else if(s[i]=='?')
                    ans+="D";
                    else if( i+1<n&&s[i]=='P' && (s[i+1]=='?') ){
                       ans+=s[i];
                        s[i+1]='D';
                     }else
                    ans+=s[i];
          }
            cout<<ans<<endl;
     }
   }
 }


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

int main(){
  int N,M;
  cin>>N>>M;
  int mir=N,mal=0;
  vector<int> L(M),R(M);
  for(int i=0;i<M;i++){
    cin>>L.at(i)>>R.at(i);
    mir=min(mir,R.at(i));
    mal=max(mal,L.at(i));
  }
  if(mir<mal){
    cout<<0<<endl;
  }else{
    cout<<mir-mal+1<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int a[5], b[5];
    int sum = 0;
    for(int i = 0; i < 5; i++) cin >> a[i];
    for (int i = 0; i < 5; ++i) {
        b[i] = (a[i] + 9) / 10 * 10;
        sum += b[i];
    }

    int ans = 10000;
    for (int i = 0; i < 5; ++i) {
        ans = min(ans, sum - b[i] + a[i]);
    }

    cout << ans << endl;
}

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

int main() {
  int A, B, C, D, P;
  cin >> A >> B >> C >> D >> P;
  
  int X = A * P;
  int Y = B;
  if (P > C) Y += (P - C) * D;

  cout << min(X, Y) << endl;

  return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
int BubbleSort(int *a,int b);

int main(int argc, const char * argv[]) {
  int a[100],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  printf("%d\n",BubbleSort(&a,n));
}

int BubbleSort(int *a,int n){
  int i,tmp,count=0 ;
  int flag = 1;

  while(flag){
    flag=0;
    for(i=n-1;i>=1;i--){
      if(a[i]<a[i-1]){
	count++;
	tmp=a[i];
	a[i]=a[i-1];
	a[i-1]=tmp;
	flag=1;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  return count;
}


Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <queue>

int main()
{
	std::string S;
	std::cin >> S;
	std::cout << S;
	if (S[S.size() - 1] == 's') {
		std::cout << "es";
	}
	else {
		std::cout << "s";
	}
	std::cout << std::endl;
	return 0;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	int n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	long long ans = 0;
	map<long long, int> M;
	M[0] = 1;
	long long s = 0;
	for (int x : a) {
		s += x;
		ans += M[s];
		M[s] += 1;
	}

	cout << ans << "\n";

	return 0;
}

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

flag = 0
cnt = 0

while flag == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            flag = 1
            break
    if flag == 0:
        cnt += 1

print(cnt)


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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<string>> S( H, vector<string>( W ) );
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			cin >> S[i][j];
		}
	}

	int ansh;
	char answ;
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( S[i][j] == "snuke" ) {
				ansh = i + 1;
				answ = 'A' + j;
				break;
			}
		}
	}

	cout << answ << ansh << endl;
}

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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int n,q,k;
vector<P> vp[100010];
int point[100010];
ll len[100010];

void dfs(int now,ll sum){
    len[now] = sum;
    for(auto x: vp[now]){
        if(!point[x.first]){
            point[x.first] = 1;
            dfs(x.first,sum+x.second);
        }
    }
}

int main()
{
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a,b,c;
        cin >> a >> b >> c;
        vp[a].emplace_back(b,c);
        vp[b].emplace_back(a,c);
    }
    cin >> q >> k;
    point[k] = 1;
    dfs(k,0);
    for(int i = 0; i < q; i++){
        int x,y;
        cin >> x >> y;
        cout << len[x]+len[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 11520
import sys
input = sys.stdin.readline
s=list(input())
x,y = map(int, input().split())
y=abs(y)
s.append('T')
x1=[]
y1=[]

count=0
u=0
for i in range(len(s)):
    if s[i]=='F':
        count+=1
    else:
        if u%2==0:
            x1.append(count)
            u+=1
            count=0
        else:
            y1.append(count)
            u+=1
            count=0
v=sum(x1)
w=sum(y1)
v-=x1[0]
x-=x1[0]
x1.pop(0)
x=abs(x)
if v<x or w<y:
    print('No')
    exit()

dpx=[[0 for i in range(v+1)] for j in range(len(x1)+1)]
dpx[0][-1]=1

for i in range(len(x1)):
    for j in range(v+1):
        if dpx[i][j]==1:
            if j-2*x1[i]>=0:
                dpx[i+1][j-2*x1[i]]=1
            dpx[i+1][j]=1

if len(y1)==0:
    y1.append(0)
dpy=[[0 for i in range(w+1)] for j in range(len(y1)+1)]
dpy[0][-1]=1

for i in range(len(y1)):
    for j in range(w+1):
        if dpy[i][j]==1:
            if j-2*y1[i]>=0:
                dpy[i+1][j-2*y1[i]]=1
            dpy[i+1][j]=1

if dpy[-1][y]==1 and dpx[-1][x]==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 112348
S=list(input())
def main():
    while True:
        for i in range(len(S)):
            if (i+1)%2==1:
                if S[i]!='R' and S[i]!='U' and S[i]!='D':
                    return 'No'
                    break
            else:
                if S[i]!='L' and S[i]!='U' and S[i]!='D':
                    return 'No'
                    break
                
        return 'Yes'

print(main())

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

N,M=map(int,input().split())
A=list(map(int,input().split()))

B=[-a for a in A]
B.sort()

import heapq

heapq.heapify(B)

for i in range(M):
    x=-heapq.heappop(B)
    heapq.heappush(B,-(x//2))

    #print(B)

print(-sum(B))

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin>>n>>k;
    long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long ans=0;
    for(int i=0;i<n-k;i++)
    {
        ans=ans+a[i];
    }
    cout<<ans;
}

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

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  if(S.length()%2==1){
    cout<<"No"<<endl;
    return 0;
  }

  int l = S.length()/2;

  string S1 = S.substr(0,l);
  string S2 = S.substr(l,l);

  if(S1==S2){
    cout<<"Yes"<<endl;
    return 0;
  }
  else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
while True:
	n,x = list(map(int,input().split()))
	if n == 0 and x == 0:
		break

	count = 0
	for a in range(1,x//3):
		for b in range(a+1,x//2):
			c = x - (a + b)
			if b < c <= n:
				count += 1
	print(count)

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

int check(vector<vector<int>>&sen,int now,map<int,int>alr){
  bool ok=true;
  alr[now]=1;
  for(auto x:alr){
    if(x.second!=1)
      ok=false;
  }
  if(ok){
    return 1;
   // cout << now << "#1" << endl;
  }
  int ans=0;
  for(int i=0;i<sen.at(now).size();i++){
    if(alr[sen.at(now).at(i)]==0)
    ans += check(sen,sen.at(now).at(i),alr);
  }
  //cout << now << "#" << ans << endl;
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>>sen(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    sen.at(a-1).push_back(b-1);
    sen.at(b-1).push_back(a-1);
  }
  map<int,int>alr;
  for(int i=0;i<n;i++)
    alr[i]=0;
  cout << check(sen,0,alr) << endl;
  return 0;
} 

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main(){
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++){
    cin >> r[i];
    r[i]--;
  }
  vector<vector<int>> d(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++){
    d[i][i] = 0;
  }
  for (int i = 0; i < M; i++){
    int A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    d[A][B] = C;
    d[B][A] = C;
  }
  for (int k = 0; k < N; k++){
    for (int i = 0; i < N; i++){
      for (int j = 0; j < N; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = INF;
  vector<int> p(R);
  for (int i = 0; i < R; i++){
    p[i] = i;
  }
  while (1){
    int tmp = 0;
    for (int i = 0; i < R - 1; i++){
      tmp += d[r[p[i]]][r[p[i + 1]]];
    }
    ans = min(ans, tmp);
    if (!next_permutation(p.begin(), p.end())){
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pb push_back
int main(int argc, char** argv) {
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		printf("Yes");
		
	}
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace A_ABC126
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            string str = ReadLine();
            string mae = str.Substring(0,s[1]-1);
            string ushiro = str.Substring(s[1],str.Length-s[1]);
            string chg = str[s[1]-1].ToString();
            chg = chg.ToLower();


            WriteLine(mae+chg+ushiro);
        }
    }
}

Measured memory_bytes: 11220
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
// const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	int n; cin >> n;
	vector<int> a(n);

	rep(i,n){
		cin >> a[i];
	}

	Sort(a);

	ll m = 1;
	rep(i,n){
		if(a[i] == 0){
			cout << 0 << endl;
			return 0;
		}
		long double c =1000000000000000000.0/a[i];
		cerr << m << "," << c << endl;
		if(m > c){
			cout << -1 << endl;
			return 0;
		}
		m *= a[i];
	}
	if(m >1000000000000000000){
			cout << -1 << endl;
			return 0;
		}

	cout << m << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc169/tasks/abc169_b


Measured memory_bytes: 4000
n=int(raw_input())
a=[]
for i in range(n):
    a.append(int(raw_input()))

m=max(a)
c=a.count(m)

if c > 1:
    for i in range(n):
        print m
else:
    s=sorted(a)[-2]
    for i in range(n):
        if a[i] != m:
            print m
        else:
            print s


Measured memory_bytes: 16716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	char c;
	int h,w,i,j,cnt=0;;
	scanf("%d%d%*c",&h,&w);
	FOR(i,0,h){
		FOR(j,0,w){
			scanf("%c",&c);
			if(c=='#') cnt++;
		}
		scanf("%*c");
	}
	if(cnt==h+w-1) puts("Possible");
	else puts("Impossible");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    int a, b;
    char op;
    
    cin >> a >> op >> b;
    
    if(op == '+') {
        cout << a+b << "\n";
    } else {
        cout << a-b << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner as = new Scanner(System.in);
		
		String T = "";
		String TD;
		String W;
		String str = "";
		int j = 0;
		int i = 0;
		int k = 0;
		int count = 0;
		int same = 0;
		int flag = 0;
		
		
		W = as.nextLine();
		W = W.toLowerCase();
	    
	    
	    
	    while(as.hasNext()){                  //EOF?????§??±????????????????????£?????????
	    	
	    	T = as.next();
	    	T = T.toLowerCase();
       
	    	if(T == "END_OF_TEXT"){
		    
	    		break;
	    		
	    	}
	    	
	    	if(T.indexOf(W) == 0 && T.lastIndexOf(W) == 0){
	    		
	    		count++;
	    		
	    	}
	    	
	    	//System.out.println(T);
	    	//System.out.println(T.indexOf(W)+":"+T.lastIndexOf(W));
	    	
	    	
             
        }
	    
	    str = String.valueOf(count);
	    System.out.println(str);
	    
	    

	}

}

Measured memory_bytes: 26252
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

int ans = 0;
int n;
void f(int num, int keta, int cnt){
    if(keta == cnt){
        if(num > n) return;

        int flag = 0;
        while(num > 0){
            if(num % 10 == 3) flag |= 1;
            if(num % 10 == 5) flag |= 2;
            if(num % 10 == 7) flag |= 4;
            num /= 10;
        }
        if(flag == 7) ans++;
        return;
    }
    f(num * 10 + 3, keta, cnt+1);
    f(num * 10 + 5, keta, cnt+1);
    f(num * 10 + 7, keta, cnt+1);
}

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

    cin >> n;
    REP(i, 9){
        f(0, i+1, 0);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    bool a = false;
    bool b = false;
    bool c = false;

    for(int i = 0 ; i < s.size(); i++)
    {

    if(s[i] == 'c') c = true;
    if(s[i] == 'b') b = true;
    if(s[i] == 'a') a = true;

    }

    if(a && b && c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

s = arr_data[0][0]

print("Yes" if s[0:4]=="YAKI" else "No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < k; ++i) {
		vector<int> g(n);
		
		for(int j = 0; j < n; ++j) {
			int x = max(0, j - a[j]);
			int y = j + a[j] + 1;
		
			g[x]++;
			if( y < n ) g[y]--;
		}
		
		for(int j = 1; j < n; ++j) {
			g[j] += g[j - 1];
		}
		
		if( a == g ) break;

		a = g;
	}
	
	for(auto& ans : a) {
		cout << ans << " ";
	}
	
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 4840
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <numeric>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define rng mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count())

#define ri(...) i64 __VA_ARGS__; rx(__VA_ARGS__)
#define rc(...) char __VA_ARGS__; rx(__VA_ARGS__)
#define rs(...) string __VA_ARGS__; rx(__VA_ARGS__)
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << '[' << #__VA_ARGS__ << "]: "; dbg_log(__VA_ARGS__)
#else
#define dbg(...) ;;
#endif

#define fa(i, v) for (auto &i : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(i) ri(_i); fi(i, _i)

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

typedef uint32_t u32;
typedef int32_t i32;
typedef uint64_t u64;
typedef int64_t i64;
#ifdef __SIZEOF_INT128__
typedef __uint128_t u128;
typedef __int128_t i128;
#endif
typedef vector<i64> vi;
typedef vector<vi> vvi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) out << x << ' ';
    return out;
}

template<typename T>
inline void rx(T &x) {
    cin >> x;
}

template<typename T, typename... R>
inline void rx(T &x, R &... l) {
    cin >> x;
    rx(l...);
}

template<typename T>
inline void dbg_log(const T &x) {
    cerr << x << '\n';
}

template<typename T, typename... R>
inline void dbg_log(const T &x, const R &... l) {
    cerr << x << ", ";
    dbg_log(l...);
}

template<typename T>
inline void wl(const T &x) {
    cout << x << '\n';
}

template<typename T, typename... R>
inline void wl(const T &x, const R &... l) {
    cout << x << ' ';
    wl<R...>(l...);
}

int main() {
    fio;

    ri(n);
    rvi(a, n);
    sort(rall(a));
    i64 res = a[0];
    n -= 2;
    i32 i = 1;
    while (true) {
        if (n-- == 0) break;
        res += a[i];
        if (n-- == 0) break;
        res += a[i];
        i++;
    }
    wl(res);

    return 0;
}


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

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=1e3+5;
const int S=1e4+5;
ll dp[N][S];
int w[N],s[N],v[N];
ll calc(int tr,int sss)
{
    if(tr==-1)
        return 0;
    if(dp[tr][sss]!=-1)
        return dp[tr][sss];
    dp[tr][sss]=calc(tr-1,sss);
    int ss=sss;
    if(ss==S-1)
        ss=s[tr];
    else
        ss=min(ss-w[tr],s[tr]);
    if(ss>=0)
        dp[tr][sss]=max(dp[tr][sss],v[tr]+calc(tr-1,ss));
    return dp[tr][sss];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    int n;
    scanf("%i",&n);
    vector<pair<pair<int,int>,pair<int,int> > > lol(n);
    for(int i=0;i<n;i++)
        scanf("%i %i %i",&lol[i].s.f,&lol[i].f.s,&lol[i].s.s),lol[i].f.f=lol[i].f.s+lol[i].s.f;
    sort(all(lol));
    for(int i=0;i<n;i++)
    {
        w[i]=lol[i].s.f;
        s[i]=lol[i].f.s;
        v[i]=lol[i].s.s;
    }
    printf("%lld\n",calc(n-1,S-1));
    return 0;
}

Measured memory_bytes: 78848
#include <iostream>
#include <set>

int main(){
    int n, result = 0;
    std::string s;
    std::cin >> n >> s;
    for(int i = 0; i < n - 1; i++){
        std::set<char> count;
        for(int j = 0; j <= i; j++){
            for(int k = i + 1; k < n; k++){
                if(s[j] == s[k]){
                    count.insert(s[j]);
                }
            }
        }
        result = std::max(result, int(count.size()));
    }
    std::cout << result;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
ll gcd(ll x, ll y) {

	if (y>x) {
		ll k = y;
		y = x;
		x = k;
	}

	if (x%y == 0) {
		return y;
	}
	else {
		return gcd(y, x%y);
	}

}


int main()
{
ll A, B;
	cin >> A >> B;
	vecl(C);
	
	ll g = gcd(A, B);
	ll i = 1;
	while (i*i<=g) {
		if (g%i==0) {
			pb(C, i);
			if (g/i!=1) {
				pb(C, g / i);
			}

		}
		i++;
	}

	vecl(ANS)
	int ans = 0;
	sorts(C);
	for (int x = 0; x < (ll)C.size();x++) {
		bool flag = true;
		for (int y = 0; y < (ll)ANS.size();y++) {
			if (gcd(C[x],ANS[y])!=1) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans++;
			pb(ANS,C[x])
		}
	}
	ce(ans)
    return 0;
}



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

using namespace std;

int h, w, ans;
string s[2200];
int a[2200][2200][4];

void dfs() {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;
      if (j == 0) {
        a[i][j][0] = 1;
      } else {
        a[i][j][0] = a[i][j-1][0] + 1;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = w-1; j >= 0; j--) {
      if (s[i][j] == '#') continue;
      if (j == w-1) {
        a[i][j][1] = 1;
      } else {
        a[i][j][1] = a[i][j+1][1] + 1;
      }
    }
  }
  
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      if (s[j][i] == '#') continue;
      if (j == 0) {
        a[j][i][2] = 1;
      } else {
        a[j][i][2] = a[j-1][i][2] + 1;
      }
    }
  }
  
  for (int i = 0; i < w; i++) {
    for (int j = h-1; j >= 0; j--) {
      if (s[j][i] == '#') continue;
      if (j == h-1) {
        a[j][i][3] = 1;
      } else {
        a[j][i][3] = a[j+1][i][3] + 1;
      }
    }
  }
}

int main() {
  cin >> h >> w;
  
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  
  dfs();
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int sum = 0;
      for (int k = 0; k < 4; k++) {
        sum += a[i][j][k];
      }
      sum -= 3;
      ans = max(ans, sum);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
void func(vector<int>& l, int depth, int idx){
  ;
}
int main() {
  int n;cin>>n;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    mp[a]=b;
  }
  auto it=mp.rbegin();
  int ans=it->first+it->second;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8268
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define fi first
#define se second
const int inf = 1e9+7;
int mod = 1e9+7;

int a[100000];
signed main(){
	int n, x, y;
	scanf("%lld%lld%lld", &n, &x, &y);
	rep(i,n)scanf("%lld", &a[i]);
	int ans = 0;
	repi(i,1,n){
		ans += min((a[i]-a[i-1])*x, y);
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int INF = 1000;
    while (1) {
        int N, M;
        cin >> N >> M;
        if (!N & !M) break;
        vector<int> taro(N);
        vector<int> hanako(M);
        int sumT = 0, sumH = 0;
        for (int i = 0; i < N; i++) {
            cin >> taro[i];
            sumT += taro[i];
        }
        for (int i = 0; i < M; i++) {
            cin >> hanako[i];
            sumH += hanako[i];
        }

        pair<int, int> ans = {INF, INF};
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if (sumT - taro[i] + hanako[j] == sumH - hanako[j] + taro[i]) {
                    if (taro[i] + hanako[j] < ans.first + ans.second) {
                        ans.first = taro[i];
                        ans.second = hanako[j];
                    }
                }
            }
        }
        if (ans.first == 1000) {
            cout << -1 << endl;
        } else {
            cout << ans.first << " " << ans.second << endl;
        }
    }
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    vector<int> A(M);
    for(int i=0;i<M;i++)
    {
        cin >> A.at(i);
    }

    if(N - accumulate(ALL(A),0) < 0) cout << "-1" << endl;
    else                             cout << N - accumulate(ALL(A),0) << endl;

    return 0;
}

Measured memory_bytes: 3668
// Date: 2020-03-28

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout << #x << " = " << x << endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int ans[N], n, x, y;
int main() {
    FIO;
    cin >> n >> x >> y;
    rep(i, 1, n) rep(j, i+1, n) {
        int dis = j-i;
        if(j <= x || i >= y) dis = j-i;
        else if(x <= i && j <= y) {
            chkmin(dis, i-x+y-j+1);
        }
        else if(i <= x && x <= j && j <= y) {
            chkmin(dis, x-i+1+y-j);
        }
        else if(x <= i && i <= y && y <= j) {
            chkmin(dis, j-y+1+i-x);
        }
        else if(i <= x && y <= j) chkmin(dis, x-i+j-y+1);
        ans[dis]++;
    }
    rep(i, 1, n-1) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
set<int> sett;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, a;
	cin >> n;
	set<int>::iterator it = sett.begin();
	while (n--)
	{
		cin >> a;
		it = sett.find(a);
		if (it != sett.end())
			sett.erase(it);
		else
			sett.insert(a);
	}
	cout << sett.size() << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int n ,q;
  int a[1005];
  cin >> n;

  for (int i= 0; i < n; ++i) cin >> a[i];

  cin >> q;
  while(q--) {
    int s, e, t;
    cin >> s >> e >> t;
    swap_ranges(a+s, a+e, a+t);
  }

  for (int i= 0; i < n; ++i) {
    cout << a[i] << (i+1 < n ? ' ' : LF);
  }

  return 0;
}




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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

VL enum_prime(const int n) {
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for(int i = 2; i * i <= n; ++i) {
    if(is_prime[i]) {
      for(int j = 2; i * j <= n; ++j) is_prime[i * j] = false;
    }
  }
  VL res;
  for(int i = 0; i < is_prime.size(); ++i) {
    if(is_prime[i]) res.push_back(i);
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    ll max_d = n / i;
    ans += (max_d + 1) * i * max_d / 2;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 3652