akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mk make_pair
    #define ft first
    #define sc second
    #define ppb pop_back
    #define sz size
    #define forn(i,a,n) for(i=a;i<n;i++)
    #define M 1000000007
    #define inf 2e18
    
    int main() {

   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll t;
    cin>>t;
    ll i, arr[t];
    for(i=0;i<t;i++)
    	cin>>arr[i];
    ll dp[t];
    memset(dp,0,sizeof dp);
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<t;i++)
    	dp[i]=min(dp[i-1]+ abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));

    cout<<dp[t-1];
    return 0;
    } 

Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int[] n=new int[3];
    for(int i=0;i<3;i++){
      n[i]=sc.nextInt();
    }
    Arrays.sort(n);
    if((n[0]==n[1]&&n[1]!=n[2])||(n[0]!=n[1]&&n[1]==n[2])){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using Z=long;
Z S(vector<pair<int,int>> a){
sort(a.begin(),a.end());Z A=0;
priority_queue<int,vector<int>,greater<>> Q;
for(auto [k,d]:a){
Q.emplace(d);A+=d;
while(Q.size()>k)A-=Q.top(),Q.pop();
}return A;}
int main(){
	int q; scanf("%d",&q);
	rep(_,q){
		int n; scanf("%d",&n);
		Z sum=0;
		vector<pair<int,int>> L,R;
		rep(i,n){
			int k,l,r; scanf("%d%d%d",&k,&l,&r);
			if     (l>r) L.emplace_back( k ,l-r), sum+=r;
			else if(r>l) R.emplace_back(n-k,r-l), sum+=l;
			else         sum+=l;
		}
		cout<<sum+S(L)+S(R)<<endl;
	}

}


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

int N, ans = 0;

void dfs(long long n, int i) {
  if (n > N) return;
  if (i == 7) ans++;
  dfs(n * 10 + 3, i | 1);
  dfs(n * 10 + 5, i | 2);
  dfs(n * 10 + 7, i | 4);
}

int main() {
  cin >> N;

  dfs(0, 0);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9+7)
#define MAX_V (10)
#define MAX_E (45)
#define MAX_C (100)

int V, E;
int D[MAX_V][MAX_V];

void warshall_floyd() {
  for (size_t u = 0; u < V; u++)
    for (size_t v = 0; v < V; v++)
      for (size_t w = 0; w < V; w++) D[u][v] = D[v][u] = min(D[u][v], D[u][w] + D[w][v]);
}

void solve() {
  int ans_c, ans_d = INF;

  warshall_floyd();

  for (size_t v = 0; v < V; v++) {
    int cost = 0;
    for (size_t u = 0; u < V; u++) cost += (D[u][v] < INF)? D[u][v]: 0;
    if (cost < ans_d) {
      ans_c = v;
      ans_d = cost;
    }
  }

  printf("%d %d\n", ans_c, ans_d);
}

int main() {
  while (true) {
    scanf("%d", &E);
    if (E == 0) break;

    for (size_t u = 0; u < MAX_V; u++)
      for (size_t v = 0; v < MAX_V; v++) D[u][v] = (u == v)? 0: INF;

    V = 0;
    for (size_t i = 0; i < E; i++) {
      int v, u, cost;
      scanf("%d %d %d", &u, &v, &cost);
      D[u][v] = D[v][u] = cost;
      V = max(V, (max(u, v)));
    }
    V++;

    solve();
  }

  return 0;
}

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

int main(){
  int d;
  int c[27];
  int s[400][27];
  int t[400];
  static int last[27];//最後の開催日

  cin >> d;
  rep(i, 26)cin >> c[i+1];
  rep(i, d){
    rep(j, 26){
      cin >> s[i+1][j+1];
    }
  }

  for(int i=1;i<=d;i++){
    int mx = -INF;
    int mxi;
    for(int j=1;j<=26;j++){
      int tmp=0;
      tmp += s[i][j];
      for(int k=1;k<=26;k++){
        if(j!=k)tmp-=(i-last[k])*c[k];
      }
      if(tmp>mx){
        mx = tmp;
        mxi = j; 
      }
    }
    t[i]=mxi;
    last[t[i]]=i;
  }

  //
  int target = 0;
  rep(i, 26)last[i+1]=0;
  for(int i=1;i<=d;i++){
    target += s[i][t[i]];
    last[t[i]]=i;
    for(int j=1;j<=26;j++)target-=(i-last[j])*c[j];
  }

  pair<int, int> pr[26];
  rep(i, 26){
    pr[i] = pair<int, int>(c[i+1], i+1);
  }
  sort(pr, pr+26);
  
  //ここから焼きなまし法
  rep(l, 100){
    int aft = pr[l/5].second;
    for(int k=1;k<=d;k++){
      //k日目をaftに変更する
      int tmp = 0;
      rep(i, 26)last[i+1]=0;
      for(int i=1;i<=d;i++){
        if(i==k){
          tmp += s[i][aft];
          last[aft]=i;
          for(int j=1;j<=26;j++)tmp-=(i-last[j])*c[j];
          continue;
        }
        tmp += s[i][t[i]];
        last[t[i]]=i;
        for(int j=1;j<=26;j++)tmp-=(i-last[j])*c[j];
      }
      // cout << target << ":" << tmp << endl;
      if(tmp>target){
        t[k]=aft;
        target = tmp;
      }
    }
  }
  
  rep(i, d)cout << t[i+1] << endl;
  return 0;
}


Measured memory_bytes: 3716
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
if X<=x[-1] and x[-1]<y[0] and y[0]<=Y:
    print("No War")
else:
    print("War")


Measured memory_bytes: 8924
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <cstring>
using namespace std;
int main(){
    int x;
    cin>>x;
    if(x>=400&&x<=599){
    	cout<<8;
	}
	if(x>=600&x<=799){
    	cout<<7;
	}
	if(x>=800&&x<=999){
    	cout<<6;
	}
	if(x>=1000&&x<=1199){
    	cout<<5;
	}if(x>=1200&&x<=1399){
    	cout<<4;
	}
	if(x>=1400&&x<=1599){
    	cout<<3;
	}
	if(x>=1600&&x<=1799){
    	cout<<2;
	}
	if(x>=1800&&x<=1999){
    	cout<<1;
	}
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define dl double
using namespace std;
const int maxn=2e5+5;
const dl pi=M_PI,esp=1e-7;
int n,l,r,tot;
dl ans;
int f[maxn],b[maxn];
struct node{
	int x,y;
}a[maxn],s,t;
bool cmp1(node a,node b){return a.x<b.x;}
signed main()
{
	//freopen("loveround.in","r",stdin);freopen("loveround.out","w",stdout);
	scanf("%lld%lld%lld%lld%lld",&s.x,&s.y,&t.x,&t.y,&n);
	if (s.x>t.x){swap(s.x,t.x);swap(s.y,t.y);}
	for (int i=1;i<=n;i++)scanf("%lld%lld",&a[i].x,&a[i].y);
	sort(a+1,a+n+1,cmp1);
	for (int i=1;i<=n;i++){
		if (a[i].x>=min(s.x,t.x)&&a[i].x<=max(s.x,t.x)&&a[i].y>=min(s.y,t.y)&&a[i].y<=max(s.y,t.y))b[++tot]=s.y>t.y?-a[i].y:a[i].y;
	}
	int len=0;f[0]=-1e9;
	for (int i=1;i<=tot;i++){
		if (b[i]>f[len])f[++len]=b[i];else{
			int p=upper_bound(f+1,f+len+1,b[i])-f;
			f[p]=b[i];
		}
	}
	if (len==min(abs(s.y-t.y),abs(s.x-t.x))+1) ans=abs(s.x-t.x)*100+abs(s.y-t.y)*100+(len-1)*(5*pi-20)+(10*pi-20);
	 else ans=abs(s.x-t.x)*100+abs(s.y-t.y)*100+len*(5*pi-20);
	printf("%.11lf",ans);
	return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		outer: while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			int[] s1 = new int[n];
			int[] s2 = new int[m];
			int sum1 = 0, sum2 = 0;
			for (int i = 0; i < n; ++i) {
				s1[i] = sc.nextInt();
				sum1 += s1[i];
			}
			for (int i = 0; i < m; ++i) {
				s2[i] = sc.nextInt();
				sum2 += s2[i];
			}
			Arrays.sort(s1);
			Arrays.sort(s2);

			int diff = sum2 - sum1;
			int t = 0;
			for (int i = 0; i < n; ++i) {
				while (t + 1 < m && 2 * (s2[t] - s1[i]) < diff) {
					++t;
				}
				if (2 * (s2[t] - s1[i]) == diff) {
					System.out.println(s1[i] + " " + s2[t]);
					continue outer;
				}
			}
			System.out.println(-1);
		}
		sc.close();
	}
}

