akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,ans = 0;
    cin >> n;
    VI enemy(n+1);
    VI capa(n);
    rep(i,n+1) cin >> enemy[i];
    rep(i,n) cin >> capa[i];
    rep(i,n){
        if(enemy[i] - capa[i] <= 0){
            ans += enemy[i];
            if(enemy[i+1] <= capa[i] - enemy[i]){
                ans += enemy[i+1];
                enemy[i+1] = 0;
            }else{
                ans += capa[i] - enemy[i];
                enemy[i+1] = enemy[i+1] - (capa[i] - enemy[i]);
            }
        }else{
            ans += capa[i];
        }
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll x[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	ll a,b;
	cin>>a>>b;
	if(x[a]==x[b])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

/*int main(){
    long long long long n;
    cin >> n;
    vector<long long> amount(5);
    vector<long long> round(5);


    for(long long i=0;i<5;i++){
        cin >> amount[i];
    }

    for(long long i=0;i<5;i++){
        round[i]=n/amount[i];
        if(n%amount[i]!=0){
            round[i]++;
        }
        if(i!=0 && i!=4){
            round[i]--;
        }
    }

    

    long long ans=0;
cout << '-' << endl;
    for(long long i=0;i<5;i++){
        ans+=round[i];
        
        cout << round[i] << endl;
    }

    cout << ans << endl;
}*/

/*int main(){
    long long n;
    cin >> n;
    vector<long long> amount(5);
    vector<long long> num(6);
    long long ans=0;
    bool flg=true;


    for(long long i=0;i<5;i++){
        cin >> amount[i];
    }

    for(long long i=0;i<6;i++){
        //cin >> amount[i];
        
        num[i]=0;
        if(i==0) num[0]=5;
    }

    while(flg){
    for(int i=0;i<5;i++){
        if(num[i]!=0){
            if(num[i]-amount[i]>=0){
                num[i]-=amount[i];
                ans++;
            }
            else{
                num[i]=0;
            }
            if(num[i+1]+amount[i]<=5){
                num[i+1]+=amount[i];
            }
            else{
                num[i+1]=5;
            }
        }
    }


    if(num[0]==0 && num[1]==0 && num[2]==0 && num[3]==0 && num[4]==0){
        flg=false;
    }
    else{
        ans++;
    }
    }



    
    cout << ans << endl;
}*/

/*
int main(){
        long long n;
    cin >> n;
    vector<long long> amount(5);
    vector<long long> round(5);


    for(long long i=0;i<5;i++){
        cin >> amount[i];
    }

    for(long long i=0;i<5;i++){
        round[i]=n/amount[i];
        if(n%amount[i]!=0){
            round[i]++;
        }
        if(i!=0 && i!=4){
            round[i]--;
        }
    }

    

    long long ans=0;
cout << '-' << endl;
    for(long long i=0;i<5;i++){
        ans+=round[i];
        
        cout << round[i] << endl;
    }

    cout << ans << endl;
}*/

int main(){
    long long n;
    cin >> n;
    long long amount[5];
    long long ans=0;

    for(int i=0;i<5;i++){
        cin >> amount[i];
    }

    long long minimum = min(min(min(min(amount[1],amount[2]),amount[3]),amount[4]),amount[0]);

    ans = ((n + minimum - 1) / minimum) + 4;


    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int n,a,b,x;
int main(){
	cin>>n>>a>>b;
    x=n*a;
	if(x<b)cout<<x;
	else if(x>b)cout<<b;
	else cout<<b;
	return 0;
}

Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i).sort!
a, b = c - a, c - b

diva, a = a.divmod(2)
divb, b = b.divmod(2)
ans = diva + divb

case a + b
when 2
  puts ans + 1
when 1
  puts ans + 2
else
  puts ans
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;
typedef long long ll;

ll l, r;

void solve() {
  if (r - l >= 2019) {
    cout << 0 << endl;
    return;
  }
  int ans = 2019;
  r = r % 2019;
  l = l % 2019;
  if (r < l) {
    r += 2019;
  }
  for (int i=l;i<=r;i++) {
    for (int j=i+1;j<=r;j++) {
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> l >> r;
  solve();
}


Measured memory_bytes: 256
# coding: utf-8
import math
h, w = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

i = 0
l = []
flg = True
while i < N:
    if A[i] > 0:
        if flg:
            l.append(str(i+1))
        else:
            l.insert(0,str(i+1))
        A[i] -= 1
    else:
        i += 1
    if len(l) == w:
        print(' '.join(l))
        if flg:
            flg = False
        else:
            flg = True
        l = []

Measured memory_bytes: 3188
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

int main() {
	ll ans[4];
	REP(i, 0, 3) {
		ans[i] = 1e10;
	}
	ll a, b;
	cin >> a >> b;
	if (a <= b) {
		ans[0] = b - a;
	}
	if (a <= -b) {
		ans[1] = -b - a + 1;
	}
	if (-a <= b) {
		ans[2] = b + a + 1;
	}
	if (-a <= -b) {
		ans[3] = -b + a + 2;
	}
	cout << min({ ans[0],ans[1],ans[2],ans[3] }) << endl;

		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};



int main()
{

int n,k;
cin>>n>>k;


for(int i=1;i<=k;i++){
	mint a1,a2,ans;
	combination c1(n-k+1);
	combination c2(k-1);
	a1=c1(n-k+1,i);
	a2=c2(k-1,i-1);
	ans=a1*a2;
	cout<<ans<<endl;
}
}


Measured memory_bytes: 256
#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 INF 1e9
#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;

ll mod=1000000007;

int main() {
  int a,b;cin >> a >> b;
  if(a <10 && b<10)cout << a*b;
  else cout << -1;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  int half=n/2;
  int a,b;
  a=d[half-1];
  b=d[half];
  int ans;
  ans=b-a;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N;
  int sum = 0;
  cin>>N;
  for(int i = 0;i < N; i++){
    int x,y;
    
    cin>>x>>y;
    sum = sum + y - x + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s0 = [input() for _ in range(n)]
s1 = [input() for _ in range(m)]


def match(i0, i1):
    for j0 in range(m):
        for j1 in range(m):
            if s0[i0 + j0][i1 + j1] != s1[j0][j1]:
                return False
    return True


def answer():
    for i0 in range(n - m + 1):
        for i1 in range(n - m + 1):
            if match(i0, i1):
                return True
    return False


if answer():
    print("Yes")
else:
    print("No")


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

int main(){
	int N, i, j;
	scanf("%d", &N);
	int *s = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &s[i]);
	}
	int M = N * 100;
	int *sum = (int *)malloc(sizeof(int) * M);
	for(i = 1; i < M; i++){
		sum[i] = 0;
	}
	sum[0] = 1;
	for(i = 0; i < N; i++){
		for(j = M - 1; j >= s[i]; j--){
			if(sum[j] == 0 && sum[j - s[i]] == 1){
				sum[j] = 1;
			}
		}
	}
	/*for(i = 0; i < M; i++){
		printf("sum[%d] = %d\n", i, sum[i]);
	}*/
	for(j = M - 1; j >= 0; j--){
		if(sum[j] == 1 && j % 10 != 0){
			printf("%d\n", j);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 256
def dfs(s, mx, n):
    if len(s) == n:
        print(s)
        return

    c = 'a'
    while c <= mx:
        nmx = mx
        if c == mx:
            nmx = chr(ord(c) + 1)
        dfs(s + c, nmx, n)
        c = chr(ord(c) + 1)

n = int(input())
dfs("", 'a', n)


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

string alpha = "IVXLCDM";
int val[] = {1, 5, 10, 50, 100, 500, 1000};

int indexOf(int ch) {
  for(int i = 0; i < (int)alpha.size(); i++) {
    if( alpha[i] == ch )
      return i;
  }
  return -1;
}

int main() {
  for(string str; cin >> str; ) {
    int sum = 0;
    for(int i = 0; i < (int)str.size(); i++) {
      if ( i + 1 < (int)str.size() && indexOf( str[i] ) < indexOf(str[i + 1]) ) {
          sum -= val[indexOf(str[i])];
        } else {
          sum += val[indexOf(str[i])];
        }
        }
      cout << sum << endl;
    }
    return 0;
  }

Measured memory_bytes: 0
#include <iostream>
#include <cstring>

const int WIN_SCORE = 3;
const int DRAW_SCORE = 1;

int main(void) {
  int n = 0;

  int taroScore = 0;
  int hanakoScore = 0;

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::string taroCard;
    std::string hanakoCard;

    std::cin >> taroCard;
    std::cin >> hanakoCard;

    if (taroCard.compare(hanakoCard) > 0) {
      taroScore += WIN_SCORE;
    } else if (taroCard.compare(hanakoCard) < 0) {
      hanakoScore += WIN_SCORE;
    } else {
      taroScore += DRAW_SCORE;
      hanakoScore += DRAW_SCORE;
    }
  }

  std::cout << taroScore << " " << hanakoScore << std::endl;
  
  return 0;
}

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

using namespace std;


int main() {
	int a, b;
	string op;
	cin >> a >> op >> b;
	if (op == "+")
	{
		cout << a + b << endl;
	}
	else if (op == "-")
	{
		cout << a - b << endl;
	}
}

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

int n, m;
int q;

/// --- Union Find Library {{{ ///

struct UF {
  int n;
  vector<int> par, rank;
  UF(int n): n(n), par(n, -1), rank(n, 0) {}
  int find(int x) {
    return par[x] < 0 ? x : par[x] = find(par[x]);
  }
  int size(int x) {
    return -par[find(x)];
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(rank[a] > rank[b]) swap(a, b);
    par[b] += par[a];
    par[a] = b;
    if(rank[a] == rank[b]) rank[b]++;
  }
};

/// }}}--- ///

using P = tuple<int, int, int>;
const int N = 4000;
vector<int> tree[N];
vector<pair<int, int>> treetwo[N];

int g[N][N];
int par[N][13];
int dist[N][13];
int dep[N];

void dfs(int i, int p = -1, int d = 0) {
  par[i][0] = p;
  dep[i] = d;
  if(p != -1) dist[i][0] = g[i][p];
  for(int j : tree[i]) if(j != p) {
    dfs(j, i, d + 1);
  }
}

void build() {
  dfs(0);
  for(int i = 1; i < 13; i++) {
    for(int j = 0; j < n; j++) {
      int p = par[j][i - 1];
      int d = dist[j][i - 1];
      if(p != -1) {
        par[j][i] = par[p][i - 1];
        dist[j][i] = max(d, dist[p][i - 1]);
      } else par[j][i] = -1;
    }
  }
}

int lca(int a, int b) {
  if(dep[a] > dep[b]) swap(a, b);
  // cerr << "dep ab = "<< dep[a] << " , " << dep[b] << endl;
  for(int i = 12; i >= 0; i--) {
    int p = par[b][i];
    if(p != -1 && dep[p] >= dep[a]) b = p;
  }
  if(a == b) return a;
  // cerr << "dep ab = "<< dep[a] << " , " << dep[b] << endl;
  // cerr << "ab = "<< a << " , " << b << endl;
  for(int i = 12; i >= 0; i--) {
    int pa = par[a][i];
    int pb = par[b][i];
    if(pa != pb) a = pa, b = pb;
  }
  return par[a][0];
}

int calc(int top, int a) {
  int res = 0;
  for(int i = 12; i >= 0; i--) {
    int p = par[a][i];
    if(p != -1 && dep[p] >= dep[top]) res = max(res, dist[a][i]), a = p;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;

  vector<P> es;
  for(int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    es.emplace_back(c, a, b);
  }
  sort(begin(es), end(es));

  UF treeone(n);
  ll cost = 0;

  // kruskal
  for(int i = 0; i < m; i++) {
    int a = get<1>(es[i]), b = get<2>(es[i]), c = get<0>(es[i]);
    if(!treeone.same(a, b)) {
      treeone.unite(a, b);
      tree[a].emplace_back(b);
      tree[b].emplace_back(a);
      treetwo[a].emplace_back(b, c);
      treetwo[b].emplace_back(a, c);
      g[a][b] = c;
      g[b][a] = c;
      cost += c;
    }
  }
  // doubling
  build();

  cin >> q;
  for(int i = 0; i < q; i++) {
    int s, t; cin >> s >> t;
    s--; t--;
    int l = lca(s, t);
    // cerr << "s = " << s + 1 << " , t = " << t + 1 << " , lca = " << l + 1 << endl;
    ll ans = cost;
    if(s == l) ans -= calc(s, t);
    else if(t == l) ans -= calc(t, s);
    else ans -= max(calc(l, s), calc(l, t));
    cout << ans << endl;
  }

}


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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'I') {
      cnt++;
    } else {
      cnt--;
    }
    ans = max(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
    std::string strb = "DEFGHIJKLMNOPQRSTUVWXYZABC";
    std::string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    std::map<char, int> m;
    for (int i = 0; i < 26; i++) m.insert({strb[i], i});
    std::string strc, res = "";
    std::cin >> strc;
    for (int i = 0; i < strc.size(); i++) {
        res += str[m[strc[i]]];
    }
    std::cout << res << std::endl;
    return  0;
}



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

int main(){
  int x,y,s;
  while(cin>>x>>y>>s,x!=0){
    int res=0;
    for(int i=1;i<=s;i++){
      for(int j=1;j<=s;j++){
	if(int(i*double(x+100)/100)+int(j*double(x+100)/100)==s){
	  res=max(res,int(i*double(y+100)/100)+int(j*double(y+100)/100));
	}
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define mod ll(2019)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    ll n = s.size();
    vector<ll> v(mod, 0LL);
    v[0] = 1;
    ll coef = 1;
    ll num = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll tmpnum = s[n-1-i]-'0';
        num += coef*tmpnum;
        num %= mod;
        coef *= 10;
        coef %= mod;
        v[num]++;
    }
    for(int i = 0; i < mod; i++){
        ans += v[i]*(v[i]-1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    ll n, k; cin >> n >> k;

    if (n < k) {
        if (n < abs(n - k)) cout << n << endl;
        else cout << abs(n - k) << endl;
        return 0;
    }

    n %= k;
    if (n < abs(n - k)) cout << n << endl;
    else cout << abs(n - k) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    auto sign = [](int x){
        if (x == 0) return 0;
        else if (x > 0) return 1;
        else return -1;};
    
    ll pos = 0, neg = 0;
    REP(i,2) {
        int now = 0;
        int prevsign = 0;
        ll count = 0;
        if (i == 0) prevsign = -1;
        else prevsign = 1;

        REP(j,n) {
            now += v[j];
            int s = sign(now);
            //cerr << i << " " << j << " " << now << " " << s;
            if (prevsign == s || s == 0) {
                count += abs(now) + 1;
                if (prevsign == 1) {
                    now = -1;
                } else {
                    now = 1;
                }
            }
            prevsign = sign(now);
            //cerr << " " << count << endl;
        }
        if (i == 0) pos = count;
        else neg = count;
    }

    cout << min(pos,neg) << endl;
    

    return 0;
}

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

int main() {
	int q;
	cin >> q;
	vector<int> v;

	for (int i = 0; i < q; i++) {
		int c; cin >> c;
		if (c == 0) {
			int x;
			cin >> x;
			v.push_back(x);
		}
		else if (c == 1) {
			int p;
			cin >> p;
			cout << v[p] << endl;
		}
		else {
			v.pop_back();
		}
	}

}
	



Measured memory_bytes: 3924
#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);
	ll a, b, c; cin>>a>>b>>c;
	cout << min(c, b/a) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include<stdio.h>
#include <string.h>
#include<algorithm>
#include <queue>
typedef long long ll;
const int mod=998244353;
const int maxn=1e6+5;
const ll INF=100000000000000005;
const double eps=1e-11;
using namespace std;
ll n,m,p;
struct node{
    int w,v;
    bool friend operator<(node a,node b)
    {
        return a.w<b.w;
        if(a.w==b.w) return a.w>b.w;
    }
}save[3005];
ll dp[3005][6005];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&save[i].w,&save[i].v);
    sort(save+1,save+1+n);
    for(int i=1;i<=n;i++)
    {
        for(int k=0;k<save[i].w+m;k++)
        {
            if(k>=save[i].w) dp[i][k]=max(dp[i-1][k],dp[i-1][k-save[i].w]+save[i].v);
            else dp[i][k]=dp[i-1][k];
        }
    }
    ll res=0;
    for(int i=1;i<=n;i++) res=max(dp[n][m+save[i].w-1],res);
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 141056
// IN THE NAME OF GOD "HEAD"
//OM NAMAHA SHIVAYA

#include <iostream>
using namespace std;
main()
{
    int  a,b,c,d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    while(a > 0  and c > 0)
    {
        a = a - d;
        c = c - b;
    }

    if(a <= 0 and c > 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

}





Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
using namespace std;
int pd[100010],arr[100010];
int main()
{
    int a,b,c,i;
    cin>>a>>b>>c;
    for(i=0;i<=1000;i++)
    {
        int a1,b1,c1;
        if((a&1)||(b&1)||(c&1))
        {
            cout<<i<<endl;
            break;
        }

            a1=(b/2+c/2);
            b1=(a/2+c/2);
            c1=(a/2+b/2);
            a=a1;
            b=b1;
            c=c1;
    
    }
    if(i==1001) cout<<-1<<endl;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			var positions = IO.ReadIntArray().ToList();
			positions.Insert(0 , positions[intArray[1] - 1] - intArray[0]);

			var checkDatas = Enumerable.Range(1 , intArray[1]).Select(iIndex =>
			{
				return new
				{
					Index = iIndex - 1,
					Distance = positions[iIndex] - positions[iIndex - 1]
				};
			})
			.ToArray();

			var maxDistanceData = checkDatas.Max(iData => iData.Distance);
			IO.Write(intArray[0] - maxDistanceData);
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

public class Test
{
	public static void Main()
	{
		// my code goes here
		int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		int l = s.Length;
		char[] c = new char[l];
		c = s.ToCharArray();
		int[] d = new int[l];
		for(int j=0;j!=l;j++){
			d[j] = (int)c[j];
			d[j] += n;
			if(d[j]>=91){
				d[j] -= 26;
			}
			c[j] = (char)d[j];
		}
		string ans = new string(c);
		Console.WriteLine(ans);
		
	}
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int t = sc.nextInt();
        long ans = 0;
        int preT = sc.nextInt();
        for (int i = 1; i < n; i++) {
            int ti = sc.nextInt();

            if (ti - preT >= t) {
                ans += t;
            } else {
                ans += ti - preT;
            }
            
            preT = ti;
        }
        System.out.println(ans + t);
    }
}


Measured memory_bytes: 62404
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <set>
#include <string>
//#include <cmath>
using namespace std;
int q,m,n,k,t,p,x,y,x1,y1,t1;
bool le;char ch;
int main()
{
    scanf("%d",&n);
    x=y=t=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%d%d%d",&t1,&x1,&y1);
        m=abs(x-x1)+abs(y-y1);
        if(t1-t<m||(t1-t-m)%2==1)
        {
            printf("No\n");
            return 0;
        }
        x=x1;
        y=y1;
        t=t1;
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,a[N];
int dp[88][3333],ok[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=2;i<=n;i++){
    if(a[i]>a[i-1])ok[i-1]=1;
  }
  LL last=1000;
  LL tmp=0;
  for(int i=1;i<=n;i++){
    if(ok[i]){
      tmp+=last/a[i];
      last%=a[i];
    }else{
      last+=1ll*tmp*a[i];
      tmp=0;
    }
  }
  cout<<last<<'\n';
  return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#define Max 100005
using namespace std;

vector<pair<int,int>>vec;

int par[Max];


bool cmp(pair<int,int>&a,pair<int,int>&b){
	return (a.second == b.second)?(a.first > b.first):(a.second > b.second);
}


int find(int x){
	if(x < 0)
		return x;
	else if(par[x] == x)
		return x;
	par[x] = find(par[x]);
	return par[x];
}




int main(){

	int n,m,x,y,i;

	for(i=0;i<Max;i++)
		par[i]=i;

	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		vec.push_back(make_pair(x,y));
	}

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

	int index,pos,reward = 0;

	for(i=0;i<vec.size();i++){
		index = find(m-vec[i].first);
		if(index < 0)
			continue;
		pos = find(index-1);
		par[index] = pos;
		reward += vec[i].second;
	}

	printf("%d\n",reward);

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
  rep (i, h) rep (j, w) cin >> a[i][j];
  rep (i, h) rep (j, w) cin >> b[i][j];
  vector<vector<int>> c(h, vector<int>(w));
  rep (i, h) rep (j, w) c[i][j] = abs(a[i][j] - b[i][j]);
  constexpr int maxdif = 80 * 160;
  vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(maxdif)));
  dp[0][0][c[0][0]] = true;
  rep (i, h) {
    rep (j, w) {
      rep (k, maxdif) {
        if (dp[i][j][k]) {
          if (i < h - 1) dp[i + 1][j][k + c[i + 1][j]] = dp[i + 1][j][abs(k - c[i + 1][j])] = true;
          if (j < w - 1) dp[i][j + 1][k + c[i][j + 1]] = dp[i][j + 1][abs(k - c[i][j + 1])] = true;
        }
      }
    }
  }
  rep (i, maxdif) {
    if (dp[h - 1][w - 1][i]) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

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

int H = 1, W = 1;

int main() {
    for (;H*W != 0;) {
        cin >> H >> W;
        if (H*W != 0) {
            for (int j=0; j<H; j++) {
            for (int i=0; i<W; i++) cout << '#';
            cout << endl;
            }
        cout << endl;
        }
    }
}


Measured memory_bytes: 3120
#include<stdio.h>
#include<string.h>
typedef struct {
	char direction[100];
	int num1,num2,num3,num4,num5,num6;
}DICE_t;
int main(){
	int n;
	scanf("%d",&n);
	DICE_t a[n];
	for(int x=0;x<n;x++){
	    scanf("%d %d %d %d %d %d",&a[x].num1,&a[x].num2,&a[x].num3,&a[x].num4,&a[x].num5,&a[x].num6);
	}
	int x,y;
	for(x=0;x<(n-1);x++){
		for(y=(x+1);y<n;y++){
	    int dummy,turn=0;
	    while(turn<24){
		    if(turn%4==0&&turn!=0){
		    	strcpy(a[y].direction,(turn%8==4 ?"SSEN":"ESEN"));
	    	}
    		else{
    			strcpy(a[y].direction,"SEN");
    		}
    	    for(int i=0;a[y].direction[i]!=0;i++){
    	        if(a[y].direction[i]=='N'){
		            dummy=a[y].num5;
	            	a[y].num5=a[y].num1;
	            	a[y].num1=a[y].num2;
	            	a[y].num2=a[y].num6;
	        	    a[y].num6=dummy;
	            }
	            else if(a[y].direction[i]=='S'){
		             dummy=a[y].num6;
	            	a[y].num6=a[y].num2;
	            	a[y].num2=a[y].num1;
	            	a[y].num1=a[y].num5;
	            	a[y].num5=dummy;
	            }
    	    	else if(a[y].direction[i]=='E'){
		            dummy=a[y].num4;
	        	    a[y].num4=a[y].num6;
	        	    a[y].num6=a[y].num3;
	        	    a[y].num3=a[y].num1;
	        	    a[y].num1=dummy;
	            }
	            else if(a[y].direction[i]=='W'){
	                dummy=a[y].num1;
	            	a[y].num1=a[y].num3;
	            	a[y].num3=a[y].num6;
	            	a[y].num6=a[y].num4;
	            	a[y].num4=dummy;
	            }	
    	    }
	    	if(a[x].num1==a[y].num1&&a[x].num2==a[y].num2&&a[x].num3==a[y].num3&&a[x].num4==a[y].num4&&a[x].num5==a[y].num5&&a[x].num6==a[y].num6)break;
	    	turn++;
	    }
		if(a[x].num1==a[y].num1&&a[x].num2==a[y].num2&&a[x].num3==a[y].num3&&a[x].num4==a[y].num4&&a[x].num5==a[y].num5&&a[x].num6==a[y].num6)break;
		}
	if(a[x].num1==a[y].num1&&a[x].num2==a[y].num2&&a[x].num3==a[y].num3&&a[x].num4==a[y].num4&&a[x].num5==a[y].num5&&a[x].num6==a[y].num6)break;
	}
	if(a[x].num1==a[y].num1&&a[x].num2==a[y].num2&&a[x].num3==a[y].num3&&a[x].num4==a[y].num4&&a[x].num5==a[y].num5&&a[x].num6==a[y].num6){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int A, P; cin >> A >> P;
    int sum = A*3 + P;
    cout << sum / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long s = sc.nextLong();
        sc.close();

        int count = 0;
        while (s > 5) {
            if (s >= 500) {
                s -= 500;
                count += 1000;
            } else if (s >= 5) {
                s -= 5;
                count += 5;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,count=0;
  cin>>N;
  vector<ll> vec(N),v(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<N;i++){
    v.at(vec.at(i)-1)++;
  }
  for(ll i=0;i<N;i++){
    if(v.at(i)>=2){count+=v.at(i)*(v.at(i)-1)/2;}
  }
  for(ll i=0;i<N;i++){
    if(count==0){cout<<0<<endl;}
    else if(v.at(vec.at(i)-1)>1){
    count-=v.at(vec.at(i)-1)-1;
    cout<<count<<endl;
    count+=v.at(vec.at(i)-1)-1;
    }else{
    cout<<count<<endl;
    }
  }
}

Measured memory_bytes: 5760
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  n = int(input())
  s = input()
  ans = 0
  x = 0
  for i in range(n):
    if s[i] == 'I':
      x += 1
      ans = max(ans,x)
    elif s[i] == 'D':
      x -= 1
      ans = max(ans,x)
  print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut maru = 0;
    for i in 0..s.len() {
        if s[i] == 'o' {
            maru += 1;
        }
    }
    if max(0, 15 - s.len() as i32) + maru >= 8 {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

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


Measured memory_bytes: 4352
N,X,Y=map(int,input().split())

X-=1
Y-=1
A=[0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        a=min(j-i,abs(j-Y)+1+abs(X-i))
        A[a-1]+=1

for i in A:
    print(i)



Measured memory_bytes: 3444
#!/usr/bin/env python3
import sys


def solve(M: int):
    print(48-M)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    solve(M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    string s,t; cin>>s>>t;

    int g=__gcd(N,M);
    for(int i=0;i<g;i++){
        int a=N/g*i;
        int b=M/g*i;
        if(s[a]!=t[b]){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<N/g*M<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>

using namespace std;

int main(){
  int i,j,k,n,m;
  string s;
  cin >> n;
  //cout << n/2+1 << endl;
  if(n%2==0)cout << n*n/4 << endl;
  else cout << (n/2+1)*(n/2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int x, y, z,tmp;
    scanf("%d %d %d", &x, &y, &z);

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z=tmp;

    printf("%d %d %d",x,y,z);
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
 ll n, k;
 cin >> n >> k;
 cout << (n >= 10 ? k : k + 100 * (10 - n)) << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1000000000 + 7, INF = 1e18;

lint N;
string s;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	cin >> s;
	lint cnt = 0;
	REP(i, N - 1) {
		if (s[i + 1] == 'E') cnt++;
	}
	lint minv = cnt;
	REP(i, N - 1) {
		if (s[i] == 'W') cnt++;
		if (s[i + 1] == 'E') cnt--;
		chmin(minv, cnt);
	}
	cout << minv << endl;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define N 2005
#define mod 1000000007

using namespace std;

int n,m,ans;
char mp[N][N];
int s[N][N],x[N][N],z[N][N],y[N][N];

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n;++i)
		scanf("%s",mp[i] + 1);
	for(int i = 1 ; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			if(mp[i][j] == '.')
				z[i][j] = z[i][j - 1] + 1;
	for(int i = 1 ; i <= n; ++i)
		for(int j = m; j >= 1; --j)
			if(mp[i][j] == '.')
				y[i][j] = y[i][j + 1] + 1;
	for(int i = 1 ; i <= m; ++i)
		for(int j = 1; j <= n; ++j)
			if(mp[j][i] == '.')
				s[j][i] = s[j - 1][i] + 1;
	for(int i = 1 ; i <= m; ++i)
		for(int j = n; j >= 1; --j)
			if(mp[j][i] == '.')
				x[j][i] = x[j + 1][i] + 1;
	for(int i = 1; i <= n;++i)
		for(int j = 1; j <= m; ++j)
			ans = max(ans,s[i][j] + x[i][j] + z[i][j] + y[i][j] - 3);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 66944
use std::io;


fn main() {
    loop {
        let mut x = read::<usize>();
        if x.iter().all(|&n| n == 0) { break; }
        x.sort();
        println!("{} {}", x[0], x[1]);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  string S;
  cin >> N >> S;
  ll R = 0;
  ll G = 0;
  ll B = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      R++;
    } else if (S[i] == 'G') {
      G++;
    } else {
      B++;
    }
  }
  ll ans = R*G*B;

  for (int i = 1; i < N; i++) {
    for (int j = 0; j+i+i < N; j++) {
      if (S[j] != S[j+i] && S[j+i] != S[j+i+i] && S[j+i+i] != S[j]) {
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static readonly long MOD = 1000000000 + 7;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = ReadLine().Split(' ').Select(int.Parse).ToList();

            int v = 0;
            int e = 0;
            for (int i = 0; i < n; i++)
            {
                v += a[i];
            }
            for (int i = 1; i < n; i++)
            {
                e += Math.Min(a[i - 1], a[i]);
            }
            int ans = v - e;
            WriteLine(ans);
        }
    }
}



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

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, min;

    // A, B, C 入力
    scanf("%d%d%d", &a, &b, &c);

    min = b/a;

    if (c < min) min = c;

    printf("%d\n", min);

    return 0;
}


Measured memory_bytes: 128
// https://atcoder.jp/contests/agc014/tasks/agc014_b
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> v(n + 1, 0);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }
    bool ans = true;
    for (auto x : v) {
        if (x % 2 != 0) {
            ans = false;
            break;
        }
    }
    if (ans)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


Measured memory_bytes: 640
import math
LogT={1:1}
def  div2(X):
    if X in LogT:
        return LogT[X]
    else:
        v = 1+div2(math.floor(X/2))*2
        LogT[X]=v
        return v

if __name__=='__main__':
    H=int(input())
    print (div2(H))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 int inf = 1001001001;

int n;
vector<vector<int>> tree;
vector<int> cnt,ans;

void dfs(int now = 0,int p = -1,int sum = 0) {
    sum += cnt[now];
    ans[now] = sum;
    for(int i : tree[now]) {
        if(i == p) continue;
        dfs(i,now,sum);
    }
}

int main() {
    int q;
    cin >> n >> q;
    tree.resize(n);
    cnt.resize(n);
    ans.resize(n);
    rep(i,n) ans[i] = -1;
    rep(i,n-1) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    rep(i,q) {
        int p,x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }
    dfs();
    rep(i,n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    string S;cin >> S;  
    vector<int> W(S.size());
    vector<int> R(S.size());
    int lim = S.size();

    int ru = 0;
    rep(i,lim){
        if(S[i] == 'W'){
            ru++;
            W[i] = ru;
        }
        else{
            W[i] = ru;
        }
    }
    ru = 0;
    for(int i = lim-1;i >= 0;i--){
        if(S[i] == 'R'){
            ru++;

        }
        R[i] = ru;
    }

    int wn = W[lim-1];
    int rn = R[0];

    int ans = 0;
        rep(i,lim){
            if(W[i] >= R[i]){
                ans = R[i];
                break;
            }
            else if(S[i] == 'R'){
                if(W[i] + 1 >= R[i]){
                    ans = R[i] - 1;
                    break;
                }
            }
        }



    cout << ans << endl;
}

Measured memory_bytes: 5224
n,m = map(int,input().split())

a = [1] * (n+1)

for i in range(m):
    a[int(input())] = 0

for i in range(n+1):
    if i > 1:
        a[i] = (a[i-2] + a[i-1])%(10**9+7) * a[i]

print(a[n])


Measured memory_bytes: 6964
#include <stdio.h>
void aprint(int[],int);
void insertionSort(int[],int);
int main(){
  int N;
  int i;
  int A[100];

  scanf("%d",&N);
  while(N<0&&N>100){
    scanf("%d",&N);
  }
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  aprint(A,N);
  insertionSort(A,N);
  return 0;
}

void insertionSort(int A[],int N){
  int i,j,v;

  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    aprint(A,N);
  }
}

void aprint(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2124
s=gets.chomp

count=0
n=s.length
(n-1).times do |i|
    if s[i]==s[i+1]
        count+=1
        if s[i+1]=="0"
            s[i+1]="1"
        else
            s[i+1]="0"
        end
    end
end
puts count


Measured memory_bytes: 14508