akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t
ll N, a, b, c;
vector<ll> V;
ll ans = INF;


int main(){
    cin >> N >> a >> b >> c;
    V.resize(N);
    for(int i = 0; i < N; i++) cin >> V[i];

    for(int i = 1; i < (1<<N); i++){
        for(int j = 1; j < (1<<N); j++){
            for(int k = 1; k < (1<<N); k++){
                bitset<10> B1 = i;
                bitset<10> B2 = j;
                bitset<10> B3 = k;
                if(!(B1&B2).none() || !(B2&B3).none() || !(B3&B1).none()) continue;

                ll len1 = 0, len2 = 0, len3 = 0;
                ll mp1 = 0, mp2 = 0, mp3 = 0;
                for(int i = 0; i < N; i++) if(B1[i] == 1) len1 += V[i];
                for(int i = 0; i < N; i++) if(B2[i] == 1) len2 += V[i];
                for(int i = 0; i < N; i++) if(B3[i] == 1) len3 += V[i];
                mp1 += (B1.count()-1)*10;
                mp2 += (B2.count()-1)*10;
                mp3 += (B3.count()-1)*10;

                mp1 += abs(len1-a);
                mp2 += abs(len2-b);
                mp3 += abs(len3-c);
                ans = min(ans, mp1+mp2+mp3);
            }
        }
    }




    cout << ans << endl;
    

}



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