Measured memory_bytes: 28992
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    };

    if let Some(_) = a.iter().find(|&&x| x == 0) {
        println!("{}", 0);
    } else {
        let ans = a.iter().fold(1u64, |acc, &x| acc.saturating_mul(x));
        if ans > 10u64.pow(18) {
            println!("{}", -1);
        } else {
            println!("{}", ans);
        }
    }
}


Measured memory_bytes: 4492
#include <stdio.h>

int main(){
	int n,w,max = 0,tmp = 0;
	int a[3][101];
	scanf("%d",&n);
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(int p=1;p<=n;p++){
		w = 1;
		tmp = 0;
		for(int i=1;i<=n;i++){
			tmp += a[w][i];
			if (i==p) {
				w = 2;
				tmp += a[w][i];
			}
			if (max < tmp) {
				max = tmp;
			}
		}
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

const ll MAX = 1000000000000000000;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  vector<ll> a(n, 0);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i, n) {
    if (a[i] <= MAX / ans) {
      ans *= a[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get() {}template<class H, class...T>void get(H&h, T&...t) { cin >> h; get(t...); }
template<class T>void geti(T&a) { for (auto&_ : a)cin >> _; }
template<class T>void getii(T&a) { for (auto&_ : a)geti(_); }
void put(string d) {}template<class H, class...T>void put(string d, H&h, T&...t) { cout << h; if (sizeof...(t))cout << d; put(d, t...); }
template<class T>void puti(T&a, string d = " ") { bool f = 1; for (auto&_ : a)cout << (exchange(f, 0) ? "" : d) << _; cout << endl; }
template<class T>void putii(T&a, string d = " ") { for (auto&_ : a)puti(_, d); }
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int gcd(int a, int b) {
    if (b > a) {
        swap(a, b);
    }
    while (b!=0) {
        int tmp = a%b;
        a = b;
        b = tmp;
    }
    return a;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b)<<endl;
}



Measured memory_bytes: 3112
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n+1][2];
    dp[n-1][0]=0;
    dp[n-1][1]=a[n-1];
    dp[n-2][0]=max(a[n-2],a[n-1]);
    for(int i=n-3;i>=0;i--)
    {
        if((n-i)%2)
        {
            dp[i][1]=a[i]+dp[i+2][1];
            dp[i][0]=max(a[i]+dp[i+2][0],dp[i+1][0]);
        }
        else
        {
            dp[i][1]= -INF;
            dp[i][0]=max(dp[i+1][1],a[i]+dp[i+2][0]);
        }
    }
    int ans;
    ans=dp[0][0];
    if(n%2)
        ans=max(ans,dp[1][0]);
    cout<<ans<<endl;
    
}


int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	long long int n,k;
	cin>>n>>k;
	cout<<floor(log(n)/log(k))+1;
	return 0;
}

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

