akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

//----------------------------------------------------------------

int main()
{
    ll sum;
    cin >> sum;
    ll d = sum % 10;
    sum = sum / 10;
    ll c = sum % 10;
    sum = sum / 10;
    ll b = sum % 10;
    sum = sum / 10;
    ll a = sum % 10;
    if (a + b + c + d == 7)
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if (a + b + c - d == 7)
    {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if (a + b - c + d == 7)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if (a + b - c - d == 7)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }
    else if (a - b + c + d == 7)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if (a - b + c - d == 7)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if (a - b - c + d == 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if (a - b - c - d == 7)
    {
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	int arr[N];
	int count[100001]={0};
	int x=0; int y=0;
	for (int i=0; i<N; i++){
		cin >> arr[i];
	}
	for (int i=0; i<N; i++){
		count[arr[i]]++;
	}
	int total=0;
	for (int i=0; i<100001; i++){
		if (count[i]){
			total++;
			if (count[i]%2==0) x++;
		}
	}
	if (x%2) cout << total-1 << endl;
	else cout << total << endl;
}


Measured memory_bytes: 1024
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();
            final String[] sl = s.split(" ");

            HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();

            for (int i = 0; i < sl.length; i++) {
                int k = Integer.parseInt(sl[i]);
                if (hm.containsKey(k)) {
                    hm.put(k, hm.get(k) + 1);
                } else {
                    hm.put(k, 1);
                }
            }

            String ans = "NO";
            if (hm.containsKey(5) && hm.containsKey(7)
                && hm.get(5) == 2 && hm.get(7) == 1) ans = "YES";

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 20564
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        
        int sum=0;
        for(int i=0; i<3; i++){
            if(s.charAt(i)==s.charAt(i+1)){
                sum++;
            }
        }
        if(sum==0){
            System.out.println("Good");
        }
        else{
            System.out.println("Bad");
        }
        sc.close();
    }
}

Measured memory_bytes: 23380
#include <stdio.h>

int main(){

  int i,j,k,N1,N2;

  scanf("%d%d",&N1,&N2);

  if(N1 > N2){
    j = N1;
    N1=N2;
    N2=j;
  }

  k=N1%N2;
  while(k!=0){
    N1=N2;
    N2=k;
    k=N1%N2;
  }

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

  return 0;
}
  



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

int main() {
  int N;
  cin >> N;
  vector A(N, 0);
  for (int i = 0, a; cin >> a; i++) A.at(i) = --a;
  int cnt = 0;
  for (int i = 0; i < N; i++) if (A.at(A.at(i)) == i) cnt++;
  cout << cnt / 2 << "\n";
}

Measured memory_bytes: 3732
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

ll f(ll b,ll n,ll S=0){
    if(n<b){
        return S+n;
    }else{
        return f(b,n/b,S+n%b);
    }
}