#define pb push_back
int main(){
  int N;
  string s[10000];
  vector<string> t1,t2,t3;
  cin>>N;
  int result=0;
  rep(i, 0, N){
    cin >> s[i];
    int n = s[i].length();
     if(s[i][n-1]=='A'&&s[i][0]=='B') t1.pb(s[i]);
     else if(s[i][n-1]=='A') t2.pb(s[i]);
     else if(s[i][0]=='B') t3.pb(s[i]);
    rep(j, 0, n-1){
      if(s[i][j]=='A' && s[i][j+1]=='B') result++;
    }
  }
  int min1 = min(t2.size(),t3.size());
  int max1 = max(t2.size(),t3.size());
  if(max1!=0){
    result += t1.size() + min1;
  }else if(t1.size()>1){
    result += t1.size()-1;
  }
  cout<<result<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
using namespace std;
string c[55],x;
  int t[55],n,i,sum=0;
int main(){

cin>>n;
  for(i=0;i<n;i++){

  cin>>c[i]>>t[i];

}
cin>>x;
for(i=n-1;i>0;i--){
  if(c[i]==x)
      break;
      else
      sum=sum+t[i];

  }

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

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
int N;
cin >> N;
vector<int64_t> L(N);
for(int i=0; i<N; i++)
{
    cin >> L.at(i);
}
int count=0;
for(int i=0; i<N; i++)
{
 
    for(int j=0; j<N; j++)
    {
        for(int k=0; k<N; k++)
        {
            if((i!=k)&&(k!=j)&&(i!=j))
            {
            if((!(L.at(i)==L.at(k)))&&(!(L.at(i)==L.at(j)))&&(!(L.at(k)==L.at(j))))
            {
                if((L.at(i)+L.at(j)>L.at(k))&&(L.at(i)+L.at(k)>L.at(j))&&(L.at(k)+L.at(j)>L.at(i)))
                {
                    count++;
                }
            }
            }
        }
    }
}
cout << count/6 << endl;
}


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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()

int main(){
  uint64_t n;
  cin >> n;
  uint64_t q = sqrt(static_cast<long double>(n));
  while(q*q<n)++q;
  if(q * q == n){
    printf("0 0 %lu 0 0 %lu\n", q, q);
    return 0;
  }
  while(true){
    uint64_t r = q * q - n;
    for(uint64_t x = 1; x * x <= r; ++x){
      if(r % x == 0 && r / x <= 1000000000){
        printf("0 0 %lu %lu %lu %lu\n", q, x, r / x, q);
        return 0;
      }
    }
    ++q;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int n;
  cin >> n;
  set<string> st;
  rep(i, n){
    string s; cin >> s;
    st.insert(s);
  }

  cout << st.size() << ln;
}

Measured memory_bytes: 19176
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
const int V=120;
const int En=2100000;
struct Elf{int u,v;double len;}b[En];
const double oo=1e100;
double ret;
int N,M,Root;
int id[V],pre[V],cnt,vis[V];
double in[V];
bool TreeMST()
{
	ret=0.0;
	int i,u,v;
	while(1)
	{
		for(i=0;i<N;i++)
		in[i]=oo;
		memset(pre,-1,sizeof(pre));
		for(i=0;i<M;i++)
		{
			u=b[i].u;
			v=b[i].v;
			if(b[i].len<in[v]&&u!=v)
			{
				pre[v]=u;
				in[v]=b[i].len;
			}
		}
		for(i=0;i<N;i++)
		{
			if(i==Root)continue;
			if(pre[i]==-1)return false;
		}
		in[Root]=0;
		cnt=0;
		memset(id,-1,sizeof(id));
		memset(vis,-01,sizeof(vis));
		for(i=0;i<N;i++)
		{
			ret+=in[i];v=i;
			while(vis[v]!=i&&id[v]==-1&&v!=Root)
			{vis[v]=i;v=pre[v];}
			if(v!=Root&&id[v]==-1)
			{
				for(u=pre[v];u!=v;u=pre[u])
				id[u]=cnt;
				id[v]=cnt++;
			}
		}
		if(cnt==0)return true;
		for(i=0;i<N;i++)
		if(id[i]==-1)id[i]=cnt++;
		for(i=0;i<M;i++)
		{
			v=b[i].v;
			b[i].u=id[b[i].u];
			b[i].v=id[b[i].v];
			if(b[i].u!=b[i].v)
			b[i].len-=in[v];
		}
		N=cnt;
		Root=id[Root];
	//	for(i=0;i<N;i++)printf("%d ",pre[i]);
	//	printf("%d %d\n",cnt,Root);
	}
}
double sqr(double x){return x*x;}
int m,n;
double a[120][120];
double Cal(int x,int y,double r)
{
	double ret=0.0;
	for(int i=0;i<m;i++)
	ret+=sqr(a[x][i]-a[y][i]*r);
	return ret;
}
int i,j,k;
double lo,up,mid1,mid2;
int main()
{
	while(~scanf("%d%d",&m,&n))
	{
		for(i=1;i<=n;i++)
		{
			for(j=0;j<m;j++)
			scanf("%lf",&a[i][j]);
		}
		N=n+1;M=0;
		for(i=1;i<=n;i++)
		{
			b[M].u=0;
			b[M].v=i;
			double te=0.0;
			for(j=0;j<m;j++)
			te+=a[i][j]*a[i][j];
			b[M++].len=te;
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(i==j)continue;
				lo=-1e10;up=1e10;
				for(k=0;k<100;k++)
				{
					mid1=2.0*lo/3.0+up/3.0;
					mid2=lo/3.0+2.0*up/3.0;
					if(Cal(j,i,mid1)>Cal(j,i,mid2))lo=mid1;
					else up=mid2;
				}
				b[M].u=i;
				b[M].v=j;
				b[M++].len=Cal(j,i,lo);
			}
		}
	//	for(i=0;i<M;i++)
	//	printf("%d %d %.7f\n",b[i].u,b[i].v,b[i].len);
		Root=0;
		if(TreeMST())printf("%.8f\n",ret);
		else puts("Obsidian");
	}
}

Measured memory_bytes: 0
import math

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

ans = 0.0

for i in range(N):
    if i+1 > K:
        ans += 1.0/N
        continue
    else:
        x = math.log2(K/(i+1))
        x = math.ceil(x)
        ans += math.pow(0.5, x) * (1.0/N)

print("{:.10f}".format(ans))



Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int a, b, c;
    float d;

    scanf("%d %d %d", &a, &b, &c);

    d= (float)a/b;

    if (d <= c)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1636
n = int(input())

score_a = 0
score_b = 0
for i in range(n):
    a, b = input().split()
    if a > b:
        score_a += 3
    elif a == b:
        score_a += 1
        score_b += 1
    else:
        score_b += 3
print(score_a, score_b)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	vector<vector<ll> > arr (n,vector<ll>(3));
	vector<vector<ll> > dp (n,vector<ll>(3,0));
	for(int day = 0;day<n;day++)
	{
		for(int i=0;i<3;i++)
			cin>>arr[day][i];
		if(day == 0)
		{
			dp[day][0] = arr[day][0];
			dp[day][1] = arr[day][1];
			dp[day][2] = arr[day][2];
		}
		else
		{
			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					if(i!=j)
					{
						dp[day][i] = max(dp[day][i],arr[day][i] + dp[day-1][j]);
					}
				}
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

Measured memory_bytes: 11136
#include<iostream>

using namespace std;

int main(){
	int n, x;
	for (int a = 0; a < 100; a++) {
		cin >> n >> x;
		int i, j, k;
		int S = 0;
		int A[100][100][100];
		for (i = 0; i < n; i++) {
			for (j = 0;j < n; j++) {
				for (k = 0;k < n; k++) {
					if (x == i + j + k + 3 && i != j && j != k && k != i) {
						A[i][j][k] = 1;
					}
					else A[i][j][k] = 0;
					
					S += A[i][j][k];
				}
			}
		}
		if (n == 0 && x == 0) {
			break;
		}
		else cout << S / 6 << endl;
	}
	return 0;
}




Measured memory_bytes: 3080
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;

struct Node {
	ll key;
	Node* right, * left, * parent;
};

Node* root, * NIL;
Node* treeMininum(Node* x) {
	while (x->left != NIL) x = x->left;
	return x;
}
Node* find(Node* u, ll k) {
	while (u != NIL && k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}
Node* treeSuccessor(Node* x) {
	if (x->right != NIL) return treeMininum(x->right);
	Node* y = x->parent;
	while (y != NIL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node* z) {
	Node* y;
	Node* x;

	if (z->left == NIL || z->right == NIL) y = z;
	else y = treeSuccessor(z);
	if (y->left != NIL) {
		x = y->left;
	}
	else {
		x = y->right;
	}
	if (x != NIL) {
		x->parent = y->parent;
	}
	if (y->parent == NIL) {
		root = x;
	}
	else {
		if (y == y->parent->left) {
			y->parent->left = x;
		}
		else {
			y->parent->right = x;
		}
	}
	if (y != z) {
		z->key = y->key;
	}

	free(y);
}
void insert(ll k) {
	Node* y = NIL;
	Node* x = root;
	Node* z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node* u) {
	if (u == NIL) return;
	inorder(u->left);
	cout << ' ' << u->key;
	inorder(u->right);
}
void preorder(Node* u) {
	if (u == NIL) return;
	printf(" %lld", u->key);
	preorder(u->left);
	preorder(u->right);
}
int main() {
	ll N, i, X;
	string com;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> com;
		if (com.at(0) == 'f') {
			cin >> X;
			Node* t = find(root, X);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		if (com == "insert") {
			cin >> X;
			insert(X);
		}
		else if (com == "print") {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
		else if (com == "delete") {
			cin >> X;
			treeDelete(find(root, X));
		}
	}
}



Measured memory_bytes: 22020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> d(200, vector<ll>(200,1e18));
void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i,N){
        cin >> S[i];
    }
    vector<vector<ll>> G(N);
    rep(i,N){
        d[i][i] = 0;
        rep(j,N){
            if(S[i][j] == '1'){
                G[i].push_back(j);
                d[i][j] = 1;
            }
        }
    }
    
    vector<ll> memo(N,1e18);
    memo[0] = 0;
    queue<Pll> que;
    que.push(Pll(0,-1));
    while(!que.empty()){
        ll v = que.front().fi;
        ll p = que.front().se;
        que.pop();
        for(auto& u:G[v]){
            if(u == p) continue;
            if(memo[u] != 1e18){
                if((memo[v] + 1 - memo[u]) % 2 == 1){
                    cout << -1 << endl;
                    return 0;
                }
                continue;
            }
            que.push(Pll(u,v));
            memo[u] = memo[v] + 1;
        }
    }
    warshall_floyd(N);
    ll ans = -1;
    rep(i,N){
        rep(j,N){
            cmax(ans,d[i][j]);
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 4328
[x,y] = list(map(int, input().split()))
s1 = [1,3,5,7,8,10,12]
s2 = [4,6,9,11]
if x == 2:
  print("No")
elif x in s1 and y in s1:
  print("Yes")
elif x in s2 and y in s2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
x,y,a,b,c=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
q=[int(i) for i in input().split()]
r=[int(i) for i in input().split()]

p.sort()
q.sort()
r.sort()

p=p[-x:]
q=q[-y:]

ans=p+q+r
ans.sort()
ans=ans[-x-y:]
print(sum(ans))


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

int n,k,s;
int dp(int i,int num,int cnt)
{
  //  cerr<<i<<" "<<num<<" "<<cnt<<endl;
  if(num==0 && cnt==0)
    return 1;
  if(i>n)
    return 0;
  if(num<0)
    return 0;
  if(cnt<0)
    return 0;

  int ans=0;
  ans+=dp(i+1,num-i,cnt-1);
  ans+=dp(i+1,num,cnt);
  return ans;

}


int main()
{
  for(;cin>>n>>k>>s,n;)
    {
      cout<<dp(1,s,k)<<endl;
    }
}

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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int L[110000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++)cin >> L[i];
    sort(L, L + N), reverse(L, L + N);
    int sum = 0;
    for (int i = 1; i < N; i++)sum += L[i];
    if (L[0] < sum)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def solve():
  N = int(input())
  A = [int(i) for i in input().split()]
  B = [ False ] * N
  for i in range(N - 1, -1, -1):
    count = 0
    for j in range(N // (i + 1)):
      if B[(j + 1) * (i + 1) - 1]:
        count += 1
    if count % 2 != A[i]: B[i] = True

  print(B.count(True))
  for i in range(N):
    if B[i]: print(i + 1)

solve()

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

int main() {
    int N;
    set<string> st;
    cin >> N;
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        st.insert(S);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 19204
fun main(args: Array<String>) {
    val (h, w, k) = readLine()!!.split(' ').map { it.toInt() }
    val map = Array<String>(h) {""}

    repeat(h) {
        val s = readLine()!!
        map[it] = s
    }

    var answer = 0

    val digits = h + w
    val max = Math.pow(2.0,digits.toDouble()).toInt()
    for (i in 0..max) {
        val fullStr = String.format("%${digits}s", Integer.toBinaryString(i)).replace(" ", "0")
        val delH = fullStr.substring(0,h)
        val delW = fullStr.substring(h,h+w)
        var cnt = 0
        for (i in 0 until h) {
            for (j in 0 until w) {
                if (map[i][j] == '#' && delH[i] != '0' && delW[j] != '0') cnt++
            }
        }
        if (cnt == k) answer++
    }
    println(answer)
}


Measured memory_bytes: 55176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define test() ll t;cin>>t;while(t--)
int main()
{
	ll n,r;
  cin>>n>>r;
  if(n>=10)
  {
	cout<<r;
  }
  else
  {
    cout<<r+100*(10-n);
  }
}

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

using namespace std;

const int N = 1010;

int n;
vector<pair<int, int>> adj[N][N];
int inDeg[N][N];

void addEdge(int u, int v, int uu, int vv) {
    if (u > v) swap(u, v);
    if (uu > vv) swap(uu, vv);
    adj[u][v].push_back({uu, vv});
    inDeg[uu][vv]++;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        vector<int> a(n - 1);
        for (int &u : a) {
            cin >> u;
        }
        for (int j = 0; j + 1 < a.size(); j++) {
            addEdge(i, a[j], i, a[j + 1]);
        }
    }
    queue<pair<int, int>> q;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (inDeg[i][j] == 0) {
                q.push({i, j});
            }
        }
    }
    int res = 0;
    while (!q.empty()) {
        vector<pair<int, int>> now;
        while (!q.empty()) {
            pair<int, int> u = q.front();
            q.pop();
            now.push_back(u);
        }
        res++;
        for (auto v : now) {
            for (auto w : adj[v.first][v.second]) {
                inDeg[w.first][w.second]--;
                if (inDeg[w.first][w.second] == 0) {
                    q.push(w);
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (inDeg[i][j] > 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n>>m;
	if(n>=10)
		return cout<<m,0;
	m+=(100*(10-n));
	cout<<m<<endl;
}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];
  
  string  ans = "APPROVED";

  REP(i,N) {
    if (A[i]%2==0) {
      if (A[i]%3==0 || A[i]%5==0) {
        continue;
      } else {
        ans  = "DENIED";
        break;
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        boolean isOk = true;
        for(int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            if(A[i]  % 2 == 0) {
                if(!(A[i] % 6 == 0 || A[i] % 10 == 0)) {
                    isOk = false;
                }
            }
        }
        if(isOk){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
        return;
    }
}


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  string S;
  cin >> S;
  int ans=0;
  for(int i=0;i<S.size()/2;i++){
    if(S.at(i)!=S.at(S.size()-1-i)){
      ans++;
    }
  }
  cout << ans << endl;
  
}
      
  
  
  

Measured memory_bytes: 256
import java.util.*;
 class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){

			int m = sc.nextInt();
		    int f = sc.nextInt();
			int r = sc.nextInt();
			
			if(m == -1 && r == -1 && f == -1){
				return;
			}else if(m == -1 || f == -1){
				System.out.println("F");
			} else if(m + f >= 80){
				System.out.println("A");
			} else if(m + f >= 65 ){
				System.out.println("B");
			} else if(m + f >= 50){
				System.out.println("C");
			} else if(m + f >= 30){
				if(r >= 50){
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} 
			else if(m + f < 30){
				System.out.println("F");
			}

	  }
	}
}


Measured memory_bytes: 26484
from collections import Counter
N = int(input())
data = [0] * N


for i in range(0, N):
    data[i] = input()

count = Counter(data)
#count = sorted(count, key=lambda x: x[0])
#count = sorted(count)
most = count.most_common()
mostNum = most[0][1]
'''
print(count)    # counter_object
print(most)     # list;[(val,num),(val,num),/////]
print(mostNum)  # number of most
'''
most.sort()

for i in most:
    if (i[1] == mostNum):
        print(i[0])


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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=110,K=100010;
int a[N];
bool dp[K];
int n,k;

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n>>k;
	for(int i=0;i<n;++i)cin>>a[i];
	for(int i=0;i<=k;++i)
		for(int j=0;j<n;++j)
			if(i-a[j]>=0)
				dp[i]|=!dp[i-a[j]];
	cout<<(dp[k]?"First":"Second")<<endl;
}


Measured memory_bytes: 3736
#include<stdio.h>

int main(){
  int A,B,T;
  int sum = 0;
  scanf("%d %d %d",&A,&B,&T);
  for(int i = 1;i <= T;i++){
    if(i % A == 0){
      sum += B;
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=0;
    int n,m;
    cin>>n>>m;
    long long tmp=1900;
    for(int i=0;i<m;i++)tmp*=2;
    ans+=tmp*m;
    tmp=100*(n-m);
    for(int i=0;i<m;i++)tmp*=2;
    ans+=tmp;
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];

        Int x = 1;
        Int ans = 0;
        for (int i = 0; i < N; ++i) {
            if (i == 0) {
                ans += A[i] - 1;
                x = 2;
            } else {
                if (A[i] <= x) {
                    chmax(x, A[i] + 1);
                    continue;
                }
                ans += (A[i] - 1) / x;
            }
        }

        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main()
{
    int x, t;
    cin >> x >> t;
    cout << max(x-t,0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;

    long long a[n], b, ans = 1;

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

    for (int i = 0; i < n; i++)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] <= 1000000000000000000 / ans)
            ans *= a[i];
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4412
#include <stdio.h>
int main(void){
    // Your code here!
    double r, a, b;
    scanf("%lf %lf %lf", &r, &a, &b);
    a=r*r*3.14159265359;
    b=2*r*3.14159265359;
    printf("%f %f", a, b);
    return 0;

}



Measured memory_bytes: 2104
//  AtCoder Beginner Contest 134 
//  ドタバタしてるけど頑張るぞー
#include <stdio.h>
int main(void){
    int i,j;    //ループ用変数
    int x,n,count;
    char box[256] = {};
    char box2[256] = {};
    count = 0;
    
    //  入力
    scanf("%d",&x);
    
    //  処理
    x = 3 * (x * x);
    //  出力
    printf("%d",x);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = n; i >= 1; i--)
  {
    /*if (i >= k) {
      ans += 1/n;
      continue;
    }*/
    double p = 1;
    int x = i;
    while (x < k) {
      x *= 2;
      p *= 0.5;
    }
    
    ans += p / n;
  }
  cout << setprecision(10);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3732
(n,),*csf = [list(map(int, s.split())) for s in open(0)]

for j in range(n):
    t = 0
    for i in range(j,n-1):
        c,s,f = csf[i]
        t = max(t,s)
        t = s + (0-(s-t)//f * f)
        t += c
    print(t)

Measured memory_bytes: 74196
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val d = List.fill(n)(sc.nextInt() == sc.nextInt())
  var ok = false
  for (i <- 0 to n-3 if d(i) && d(i+1) && d(i+2)) {
    ok = true
  }
  println(if (ok) "Yes" else "No")
}


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

using namespace std;

typedef long long int ll;
typedef vector<ll> V;
typedef vector<V> VV;

int main() {
  // Happy hacking!
  ll n, m;
  V a;
  ll replace_idx = 0;
  vector<pair<ll, ll>> bc;

  cin >> n >> m;
  for(ll i=0; i<n; i++) {
    ll t;
    cin >> t;
    a.push_back(t);
  }
  for(ll i=0; i<m; i++) {
    ll bt, ct;
    cin >> bt >> ct;
    bc.push_back(make_pair(bt, ct));
  }

  sort(a.begin(), a.end());
    sort(bc.begin(), bc.end(), [](auto x, auto y) { return x.second > y.second; });

  for(auto itr=bc.begin(); itr!=bc.end(); itr++) {
    ll n_replace = itr->first;
    for(ll i=0; i<n_replace; i++) {
      //cout << replace_idx << endl;
      if(replace_idx >= n) break;
      if(a[replace_idx] >= itr->second) break;

      a[replace_idx] = itr->second;
      replace_idx++;
    }
  }

  ll res = 0;
  for(auto itr=a.begin(); itr!=a.end(); itr++) {
    res += *itr;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3188
fun main(args: Array<String>) {
  val S = readString()
  if (S.length % 2 == 1) {
    println("No")
    return
  }
  for (i in 0 until S.length / 2) {
    if (S[i * 2] != 'h' || S[i * 2 + 1] != 'i') {
      println("No")
      return
    }
  }
  println("Yes")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map(Integer::parseInt)
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 33820
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(double i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int n;
vector<int> v;
int main(){
    
    ll n;
    cin>>n;
    vector<int> s(n);
    ll sum=0;
    rep(i,n){
        cin>>s[i];
        sum+=s[i];
    }
    if(sum%10!=0){
        cout<<sum<<endl;return 0;
    }
    
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++){
        if(s[i]%10!=0){
            cout<<sum-s[i]<<endl;return 0;
        }
        
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S,T;
int A,B;
string U;
int main()
{
	cin>>S>>T;
	cin>>A>>B;
	cin>>U;
	if(U==S)
	{
		cout<<A-1<<' '<<B<<endl;
	}
	if(U==T)
	{
		cout<<A<<' '<<B-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=305,INF=1<<25;

int N;
int diss[MAX][MAX][23];
void floyd(){
    for(int l=0;l<20;l++){
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++){
                    diss[i][j][l]=min(diss[i][j][l],diss[i][k][l]+diss[k][j][l]);
                }
            }
        }
    }
}

vector<pair<int,ll>> G[MAX];
ll dis[MAX];

void dijkstra(int u){
    dis[u]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
    
    PQ.push(make_pair(0,u));
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(dis[b]<a) continue;
        for(int i=0;i<G[b].size();i++){
            int c=G[b][i].first;
            ll d=G[b][i].second;
            if(dis[c]>dis[b]+d){
                dis[c]=dis[b]+d;
                PQ.push(make_pair(dis[c],c));
            }
        }
    }
    return;
}//a,dが長さ

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int M,t,s,g;cin>>N>>M>>t>>s>>g;
        if(N+M==0) break;
        s--;g--;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                for(int k=0;k<t;k++){
                    diss[i][j][k]=INF;
                    diss[i][i][k]=0;
                }
            }
            dis[i]=INF;
            G[i].clear();
        }
        
        for(int i=0;i<M;i++){
            int a,b,c,d;cin>>a>>b>>c>>d;
            a--;b--;d--;
            diss[a][b][d]=min(diss[a][b][d],c);
            diss[b][a][d]=min(diss[b][a][d],c);
        }
        
        floyd();
        
        vector<int> cn(t);
        vector<vector<int>> cost(t,vector<int>(20005));
        
        for(int i=0;i<t;i++){
            cin>>cn[i];
        }
        
        for(int i=0;i<t;i++){
            vector<int> x(cn[i],INF),y(cn[i]);
            for(int j=0;j<cn[i]-1;j++){
                cin>>x[j];
            }
            for(int j=0;j<cn[i];j++){
                cin>>y[j];
            }
            int id=0;
            for(int j=1;j<=20000;j++){
                if(x[id]<j) id++;
                
                cost[i][j]=cost[i][j-1]+y[id];
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(i==j) continue;
                for(int k=0;k<t;k++){
                    if(diss[i][j][k]<INF){
                        G[i].push_back({j,cost[k][diss[i][j][k]]});
                        //if(M==4) cout<<i<<" "<<j<<" "<<k<<" "<<cost[k][diss[i][j][k]]<<endl;
                    }
                }
            }
        }
        
        dijkstra(s);
        
        if(dis[g]<INF){
            cout<<dis[g]<<endl;
        }else{
            cout<<-1<<endl;
        }
    }
}





Measured memory_bytes: 9368
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    rep(i,0,26){
        if(s[k-1]==A[i])s[k-1]=a[i];
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
const int MOD  = int(1e9)+7;


struct mint {
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD) {}
  mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


const int M = 60;
mint dp[M+1][2][2][2];


int main() {
  ll L, R; cin >> L >> R;
  dp[0][0][0][0] = 1;

  rep(i, M) {
    int Li = L>>(M-1-i)&1; // L の上から i 桁目
    int Ri = R>>(M-1-i)&1; // R の上から i 桁目
    rep(j, 2) rep(l, 2) rep(r, 2) rep(xi, 2) rep(yi, 2) {
      int j2 = j, l2 = l, r2 = r; // 遷移前の状態をコピー

      if (xi > yi) continue; // (x の i 桁目) ≦ (y の i 桁目) でなければ無視

      if (!j && (xi^yi)) continue; // (1, 1) が現れる前に (0, 1) か (1, 0) が現れたら無視
      if (xi&yi) j2 = 1;           // (1, 1) が現れたら j2 を更新

      if (!l && (xi < Li)) continue;
      if (xi > Li) l2 = 1;

      if (!r && (yi > Ri)) continue;
      if (yi < Ri) r2 = 1;

      dp[i+1][j2][l2][r2] += dp[i][j][l][r]; // 遷移式
    }
  }

  mint ans = 0;
  rep(l, 2) rep(r, 2) ans += dp[M][1][l][r];
  cout << ans << '\n';
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;


int main()
{
	int N, M;
	vector<int> A;

	cin >> N >> M;

	for(int i=0; i<M; i++){
		int tmp;
		cin >> tmp;
		N -= tmp;
	}

	if(N < 0){
		N = -1;
	}

	 
	
	cout << N;

	return 0;
	
}

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

int main() {
  int n,m;
  cin>>n>>m;
  std::vector<int> a(n),b(n),c(m),d(m);
  int kkk,mmm,ans;
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<m;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
    mmm=-1;
    for(int j=0;j<m;j++){
      kkk=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(mmm>kkk||mmm==-1){mmm=kkk;ans=j;}
    }
    cout<<ans+1<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void) {
	double x1, x2, y1, y2, x, y, z, length;
	
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	
	x = x2 - x1;
	y = y2 - y1;
	
	z = pow(x, 2.0) + pow(y, 2.0);
	
	length = sqrt(z);
	
	printf("%f\n", length);
	
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{

    ll a;
    cin >> a;
    
    // double b[a];
    // for (int i = 0; i < a; i++)
    // {
    //     cin >> b[i];
    // }

    // sort(b, b + a);

    // for (int i = 0; i < (a - 1); i++)
    // {
    //     b[i + 1] = (b[i] + b[i + 1]) / 2;
    // }

    // // cout << fixed;
    // // cout << setprecision(14);
    cout << a*a*a << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db double
using namespace std;
db sr(db a) {
  db mi = 0;
  db ma = a;
  for (int i = 0; i < 100; i ++) {
    db mu = (mi + ma) / 2;
    if (mu * mu < a) mi = mu;
    else ma = mu;
  }
  return ma;
}
db nj(db a) {
  return a * a;
}
int main () {
  int N;
  cin >> N;
  vector<db>x(N);
  vector<db>y(N);
  for (int i = 0; i < N; i ++) cin >> x[i] >> y[i];
  db n = (db)N;
  db ans = 0;
  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < N; j ++) {
      ans += sr(nj(x[i] - x[j]) + nj(y[i] - y[j]));
    }
  }
  ans /= n;
  cout << setprecision(8) << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    // d[i] is root => d[i] < 0 & d[i] is the size of tree
    // d[i] is child => d[i] >= 0 & d[i] = i.parent
    vector<int> d;

    DisjointSet() {}
    DisjointSet(int size) : d(size, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if ( d[x] > d[y] ) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
/* global variables */
/* function */
/* main */
int main(){
    int n, m, k;
    cin >> n >> m >> k;
    DisjointSet friendRelation = DisjointSet(n);
    vector<int> blockCnt(n), friendCnt(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        friendRelation.unite(a, b);
        friendCnt[a]++;
        friendCnt[b]++;
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        // a, bが同じクラスタならBlock
        if (friendRelation.same(a, b)) {
            blockCnt[a]++;
            blockCnt[b]++;
        }
    }
    // 友達候補 = Union findで同じクラスタの人数 - 自分 - すでに友達 - Block
    for (int i = 0; i < n; i++) {
        if (i) cout << ' ';
        cout << friendRelation.size(i) - 1 - friendCnt[i] - blockCnt[i];
    }
    cout << '\n';
}


Measured memory_bytes: 4564
def main():
    N = int(input())
    a = [None] + list(map(int, input().split()))
    b = [None] + [0]*N
    for i in range(N, 0, -1):
        ball = [b[j] for j in range(i, N+1, i)]
        if sum(ball) % 2 != a[i]:
            b[i] = 1
    ans = [str(i) for i, n in enumerate(b) if n==1]
    print(len(ans))
    print(' '.join(map(str, ans)))
main()

Measured memory_bytes: 19248
prime = [True]*((10**5)+1)
prime[0]=False
prime[1]=False
for i in range(2,10**3):
  if i*i>10**5:
    break
  if prime[i]:
    for j in range(i,10**5):
      if i*j>10**5:
        break
      prime[i*j]=False

prime2017 = [x for x in prime]
prime2017[2] = False
for i in range(3,(10**5)+1):
  if prime[i]:
    prime2017[i] = prime[(i+1)//2]

count = 0
csum = [0]*((10**5)+1)
for i in range((10**5)+1):
  if prime2017[i]:
    count+=1
  csum[i]=count

N = int(input())
for _ in range(N):
  l,r = map(int,input().split())
  print(csum[r]-csum[l-1])
    

Measured memory_bytes: 52640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
char c[2005][2005];
int row[2005][2005],col[2005][2005];
int main(){
	int h,w;
	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++){
		scanf("%s",c[i]);
	}
	for(int i=0;i<h;i++){
		if(c[i][0]=='.') row[i][0]=1;
		for(int j=1;j<w;j++){
			if(c[i][j]=='.') row[i][j]=row[i][j-1]+1;
		}
		for(int j=w-2;j>=0;j--){
			if(c[i][j]=='.') row[i][j]=max(row[i][j],row[i][j+1]);
		}
	}
	int ma=0;
	for(int i=0;i<w;i++){
		if(c[0][i]=='.') col[0][i]=1;
		for(int j=1;j<h;j++){
			if(c[j][i]=='.') col[j][i]=col[j-1][i]+1;
		}
		for(int j=h-2;j>=0;j--){
			if(c[j][i]=='.') col[j][i]=max(col[j][i],col[j+1][i]);
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(c[i][j]=='.')ma=max(ma,row[i][j]+col[i][j]-1);
		}
	}
	cout<<ma;
}

Measured memory_bytes: 35584
from itertools import permutations

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

res = 0
for P in permutations(range(N), N):
    if P[0] != 0:
        continue
    for i in range(N - 1):
        if P[i + 1] not in G[P[i]]:
            break
    else:
        res += 1

print(res)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    V<int> v;
    for(int i = 0; i < 3; i++){
        int a, b; cin >> a >> b;
        v.push_back(a);
        v.push_back(b);
    }

    sort(ALL(v));

    if(v[1] != v[2] || v[3] != v[4]){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }


    return 0;
}


Measured memory_bytes: 3628
h, w = gets.chop.split.map(&:to_i)
$table = []
h.times do
  $table << gets.chop.split('')
end

def check(i, j)
  return true if $table[i].nil? || $table[i][j].nil?
  $table[i][j] == "."
end

ans = "Yes"
h.times do |i|
  w.times do |j|
    if $table[i][j] == "#"
      ans = "No" if check(i-1, j) && check(i+1, j) && check(i, j-1) && check(i, j+1)
    end
  end
end

puts ans


Measured memory_bytes: 2044
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define err(x) cout << #x << ": " << x << endl;

using namespace std;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef map <int, int> mi;

const int N = 1e4 + 10, MAX = 1e2 + 10;
int n, m, h, w, a[N], t[MAX][MAX];

main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> h >> w >> n;
	for (int i = 1 ; i <= n ; i++)
		cin >> a[i];
	int color = 1;
	for (int i = 1 ; i <= h ; i++){
		if (i & 1){
			for (int j = 1 ; j <= w ; j++){
				if (a[color] == 0)
					color++, t[i][j] = color, a[color]--;
				else if (a[color] > 0)
					t[i][j] = color, a[color]--;
			}
		}
		else {
			for (int j = w ; j >= 1 ; j--){
				if (a[color] == 0)
					color++, t[i][j] = color, a[color]--;
				else if (a[color] > 0)
					t[i][j] = color, a[color]--;
			}
		}
	}
	for (int i = 1 ; i <= h ; i++){
		for (int j = 1 ; j <= w ; j++)
			cout << t[i][j] << " ";
		cout << '\n';
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int a[n];
    memset(a,-1,sizeof(a));
    int r=1;
    while(m--)
    {
        int s,c;
        cin>>s>>c;
        if(n!=1 && s==1 && c==0) {
            r=0;
            break;
        }
        if(a[s-1]==-1||a[s-1]==c)
        a[s-1]=c;
        else
        {
            r=0;
            break;
        }
    }
    if(r==0)
    {cout<<"-1"<<endl;
    return 0;
    }

    if(n==1){
        if(a[0]==-1) cout << 0;
        else cout << a[0];

        return 0;
    }
    
    for(int i=0 ; i<n ; i++){
        if(i==0 && a[i]==-1) {
            a[i]=1;
        }
        else if(a[i]==-1){
            a[i]=0;
        }
    }

    for(int i=0 ; i<n ; i++) {
        cout << a[i];
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string S;
    cin >> S;

    int n = S.size();
    
    for(int i = 1; i < n; i++) {
        if (S[i-1] == S[i]) {
            cout << i << " " << i+1 << endl;
            return 0;
        } else if (i >= 2 && S[i-2] == S[i]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;

    return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll n,r;
	ll res = 0;
	cin >> n>>r;
	res = r;
	if (n < 10) {
		res += 100 * (10 - n);
	}

	cout << res << endl;
	return(0);
}

Measured memory_bytes: 256
//   <<In The Name Of God>>
// PTD
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

const int maxn = 1e5 + 1;
bool b[maxn];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n, ans = 0;
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		if (!b[a])
			ans++;
		b[a] = 1;
	}
	//cout << ans << endl;
	if (ans % 2 != 0)
		cout << ans << endl;
	else
		cout << ans - 1 << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
  cin >> N;
  int V[N];
  int C[N];
  
for(int i = 0;i < N;i++){
  cin >> V[i];
}
  
for(int i = 0;i < N;i++){
  cin >> C[i];
}

int ans = 0;
  
  for(int i = 0;i < N;i++){
    if(V[i] > C[i]) ans += V[i] - C[i];  
  }
  
cout << ans << endl; 
return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct Point{
  double x;
  double y;
}Point;

void koch(int n,Point a,Point b){
  if(n==0)return; 
  Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)* cos(th)-(t.y-s.y)* sin(th)+s.x;
  u.y=(t.x-s.x)* sin(th)+(t.y-s.y)* cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,d,i,j,k,c1=0; cin>>n>>d;
    int a[n][d];
    double x=0;
    for(i=0;i<n;i++) for(j=0;j<d;j++) cin>>a[i][j];
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            for(k=0;k<d;k++){
                x+=pow((a[i][k]-a[j][k]),2);
            }
            x=sqrt(x);
            if(floor(x)==ceil(x)) c1++;
            x=0;
        }
    }
    cout<<c1<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) { cin >> a[i]; }
  sort(a, a + n);
  ll diff = min(a[0], a[n - 1] - a[0]);
  ll ans = a[0];
  REP(i, n - 1) {
    ll tmp = max(diff, min(a[i], a[n - 1] - a[i]));
    if (tmp != diff) {
      diff = tmp;
      ans = a[i];
    }
  }
  cout << a[n - 1] << " " << ans;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int flag = 2*x==W && 2*y==H ? 1 : 0;
		
		System.out.println((double)W*H/2+" "+flag);
	}		
}


Measured memory_bytes: 22736