int main(){
    long long a,b,x;
    cin >> x;

    for(long long a = -1000;a<=1000;a++){
        for(long long b = -1000;b <= 1000;b++){
            if(a * a * a * a * a  - (b * b * b * b * b) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	boolean isContained = false;
      	for(int i = 0; i < s.length(); i++) {
        	if(s.contains("a") && s.contains("b")
               && s.contains("c")) isContained = true;
        }
      	if(isContained) {
        	System.out.println("Yes");  
        } else {
        	System.out.println("No");  
        }
	}
}

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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, x;
    cin >> n >> m >> x;
    bitset<101> a;
    for (int i = 0; i < m; i++) {
        int t;
        cin >> t;
        a[t] = true;
    }
    int rights = 0;
    for (int i = x + 1; i < n; i++) {
        rights += a[i];
    }
    int lefts = 0;
    for (int i = x - 1; 0 < i; i--) {
        lefts += a[i];
    }
    cout << min(rights, lefts) << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
//Solution for aoj:0042 A Thief
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
using namespace std;
int w, n, c;
char a;
int trs[1001][2];
int dp[1001][1001];
int main(){
	while (cin >> w){
		if (!w)
			return 0;
		c++;
		cin >> n;
		for (int i = 1; i <= n; i++){
			cin >> trs[i][0] >> a >> trs[i][1];
		}
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= w; j++){
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (j >= trs[i][1])
					dp[i][j] = max(dp[i][j], dp[i - 1][j - trs[i][1]] + trs[i][0]);
			}
		}
		for (int i = 1; i <= w; i++){
			if (dp[n][i] == dp[n][w]){
				cout << "Case " << c << ':' << endl << dp[n][i] << endl << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  bool check = false;
  
  for (int k = 0; k < N; k++){
    cin >> b.at(k);
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (A.at(i).at(j) == b.at(k)){
          A.at(i).at(j) = 0;
        }
      }
    }
  }
  
  for (int i = 0; i < 3; i++){
    if (A.at(i).at(0) + A.at(i).at(1) + A.at(i).at(2) == 0){
      check = true;
    }
    else if (A.at(0).at(i) + A.at(1).at(i) + A.at(2).at(i) == 0){
      check = true;
    }
  }
  
  if (A.at(0).at(0) + A.at(1).at(1) + A.at(2).at(2) == 0
      || A.at(2).at(0) + A.at(1).at(1) + A.at(0).at(2) == 0){
    check = true;
  }
  
  if (check){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int H,W;
    cin>>H>>W;
    vector<string> vs(H);
    for(int i=0;i<H;i++){
        string s;
        cin>>s;
        vs[i]=s;
    }
    vvi l(H,vi(W,0)),d(H,vi(W,0)),u(H,vi(W,0)),r(H,vi(W,0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(vs[i][j]=='#'){
                l[i][j]=0;
                u[i][j]=0;
            }else{
                if(j-1>=0){
                    l[i][j]=l[i][j-1]+1;
                }else{
                    l[i][j]=1;
                }
                if(i-1>=0){
                    u[i][j]=u[i-1][j]+1;
                }else{
                    u[i][j]=1;
                }
            }
        }
    }

    for(int i=H-1;i>=0;i--){
        for(int j=W-1;j>=0;j--){
            if(vs[i][j]=='#'){
                r[i][j]=0;
                d[i][j]=0;
            }else{
                if(j+1<W){
                    r[i][j]=r[i][j+1]+1;
                }else{
                    r[i][j]=1;
                }
                if(i+1<H){
                    d[i][j]=d[i+1][j]+1;
                }else{
                    d[i][j]=1;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(vs[i][j]='.'){
                int count=l[i][j]+r[i][j]+u[i][j]+d[i][j]-3;
                ans=max(ans,count);
            }
        }
    }
    out(ans);

}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 67200
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

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

    ll ans = a*x + b*y;

    ans = min(ans, 2*c*x + b*max((ll)0, y-x));
    ans = min(ans, a*max((ll)0, x-y) + 2*c*y);

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<typename S, typename T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<typename S, typename T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T> bool print_(const T& a) {
    cout << a;
    return true;
}
template <typename T> bool print_(const vector<T> &vec) {
    for(auto &a : vec) {
        cout << a;
        if(&a != &vec.back()) cout << " ";
    }
    return false;
}
template <typename T> bool print_(const vector<vector<T>>& vv) {
    for(auto &v : vv) {
        for(auto &a : v) {
            cout << a;
            if(&a != &v.back()) cout << " ";
        }
        if(&v != &vv.back()) cout << "\n";
    }
    return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail> 
void print(Head &&head, Tail &&... tail) {
    bool f = print_(head);
    if(sizeof...(tail) != 0) cout << (f ? " " : "\n");
    print(forward<Tail>(tail)...);
}
#pragma endregion

map<ll, ll> mp;
ll solve(ll x){
    if(x == 0) return 0;
    if(x == 1) return 1;
    if(mp.count(x)) return mp[x];
    if(x % 2 == 0) return mp[x] = ((2*solve(x/2))%MOD + solve(x/2-1))%MOD;
    else return mp[x] = ((2*solve((x-1)/2))%MOD + solve((x-1)/2+1))%MOD;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    print(solve(n+1));
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    string s;
    cin>>s;
    vector<ll> a(s.size());
    for(int i=0;i<s.size();i++){a[i]=s[i]-'A';}
    ll w=0;
    ll count=0;
    for(int i=0;i<a.size();i++){
        if(a[i]>w){count+=a[i]-w;}
        else{count+=a[i]+26-w;}
        w=a[i];
    }
    cout<<count/26<<endl;
    
    return 0;
}



Measured memory_bytes: 3216
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int pre[M],suf[M];
 main()

{
    fast
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sum=0;
    f(i,1,n)
    {
       if(s[i-1]=='W')sum++;
       pre[i]=sum;
    }
    sum=0;
    rf(i,n,1)
    {
       if(s[i-1]=='R')sum++;
       suf[i]=sum;
    }
    int ses=n;
    f(i,0,n)
    {
      int cost=max(suf[i+1],pre[i]);
      ses=min(ses,cost);
    }
    cout<<ses<<endl;

}





































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

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

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

    ll N,M; cin >> N >> M;
    ll sum = 0;
    ll tmp;

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

    if(sum > N) cout << -1 << endl;
    else cout << N-sum << endl;

    return 0;

}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
char s[500010];int n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int ans=0;
	for(int l=1,r=2;l<=n;){
		while(l<=n&&s[l]=='0')++l;
		if(l>n)break;
		if(l+1>r)r=l+1;
		++ans;
		while(r<=n&&s[r]>=s[r-1])r++;
		if(r>n)break;
		while(1){
			++l;
			if(s[l-1]==s[r-1])break;
		}
		for(int ct=n;ct>=l;ct--){
			s[ct]++;
			if(s[ct]>'9')s[ct]-=10;else break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 768
import java.util.Scanner
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val s: Long = sc.nextLong
    val kehin = List.fill(s.toInt)(sc.next)
    
    val result = kehin.distinct
    
    println(result.length)
    
  }
}

Measured memory_bytes: 80072
#include <iostream>
#include <sstream>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long 

const ll inf = numeric_limits<ll>::min();

int N;
int F[100][10];
ll P[100][11];
int Sale[10];

//整数nを二進数に変換し配列Saleに代入
void to_binary(int n){
	for(int i=0;i<10;i++){
		Sale[i] = n%2;
		n /= 2;
		//cout << Sale[i];
	}
	//cout << ": ";
}

// 店kによって発生する利益を計算
ll cal_ben(int k){
	int count = 0;
	for(int i=0;i<10;i++){
		if(F[k][i]==1 && Sale[i]==1) count++;
	}
	return P[k][count];
}


ll total_ben(int n){
	ll ans=0;
	to_binary(n);
	for(int i=0;i<N;i++){
		ans += cal_ben(i); 
	}
	//cout << ans << endl;
	return ans;
}



int solve(){
	ll ans = inf;

	for(int i=1;i<1024;i++){
		ans = max(ans, total_ben(i));
	}

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

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<10;j++){
			cin >> F[i][j]; 
		}
	}

	for(int i=0;i<N;i++){
		for(int j=0;j<11;j++){
			cin >> P[i][j];
		}
	}

	solve();

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

s = input()


before = int(s[0:2])
after = int(s[2:4])

before_year = False
after_year = False
before_m = False
after_m = False

if before > 12:
    before_year = True
else: before_m = True

if after > 12:
    after_year = True
else: after_m = True

if before==0 and after==0:
    print('NA')
elif before ==0 and after_m==True:
    print('YYMM')
elif after == 0 and before_m==True:
    print('MMYY')
elif before==0 or after==0:
    print('NA')
elif before_year==True and after_year==True:
    print('NA')
elif before_m==True and after_m==True:
    print('AMBIGUOUS')
elif before_year==True and after_m==True:
    print('YYMM')
elif before_m==True and after_year==True:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    str s;
    cin >> s;
    int n = sz(s);
    cout << str(n, 'x') << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int binary[10];
int check[100];
void init (void) {
  for (int i = 0; i < 100; i++) {
    check[i] = 0;  
  }  
}
void ten_two (int x) {
  int sub = 1;
  for (int i = 0; i < 9; i++) {
    sub = sub * 2;    
  }   
  for (int i = 0; i < 10; i++) {
    if (x >= sub) {
      if (sub != 0) {
        binary[i] = 1;
      }
      x = x - sub;  
    }  
    else {
      binary[i] = 0;  
    }
    sub = sub / 2;
  }
}

int main () {
  int N;
  cin >> N;
  int F[N][10];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];  
    }  
  }
  long long P[N][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> P[i][j];  
    }  
  }
  long long ans = -1000000007;
  for (int a = 1; a <= 1023; a++) {
    init();
    ten_two(a);
    long long subsub = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 10; j++) {
        if (F[i][j] == 1 && binary[j] == 1) {
          check[i]++;    
        }  
      }  
    }      
    for (int i = 0; i < N; i++) {
      subsub = subsub + P[i][check[i]];
    }
    if (subsub > ans) {
      ans = subsub;  
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from functools import reduce
n, *s = open(0).read().split()
u = []
for t in s:
    close_cnt = 0
    tmp = 0
    for c in t:
        tmp += (1 if c == '(' else -1)
        close_cnt = min(close_cnt, tmp)
    u.append((close_cnt, tmp - close_cnt))
M = 10**6 + 1
acc = 0
for a, b in sorted([x for x in u if sum(x) >= 0], key=lambda z: -z[0]):
    if acc + a < 0:
        print("No")
        exit(0)
    else:
        acc += a + b
for a, b in sorted([x for x in u if sum(x) < 0], key=lambda z: -z[1]):
    if acc + a < 0:
        print("No")
        exit(0)
    else:
        acc += a + b
print(("No" if acc else "Yes"))

Measured memory_bytes: 101572
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

string s,t;cin>>s>>t;
int c=0,n=s.length();
for(int i=0;i<n;i++){
	if(s[i]!=t[i]) c++;
}
cout<<c;
}