int main(){
    
    ll s,n;
    cin >> n>>s;
    
    if(n==s){
        cout << n+1<<endl;
    }else{
        ll sq=2;
        
        while(sq*sq<=n){
            if(s==f(sq,n)){
                cout << sq<<endl;
                return 0;
            }
            sq++;
        }
        
        ll p = 1;
        ll ans = -1;
        
        while(p*p<n){
            ll b = (n-s)/p+1;
            if(b>=2&&s==f(b,n)&&p<b&&0<=s-p&&s-p<b){
                ans = b;
            }
            p++;
        }
        
        cout << ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long L, R;
  int x;
  cin >> L >> R;
  vector<int> Z(0,0);
  x=R-L;
  x=min(x, 2020);
  L%=2019;
  for(int i=0; i<=x; i++){
    Z.push_back(L);
    L++;
    L%=2019;
  }
  stable_sort(Z.begin(), Z.end());
  int ans=2019;
  for(int i=0; i<Z.size()-1; i++){
    bool finish=false;
    for(int j=i+1; j<Z.size(); j++){
      int temp=Z[i]*Z[j];
      temp%=2019;
      ans=min(ans, temp);
      if(ans==0){
        finish=true;
        break;
      }
    }
    if(finish) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
lnt a[N],b[N];
constexpr lnt mod = 1000000007;
lnt ppp(lnt a,lnt x){
    lnt ans = 1;
    for(;x;x>>=1){
        if(x&1){ans*=a;ans%=mod;}
        a=a*a%mod;
    }
    return ans;
}
bool sol(){
    int n;
    if(RI(n)==EOF)return 0;
    FZ(i,n){int x; RI(x); a[i] = x;}
    FZ(i,n){int x; RI(x); b[i] = x;}
    auto ml = *max_element(a,a+n);
    auto mr = *max_element(b,b+n);
    if(ml!=mr){
        puts("0");
        return 1;
    }
    auto l = find(a,a+n,ml)-a;
    auto r = n;
    FB(i,n)if(b[i]==mr){
        r = i; break;
    }
    if(l>r){
        puts("0");
        return 1;
    }
    lnt ans = ppp(ml,max(lnt(r-l-1),0ll));
    reverse(b,b+n);
    for(auto c:{a,b}){
        lnt last = 0;
        FZ(i,n)if(i&&c[i]!=c[i-1]){
            //printf("%d %d\n",int(c[i-1]),i-last-1);
            ans*= ppp(c[i-1],i-last-1);
            ans%=mod;
            last = i;
        }
    }
    printf("%d\n",int(ans));
    return 1;
}
int main(){
    while(sol());
    return 0;
}


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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define var auto
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;

int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;

    string s; cin>>s;
    int n = s.size(), m; cin>>m;
    deque<char> v;
    for(char &i: s)v.pb(i);
    int rev = 0;
    while(m--){
        int type; cin>>type;
        if(type==1) rev++;
        else {
            int d; char val; cin>>d>>val;
            if(isOdd(rev)) d = (d==1?2:1);
            if(d==1) v.push_front(val);
            else v.pb(val);
        }
    }
    if(isOdd(rev)) reverse(all(v));
    for(var &i: v)cout<<i;
	return 0;
}


Measured memory_bytes: 976
n,k = map(int,input().split())
s = list(input())+['-1']

num = [0]
for i in range(1,n+1):
    if s[i-1] != s[i]:
        num.append(i)
# print(num)

ans,lennum = num[1],len(num)
for i in range((s[0]=='1')-1,lennum-2,2):
    l,r = max(i,0),min(i+2*k+1,lennum-1)
    ans = max(ans,num[r]-num[l])
print(ans)

Measured memory_bytes: 85140
#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 ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

ll a[20][20];


bool dist(ll x, ll y, ll n){
  ll ans = 0, i,j,k;
  forn(0,n,i){
    ans += (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
  }
  ll sq = sqrtl(ans);
  return (sq * sq == ans);
}

int main(){
  fastio
  ll n,i,j,k,d;
  string s;

  cin >> n >> d;

  forn(0,n,i){
    forn(0,d,j){
      cin >> a[i][j];
    }
  }
  ll ans = 0;
  forn(0,n,i){
    forn(i + 1,n,j){
      ans += dist(i,j,d);
    }
  }
  cout << ans << '\n';

  ktj();
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int G[8][8][8][8][8][8][8][8];
int d[4] = {1, -1, 4, -4};
struct node
{
    int a[8];
    int steps = 0;
    node(){for(int i = 0; i < 8; i++) a[i] = i;}
    bool friend operator==(node x, node y)
    {
        for(int i = 0; i < 8; i++) if(x.a[i] != y.a[i]) return false;
        return true;
    }
};
int main()
{
    node perf;
    queue<node> que;
    que.push(perf);
    while(!que.empty())
    {
        node e = que.front(); que.pop();
        int* a = e.a;
        int zero = 0;
        for(int i = 0; i < 8; i++) if(e.a[i] == 0) {zero = i;}
        //cout<<e.steps << endl;
        for(int i = 0; i < 4; i++)
        {
            if(i == 0 && (zero % 4 == 3)) continue;
            if(i == 1 && (zero % 4 == 0)) continue;
            if(i == 2 && (zero + d[i] > 7)) continue;
            if(i == 3 && (zero + d[i] < 0)) continue;
            node rem_e = e;
            /*for(int i = 0; i < 8; i++) cout<<rem_e.a[i]<<" ";
            cout<<endl;*/
            int tmp = e.a[zero]; e.a[zero] = e.a[zero + d[i]]; e.a[zero + d[i]] = tmp;
            if(e == perf || G[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][a[7]] != 0) {e = rem_e;continue;}
            e.steps++;
            que.push(e);
            G[a[0]][a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][a[7]] = e.steps;
            e = rem_e;/*
            for(int i = 0; i < 8; i++) cout<<e.a[i]<<" ";
            cout<<endl;*/
        }
    }
    int a[10];
    for(int i = 0; i < 10; i++) a[i] = i;
    while(cin>>a[1])
    {
        for(int i = 2; i <= 8; i++) cin >> a[i];
        cout << G[a[1]][a[2]][a[3]][a[4]][a[5]][a[6]][a[7]][a[8]] << endl;
    }
    return 0;
}



Measured memory_bytes: 26704
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
    int h, w;

    cin>>h>>w;

    vs s(h);

    rep(i, h) cin>>s[i];

    vvll sum_h(h, vll(w+1, 0)), sum_h_r(h, vll(w+1, 0)), sum_w(w, vll(h+1, 0)), sum_w_r(w, vll(h+1, 0));

    rep(i, h){
        rep(j, w){
            if(s[i][j]=='.'){
                sum_h[i][j+1]=sum_h[i][j]+1;
            }else{
                sum_h[i][j+1]=0;
            }
        }

        reprev(j, w){
            if(s[i][j]=='.'){
                sum_h_r[i][j]=sum_h_r[i][j+1]+1;
            }else{
                sum_h_r[i][j]=0;
            }
        }
    }

    rep(j, w){
        rep(i, h){
            if(s[i][j]=='.'){
                sum_w[j][i+1]=sum_w[j][i]+1;
            }else{
                sum_w[j][i+1]=0;
            }
        }

        reprev(i, h){
            if(s[i][j]=='.'){
                sum_w_r[j][i]=sum_w_r[j][i+1]+1;
            }else{
                sum_w_r[j][i]=0;
            }
        }
    }

    ll ans=0;
    rep(i, h){
        rep(j, w){
            ll temp=sum_h[i][j+1]+sum_h_r[i][j]+sum_w[j][i+1]+sum_w_r[j][i]-3;
            ans=max(ans, temp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 131712
path = []
for i in range(3):
    path.extend(list(map(int, input().split())))
res = []
for i in range(1,5):
    res.append(path.count(i))
if res.count(1) == 2 and res.count(2) == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
from collections import Counter
# 素因数分解
# 戻り値: リスト
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

yakusu = []
n = int(input())
for i in range(1, n+1):
    yakusu += prime_factor(i)
c = Counter(yakusu)
d = {}
for ik, iv in c.items():
    for jk, jv in c.items():
        for kk, kv in c.items():
            if len(set([ik, jk, kk])) != 3:
                continue
            if iv >= 74:
                d[ik**74] = 0
            if iv >= 24 and jv >= 2:
                d[(ik**24)*(jk**2)] = 0
            if iv >= 14 and jv >= 4:
                d[(ik**14)*(jk**4)] = 0
            if iv >= 4 and jv >= 4 and kv >= 2:
                d[(ik**4)*(jk**4)*(kk**2)] = 0
print(len(d.values()))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

const int M=1000000007;
int n,X,Y,Ans=1;
int c[200001],w[200001]={1000000001};
int minw[200001];

int colors[200001],h[200001],nxt[1600001],to[1600001],tot;
void ins(int*arr,int x,int y){nxt[++tot]=arr[x];to[tot]=y;arr[x]=tot;}
void insw(int x,int y){ins(h,x,y);ins(h,y,x);}

int frc[200001]={0,1},inv[200001]={0,1};

int vis[200001],cnt[200001],stk[200001],tyq,cnts;

void DFS(int u){
	vis[u]=1; if(!cnt[c[u]]) stk[++tyq]=c[u]; ++cnt[c[u]]; ++cnts;
	for(int i=h[u];i;i=nxt[i]){
		if(!vis[to[i]]) DFS(to[i]);
	}
}

int main(){
	scanf("%d%d%d",&n,&X,&Y);
	F(i,1,n) scanf("%d%d",c+i,w+i);
	F(i,2,200000) frc[i]=(ll)frc[i-1]*i%M;
	F(i,2,200000) inv[i]=(ll)(M-M/i)*inv[M%i]%M;
	F(i,2,200000) inv[i]=(ll)inv[i-1]*inv[i]%M;
	F(i,1,n) ins(colors,c[i],i);
	F(i,1,n){
		int mini=0;
		for(int j=colors[i];j;j=nxt[j])
			if(w[to[j]]<w[mini]) mini=to[j];
		if(!mini) continue;
		minw[i]=mini;
		for(int j=colors[i];j;j=nxt[j])
			if(to[j]!=mini&&w[to[j]]+w[mini]<=X) insw(mini,to[j]);
	}
	dF(i,n,2) if(w[minw[i]]<w[minw[i-1]]) swap(minw[i],minw[i-1]);
	dF(i,n,3) if(w[minw[i]]<w[minw[i-1]]) swap(minw[i],minw[i-1]);
	F(k,1,2){
		if(!minw[k]) break;
		F(i,1,n){
			if(c[i]!=c[minw[k]]&&w[i]+w[minw[k]]<=Y)
				insw(minw[k],i);
		}
	}
	F(i,1,n){
		if(!vis[i]){
			tyq=cnts=0;
			DFS(i);
			Ans=(ll)Ans*frc[cnts]%M;
			F(j,1,tyq) Ans=(ll)Ans*inv[cnt[stk[j]]]%M, cnt[stk[j]]=0;
		}
	}
	printf("%d",Ans);
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;

    int k_possible = (n - 1) * (n - 2) / 2;
    if (k > k_possible) {
        printf("-1\n");
        return 0;
    }

    int num = (n - 1) + (k_possible - k);
    printf("%d\n", num);
    for (int v = 1; v <= n - 1; v++) {
        printf("%d %d\n", v, n);
    }

    num = k_possible - k;
    for (int i = 1; i <= n - 1 && num; i++) {
        for (int j = i + 1; j <= n - 1 && num; j++) {
            printf("%d %d\n", i, j);
            --num;
        }
    }

    return 0;
}


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

vector<int> dxs = {-1, 1, 0, 0}, dys = {0, 0, -1, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s.at(i);
    }

    int res = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '#')
            {
                continue;
            }

            int mx = 0;
            vector<vector<bool>> v(h, vector<bool>(w, true));
            queue<pair<pair<int, int>, int>> q;
            q.push({{i, j}, 0});
            v.at(i).at(j) = false;
            while (!q.empty())
            {
                int pi = q.front().first.first, pj = q.front().first.second;
                int l = q.front().second;
                q.pop();

                mx = max(mx, l);

                for (int k = 0; k < 4; k++)
                {
                    int dx = dxs.at(k), dy = dys.at(k);
                    if (0 <= pi + dy && pi + dy < h && 0 <= pj + dx && pj + dx < w)
                    {
                        if (s.at(pi + dy).at(pj + dx) == '.' && v.at(pi + dy).at(pj + dx))
                        {
                            q.push({{pi + dy, pj + dx}, l + 1});
                            v.at(pi + dy).at(pj + dx) = false;
                        }
                    }
                }
            }

            res = max(res, mx);
        }
    }
    cout << res << endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() <= k)cout << s << endl;
	else cout << s.substr(0, k) + "..." << endl;
	return 0;
}

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


int gcd(int a, int b)
{
    return (b == 0) ? a : gcd(b, a % b);
}

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int C = gcd(A, B);
    int cnt = 1;
    while (cnt < K) {
        C--;
        if (A % C == 0 && B % C == 0) cnt++;
    }

    cout << C << endl;
    return 0;
}

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

int main (){
    string s;
    cin >> s;
    int year,month,day;
    year = (s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    if(year < 2019){
        cout << "Heisei" << endl;
        return 0;
    }
    else if(year > 2019){
        cout << "TBD" << endl;
        return 0;
    }

    month = (s[5]-'0')*10+(s[6]-'0');
    if(month <=4){
        cout << "Heisei" << endl;
        return 0;
    }
    else if(month > 4){
        cout << "TBD" << endl;
    }

    day = (s[8]-'0')*10+(s[9]-'0');

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	int le=0, lw=0, re=0, rw=0, tote=0, totw=0, minv=300000, tmpv, i;
	int lt=0, rt=0;
	cin >> n >> s;
	for(i=0; i<n; i++)
	{
		if(s[i] == 'E')
		{
			tote ++;
		}
		else
		{
			totw ++;
		}
	}
	if(s[0] == 'E')
	{
		re = tote - 1;
		rw = totw;
	}
	else if(s[0] == 'W')
	{
		re = tote;
		rw = totw -1 ;
	}
	rt = re ;
	lt = 0;
	minv = rt + lt;
	for(i=1; i<n; i++)
	{
		if(s[i-1] == 'W')
		{
			lt ++;
			lw ++;
		}
		else if(s[i-1] == 'E')
		{
			le ++;
		}
		if(s[i] == 'E')
		{
			re = tote - le - 1;
			rw = totw - rw;
		}
		else if(s[i] == 'W')
		{
			re = tote - le;
			rw = totw - lw - 1;
		}
		tmpv = lw + re;
		if(tmpv < minv)
		{
			minv = tmpv;
		}
	}
	
	cout << minv;
	return 0;
	
}

Measured memory_bytes: 900
/**
 * Title:
 * Url:
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    string s; cin >> s;
    if((s[0]!=s[1])|(s[0]!=s[2])|(s[1]!=s[2])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int islands = 0, bridges = 0, fromIsland = 0, toIsland = 0;
    bool answer = false;
    std::cin >> islands >> bridges;
    std::vector<int> from1(islands + 1, 0);
    std::vector<int> fromN(islands + 1, 0);
    for (int i = 0; i < bridges; ++i) {
        std::cin >> fromIsland >> toIsland;
        if (fromIsland == 1 && toIsland == islands) {
            answer = true;
        }
        else if (fromIsland == 1) {
            ++from1[toIsland];
            if (from1[toIsland] && fromN[toIsland]) {
                answer = true;
            }
        }
        else if (toIsland == islands) {
            ++fromN[fromIsland];
            if (from1[fromIsland] && fromN[fromIsland]) {
                answer = true;
            }
        }
    }
    std::cout << ((answer) ? "POSSIBLE" : "IMPOSSIBLE") << "\n"; 
    system("pause");
    return 0;
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

struct RMQ {
  long dat[kMax5][20];
  long dat2[kMax5][20];

  RMQ() {}
  void init(const vector<long> & a) {
    auto n = a.size();
    rep(i, 0, n - 2) {
      dat[i][1] = max(a[i], a[i + 1]);
      dat2[i][1] = min(a[i], a[i + 1]);
      // cout << i << " " << 1 << " " << dat[i][1] << " " << dat2[i][1] << endl;
    }
    for (auto j = 2; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = max(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto min_dat = min(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
        auto max_dat2 = max(dat2[i][j - 1], dat2[i + (1 << (j - 1))][j - 1]);
        dat2[i][j] = max(min_dat, max_dat2);
        // cout << i << " " << j << " " << dat[i][j] << " " << dat2[i][j] << endl;
      }
    }
  }

  long query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    auto dat_l = dat[l][k];
    auto dat_r = dat[r - (1 << k) + 1][k];
    auto dat2_l = dat2[l][k];
    auto dat2_r = dat2[r - (1 << k) + 1][k];
    // auto min_dat = min(dat[l][k], dat[r - (1 << k) + 1][k]);
    // auto max_dat2 = max(dat2[l][k], dat2[r - (1 << k) + 1][k]);
    if (dat_l == dat_r && dat2_l == dat2_r) {
      return dat2_l;
    } else if (dat_l == dat_r) {
      return max(dat2_l, dat2_r);
    } else if (dat2_l == dat2_r){
      return min(dat_l, dat_r);
    } else if (dat_l == dat2_r){
      return dat_l;
    } else if (dat2_l == dat_r){
      return dat2_l;
    } else {
      return max(min(dat_l, dat_r), max(dat2_l, dat_r));
    }
  }
};

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

  ll ans = 0;
  string s;
  int n, k, q;
  cin >> n >> k >> q;

  vector<long> a(n + 1, 0);
  rep(i, 1, q) {
    int a0;
    cin >> a0;
    a[a0]++;
  }
  rep(i, 1, n) {
    if (k > q - a[i]) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 1408
/*                        
                            In the name of Almighty ALLAH
                                    ISLAM IS PEACE

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/


#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb               push_back
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(v)           v.begin(),v.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;



int main() {
    
    FASTIO;
    
    ll t, cnt=0;
    cin >> t;
    bool br=0;
    for(ll i=0; i<t; i++){
        ll a, b;
        cin >> a >> b;
        if(a==b) ++cnt;
        else cnt=0;
        
        if(cnt==3) br=1;
    }
    
    if(br) cout << "Yes" << endl;
    else cout << "No" << endl;
    
	return 0;
}

Measured memory_bytes: 3636
n , x = input().split()
n = int(n)
x = int(x)
m = []
i_min = 0
result = 0

for i in range(n):
  m.append(int(input()))

for i in range(len(m)):
  x -= m[i]
  result += 1

for i in range(len(m)):
  if m[i_min] > m[i]:
    i_min = i

for i in range(x):
  if x >= m[i_min]:
    result += 1
    x -= m[i_min]
  else:
    break

print(result)

Measured memory_bytes: 3064
def print_area(stack):
    if len(stack) == 0:
        print(len(stack))
    else:
        print(len(stack), end=" ")
    for i,j in enumerate(stack):
        if i == len(stack)-1:
            print(j[1])
        else:
            print(j[1], end=" ")    

def calc_flood_area(in_data):
    stack1 = []
    stack2 = []
    total_area = 0
    for i,symbol in enumerate(in_data):
        if symbol == "\\":
            stack1.append(i)
        elif symbol == "_":
            pass
        elif symbol == "/" and stack1:
            j = stack1.pop()
            a = int(i)-int(j)
            total_area += a
            while stack2 and stack2[-1][0] > j:
                a += stack2[-1][1]
                stack2.pop()
            stack2.append((j, a))
                
    print(total_area)
    print_area(stack2)

in_data = input()
calc_flood_area(in_data)


Measured memory_bytes: 6380
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		boolean[] isPrime = isPrimeN(100000);

		int[] sum = new int[100001];
		sum[0] = 0;
		for(int i=1; i<=100000; i+=2) {
			if(like2017(i, isPrime))
				sum[i] = sum[i-1] + 1;
			else
				sum[i] = sum[i-1];

			sum[i+1] = sum[i];
		}

		int Q = sc.nextInt();
		for(int i=0; i<Q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(sum[r]-sum[l-1]);
		}

	}

	public static boolean like2017(int n, boolean[] isPrime) {
		if(n % 2 == 0)
			return false;

		if(isPrime[n] && isPrime[(n+1)/2])
			return true;
		else
			return false;
	}

	//n以下のすべての数の高速な素数判定(エラトステネスの篩)
	public static boolean[] isPrimeN(int n) {

		boolean[] isPrime = new boolean[n+1];
		Arrays.fill(isPrime, true);
		isPrime[0] = false;
		isPrime[1] = false;

		int sqrt = (int)Math.sqrt(n);

		//割れる数はsqrt以下
		for(int i=2; i<=sqrt; i++) {
			if(isPrime[i]) {
				for(int j=i*i; j<=n; j+=i) {
					isPrime[j] = false;
				}
			}
		}

		return isPrime;
	}

}


Measured memory_bytes: 64944
a = [list(map(int, input().split())) for _ in range(3)]
d = [[0] * 3 for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1
for i in range(3):
    if sum(d[i]) == 3:
        print('Yes')
        exit(0)
for i in range(3):
    res = 0
    for j in range(3):
        res += d[j][i]
    if res == 3:
        print('Yes')
        exit(0)
res = 0
for i in range(3):
    res += d[i][i]
if res == 3:
    print('Yes')
    exit(0)
res = 0
for i in range(3):
    res += d[i][2 - i]
if res == 3:
    print('Yes')
    exit(0)
print('No')


Measured memory_bytes: 3064
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

mod rolling_hash {
    const MASK_30: u64 = (1 << 30) - 1;
    const MASK_31: u64 = (1 << 31) - 1;
    const M: u64 = (1 << 61) - 1;
    const B: u64 = 1_000_000_000 + 9;
    pub struct RollingHash {
        h: Vec<u64>,
        p: Vec<u64>,
    }
    impl RollingHash {
        pub fn new(s: &[u64]) -> Self {
            let n = s.len();
            let mut h = vec![0; n + 1];
            let mut p = vec![0; n + 1];
            p[0] = 1;
            for i in 0..n {
                h[i + 1] = mul(h[i], B) + s[i];
                p[i + 1] = mul(p[i], B);
            }
            Self { h, p }
        }
        pub fn get(&self, range: std::ops::Range<usize>) -> u64 {
            let l = range.start;
            let r = range.end;
            (self.h[r] + M - mul(self.h[l], self.p[r - l])) % M
        }
    }
  	#[inline]
    fn mul(a: u64, b: u64) -> u64 {
        let au = a >> 31;
        let ad = a & MASK_31;
        let bu = b >> 31;
        let bd = b & MASK_31;
        let mid = ad * bu + au * bd;
        let midu = mid >> 30;
        let midd = mid & MASK_30;
        (au * bu * 2 + midu + (midd << 31) + ad * bd) % M
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    use rolling_hash::RollingHash;

    let n: usize = rd.get();
    let s: String = rd.get();
    let t = s.chars().map(|c| c as u64).collect::<Vec<_>>();
    let rh = RollingHash::new(&t);
    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            let mut ok = 0;
            let mut ng = std::cmp::min(j - i, n - j) + 1;
            while ng - ok > 1 {
                let m = (ng + ok) / 2;
                if rh.get(i..(i + m)) == rh.get(j..(j + m)) {
                    ok = m;
                } else {
                    ng = m;
                }
            }
            ans = std::cmp::max(ans, ok);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[1<<18],b[1<<18],c,dist[1<<18],T[1<<18],cnt,U[1<<18];
vector<pair<int, int> >x[110000],y[110000];bool used[210000];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<m;i++){scanf("%d%d",&a[i],&b[i]);x[a[i]].push_back(make_pair(b[i],i));x[b[i]].push_back(make_pair(a[i],i));}
	fill(dist,dist+n+1,-1);dist[1]=0;queue<int>Q;Q.push(1);
	while(!Q.empty()){int a1=Q.front();Q.pop();for(pair<int,int>i:x[a1]){if(dist[i.first]==-1){dist[i.first]=dist[a1]+1;Q.push(i.first);}}}
	for(int i=1;i<=n;i++){for(pair<int,int>j:x[i]){if(dist[i]<dist[j.first]){y[i].push_back(j);T[j.first]++;}}}
	for(int i=0;i<q;i++){
		scanf("%d",&c);c--;queue<pair<int,int> >Q1; int ss=-1;
		if(dist[a[c]]<dist[b[c]])ss=b[c];
		if(dist[a[c]]>dist[b[c]])ss=a[c];
		if(ss>=1&&U[ss]==0&&used[c]==false){
			Q1.push(make_pair(ss,c));
			while(!Q1.empty()){
				int a1=Q1.front().first,a2=Q1.front().second;Q1.pop();
				if(U[a1]==1||used[a2]==true)continue;T[a1]--;used[a2]=true;if(T[a1]!=0)continue;cnt++;U[a1]=1;
				for(pair<int,int>j:y[a1]){if(U[j.first]==0)Q1.push(j);}
			}
		}
		printf("%d\n",cnt);
	}
}

Measured memory_bytes: 20064
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())
    a_s = list(map(int, input().split()))

    if n == 1:
        print(0)
        return

    ans = 0
    work = a_s[0]
    for a in a_s[1:]:
        if work - a > 0:
            ans += work - a
        else:
            work = a

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5
2 1 5 4 3"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
3 3 3 3 3"""
        output = """0"""
        self.assertIO(test_input, output)

    # 自作テストパターン
    def test_original(self):
        pass


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 97616
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];

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

    cout << count << endl;
}

Measured memory_bytes: 256
s=input()
k=int(input())
s_list=[]
for p in range(len(s)):
    for q in range(min(5,len(s[p:]))):
        if(not(s_list.__contains__(s[p:p+q+1]))):
                s_list.append(s[p:p+q+1])
s_list_sort=sorted(s_list)
print(s_list_sort[k-1])

Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
using namespace std;
int main()
{
 ll w,h,x,y, ct=0;
 cin>>w>>h>>x>>y;
 cout<<((double)w*(double)h)/2<<" ";
 if(2*x==w&&2*y==h) cout<<1;
 else cout<<0;
 
 
 
 
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int c[55][55],n,P,x;
signed main(){
	c[0][0]=1;
	for (int i=1;i<=50;i++){
		c[i][0]=1;
		for (int j=1;j<=i;j++)c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	scanf("%lld%lld",&n,&P);
	int cnt1=0,cnt2=0,ans=0;
	while (n--){
		scanf("%lld",&x);
		if (x&1)cnt1++;
		else cnt2++;
	}
	if (cnt1&1)P^=1;
	for (int i=P;i<=cnt1;i+=2)ans+=c[cnt1][i]*1LL<<cnt2;
	printf("%lld\n",ans);
}

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

int main(){
  int N,X; cin >> N >> X;
  int L[110];
  for (int i = 0; i < N; i++){
    cin >> L[i];
  }
  int res = 1;
  int now = L[0];
  for (int i = 1; now <= X; i++){
    res++;
    now += L[i];
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        if(n*a > b) ans = b;
        else ans = n*a;
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cctype>
using namespace std;

enum FACE { TOP,BACK, RIGHT ,LEFT , FRONT,  BOTTOM};
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (int f) { return var[id[f]]; }
  const T& operator[] (int f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_n() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_s() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_e() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_w() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_w():roll_s()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

int main()
{
	dice<int> d;
	for(int i=0;i<6;i++){
		int n; cin >>n;
		d[i] = n;
	}
	vector<dice<int> > vd;
	vd = d.all_rolls();

	int n;cin >> n;
	for(int i=0;i<n;i++){
		int top,back;
		cin >> top >> back;
		for(int i=0;i<vd.size();i++){
			if(vd[i][TOP] == top && vd[i][BACK] == back){
				cout << vd[i][RIGHT] << endl;
				break;
			}
		}
	}
    return 0;
}

Measured memory_bytes: 1200
n = int(input())
p = list(map(int, input().split()))
answer = 0
for i in range(1,n-1):
    if p[i] != min(p[i-1],p[i],p[i+1]) and p[i] != max(p[i-1],p[i],p[i+1]):
        answer += 1
print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
  
map <ll,int> p;
ll a[N];

inline bool check(int n){
	for(int i = 1;i <= n;++i){
		if(p[a[i]]) return 0;
		p[a[i]]++;
	}
	return 1;
}

int main() {
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;++i) scanf("%lld",&a[i]);
	if(check(n)) printf("YES\n");
	else printf("NO\n");
    return 0;
}

Measured memory_bytes: 14336
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)

Measured memory_bytes: 18448
#include <iostream>
#include <map>

int main() {
	std::uint32_t N;
	std::uint64_t area = 0, A;

	std::map<std::uint64_t, std::uint64_t> occurences;
	std::cin >> N;

	for (std::uint32_t i = 0; i < N; ++i) {
		std::cin >> A;

		if (!occurences.count(A)) {
			occurences.insert({A, 1});
		} else {
			++occurences[A];
		}
	}

	for (auto it = occurences.rbegin(); it != occurences.rend(); ++it) {
		if (it->second >= 2) {
			std::uint64_t L = static_cast<std::uint64_t>(it->first);

			if (it->second >= 4) {
				area = area > 0 ? area * L : L * L;
				break;
			} else {
				if (area) {
					area *= L;
					break;
				} else {
					area = L;
				}
			}

		}
	}

	std::cout << area << std::endl;

	return 0;
}

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

using namespace std;

int n,m,i,j;
char x;
bool tablica[1003][1003];
int dp[1003][1003];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cin >> x;
            if(x == '.'){
                tablica[i][j] = 1;
            }
            else{
                tablica[i][j] = 0;
            }
        }
    }
    dp[1][0] = 1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(tablica[i][j]){
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
            }
        }
    }
    cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;

void solve(int tc) {
	int r;
	cin>>r;
	cout<<6.283185*r<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    for(int tc=1; tc<=t; ++tc) {
        solve(tc);
    }    
    return 0;
}

Measured memory_bytes: 3804
n = int(input())
a = [int(_) for _ in input().split()]
ans1 = 0
ans2 = 0
tmp1 = 0
tmp2 = 0

flag = False
for i in a:
    tmp1 += i
    if flag and tmp1 <= 0:
        ans1 += 1-tmp1
        tmp1 = 1
    elif not flag and tmp1 >= 0:
        ans1 += tmp1+1
        tmp1 = -1
    
    if flag:
        flag = False
    else:
        flag = True

flag = True
for i in a:
    tmp2 += i
    if flag and tmp2 <= 0:
        ans2 += 1-tmp2
        tmp2 = 1
    elif not flag and tmp2 >= 0:
        ans2 += tmp2+1
        tmp2 = -1
    
    if flag:
        flag = False
    else:
        flag = True

print(min(ans1, ans2))

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

using namespace std;
#define int            long long
#define f(i,n)        for(int i=0;i<(n);++i)
#define fA(i,a,n)     for(int i=a;i<=(n);++i)
#define fD(i,a,n)     for(int i=a;i>=(n);--i)
#define tc 			  int t;cin>>t;f(testcase,t)
#define pii             pair<int,int>
#define pi  		   3.1415926535897932384626433832795028841971693993
void c_p_c() {

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
#endif
}

int32_t main() {

	c_p_c();

	long double a, b, h, m;
	cin >> a >> b >> h >> m;

	h = (h * 30) + (m / 2);
	m = m * 6;
	long double angle = max(h, m) - min(h, m);
	long double cangle = 360 - angle;

	angle = min(angle, cangle);
	angle = angle * (pi / 180);
	long double c = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle)));
	cout << fixed << setprecision(20) << c;


	return 0;
}


Measured memory_bytes: 4184
import java.util.Scanner;

public class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  while(true){
   int n = sc.nextInt();
   if(n==0) break;
   int[] data = new int[n];
   int sum = 0;
   for(int i=0;i<n;++i){
    data[i] = sc.nextInt();
    sum += data[i];
   }
   int count=0;
   for(int i=0;i<n;++i){
    if(data[i]<=sum/n) count++;
   }
   System.out.println(count);
  }
 }
}


Measured memory_bytes: 59088
n = input()
num9 = n.count("9")
if num9 == len(n):
    print(sum([int(item) for item in n]))
elif num9 == len(n) - 1 and n[0] != "9":
    print(sum([int(item) for item in n]))
else:
    print(int(n[0]) - 1 + (len(n) - 1) * 9)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int,input().split()))

law_ans = 0
absminA = float('inf')
for a in A:
    law_ans += abs(a)
    absminA = min(absminA, abs(a))


cnt_neg = 0

for a in A:
    if a < 0:
        cnt_neg += 1

cnt_0 = A.count(0)

if cnt_neg%2 == 0:
    print(law_ans)
else:
#０があるときはいつでもlaw_ansになるが、absminAが0だからおっけい
    print(law_ans-2*absminA)
    



Measured memory_bytes: 19744
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]
mod = 10 ** 9 + 7

# dp[h][w] := マス目(h, w)に辿り着く通り数
dp = [[0] * W for i in range(H)]
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        if G[h][w] == '#':
            continue

        dp[h][w] += (dp[h - 1][w] + dp[h][w - 1]) % mod

print(dp[-1][-1])


Measured memory_bytes: 51440
import sys
H, W = map(int,input().split())
table = []
for _ in range(H):
    table.append(list(input()))
t_x = [0,1,0,-1]
t_y = [1,0,-1,0]

for x in range(H):
    for y in range(W):
        if table[x][y] == '#':
            flag = 1
            for k in range(4):
                n_x = x + t_x[k]
                n_y = y + t_y[k]
                if 0 <= n_x <= H-1 and 0 <= n_y <= W-1 and table[n_x][n_y] == '#':
                    flag = 0
            if flag:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 3064