akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	int p = 0;
	Pi pg = mp(0,0);
	for (char i:s){
		p += (i == 'p');
	} 
	for(char i:s){
		if(i=='p'){
			pg.F++;
			clog << 'p';
		}else{
			if(pg.S <p or pg.F == pg.S){
				pg.S++;
				clog << 'g';
			}else{
				ans++;
				pg.F++;
				p++;
				clog << 'p';
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    cin>>n;
    cout<<24-n+24<<endl;
    return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, W, h, w; cin >> H >> W >> h >> w;
  if (H % h == 0 && W % w == 0) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  ll rev = false;
  if (H % h == 0) {
    swap(H, W);
    swap(h, w);
    rev = true;
  }
  ll y = H / h;
  ll v = y + 1;
  ll vv = -((h - 1) * v + 1);
  vector pat(H, v);
  for (ll i = 0; i < H; i++) pat.at(i) = i % h == h-1 ? vv : v;
  if (rev) {
    for (ll i = 0; i < W; i++) {
      for (ll j = 0; j < H; j++) {
	if (j > 0) cout << " ";
	cout << pat.at(j);
      }
      cout << "\n";
    }
  }else {
    for (ll i = 0; i < H; i++) {
      for (ll j = 0; j < W; j++) {
	if (j > 0) cout << " ";
	cout << pat.at(i);
      }
      cout << "\n";
    }
  }

  return 0;
}



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

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


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

int main(){

    string n;cin >> n;

    for(int i=0;i<3;++i){
        if(n[i]=='1')n[i]='9';
        else if(n[i]=='9')n[i]='1';
        else continue;
    }

    cout << n << endl;

    return 0;

}


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

using namespace std;


int main()
{
	int k;
	cin >> k;
	int start = 0;
	int limit = 8;

	vector<long long> mem;

	for (int i = 1; i <= 9; i++) mem.push_back(i);

	if (k <= 9) {
		cout << k << endl;
		return 0;
	}

	while (k > mem.size()) {

		for (int i = start; i <= limit; i++) {

			if (mem[i] % 10 == 0) {
				mem.push_back(mem[i]*10);
				mem.push_back(mem[i]*10 + 1);
			}
			else if (mem[i] % 10 == 9) {
				mem.push_back(mem[i] * 10 + 8);
				mem.push_back(mem[i] * 10 + 9);
			}
			else {
				mem.push_back(mem[i] * 10 + mem[i] % 10 - 1);
				mem.push_back(mem[i] * 10 + mem[i] % 10 - 0);
				mem.push_back(mem[i] * 10 + mem[i] % 10 + 1);
			}
		}


		start = limit + 1;
		limit = mem.size() - 1;

	}


	cout << mem[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 2420
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll a; cin >> a;
	string b; cin >> b;
	int c = ((b[2] - '0') * 10) + (b[3] - '0');
	ll res = a * ((b[0] - '0') * 100 + c);
	cout << res / 100 << endl;
}

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

void dfs(const int parent, const int now, vector<int> &memo, const vector<vector<int>> &w) {
    if (memo.at(now) != -1) return;

    memo.at(now) = parent;

    for (int i = 0; i < (int)w.at(now).size(); i++) {
        dfs(parent, w.at(now).at(i), memo, w);
    }
}

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    vector<vector<int>> road(n);
    vector<vector<int>> rail(n);
    for (int i = 0; i < k; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        road.at(p).push_back(q);
        road.at(q).push_back(p);
    }
    for (int i = 0; i < l; i++) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        rail.at(r).push_back(s);
        rail.at(s).push_back(r);
    }

    vector<int> memo_road(n, -1), memo_rail(n, -1);
    for (int i = 0; i < n; i++) {
        dfs(i, i, memo_road, road);
        dfs(i, i, memo_rail, rail);
    }

    using P = pair<int, int>;
    map<P, int> m;
    for (int i = 0; i < n; i++) {
        m[P(memo_road.at(i), memo_rail.at(i))]++;
    }

    for (int i = 0; i < n; i++) {
        cout << m[P(memo_road.at(i), memo_rail.at(i))] << " ";
    }
    cout << endl;
}   

Measured memory_bytes: 27776
N, M = map(int,input().split())
A = [0]*N
B = [0]*N
d = {}

for i in range(N):
  A[i],B[i] = map(int, input().split())
  d[str(i)] = A[i]

a = sorted(d.items(), key=lambda x:x[1])
ans=0

for i in range(N):
  if M>B[int(a[i][0])]:
    M-=B[int(a[i][0])]
    ans += a[i][1]*B[int(a[i][0])]
  else:
    ans += a[i][1]*M
    break
    
print(ans)

Measured memory_bytes: 36920
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
    int n,i,j,k,a[100],tmp,count=0;
    char input[4001],*p;
     
    fgets(input,sizeof input,stdin);
    sscanf(input,"%d",&n);
     
    fgets(input,sizeof input,stdin);
    p=strtok(input," ");
    a[0]=atoi(p);
     
    for(i=1;i<n;i++){
        p=strtok(NULL," ");
        a[i]=atoi(p);
    }
     
    k=n-1;
    for(i=0;i<n-1;i++){
        for(j=0;j<k;j++){
            if(a[j]>a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
                count++;
            }
        }
        k--;
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i!=n-1){
            printf(" ");
        }
    }
    printf("\n%d\n",count);
     
     
     
     
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    long long ans = 0;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    long long i = 0, j = 0;
    while(i < n){
        if(s[j] == s[i]){
            i++;
        }
        else{
            ans += (i - j) * (i - j - 1) / 2;
            j = i;
        }
    }
    ans += (i - j) * (i - j - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

int main()
{
  long double pi = 3.14159265358979323846264338327950;
  long double A,B,C,H,M,h,m,angle;
  cin >>A >>B >>H >>M;
  
  //H時M分の時針の角度
  h = 30*H + 0.5*M;
  //cout << "h" << h << endl;
  
  //H時M分の分針の角度
  m = 6*M;
  //cout << "m" << m << endl;
  
  //time時点のAとBの角度の絶対値
  angle = abs(h-m);
  //cout << "angle" << angle << endl;
  
  //180度以内の方へ
  if(angle > 180)
  {
    angle = 360-angle;
  }
  //cout << "angle" << angle << endl;
  
  //cout << "cos" << cos(pi*angle/180) << endl;
  
  //Cを計算
  C = A*A + B*B - 2*A*B*cos(pi*angle/180);
  C = sqrt(C);
  cout << fixed << setprecision(15) << C << endl;

  
}


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

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{


int x;
cin >> x;

int ans=0,temp;
  temp=x/500;
  ans+=temp*1000;

  x=x%500;

  temp=x/5;
  ans+=temp*5;

  cout<<ans;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
	ll ret;
	
cin >> n;
	if (((n%10)==0) || ((n%10)==1) || ((n%10)==6) || ((n%10)==8)) {
		cout << "pon" << endl;
	} else if (n%10==3) {
		cout << "bon" << endl;
	} else {
		cout << "hon" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3580
#!/usr/bin/env python3

S = str(input())
# print(S)

def is_ATGC(char):
    if char == "A" or char == "C" or char == "G" or char == "T":
        return True
    return False

def is_ATGC_str(s):
    is_ATGC_str = True
    for char in s:
        if not is_ATGC(char):
            is_ATGC_str = False
    return is_ATGC_str

len_max = 0
for start in range(len(S)):
    for end in range(start+1, len(S)+1):
        # print(start, end)
        # print(S[start:end])
        s = S[start:end]
        if is_ATGC_str(s) and len(s) > len_max:
            len_max = len(s)

print(len_max)


Measured memory_bytes: 38384
fn main() {
    let mut buf = String::new();

    std::io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.trim().split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    let message = if a < b {
        "a < b"
    }else if a > b {
        "a > b"
    }else {
        "a == b"
    };

    println!("{}", message);
}


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

using namespace std;

int main()
{
    string a, b;
    cin>>a>>b;
    int m, n;
    m = a.length();
    n = b.length();
    int dp[m+1][n+1];
    for(int i = 0; i <= m; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(a[i-1] == b[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]); 
        }
    }
    
    string c;
    if(dp[m][n] == 0) c.push_back(' ');
    int i = m;
    int j = n;
    while(i > 0 && j > 0)
    {
        if(a[i-1] == b[j-1])
        {
            c.push_back(a[i-1]);
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
            
        }
    }
    reverse(c.begin(),c.end());
    cout << c;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int h, w;
vector<string> c;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> h >> w;
    c.resize(h);
    inc(i, 0, h) cin >> c[i];
    string ans = "Yes";
    inc(i, 0, h){
        inc(j, 0, w){
            int cnt = 0;
            if(c[i][j] == '.') continue;
            inc(k, 0, 4){
                int ni = i + di[k];
                int nj = j + dj[k];
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(c[ni][nj] == '#') cnt++;
            }
            if(cnt == 0) ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(n) rep(i,n)
typedef long long ll;
using namespace std;

int n;
ll A[30];
int year[30];

signed main()
{
	A[0] = 1; A[1] = 2; A[2] = 4;
	year[0] = 1; year[1] = 1; year[2] = 1;
	
	for (int i=3; i<30; i++)
	{
		A[i] = A[i-1] + A[i-2] + A[i-3];
		if (A[i] % 3650 > 0) year[i] = A[i] / 3650 + 1;
		else year[i] = A[i] / 3650;
	}
	
	while (cin >> n, n)
	{
		printf("%d\n", year[n-1]);
	}
	
	return 0;
}

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

using usize = ::std::size_t;
//using u64 = ::std::uint_least64_t;
using u64 = long long;


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
    
    u64 N, M;
    
    while (cin >> N >> M, N >0 && M>0) {
        
        vector<vector<u64>> dp(N + 1, vector<u64>(256, Inf));
        vector<u64> c(M+1), x(N+1);
        
        for (int i = 1; i <= M; i++) {
            cin >> c[i];
        }
        for (int i = 1; i <= N; i++) {
            cin >> x[i];
        }
        dp[0][128] = 0;
        
        
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= 255; j++) {
                for (int k = 1; k <= M; k++) {
                    if (j == 0) {
                        for (int jj = 0; jj <= -c[k]; jj++) {
                            if (dp[i - 1][jj] == Inf) {
                                continue;
                            }
                            dp[i][j] = min(dp[i][j], dp[i - 1][jj] + (x[i] - j)*(x[i] - j));
                        }
                    } else if (j == 255){
                        for (u64 jj = 255 - c[k]; jj <= 255; jj++) {
                            if (dp[i - 1][jj] == Inf) {
                                continue;
                            }
                            dp[i][j] = min(dp[i][j], dp[i - 1][jj] + (x[i] - j)*(x[i] - j));
                        }
                    } else if (j - c[k] >= 0 && j - c[k] <= 255) {
                        u64 jj = j - c[k];
                        if (dp[i - 1][jj] == Inf) {
                            continue;
                        }
                        dp[i][j] = min(dp[i][j], dp[i - 1][jj] + (x[i] - j)*(x[i] - j));
                    }
                }
            }
        }
        
        u64 min_dif = Inf;
        for (int i = 0; i <= 255; i++) {
            min_dif = min(min_dif, dp[N][i]);
        }
        cout << min_dif << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 43984
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int a,b,c; cin >> a >> b >> c;
cout << min(a+b, min(b+c, c+a)) << endl;

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];
int n, D[MAX],H[MAX];

void depth( int s, int d ){
  if( s == NIL )return;
  D[s] = d;
  depth( T[s].left, d + 1 );
  depth( T[s].right, d + 1 );
}

int height( int s ){
  int h1 = 0, h2 = 0;
  if( T[s].left != NIL ){
    h1 = height( T[s].left ) + 1;
  }
  if( T[s].right != NIL ){
    h2 = height( T[s].right ) + 1;
  }

  if( h1 < h2 )return H[s] = h2;
  else return H[s] = h1;
}

int sibling( int s ){
  if( T[s].parent == NIL )return NIL;
  if( T[T[s].parent].left != NIL && T[T[s].parent].left != s ){
    return T[T[s].parent].left;
  }
  if( T[T[s].parent].right != NIL && T[T[s].parent].right != s ){
    return T[T[s].parent].right;
  }
  return NIL;
}

void print( int s ){
  printf("node %d: ", s);
  printf("parent = %d, ",T[s].parent);
  printf("sibling = %d, ",sibling(s));
  int deg = 0;
  if( T[s].left != NIL )deg++;
  if( T[s].right != NIL )deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[s]);
  printf("height = %d, ", H[s]);
  if( T[s].parent == NIL ){
    printf("root\n");
  }
  else if( T[s].left == NIL && T[s].right == NIL ){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main( void ){
  int v,l,r,root = 0,i;
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    T[i].parent = NIL;
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if( l != NIL )T[l].parent = v;
    if( r != NIL )T[r].parent = v;
  }

  for( i = 0 ; i < n ; i++ ){
    if( T[i].parent == NIL )root = i;
  }
  depth( root, 0 );
  height( root );
  for( i = 0 ; i < n ; i++ )print(i);

  return 0;
}

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

using namespace std;

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

  int n = 0;

  for (unsigned int i = 0; i < s.size() / 2; i++){
    if (s[i] != s[s.size() - i - 1])
      n++;
  }


  cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n;
    cin >> n;
    int ans =0;
    for(int i=0;i<n;i++){
        int m;
        cin >> m;
        int j;
        ans++;
        for(j=2;j*j<=m;j++){
            if(m%j==0){ans--;break;}
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int, input().split()))
number = []
for i in range(N):
  number.append(0)

for i in range(N-1):
  n = A[i-1]*1
  number[n] = number[n] + 1

del number[0]
number.append(0)
for Answer in number:
  print(Answer)


Measured memory_bytes: 32252
#include<stdio.h>
#include<string.h>
int main()
{
    char s[10],t[10];
    int a,b;
    char u[10];


    // 整数の入力
    scanf("%s %s", &s,&t);
    // スペース区切りの整数の入力
    scanf("%d %d",&a,&b);
    // 文字列の入力
    scanf("%s",&u);

    //if (s == u)
    //printf("strcmp%d",strcmp(s,u));
    if (strcmp(s,u)==0)
    {
        a--;
    }
    else if (strcmp(t,u)==0)
    {
        b--;
    }

    // 出力
    printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int[] heightArr = new int[n];
        for (int i = 0; i < n; i++) {
            heightArr[i] = sc.nextInt();
        }

        int hotelCount = 0;
        for (int i = 0; i < heightArr.length; i++) {
            if (i == 0) {
                // 一番西の場合は必ず海が見える
                hotelCount++;
                continue;
            }

            boolean canSeeSea = true;
            for (int j = 0; j < i; j++) {
                if (heightArr[j] > heightArr[i]) {
                    canSeeSea = false;
                    break;
                }
            }

            if (canSeeSea) {
                hotelCount++;
            }
        }

        System.out.println(hotelCount);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

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

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N  = sc.nextLong();
		long M  = sc.nextLong();
		
		if(N >= M) {
			System.out.println(M / 2);
		} else {
			if(N > M / 2) {
				System.out.println(M / 2);
			} else {
				System.out.println(N + (M - N * 2) / 4);
			}
		}	
	}
}


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

int main()
{
    const double PI = acos(-1.0);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    auto f = [&](double t) {
        if (tan(t) <= b / a)
            return a * b - a * (a * tan(t)) / 2;
        else
            return b * (b / tan(t)) / 2;
    };
    double left = 0, right = PI / 2;
    for (int iter = 0; iter < 100; ++iter)
    {
        double theta = (left + right) / 2;
        if (f(theta) >= x)
            left = theta;
        else
            right = theta;
    }
    cout << fixed << setprecision(10) << left * 180 / PI << endl;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    vector<vector<int> > x(n),y(n);

    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
        for(int j = 0;j < a.at(i);j ++){
            x.at(i).push_back(0);
            y.at(i).push_back(0);
            cin >> x.at(i).at(j) >> y.at(i).at(j);
            x.at(i).at(j) --;
        }
    }

    int ans = 0;

    for(int bit = 0;bit < (1 << n);bit ++){
        bool hantei = true;

        for(int i = 0;i < n;i ++){
            if(!(bit & (1 << i))) continue;

            for(int j = 0;j < a.at(i);j ++){
                if(((bit & (1 << x.at(i).at(j))) && y.at(i).at(j) == 1) 
                || (!(bit & (1 << x.at(i).at(j))) && y.at(i).at(j) == 0)){

                }else{
                    hantei = false;
                }
            }
        }

        if(hantei == false) continue;

        int r = 0;
        for(int i = 0;i < n;i ++){
            if(bit & (1 << i)) r ++;
        }

        ans = max(ans,r);

    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int sum, cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                sum = 500 * i + 100 * j + 50 * k;
                if (sum == x) {
                    cnt++;
                    break;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()

	str := sc.Text()

	a := str[0]
	var b byte

	cnt := 0
	for i := 1; i < 4; i++ {
		if str[i] == a {
			cnt++
		} else {
			b = str[i]
		}
	}
	if cnt != 1 || b == 0 {
		fmt.Println("No")
		return
	}

	cnt = 0
	for i := 1; i < 4; i++ {
		if str[i] == b {
			cnt++
		}
	}
	if cnt != 2 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	char a,b,c,d;
	d = 'A';
	while(cin >> a >> b >> c){
		if(a==d) d = c;
		else if(c==d) d = a;
	}
	cout << d << endl;
}

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

void answer1() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, Y;
  cin >> N >> Y;

  // x + y + z = N &&
  // 10000 * x + 5000 * y + 1000 * z == Y
  bool can_continue = true;
  for (int x = 0; x <= Y / 10000; x++) {
    if (x > N) {
      break;
    }
    int x_made = x * 10000;

    for (int y = 0; y <= Y / 5000; y++) {
      int y_made = x_made + y * 5000;
      if (y_made > Y || x + y > N){
        break;
      }

      for (int z = 0; z <= Y / 1000; z++) {
        int z_made = y_made + z * 1000;
        if (z_made > Y || x + y + z > N) {
          break;
        } else if (z_made == Y && x + y + z == N){
          printf("%d %d %d\n", x, y, z);
          can_continue = false;
        }
      }
      if (! can_continue){
        break;
      }
    }
    if (! can_continue){
      break;
    }
  }
  if (can_continue) {
    printf("%d %d %d\n", -1, -1, -1);
  }
}

void answer2() {
  cin.tie(0);
	ios_base::sync_with_stdio(false);

  int N, Y;
  cin >> N >> Y;

  // x + y + z = N &&
  // 10000 * x + 5000 * y + 1000 * z == Y
  bool can_continue = true;
  for (int x = 0; x <= Y / 10000; x++) {
    if (x > N) {
      break;
    }
    int x_made = x * 10000;

    for (int y = 0; y <= Y / 5000; y++) {
      int y_made = x_made + y * 5000;
      if (y_made > Y || x + y > N){
        break;
      }

      int z = N - x - y;
      int z_made = y_made + z * 1000;
      if (z_made == Y) {
        printf("%d %d %d\n", x, y, z);
        can_continue = false;
        break;
      }
    }
    if (! can_continue){
      break;
    }
  }
  if (can_continue) {
    printf("%d %d %d\n", -1, -1, -1);
  }
}

int main() {
  //answer1(); // 実行時間制限超過
  answer2();
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let S: String = read();
    let mut before = S.chars().next().unwrap();
    let mut ans = 0;
    for c in S.chars() {
        if c != before {
            ans += 1;
            before = c;
        }
    }
    println!("{}", ans)
}


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    double  A,B,H,M;
    cin >>A>>B>>H>>M;
    long double  pi=3.141592653589793;
    double angle=0;
     double  angleH=30*H+M/2;
    double   angleM=6*M;
    if(angleH>angleM)angle =pi*(angleH-angleM)/180;
    else angle =pi*(angleM-angleH)/180;
    
    double ans=sqrt(A*A+B*B-2*A*B*cos(angle));
    cout <<fixed <<setprecision(20)<<ans;
return 0;
}

Measured memory_bytes: 4228
import itertools
a=input().split()
#print(type(a))
b=itertools.permutations('575')
b=list(b)
flag=0
for i in range(len(list(b))):
  c=b[i][0]+b[i][1]+b[i][2]
#  print(type(c))
  if list(c)==a:
    flag=1
print('YES' if flag==1 else 'NO' )
               

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+5;
const ll mod=1e9+7;
vi v(MAX);
void fun(ll n,ll k)
{
    ll dp[105][MAX];
    memset(dp,0,sizeof(dp));
    ll prefixsum[MAX];
    for(ll i=0;i<=n;i++)
    {
        dp[i][0]=1;
    }
    for(ll i=1;i<=n;i++)
    {
        prefixsum[0]=0;
        for(ll j=1;j<=k+1;j++)
        {
            prefixsum[j]=prefixsum[j-1]+dp[i-1][j-1];
        }
        for(ll j=1;j<=k;j++)
        {
            dp[i][j]=(prefixsum[j+1]-prefixsum[max((ll)0,j-v[i])]+mod)%mod;
        }
    }
    /*rep(i,0,n+1)
    {
        rep(j,0,k+1)
        {
            cout<<dp[i][j]<<"  ";

        }
        cout<<endl;
    }*/
    cout<<dp[n][k];
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {

   ll n,k;
   cin>>n>>k;
   rep(i,1,n+1)
   cin>>v[i];
   fun(n,k);
    }
    return 0;
}


Measured memory_bytes: 83968
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 087 A "Buying Sweets"
 *   https://abc087.contest.atcoder.jp/tasks/abc087_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int X = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();

		int ans = (X - A) % B;

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-7
#define zero(x) (((x) > 0? (x):(-x)) < eps)
using namespace std;
//https://codeforces.com/contest/1238/problems
//https://codeforces.com/contest/1238/submit

struct A{
    ll x,y,t;
}a[1000005];
int main(){
    ll n;
    ll h;
    ll sum  = 0ll;
    ll maxi = -1ll;
    sld(n)
    ll x,y;
    ll t0 = 0ll,t;
    int flag = 0;
    ll x0 = 0ll,y0 = 0ll;
    for(ll i = 0; i < n; i ++){
        sld(t) sld(x) sld(y)
        if(t -t0 >= abs(x-x0)+abs(y-y0)){
            if((t-t0)&1){
                if((abs(x-x0)+abs(y-y0))&1 ){
                    t0 = t;
                    x0 = x;
                    y0 = y;
                }else{
                    flag = 1;
                }
            }else{
                if((abs(x-x0)+abs(y-y0))&1 ){
                   flag = 1;
                }else{

                     t0 = t;
                    x0 = x;
                    y0 = y;
                }
            }

        }else{
            flag = 1;
        }
    }
    if(flag == 1){
        puts("No");
    }else{
        puts("Yes");
    }





    return 0;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
  Scanner sc;

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

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

  void run() {
    while(true) {
      int N = ni();
      int M = ni();
      int P = ni();

      if((N|M|P) == 0)break;

      int[] X = new int[N];
      int sum = 0;
      for(int i = 0; i < N; ++i) {
        sum += X[i] = ni();
      }
      int ans = 0;
      if(X[M-1] > 0) {
        ans = sum;
        ans *= 100 - P;
        ans /= X[M-1];
      }

      System.out.println(ans);
    }
  }

  int ni() {
    return sc.nextInt();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

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

void trace(int A[], int n){
    for (int i = 0; i < n-1; i++) cout << A[i] << " ";
    cout << A[n-1] << "\n";
}

int main() {
    int N, flag = 1, temp, count = 0, j;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];
    j = 0;

    while (flag){
        flag = 0;
        for (int i = N-1; i > j; i--){
            if (A[i] < A[i-1]){
                temp = A[i];
                A[i] = A[i-1];
                A[i-1] = temp;
                count++;
                flag = 1;
            }
        }
        j++;
    }
    trace(A,N);
    cout << count << endl;

    return 0;
}

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

string s;
int n,win,lose,match;

int main(){
	cin>>s;
	n = s.length();
	for(int i = 0;i < n;i++){
		if (s[i] == 'o'){
			win++;
		}else{
			lose++;
		}
		match++;
	}
	if((8 - win) <= (15 - match)){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static HashMap<String,Boolean> map = new HashMap<String,Boolean>();
	static int[] list;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			if(n == 0 && k == 0) break;
			map.clear();
			list = new int[n];
			for(int i = 0; i < n; i++) {
				list[i] = sc.nextInt();
			}
			dfs(0,new StringBuilder(),new boolean[n],k);
			System.out.println(map.size());
		}
	}
	static void dfs(int a, StringBuilder b, boolean[] c, int d) {
		if(a == d) {
			map.put(b.toString(), true);
			return;
		}
		for(int i = 0; i < c.length; i++) {
			if(c[i]) continue;
			b = b.append(String.valueOf(list[i]));
			c[i] = true;
			dfs(a+1,b,c,d);
			c[i] = false;
			b = b.deleteCharAt(b.length()-1);
			if(list[i] >= 10) b = b.deleteCharAt(b.length()-1);
		}
	}
	
}

Measured memory_bytes: 26448
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VT<pair<pair<string, int>, int>> vec(N);
    REP(i, N) {
        string s;
        int p;
        cin >> s >> p;
        vec[i] = MP(MP(s, -p), i);
    }
    SORT(vec);
    REP(i, N) {
        cout << vec[i].second + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, c;
    cin >> n >> c;
    vll x(n), v(n);
    rep(i, n) cin >> x[i] >> v[i];

    ll ans = 0;
    rep(_, 2) {
        vll sm(n+1, 0);
        rep(i, n) sm[i+1] += sm[i] + v[i];
        vll f(n+1, 0);
        rep(i, n) {
            f[i+1] = sm[i+1] - x[i];
            chmax(f[i+1], f[i]);
        }
        rep(i, n+1) {
            ll now;
            if (i == n) {
                now = f[i];
            } else {
                now = f[i] + sm[n] - sm[i] - 2 * (c - x[i]);
            }
            chmax(ans, now);
        }
        rep(i, n) {
            x[i] = c - x[i];
        }
        reverse(x.begin(), x.end());
        reverse(v.begin(), v.end());
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
H, W = map(int, input().split())
s = [input() for _ in range(H)]

L = [[-1] * W for _ in range(H)]
R = [[-1] * W for _ in range(H)]
D = [[-1] * W for _ in range(H)]
U = [[-1] * W for _ in range(H)]

for r in range(H):
    for c in range(W):
        if s[r][c] == '.':
            if c == 0:
                L[r][c] = 1
            else:
                L[r][c] = L[r][c - 1] + 1
        else:
            L[r][c] = 0

for r in range(H):
    for c in reversed(range(W)):
        if s[r][c] == '.':
            if c == W - 1:
                R[r][c] = 1
            else:
                R[r][c] = R[r][c + 1] + 1
        else:
            R[r][c] = 0

for r in range(H):
    for c in range(W):
        if s[r][c] == '.':
            if r == 0:
                U[r][c] = 1
            else:
                U[r][c] = U[r - 1][c] + 1
        else:
            U[r][c] = 0

for r in reversed(range(H)):
    for c in range(W):
        if s[r][c] == '.':
            if r == H - 1:
                D[r][c] = 1
            else:
                D[r][c] = D[r + 1][c] + 1
        else:
            D[r][c] = 0

ans = 0
for r in range(H):
    for c in range(W):
        ans = max(ans, L[r][c] + R[r][c] + D[r][c] + U[r][c] - 3)
print(ans)


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

int main() {
  int n; cin>>n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin>>vec.at(i);
  }
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    cout<<vec.at(i);
    if (i+1<n) cout<<' ';
    else cout<<endl;
  }
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    int ans = 0;
    cin >> n;
    int T;
    cin >> T;
    int t[200050];
    for(int i = 1; i <= n; i++) {
        cin >> t[i];
    }
    t[n + 1] = 2e9;
    for(int i = 1; i <= n; i++) {
        ans += min(T, t[i + 1] - t[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
        int a,b,c;
        cin >> a >> b >> c;

        int x=a,y=b,z=c;
        if(x>b){ x=b; y=a;}
        if(x>c){ x=c; z=a;}
        if(y>z){
                int tmp=z;
                z=y;
                y=tmp;
        }

        cout << z-x << endl;
        return 0;
}


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

int id[1005][1005];
int toID(int x, int y){
    if(x > y)swap(x, y);
    return id[x][y];
}

vector<vector<int> > to(1000005);

int d[1000005];
bool visited[1000005];
bool calc[1000005];
int dfs(int x){
    if(visited[x]){
        if(calc[x]){
            return d[x];
        } else {
            return -1;
        }
    }
    visited[x] = true;
    d[x] = 1;
    for(int p : to[x]){
        int k = dfs(p);
        if(k == -1)return -1;
        d[x] = max(d[x], k + 1);
    }
    calc[x] = true;
    return d[x];
}


int main() {
    int N; cin >> N;
    vector<vector<int> > A(N);
    rep(i, N){
        rep(j, N-1){
            int a; cin >> a;
            a--;
            A[i].push_back(a);
        }
    }

    int X = 0;
    rep(i, N){
        rep(j, N-1){
            int x = A[i][j];
            if(x > i){
                id[i][x] = X++;
            }
        }
    }

    rep(i, N){
        rep(j, N-1){
            A[i][j] = toID(i, A[i][j]);
        }
    }

    rep(i, N){
        rep(j, N-2){
            to[A[i][j]].push_back(A[i][j+1]);
        }
    }

    int ans = 0;
    rep(i, (N*N-1)/2){
        int y = dfs(i);
        if(y == -1){
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, y);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 53112
#include <stdio.h>

int main(void)
{
    int w[30];
    int n, i, m, a, b, t;

    scanf("%d", &n);
    for (i = 1; i <= n; i++){
        w[i] = i;
    }

    scanf("%d", &m);
    for (i = 1; i <= m; i++){
        scanf("%d,%d", &a, &b);
        t = w[b];
        w[b] = w[a];
        w[a] = t;
    }

    for (i = 1; i <= n; i++){
        printf("%d\n", w[i]);
    }

    return (0);
}


Measured memory_bytes: 1976
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;

struct UnionFind{
    vector<int> par,rank,elem;
    
    //初期化
    UnionFind(int n){
        for(int i=0;i<=n;++i){
            par.push_back(i);
            rank.push_back(0);
            elem.push_back(1);
        }
    }

    //根をFind
    int find(int i){
        if(par[i]==i)return i;

        return par[i]=find(par[i]);
    }

    //Union
    void unite(int x,int y){
        int rx=find(x);
        int ry=find(y);

        if(rx==ry)return;

        if(rank[rx]>rank[ry]){
            par[ry]=rx;
            elem[rx]+=elem[ry];
        }
        else{
            par[rx]=ry;
            elem[ry]+=elem[rx];
            if(rank[rx]==rank[ry])
                rank[ry]++;
        }
    }

    //要素数
    int element(int i){
        int pi=find(i);
        return elem[pi];
    }

    //同じ木に属するか判定
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
    int N,M;cin>>N>>M;
    int A[100010],B[100010];
    for(int i=0;i<M;i++)
        cin>>A[i]>>B[i];
    
    UnionFind UF(N);
    long long ans[100010];
    ans[M-1]=(long long)N*(N-1)/2;
    for(int i=0;i<M-1;i++){
        long long a=UF.element(A[M-1-i]);
        long long b=UF.element(B[M-1-i]);
        if(UF.same(A[M-1-i],B[M-1-i]))ans[M-2-i]=ans[M-1-i];
        else{
            UF.unite(A[M-1-i],B[M-1-i]);
            ans[M-2-i]=ans[M-1-i]-a*b;
        }
    }

    for(int i=0;i<M;i++)
        cout<<ans[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 4332