Measured memory_bytes: 3784
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split("");
        boolean ans = true;
        for(int i = 0; i < line1.length; i++){
            if(i % 2 == 0 && line1[i].equals("L"))  ans = false;
            if(i % 2 == 1 && line1[i].equals("R"))  ans = false;
        }
        if(ans) System.out.println("Yes");
        else    System.out.println("No");
    }
}

Measured memory_bytes: 23124
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
// vector<vector<int> >vec(10,vi(10));
int vec[11][11]{};
int check(int x,int y,int d){
	int i,j,sum=0;
	rep(i,0,d){
		sum+=((vec[x][i]-vec[y][i])*(vec[x][i]-vec[y][i]));
	}
	double s=sqrt(sum);
	if(abs(s-((int)s))<=DBL_EPSILON)
		return 1;
	return 0;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	// #endif
	int i,j,k,l,n,test_case,m,r,d,cnt=0;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n>>d;
		ren{
			rep(j,0,d){
				cin>>vec[i][j];
			}
		}

		rep(i,0,n){
			rep(j,i+1,n){
				cnt+=check(i,j,d);
			}
		}
		cout<<cnt<<endl;


	}
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from collections import deque

    n = int(input())
    graph = [list() for _ in range(n)]

    for i in range(n - 1):
        ai, bi = map(int, input().split())
        graph[ai - 1].append(bi - 1)
        graph[bi - 1].append(ai - 1)

    c = sorted(list(map(int, input().split())), reverse=True)

    # スコアの最大値：数列cのうち，最大値を除いた合計
    print(sum(c[1:]))

    # 書き込み方：根から大きな値を割り当てるとよさそう
    visited = [False for _ in range(n)]
    visited[0] = True
    d = deque()
    d.append(0)
    ans = [0 for _ in range(n)]
    ans[0] = c[0]
    count = 1

    while d:
        di = d.popleft()

        for dii in graph[di]:
            if not visited[dii]:
                ans[dii] = c[count]
                count += 1
                visited[dii] = True
                d.append(dii)

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6380
#include <cstdio>
#define DEBUG(d,n) {for (int i = 0; i < n; i++) {\
                        if (i != n-1)   printf("%d ", d[i]);\
                        else            printf("%d", d[i]);\
                    }   printf("\n");}
