akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  //定義一覧
  int N;
  string S;
  int P = 0;
  int W = 0;
  int G = 0;
  int Y = 0;
  
  //繰り返し回数の入力
  cin >> N;
  //繰り返し
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "P"){
    	P = 1;
    }else if(S == "W"){
    	W = 1;
    }else if(S == "G"){
    	G = 1;
    }else if(S == "Y"){
    	Y = 1;
    }
  }
  
  if((P + W + G + Y) == 3){
  	cout << "Three" << endl;
  }else if((P + W + G + Y) == 4){
  	cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
}

int main() {
    string s;
    cin>>s;
    string t;
    t=s;
    ll k;
    cin>>k;
    ll n=s.size();
    s.push_back('_');
    ll ans=0;
    for(ll i=0;i<n;i++){
        if(s.at(i)==s.at(i+1)){
            ll cnt=0;
            for(ll j=i+1;j<n;j++){
                if(s.at(i)==s.at(j)){
                    cnt++;
                }
                else{
                    break;
                }
            }
            i+=cnt;
            ans+=(cnt+1)/2;
        }
    }
    string u = t+s;
    ll ans_=0;
    for(ll i=0;i<2*t.size();i++){
        if(u.at(i)==u.at(i+1)){
            ll cnt=0;
            for(ll j=i+1;j<2*t.size();j++){
                if(u.at(i)==u.at(j)){
                    cnt++;
                }
                else{
                    break;
                }
            }
            i+=cnt;
            ans_+=(cnt+1)/2;
        }
    }
    bool flag=true;
    for(int i=0;i<t.size();i++){
        if(t.at(0)!=t.at(i)){
            flag=false;
        }
    }
    if(flag){
        cout<<t.size()*k/2<<endl;
        return 0;
    }
    cout<<(ll)(ans_-ans)*(ll)(k-1)+(ll)ans<<endl;





    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<long long> h(n);
  for(int i=0;i<n;i++)cin>>h[i];
  int max=0,count=0;
  for(int i=1;i<n;i++){
    if(h[i-1]>=h[i])count++;
    else {
      max=std::max(count,max);
      count=0;
    }
  }
  max=std::max(count,max);
  cout<<max<<endl;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
//typedef __int64 LL;
typedef pair<int,int> P;
const int INF=100000000;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0; // 可能性として000 - 999 の 1000なのでint

    for (int i = 0; i < 1000; i++) {
        int c[3] = {i/100, (i/10)%10, i%10};
        int f = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == ('0' + c[f])) f++;
            if (f == 3) break;
        }
        if (f == 3) ans++;
    }

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

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int list[101];

int main(){
  int n, i, max=0;
  while(cin >> n){
    list[n]+=1;
  }
  for(i=1; i<101; i++){
    if(list[i] >= max)max=list[i];
  }
  for(i=1; i<101; i++){
    if(list[i] == max)cout << i << endl;
  }
}

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

using namespace std;

long long comb(int n, int k)
{
    long long res = 1;
    for(int i = 1; i <= k; i++){
        res *= (n - i + 1);
        res /= i;
    }
    return res;
}