#define SWAP(d,a,b) {	int t = d[a];\
						d[a] = d[b];\
						d[b] = t;}
const int MAX = 100;

void bubbleSort(int d[], int len) {
	int lps = 0;
	for (int i = 0; i < len; i++) {
		for (int j = len-1; j > i; j--) {
			if (d[j] < d[j-1]) {
				SWAP(d, j, j-1);
				lps++;	// swap operations
			}
			// number of loop operations
		}
	}
	DEBUG(d, len);
	printf("%d\n", lps);
}

int main() {
    int n, d[MAX];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &d[i]);
     
    bubbleSort(d, n);
     
    //DEBUG(d,n); // display final step <- fixed PE
    return 0;
}

Measured memory_bytes: 2748
//by azidoazideazide(c2n14)
//E
#include<iostream>
#include<string>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
using ll=long long;
#define pb push_back

ll ans;
string s,t;
vector<int> cnt[26];

void bye(){
	cout<<"-1\n";
	exit(0);
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>s>>t;
	int sl=s.length(), tl=t.length();
	for(int i=0;i<sl;i++){
		cnt[s[i]-'a'].pb(i+1);
	}
	for(int i=0,pp=0,cp;i<tl;i++){
		int tt=t[i]-'a';
		if(!cnt[tt].size()) bye();
		else{
			cp=lower_bound(cnt[tt].begin(), cnt[tt].end(), pp) - cnt[tt].begin();
			if(cp==cnt[tt].size()){
				ans+=sl, pp=0;
				cp=lower_bound(cnt[tt].begin(), cnt[tt].end(), pp) - cnt[tt].begin();
				if(cp==sl) bye();
			}
			
			if(i==tl-1) ans+=cnt[tt][cp];
			pp=cnt[tt][cp]+1;
		}
	}
	cout<<ans<<endl;	
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
#define Rep(i,l,r) for(int (i)=(l);(i)<=(r);(i)++)
using namespace std;
map<int,ll>::iterator it;
map<int,ll> mp;
multiset<ll> values;
int n,m,l,r;
class Segtree{
	private:
		int dat[800100],tag[800100];
		void add_node(int u,int val){
			dat[u]+=val;
			tag[u]+=val;
		}
		void push_down(int u){
			if(tag[u]){
				add_node(u*2+0,tag[u]);
				add_node(u*2+1,tag[u]);
				tag[u]=0;
			}
		}
		void pr_add_seg(int u,int l,int r,int le,int ri,int val){
			if(le<=l&&r<=ri){
				add_node(u,val);
				return;
			}
			if(r<le||l>ri) return;
			push_down(u);
			int mi=(le+ri)/2;
			pr_add_seg(u*2+0,l,mi+0,le,ri,val);
			pr_add_seg(u*2+1,mi+1,r,le,ri,val);
			dat[u]=min(dat[u*2+0],dat[u*2+1]);
		}
		int pr_ask_seg(int u,int l,int r,int le,int ri){
			if(le<=l&&r<=ri) return dat[u];
			if(r<le||l>ri) return INT_MAX;
			push_down(u);
			int mi=(le+ri)/2;
			int P1=pr_ask_seg(u*2+0,l,mi+0,le,ri);;
			int P2=pr_ask_seg(u*2+1,mi+1,r,le,ri);
			return min(P1,P2);
		}
	public:
		void segment_add(int left,int righ,int val){
			pr_add_seg(1,1,n,left,righ,val);
		}
		int segment_ask(int left,int righ){
			return pr_ask_seg(1,1,n,left,righ);
		}
};
int main(){
	cin>>n>>m;
	Rep(i,1,m){mp[i]=0;values.insert(0);}
	Rep(i,1,n){
		cin>>l>>r;
		if(r!=m){
			it=mp.upper_bound(r+1);
			if(it!=mp.begin()){
				it--;
				if(it->first!=r+1){
					ll v=it->second+(r+1-it->first);
					mp[r+1]=v;values.insert(v);
				}
			}
		}
		it=mp.lower_bound(l);
		while(it!=mp.end()&&it->first<=r){
			values.erase(values.find(it->second));
			it=mp.erase(it);
		}
		cout<<((values.size())?(i+(*values.begin())):(-1))<<endl;
	}
	return 0;
}

Measured memory_bytes: 25480
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, Q;
  int x;
  int z;
   cin >> N >> K >> Q;
  vector<int> vec(N);
vector<string> vec2(N,"No");

   z = Q-K+1;
  for (int i=0; i< Q; i++) {
	cin >> x;
    vec.at(x-1)++;
    if (vec.at(x-1) >= z) {
      vec2.at(x-1) = "Yes";
    }
  }
    if (K > Q ) {
  vec2 = vector<string>(N,"Yes");}
  
  for (int i=0; i< N; i++) {
 cout << vec2.at(i) << endl;
  }
}