void Solve(){
    int n, m;
    cin>>n>>m;
    long long res = comb(n, 2);
    res += comb(m, 2);
    cout<<res<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
    	Solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
    int a;
    cin >> a;
    string s = to_string(a);
    vector<int> b(a / 2);
    for (int i = 0; i < a / 2; i++) {
        b[i] = s[i];
    }
    reverse(s.begin(), s.end());
    for (int i = 0; i < a / 2; i++) {
        if (b[i] != s[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll
void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    int left = a * b;
    int right = c - a - b;
    if (right <= 0) {
        cout << "No" << endl;
        return;
    }
    if (4LL * left < right * right) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}

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

#define int long long
int f[200][26];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<n-1;i++)
        sum+=a[i];
        if(sum>a[n-1])
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int N;
    cin>>N;
    vector<int> A(N+2);
    vector<long long> sum(N+2,0);
    for(int i=1; i<=N; i++) cin>>A[i];

    A[0] = A[N+1] = 0; 

    for(int i=1; i<=N+1; i++){
        sum[i] =  sum[i-1]+abs(A[i]-A[i-1]);
    }

    /*
    iは通らない場所

    始まりから、iー１番目の金額
    sum[i-1]

    i-1からi+1
    abs(A[i-1]-A[i+1])

    i+1からN+1
    sum[N+1] - sum[i+1]
    */

    for(int i=1; i<=N; i++){
        long long ans;
        ans = sum[i-1] + sum[N+1] + abs(A[i-1]-A[i+1]) -sum[i+1];
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, k;
	ll ans = 0;
	cin >> num >> k;
	vector<int> d(num);
	rep(i, num)
		cin >> d[i];
	sort(d.begin(), d.end());
	rep(i, k)
		ans += d[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<stdio.h>
#include <math.h>
using namespace std;


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

	if(N%500<=A){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A;
  long double B;
  cin >> A >> B;
  cout << (ll)(A * B) << endl;
}

Measured memory_bytes: 3748
import std.stdio, std.array, std.conv, std.string, std.range, std.algorithm;


void main() {
    long n = readln.strip.to!(long);
    string s = readln.strip;
    long k = readln.strip.to!(long);

    writeln(cast(dchar[])(s.map!(c => (c == s[k-1]) ? c : '*').array));
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<bool> isprime;

void eratos(ll n) {
	isprime.resize(n + 1);
	for (ll i = 0; i <= n; i++) {
		isprime[i] = true;
	}
	isprime[0] = false;
	isprime[1] = false;
	for (ll i = 2; i * i <= n; i++) {
		if (isprime[i]) {
			ll j = i + i;
			while (j <= n) {
				isprime[j] = false;
				j = j + i;
			}
		}
	}
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	eratos(200000);
	vector<int> pr; for (int i = 2; i < 200000; i++) if (isprime[i]) pr.push_back(i);

	int kkt = 89;
	while (kkt) {
		ll N, P; scanf("%lld %lld", &N, &P); if (N == -1) break;
		vector<ll> v;
		auto itr = upper_bound(pr.begin(), pr.end(), N);
		for (int i = 0; i < 100; i++) {
			v.push_back(*itr);
			itr++;
		}
		vector<ll> vv;
		for (int i = 0; i < v.size(); i++) {
			for (int j = i; j < v.size(); j++) {
				vv.push_back(v[i] + v[j]);
			}
		}
		sort(vv.begin(), vv.end());
		cout << vv[P - 1] << "\n";
	}

	return 0;
}


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

int main(){
    for(int i = 0; ; i++){
        int a,b;
        char c;
        cin >> a >> c >> b;
        if(c == '?'){
            break;
        }
        if(c == '+'){
            cout << a + b << endl;
        }else if (c == '-'){
            cout << a - b << endl;
        }else if (c == '*'){
            cout << a * b << endl;
        }else if (c == '/'){
            cout << a / b << endl;
        }

    }
    return 0;
}



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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> a( N );
	for( auto& v: a ) { cin >> v; }

	int result = 0;
	for( int i = 0; i < N; ++i ) {
		while( a[i] % 2 == 0 ) {
			a[i] /= 2;
			result += 1;
		}
	}

	cout << result << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;

#define rep(i, n) for(int i = 0, i##_len=(n); i < i##_len; i++)
#define all(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

int main(void)
{
  // code begin

  int r;
  cin >> r;
  cout << 3 * r * r << endl;

  // code end
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int MAXN = 1e6+5 ;
vector<int> v ;
// bool arr[MAXN] ;
vector<bool> arr(MAXN) ;
int countz[MAXN] ;
void sieve()
{
    for(auto x:v)
    {
        if(!arr[x])
        {
            for(int i=2*x;i<MAXN;i+=x)
            {
                arr[i] = true ;
            }
        }
    }
}
int main()
{
    int n;cin>>n;
    v.resize(n) ;
    for(int i=0;i<n;i++) 
    {
        cin>>v[i]  ;
        countz[v[i]]++ ;
    }
    sort(v.begin(),v.end()) ;
    v.erase( unique( v.begin(), v.end() ), v.end() );
    sieve() ;
    int ans = 0 ;
    for(int i=0;i<v.size();i++) 
    {
        if(!arr[v[i]] && countz[v[i]]==1) 
            ans++ ;
    }
    cout<<ans<<"\n" ;
}

Measured memory_bytes: 7916
#include<cstdio>

int main(){
    char s[10];
    scanf("%s", s);
    bool mmyy=false, yymm=false;
    if(s[0]-'0' == 1){
        if(s[1]-'0' >= 0 and s[1]-'0' <=2){
            mmyy=true;
        }
    }else if(s[0]-'0' == 0){
        if(s[1]-'0' >= 1 and s[1]-'0' <=9){
            mmyy=true;
        }
    }


    if(s[2]-'0' == 1){
        if(s[3]-'0' >= 0 and s[3]-'0' <=2){
            yymm=true;
        }
    }else if(s[2]-'0' == 0){
        if(s[3]-'0' >= 1 and s[3]-'0' <=9){
            yymm=true;
        }
    }
    if(mmyy and yymm){
        printf("AMBIGUOUS");
    }else if(mmyy){
        printf("MMYY");
    }else if(yymm){
        printf("YYMM");
    }else{
        printf("NA");
    }
    return 0;
}


Measured memory_bytes: 128
import fractions
import sys

input = sys.stdin.readline

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split())

tmp = b - a + 1

target_value=lcm(c,d)


c_a_under=(a-1)//c
c_b_under=b//c

c_a2b=c_b_under-c_a_under


d_a_under=(a-1)//d
d_b_under=b//d

d_a2b=d_b_under-d_a_under


cd_a_under=(a-1)//target_value
cd_b_under=b//target_value

cd_a2b=cd_b_under-cd_a_under

mayans = c_a2b+d_a2b-cd_a2b

print(tmp-mayans)


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

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int N; cin >> N;
	vector<long long> A(N);
	rep(i, N)cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
	priority_queue<int> pq;
	long long ans = 0;
	rep(i, N) {
		if (i == 0) {
			pq.push(A[0]);
		}
		else {
			int num = pq.top();
			pq.pop();
			pq.push(A[i]);
			pq.push(A[i]);
			ans += num;
		}
	}
	cout << ans;
}



Measured memory_bytes: 5856
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000003;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int ans = 0;
string S;

int main(){
    
    cin>>S;
    REP( i, S.size() ) if( S[i] == 'x' ) ans++;
    if( ans < 8 ) puts("YES");
    else{         puts("NO");}
    
    
    return 0;
}



Measured memory_bytes: 256
Sa = list(input())
Sb = list(input())
Sc = list(input())

s = Sa.pop(0)
while True:
    if s == 'a':
        if Sa ==[]:
            print('A')
            break
        s = Sa.pop(0)
    elif s == 'b':
        if Sb ==[]:
            print('B')
            break
        s = Sb.pop(0)
    else:
        if Sc ==[]:
            print('C')
            break
        s = Sc.pop(0)


Measured memory_bytes: 8848
#include <stdio.h>

int main(void)
{
	int all;
	int book;
	int i;
	
	while (1){
		scanf("%d", &all);
		
		if (!all){
			break;
		}
		
		for (i = 0; i < 9; i++){
			scanf("%d", &book);
			all -= book;
		}
		
		printf("%d\n", all);
	}
	
	return (0);
}

Measured memory_bytes: 0
n = int(input())
node_info_list = [0 for i in range(n)]
for i in range(n):
    node_info_raw = list(map(int, input().split()))
    node_info_list[node_info_raw[0]] = {
        'degree': node_info_raw[1],
        'children_ids': [],
        'parent': -1,
        'depth': 0,
        'type': 'root'
    }
    if node_info_list[node_info_raw[0]]['degree'] >= 1:
        node_info_list[node_info_raw[0]]['children_ids'] = node_info_raw[2:]

def know_parent_type():
    for id, node_info in enumerate(node_info_list):
        for child_id in node_info['children_ids']:
            node_info_list[child_id]['parent'] = id
            node_info_list[child_id]['type'] = 'internal node'
            if node_info_list[child_id]['children_ids'] == []:
                node_info_list[child_id]['type'] = 'leaf'

def know_depth(id):
    if node_info_list[id]['parent'] == -1:
        return 0
    else:
        return (1 + know_depth(node_info_list[id]['parent']))

know_parent_type()
for id, node_info in enumerate(node_info_list):
    node_info['depth'] = know_depth(id)
    print('node {}: parent = {}, depth = {}, {}, {}'.format(
    id,
    node_info_list[id]['parent'],
    node_info_list[id]['depth'],
    node_info_list[id]['type'],
    node_info_list[id]['children_ids']
    )
    )



Measured memory_bytes: 42880
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 105
const double pi = acos(-1);
const double EPS = 1e-12;
int n;
struct Point{
  int x,y;
  double ang;
  bool operator < (const Point &p)const
  {
    return ang < p.ang;
  }
}p[maxn * 2]; int k;
ll sumx,sumy,ans;
int main(){
  n = getint();
  for(int i = 1;i <= n;i++){
    int x = getint(), y = getint();
    if(x || y){
      p[++k] = (Point){x,y,atan2(y,x)};
      p[++k] = (Point){x,y,atan2(y,x) + 2.0 * pi};
    }
  }
  if(k == 0){
    printf("%.15f\n",sqrt(ans));
    return 0;
  }
  sort(p + 1,p + k + 1);
  for(int i = 1;i <= k;i++){
    if(p[i].ang > pi + EPS) break;
    sumx = sumy = 0;
    for(int j = i;j <= k && p[j].ang - p[i].ang < pi;j++){
      sumx += p[j].x;
      sumy += p[j].y;
      ans = max(ans,sumx * sumx + sumy * sumy);
    }
  }
  printf("%.15f\n",sqrt(ans));
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a,b,c;
    cin>>a>>b>>c;
    a%=b;
    lli ac=a%b;
    while(a!=0){
        if(a%b==c){
            out("YES");
            return 0;
        }
        a+=ac;
        a%=b;
    }
    out("NO");
}

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=100023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,w;
    cin>>n>>w;
    vector <pair<ll,ll>> v;
    ll dp[N+10];
    for(int i=1;i<=N;i++)
        dp[i]=1e18;
    dp[0]=0;
    rep(i,n)
    {
        ll a,b;
        cin>>a>>b;
        for(int j=N-1-b;j>=0;j--)
        {
            dp[j+b]=min(dp[j+b],dp[j]+a);
        }
    }
    ll ans=0;
    for(int i=1;i<=N;i++)
    {
        if(dp[i]<=w)
            ans=i;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n,T;
    cin >> n >> T;
    int c,t;
    int ans = INF;
    for(int i = 0;i < n;i++){
        cin >> c >> t;
        if(t <= T) ans = min(ans,c);
    }
    if(ans != INF) cout << ans << endl;
    else cout << "TLE" << endl;
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int N = 0;
  int f = 0;
  FOR(i,0,s.length()) {
    N *= 10;
    N += s[i] - '0';
    f += s[i] - '0';
  }
  cout << (N % f == 0 ? "Yes" : "No") << endl;
  return 0;
}

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

int main()
{
	long long N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	string ans = "NO";
	long long diff = B - A;
	for( int n = 0; n < N; n++ ) {
		if( (N - 1 - n) * C - n * D <= diff && diff <= (N - 1 - n) * D - n * C ) {
			ans = "YES";
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#define MOD 1000000007LL
#define INF 10000000000000LL
#define MAX 101
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
struct WeightedUnionFind{
    int par[110000];
    int fukasa[110000];
    int diffw[110000];
    WeightedUnionFind(){};
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            fukasa[i]=0;
            diffw[i]=0;
        }
    }
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            int r=find(par[x]);
            diffw[x]+=diffw[par[x]];
            return par[x]=r;
        }
    }
    int weight(int x){
        find(x);
        return diffw[x];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    bool unite(int x,int y,int w){
        w+=weight(x);
        w-=weight(y);
        x=find(x);
        y=find(y);
        if(x==y){
            return false;
        }
        if(fukasa[x]<fukasa[y]){
            swap(x,y);
            w=-w;
        }
        if(fukasa[x]==fukasa[y]){
            fukasa[x]++;
        }
        par[y]=x;
        diffw[y]=w;
        return true;
    }    
    int diff(int x,int y){
        return weight(y)-weight(x);
    }

};
int main() {    
    int n,m;
    cin>>n>>m;
    WeightedUnionFind uf;
    uf.init(n);
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        if(uf.same(l,r)){
            if(uf.diff(l,r)!=d){
                cout<<"No"<<endl;
                return 0;
            }
        }else{
            uf.unite(l,r,d);
        }
    }
    cout<<"Yes"<<endl;
}

                           


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

ll f(const vector<ll>::const_iterator it_s, const vector<ll>::const_iterator it_e, ll h)
{
    if (it_s == it_e) {
        return 0;
    }
    if (distance(it_s, it_e) == 1) {
        return *it_s - h;
    }

    auto count = *min_element(it_s, it_e) - h;
    auto it_n = find(it_s, it_e, h + count);
    return count + f(it_s, it_n, h + count) + f(it_n + 1, it_e, h + count);
}

void main_()
{
    ll N;
    vector<ll> hs;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(hs));

    auto ans = f(begin(hs), end(hs), 0);
    cout << ans << endl;
    return;

    //auto ans = 0;
    auto start_it = begin(hs);
    auto last_it = unique(start_it, end(hs));
    while (distance(start_it, last_it) > 2) {
        // 0ではない中で最小の値
        auto m = *min_element(start_it, last_it,
            [](auto a, auto b) {
                a = (a > 0) ? a : numeric_limits<decltype(a)>::max();
                b = (b > 0) ? b : numeric_limits<decltype(a)>::max();
                return a < b;
            });

        ll cnt = 1 + count(start_it + 1, last_it - 1, 0);

        transform(begin(hs), last_it, begin(hs), [m](auto n) { return max(n - m, 0L); });
        last_it = unique(start_it, last_it);
        ans += cnt * m;
    }

    ans += *max_element(start_it, last_it);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
a = []
a1 = []
for i in range(3):
    a2 = list(map(int, input().split()))
    a.append(a2)
    a1 += a2
n = int(input())
b = []
num = 0
for h in range(n):
    b1 = int(input())
    if b1 in a1:
        num += 1
    b.append(b1)
if num < 3:
    print('No')
else:
    z = 'No'
    for j in range(3):
        if a[j][0] in b and a[j][1] in b and a[j][2] in b:
            z = 'Yes'
            break
        if a[0][j] in b and a[1][j] in b and a[2][j] in b:
            z = 'Yes'
            break
    if z == 'No':
        if a[0][0] in b and a[1][1] in b and a[2][2] in b:
            z = 'Yes'
        elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
            z = 'Yes'
    print(z)

Measured memory_bytes: 9268
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;

map<string,ll> num;
ll par[5000],_rank[5000];
 
void init(ll n){
    for(ll i=0;i<n;i++) par[i]=i,_rank[i]=1;
}
 
ll find(ll a){
    if(par[a]==a) return a;
    else return par[a] = find(par[a]);
}
 
void unite(ll _a,ll _b){
    ll a = find(_a);
    ll b = find(_b);
    if(a==b) return;
    if(_rank[a]>_rank[b]){
        par[b] = a;
    }
    else{
        par[a] = b;
        if(_rank[a]==_rank[b]) _rank[b]++;
    }
}

int main(){
	ll N;
	cin>>N;
	string A[5000];
	ll X[5000];
	for(ll i=0;i<N;i++){
		cin>>A[i]>>X[i];
		num[A[i]] = i;
	}
	ll M;
	cin>>M;
	init(N);
	for(ll i=0;i<M;i++){
		string S,T;
		cin>>S>>T;
		unite(num[S],num[T]);
	}
	ll min_[5000]; fill_n(min_,N,LLONG_MAX);
	for(ll i=0;i<N;i++){
		ll p = find(i);
		min_[p] = min(min_[p],X[i]);
	}
	ll ans = 0;
	for(ll i=0;i<N;i++){
		ans += min_[find(i)];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    long long h[n], res = 0;
    for(int i=0; i<n; i++) cin >> h[i];
    sort(h, h+n);
    for(int i=0; i<n-k; i++) res += h[i];
    cout << res;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<pair<int, int>> bc(m);
    for (int i = 0; i < m; i++) cin >> bc[i].second >> bc[i].first;
    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end(), greater<pair<int, int>>());
    int idx = 0;
    for (int i = 0; i < m; i++) {
        for (int j = idx; j < idx + bc[i].second; j++) {
            if (j >= n) break;
            if (a[j] < bc[i].first) a[j] = bc[i].first;
        }
        idx += bc[i].second;
        if (idx >= n) break;
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];
    cout << sum << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

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

#define F first
#define S second
#define PB push_back
#define PP pop_back
#define sz(x) (int)(x.size())

using namespace std;

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

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

	int n, a;
	cin >> n;
	int arr[n + 1];
	memset(arr, 0, sizeof arr);
	for (int i = 1; i < n; i++) {
		cin >> a;
		arr[a]++;
	}
	for (int i = 1; i <= n; i++) cout << arr[i] << endl;
	return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

constexpr long long int MOD = 998244353LL;
long long int accumulated(const int score, const int n, const int k, const int a, const std::vector<long long int> &inverse, std::vector<long long int>& memo) {
	if (score + 1 == k) return 1LL;
	if (score == k) return 0LL;
	if (memo[score] >= 0) return memo[score];
	if (score + n >= k) {
		auto clear = score + n - k + 1;
		return memo[score] = (((clear + a % MOD * inverse[100] % MOD * accumulated(score + 1, n, k, a, inverse, memo)) % MOD * inverse[n] % MOD + accumulated(score + 1, n, k, a, inverse, memo)) % MOD + MOD) % MOD;
	}
	else {
		return memo[score] = ((accumulated(score + 1, n, k, a, inverse, memo) + 
			((accumulated(score + 1, n, k, a, inverse, memo) - accumulated(score + n + 1, n, k, a, inverse, memo)) % MOD * inverse[n] % MOD * a % MOD * inverse[100] % MOD)) % MOD + MOD) % MOD;
	}
}

int main() {
	int n, k, a; std::cin >> n >> k >> a;
	std::vector<long long int> inverse(std::max(n + 1, 101), 1);
	for (auto i = 2; i < inverse.size(); ++i) {
		inverse[i] = (MOD - MOD / i) * inverse[MOD % i] % MOD;
	}
	std::vector<long long int> memo(k, -1);
	std::cout << ((accumulated(0, n, k, a, inverse, memo) - accumulated(1, n, k, a, inverse, memo)) % MOD + MOD) % MOD << '\n';
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;
string S[303];
int A[303][303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	int id=1;
	FOR(y,H) {
		cin>>S[y];
		int num=0;
		FOR(x,W) if(S[y][x]=='#') num++;
		if(num==0) {
			if(y) {
				FOR(x,W) A[y][x]=A[y-1][x];
			}
		}
		else {
			int nex=id;
			FOR(x,W) {
				if(S[y][x]=='#') nex=id++;
				A[y][x]=nex;
			}
		}
	}
	
	for(y=H-1;y>=0;y--) if(A[y][0]==0) {
		FOR(x,W) A[y][x]=A[y+1][x];
	}
	
	FOR(y,H) {
		FOR(x,W) cout<<A[y][x]<<" ";
		cout<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1280
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

void main() {
    int n,a,b;
    R(n,a,b);
    W((b-a)%2==0 ? "Alice" : "Borys");
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int d = Integer.parseInt(f.readLine())%10;
        if(d == 2 || d == 4 || d == 5 || d == 7 || d == 9){
            out.println("hon");
        }else if(d == 3){
            out.println("bon");
        }else{
            out.println("pon");
        }


        out.close();
    }
}


Measured memory_bytes: 32656
#include<bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   if(abs(s[0]-s[1])==0||abs(s[1]-s[2])==0||abs(s[2]-s[3])==0) {cout<<"Bad"; return 0;}
   cout<<"Good";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int l, k;
ll dp[102][102];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> l >> k;
    dp[0][0] = 1;
    ll ans = 0;
    REP1 (i, 100) {
        REP1 (j, l) {
            if (i & 1) {
                if (j >= k) {
                    dp[i][j] += dp[i-1][j-k];
                }
                dp[i][j] += dp[i-1][j-1];
                debug(i, j, dp[i][j]);
                ans += dp[i][j];
            } else {
                dp[i][j] += dp[i-1][j-1];
            }
        }
    }

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



Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    fast
    ll h,w;
    cin>>h>>w;
    vv maze(h,vi(w,1));
    for(ll i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for(ll j=0;j<s.size();j++)
            if(s[j]=='#')
                maze[i][j]=0;
    }
    ll dis[h][w][h][w];
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
            for(ll k=0;k<h;k++)
                for(ll l=0;l<w;l++)
                    dis[i][j][k][l]=inf;
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
        {
            if(maze[i][j]==1)
            {
                dis[i][j][i][j]=0;
                if(i-1>=0 && maze[i-1][j]==1)
                {
                    dis[i][j][i-1][j]=1;
                }
                if(i+1<h && maze[i+1][j]==1)
                {
                    dis[i][j][i+1][j]=1;
                }
                if(j-1>=0 && maze[i][j-1]==1)
                {
                    dis[i][j][i][j-1]=1;
                }
                if(j+1<w && maze[i][j+1]==1)
                {
                    dis[i][j][i][j+1]=1;
                }
            }
        }

    for (ll a=0;a<h;a++)
        for(ll b=0;b<w;b++)  
            // Pick all vertices as source one by one  
            for (ll i=0;i<h;i++)  
                for(ll j=0;j<w;j++)
                // Pick all vertices as destination for the  
                // above picked source  
                    for (ll k=0;k<h;k++)  
                        for(ll l=0;l<w;l++)
                    {
                        // If vertex k is on the shortest path from  
                        // i to j, then update the value of dist[i][j]  
                        if (dis[i][j][a][b] + dis[a][b][k][l] < dis[i][j][k][l])  
                            dis[i][j][k][l] = dis[i][j][a][b] + dis[a][b][k][l];  
                    } 
    ll max_dist = 0; 
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
            for(ll k=0;k<h;k++)
                for(ll l=0;l<w;l++)
                    if(dis[i][j][k][l]!=inf && dis[i][j][k][l]>max_dist)
                        max_dist = dis[i][j][k][l];
    cout<<max_dist<<endl;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

int main()
{
   char s[10][10];

   rep(i,3) {
      cin >> s[i];
   }
   printf("%c%c%c\n", s[0][0], s[1][1], s[2][2] );
}




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

#include<math.h>
typedef long long ll;
using namespace std;

int main()
{
	ll n, m;
	vector<ll> a;
	cin >> n >> m;
	for(ll i = 0; i < m; i++)
	{
		ll v;
		cin >> v;
		a.push_back(v);
	}

	ll sum = 0;
	for(ll i = 0; i < m; i++)
	{
		sum += a.at(i);
	}
	if(n - sum < 0) cout << -1;
	else cout << n - sum;

	return 0;
}

Measured memory_bytes: 3292
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
int c[13];
int a[13][100010];
int n,m,x;
ll dfs(int now,vi v,ll cost)
{
	if(now==n)
	{
		rep(i,v.size())
		{
			if(x>v[i]) return 100000000000000;
		}
		return cost;
	}
	vi v2=v;
	rep(i,m)
	{
		v2.pb(v2[0]+a[now][i]);
		v2.erase(v2.begin(),v2.begin()+1);
	}
	/*cout<<"now:"<<now<<" ";
	rep(i,v2.size())
	{
		cout<<v2[i]<<" ";
	}
	cout<<endl;*/
	ll ans=cost;
	ll a=dfs(now+1,v2,c[now]);
	ll b=dfs(now+1,v,0);
	ans+=min(a,b);
	return ans;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>m>>x;
	rep(i,n)
	{
		cin>>c[i];
		rep(j,m)
		{
			cin>>a[i][j];
		}
	}
	vi v;
	rep(i,m) v.pb(0);
	ll ans=dfs(0,v,0);
	if(ans==100000000000000)
	{
		cout<<"-1";
	}
	else
	{
		cout<<ans;
	}
	return 0;
}

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

int main(){
  //入力
  int n,a,b;cin >> n >> a >> b;
  string s;cin >> s;
  int pass = 0,bnum = 0;
  //処理
  for(int i=0;i<n;++i){
    if(s[i] != 'c'){
      if(pass < a+b && s[i] == 'a'){
        cout << "Yes" << endl;
        pass += 1;
      } else if(pass < a+b && s[i] == 'b' && bnum + 1 <= b){
        cout << "Yes" << endl;
        pass += 1;
        bnum += 1;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  //出力
  return 0;
}

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

long gcd(long n, long m) {
	if (n == 0)return m;
	if (n < m)swap(n, m);
	return gcd(n % m, m);
}

int main() {
	int A, B; cin >> A >> B;
	if (A < 6) cout << 0;
	else if (5 < A && A < 13)cout << B / 2;
	else cout << B;
}

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

using namespace std;

int main()
{
    int n,v[55];
    double sum=0.0;

    cin>>n;

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

    sort(v,v+n);

    sum = double(v[0]+v[1])/2;

    if(n>2)
    {
        for(int i=2; i<n; i++)
        {
            sum = double(sum+v[i])/2;
        }
    }

    cout<<sum<<endl;

    return 0;
}



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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

int N;
int x[100001], y[100000];

long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

signed main(){
    cin >> N; N++;
    REP(i, N) cin >> x[i];
    sort(x, x + N);
    REP(i, N - 1){
        y[i] = x[i + 1] - x[i];
    }
    int ans = *max_element(y, y + N - 1);
    REP(i, N - 1){
        ans = gcd(ans, y[i]);
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 1024