Measured memory_bytes: 5120
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    var ans = 1L
    for (a in 1L..(Math.sqrt(m.toDouble())).toLong()) {
        if (m % a != 0L) continue
        val b = m / a
        if (a * n <= m) ans = Math.max(ans, a)
        if (b * n <= m) ans = Math.max(ans, b)
    }
    println(ans)
}


Measured memory_bytes: 38340
import java.util.*;

public class Main{
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   
   int a = sc.nextInt();
   int b = sc.nextInt();
   
    System.out.print(a/b+ " " + a%b + " ");
    System.out.printf("%.5f", (double)a/b);
    System.out.println("");
 }
}

Measured memory_bytes: 26568
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String a,b;

    private void solve() {
        a = next();
        b = next();

        for(int i = 0;i < 3;i++){
            if (a.charAt(i) == b.charAt(2-i)) continue;
            else {
                out.println("NO");
                return;
            }
        }

        out.println("YES");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22484
w,h,n = map(int,input().split())
x_li = [0]*n
y_li = [0]*n
a_li = [0]*n
for i in range(n):
    x_li[i],y_li[i],a_li[i] = map(int,input().split())

sx,sy = 0,0
gx,gy = w,h
for i in range(n):
    a,x,y = a_li[i],x_li[i],y_li[i]
    if a==1:
        sx=max(sx,x)
    if a==2:
        gx=min(gx,x)
    if a==3:
        sy=max(sy,y)
    if a==4:
        gy=min(gy,y)
x = max(0,gx-sx)
y = max(0,gy-sy)
print(x*y)

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

#define ll long long

using namespace std;

const int MAXN = 200010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int tot, cnt;

int a[MAXN], f[MAXN], ans[MAXN];
int head[MAXN];

struct edge {
	int to, next;
}e[MAXN * 2];

void add_edge(int x, int y) {
	e[++tot].to = y;
	e[tot].next = head[x];
	head[x] = tot;
	return;
}

void Dfs(int x, int fa) {
	int last;
	int l = 1, r = ans[fa], mid;
	if (!fa) f[1] = a[x], ans[1] = 1;
	else {
		while (l <= r) {
			mid = (l + r) >> 1;
			if (a[x] <= f[mid]) r = mid - 1;
			else l = mid + 1;
		}
		last = f[l];
		f[l] = a[x];
		ans[x] = ans[fa];
		if (l > ans[fa]) ++ans[x];
	}
	for (int i = head[x]; i; i = e[i].next) {
		int v = e[i].to;
		if (v != fa) Dfs(v, x);
	}
	f[l] = last;
	return;
}

int main(){
	int t;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		add_edge(u, v);
		add_edge(v, u);
	}
	
	Dfs(1, 0);
	
	for (int i = 1; i <= n; i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}



Measured memory_bytes: 23584
#約数
def divisor(x):
    ret = []
    for i in range(1,int(x ** 0.5) + 1):
        if x % i == 0:
            ret.append(i)
            if i != x // i:
                ret.append(x // i)
    return ret

n = int(input())
a = list(map(int,input().split()))

ans = []
d = [0] * n

for i in range(len(a) - 1,-1,-1):
    if d[i] % 2 != a[i]:
        ans.append(i + 1)
        for j in divisor(i + 1):
            d[j - 1]+=1

print(len(ans))
if len(ans):
    print(*ans)


Measured memory_bytes: 68700
#include <stdio.h>
 
int main(void){
    int a,i,n;
    int min = 1000000;
    int max = -1000000;
    long long int sum = 0;
    scanf("%d",&n);
     
    for(i = 0; i < n; i++){
        scanf("%d",&a);
        if(min > a) min = a;  //最小値
        if(max < a) max= a;  //最大値
        sum = sum + a;        //合計値
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2148
#include <stdio.h>

int tiisakunaihou(int a, int b) {
	return a >= b ? a : b;
}

int N;
int A[271828];

int asumisu[271828], mizuhasu[271828];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	asumisu[0]  = 0;
	for (i = 1; i <= N; i++) {
		asumisu[i] = tiisakunaihou(asumisu[i - 1], A[i]);
	}
	mizuhasu[N + 1] = 0;
	for (i = N; i >= 1; i--) {
		mizuhasu[i] = tiisakunaihou(mizuhasu[i + 1], A[i]);
	}
	for (i = 1; i <= N; i++) {
		printf("%d\n", tiisakunaihou(asumisu[i - 1], mizuhasu[i + 1]));
	}
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <math.h>

using namespace std;
const int mod = 1000000007;
const double pi = 3.141592653589793238462643382795028841971;

int main() {
	int n;
	cin >> n;
	if (n == 7 || n == 5 || n == 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;
int n,m,d[200],v[200];
int maxi[200];
int main() {
    while(1) {
        cin >> n >> m;
        if(n == 0)break;
        for(int i =0;i < n;i++)cin >> d[i] >> v[i];

        for(int i = 1;i <= m;i++)maxi[i] = 0;
        for(int i = 0;i < n;i++)maxi[d[i]] = max(maxi[d[i]],v[i]);

        int sum = 0;
        for(int i = 1;i <= m;i++)sum += maxi[i];
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
def solve(n, a, lst):
  m = max(max(lst), a)
  ans = [[[0]*(n*m+1) for i in range(n+1)] for j in range(n+1)]
  #ans[i][j][k] : lst[:i]までの中からj枚選んで合計kにする選び方
  for i in range(n+1):
    for j in range(n+1):
      for k in range(n*m+1):
        if i == 0 and j == 0 and k == 0:
          ans[i][j][k] = 1
        elif i >= 1 and k < lst[i-1]:
          ans[i][j][k] = ans[i-1][j][k]
        elif i >= 1 and lst[i-1] <= k and j >= 1:
          ans[i][j][k] = ans[i-1][j-1][k-lst[i-1]] + ans[i-1][j][k]
        else:
          ans[i][j][k] = 0
  ret = 0
  for i in range(1,n+1):
    ret += ans[-1][i][i*a]
  return int(ret)

if __name__ == "__main__":
  n, a = map(int,input().split())
  x_list = [int(i) for i in input().split()]
  ans = solve(n,a,x_list)
  print(ans)


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()



struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    char c;
    cin >> c;
    if('a' <= c && c <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#define ll long long int
#define ld long double
using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    	int a,n;
	int aa=1;
 
	cin>>n;
 
	while(n--){
		cin>>a;
		if(a%2==0){
			if(a%3!=0&&a%5!=0)
		        aa=0;
 
		}
	}
 
	if(aa==0)
		printf("DENIED");
	else
		printf("APPROVED");
	return 0;
}	
    

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let s: usize = a.iter().sum();

    let mut b: Vec<usize> = vec![0; n];
    b[0] = s;
    for i in 0..n {
        if i % 2 == 1 {
            b[0] -= 2 * a[i];
        }
    }

    for i in 1..n {
        b[i] = 2 * a[i - 1] - b[i - 1];
    }
    return b.iter().map(|it| it.to_string()).collect::<Vec<String>>().join(" ");
}


Measured memory_bytes: 14588