akhauriyash/Code-Regression huggingface dataset:
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    
    if(S.size()==2){
    }else{
        char tmp = S.at(0);
        S.at(0) = S.at(2);
        S.at(2) = tmp;
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=3005;
ll dp[N][N],A[N];
int n;

ll f(int i, int j){
	if(i==j)return 0;
	ll &r=dp[i][j];
	if(r!=-1)return r;
	int w=(n-(j-i))&1;
	if(w==0)r=max(f(i+1,j)+A[i],f(i,j-1)+A[j-1]);
	else r=min(f(i+1,j),f(i,j-1));
	return r;
}

int main(){FIN;mset(dp,-1);
	cin >> n;
	fore(x,0,n)cin>>A[x];
	cout << 2LL*f(0,n) - accumulate(A,A+n,0LL) << "\n";
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負にする（構成node数x(-1))
    //root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  //同じグループ化
  int size(int x) { return -d[root(x)];}
  //グループのnode数
    int group_num(int n){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());}
};



int main() {
  int n;
  cin>>n;
  vector<vector<ll>> A(n,vector<ll>(n));
  vector<vector<ll>> G(n,vector<ll>(n));
  vector<vector<ll>> dist(n,vector<ll>(n,INF));
  rep(i,n)dist[i][i]=0;
  vector<pair<ll,P>>v;
  ll ans=0;

  rep(i,n)rep(j,n){
    cin>>A[i][j];
    ans+=A[i][j];
  //  if(i!=j)v.push_back(make_pair(A[i][j],make_pair(i,j)));
  }
  ans/=2;
  dist=A;
    rep(i,n)rep(j,n)rep(k,n){
      dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
    }
  rep(i,n-1)for(int j=i+1;j<n;j++){
    if (dist[i][j]<A[i][j]){
      cout<<-1;return 0;
    }
    else{
      bool check=false;
      rep(k,n){
        if (k==i or k==j)continue;
        if ((dist[i][k]+dist[k][j])==dist[i][j])check=true;
      }
      if (check==true)ans-=dist[i][j];
    }
//cout<<ans<<'a'<<i<<'i'<<j<<'j'<<endl;
  }
cout<<ans;
}


Measured memory_bytes: 2432
def gcd(x, y):

   while(y):
       x, y = y, x % y

   return x
a,b,c,d = map(int,input().split())
lcm = (c*d)//gcd(c,d)
l = b-a+1
if(a%c!=0):
    p = b//c-a//c
else:
    p = b//c-a//c+1
if(a%d!=0):
    q = b//d-a//d
else:
    q = b//d-a//d+1
if(a%lcm!=0):
    r = b//lcm-a//lcm
else:
    r = b//lcm-a//lcm+1
print(l-(p+q-r))


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

int main() {
  char c;
  cin >> c;
  cout << ((c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') ? "vowel" : "consonant")
       << endl;
  getchar();
}

Measured memory_bytes: 3544
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <vector>
#include <functional>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int Cases;
vector<long long> V;
int N;

int main() {
	cin >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) cin >> V[i];
	long long sum = 0;
	for (auto x : V) sum += x;
	int k = (N - 1) / 2;
	vector<long long> ret(N);
	for (int i = 1; i < 3; i++) {
		long long tmp = 0;
		for (int j = 0; j < k; j++) {
			int idx = (i + j * 2) % N;
			tmp += V[idx];
		}
		ret[(i + N - 1) % N] = sum - tmp * 2;
	}
	vector<long long> diff(N - 1);
	for (int i = 0; i + 1 < N; i++) {
		diff[i] = V[i + 1] - V[i];
	}

	for (int i = 2; i < N; i += 2) {
		ret[i] = ret[i - 2] + 2 * diff[i - 2];
	}
	for (int i = 3; i < N; i += 2) {
		ret[i] = ret[i - 2] + 2 * diff[i - 2];
	}
	for (long long x : ret) cout << x << " ";
	cout << endl;

	return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<vector<int>>dp(n+1,vector<int>(3));
  for(int i=1;i<=n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
    dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b);
    dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c);
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
      
}

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

int main() {
  int k, a, b, c=0;
  cin >> k >> a >> b;
  for (int i=a; i<=b; i++) {
    if (i%k == 0) {
      cout << "OK" << endl;
      break;
    }
    else c++;
  }
  
  if (c==b-a+1) cout << "NG" << endl;
}


Measured memory_bytes: 3640
n = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
A.sort()
if n % 2 == 0:
  if A[::2] == A[1::2] == [i for i in range(1, n + 1, 2)]:
    ans = 2 ** (n // 2)
  else:
    ans = 0
else:
  if A == [0] or A[1::2] == A[2::2] == [i for i in range(2, n + 1, 2)]:
    ans = 2 ** (n // 2)
  else:
    ans = 0
print(ans % MOD)

Measured memory_bytes: 13880
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a = ri()
b = ri()
print(6 - a - b)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll x[N], y[N], p[N];
    pii q1[N], q2[N];
    rep(i, N){
        cin >> x[i] >> y[i] >> p[i];
    }

    ll dx[1<<N][N], dy[1<<N][N];
    rep(i, 1<<N){
        rep(j, N){
            dx[i][j] = abs(x[j]);
            rep(k, N){
                if(i&(1<<k)) chmin(dx[i][j], abs(x[j]-x[k]));
            }
        }
    }
    rep(i, 1<<N){
        rep(j, N){
            dy[i][j] = abs(y[j]);
            rep(k, N){
                if(i&(1<<k)) chmin(dy[i][j], abs(y[j]-y[k]));
            }
        }
    }
    int pw[N+1];
    pw[0] = 1;
    rep(i, N) pw[i+1] = pw[i]*3;

    ll ans[N+1];
    fill(ans, ans+N+1, INF);
    rep(i, pw[N]){
        int cnt = 0, xs = 0, ys = 0;
        rep(j, N){
            int k = i%pw[j+1]/pw[j];
            if(k == 1) cnt++, xs |= (1<<j);
            if(k == 2) cnt++, ys |= (1<<j);
        }
        ll tmp = 0;
        rep(j, N) tmp += p[j]*min(dx[xs][j], dy[ys][j]);
        chmin(ans[cnt], tmp);
    }
    
    rep(i, N+1) cout << ans[i] << endl;
}

Measured memory_bytes: 11320
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int X=N;
    int dig;
    int sum;
    while(N){
    dig = N % 10;
    sum = sum + dig;
    N = N / 10;
    }
    if(X%sum==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

 
ll modPow(ll x, ll n, ll mod = MOD){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;
 
        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}

vector<int> A(20);

vector<vector<int>> x(20), y(20);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;

  REP(i,N){
    cin >> A[i];
    x[i].resize(A[i]);
    y[i].resize(A[i]);

    REP(j,A[i]) cin >> x[i][j] >> y[i][j], x[i][j]--;
  }

  int ans = 0;
  for(int bit = 0; bit < (1 << N); bit++){

    bool ok =true;
    for(int i=0; i<N; i++){
      if(bit >> i & 1){
        for(int j=0; j<A[i]; j++){

          if(y[i][j] == 1){
            //x[i][j]が正直者
            if(bit >> x[i][j] & 1){

            }else{
              ok = false;
            }
          }else{
            //x[i][j]が不親切
            if(bit >> x[i][j] & 1){
              ok = false;
            }
          }
        }
      }
      
    }
    if(ok) ans = max(ans, __builtin_popcount(bit));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int ans = 0;
    for (int i = 111; i <= 999; i+=111) {
      if (N <= i) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int p,m,mu,max_1,max_2;
  
  p=A+B;
  m=A-B;
  mu=A*B;
  
  max_1=max(p,m);
  max_2=max(max_1,mu);
  
  cout << max_2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
n,y=map(int,input().split())
for a in range(0, min(n, y // 10000)+1):
    for b in range(0, min(n, y // 5000)+1):
        c=n-a-b
        if c>=0 and a*10000+b*5000+c*1000==y:
            print(a,b,c)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 67764
//Distance
#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(5) << sqrt(pow(x2-x1, 2) + pow(y2- y1, 2)) << endl;
	return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

ll val[2100][2100];
ll sum[2100][2100];

int main() {
    ll n, k;
    cin >> n >> k;
    memset(val, 0, sizeof(val));
    memset(sum, 0, sizeof(sum));
    rep(i, 0, n) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') y += k;
        x %= (2 * k);
        y %= (2 * k);
        val[x][y] += 1;
    }
    rep(i, 0, 2*k+1) {
        rep(j, 0, 2*k+1) {
            sum[i+1][j+1] = val[i][j];        
            sum[i+1][j+1] += sum[i+1][j];
            sum[i+1][j+1] += sum[i][j+1];
            sum[i+1][j+1] -= sum[i][j];
        }
    }
    ll ans = 0;
    rep(i, 0, k) {
        rep(j, 0, k) {
            ll t1 = sum[i][j] + sum[0][0] - sum[0][j] - sum[i][0];
            ll t2 = sum[i+k][j+k] + sum[i][j] - sum[i][j+k] - sum[i+k][j];
            ll t3 = sum[i][2 * k] + sum[0][j+k] - sum[0][2 * k] - sum[i][j+k];
            ll t4 = sum[2 * k][2 * k] + sum[i+k][j+k] - sum[i+k][2 * k] - sum[2 * k][j+k];
            ll t5 = sum[2 * k][j] + sum[i+k][0] - sum[i+k][j] - sum[2 * k][0];
            ll t = t1 + t2 + t3 + t4 + t5;
            chmax(ans, t);
            chmax(ans, n - t);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 69120
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	char s[2][n+1];
	scanf("%s %s", s[0], s[1]);
	
	ll ans = (s[0][0]==s[1][0])? 3:6;
	REP(i, 0, n-1){
		int bit = (s[0][i]==s[1][i])*2 + (s[0][i+1]==s[1][i+1]);
		if(bit==0){
			if(s[0][i]!=s[0][i+1] or s[1][i]!=s[1][i+1]) ans = ans * 3 % MOD;
		}
		if(bit==2) ans = ans * 2 % MOD;
		if(bit==3) ans = ans * 2 % MOD;
	}
	printf("%ld\n", ans);
	return 0;
}



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 << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;

    int l = 0, r = (S.size() - 1) / 2;
    int length = (S.size() - 1) / 2;
    int ans = 0;
    for (; l < r; r -= 1, length -= 1) {
        if (S.substr(l, length) == S.substr(r, length)) ans = max(ans, length * 2);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){t.in();for(var e=t.in(),r=new Array(e),n=0,i=0,o=0;o<e;o++)r[o]=t.in(),r[o]>n&&(n=r[o],i=o);for(var s=0,u=0;u<e;u++)u!=i&&(s+=r[u]);var c=n-1-s;c<0?console.log(0):console.log(c)}}]);

Measured memory_bytes: 8008
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
a = inl()
t = sum(a)
a.sort(reverse=True)
cnd = (a[m-1]*4*m >= t)
print('Yes' if cnd else 'No')


Measured memory_bytes: 38384
N = int(input())
count = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count+=1
        if count >= 3:
            flag = True
    else:
        count=0

if flag:
    print('Yes')
else:
    print('No')

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

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

  sort(a.begin(), a.end());

  int ans = 0;
  int sm = 0;
  int cnt = 0;
  for (int i = a[i]; i <= a.back(); ++i) {
    cnt = upper_bound(a.begin(), a.end(), i + 1) - a.begin();
    cnt -= lower_bound(a.begin(), a.end(), i - 1) - a.begin();

    if (cnt > sm) {
      sm = cnt;
      ans = i;
    }
    cnt = 0;
  }
  cout << sm << endl;
  //cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    int main() {
        int n;
        cin>>n;
        vector<double> d(n);
        double x;
        for(int i=0;i<n;i++){
            cin>>x;
            d[i] = 1/x;
        }
        double sum;
        for(int i=0;i<n;i++) sum+=d[i];
        sum = 1/sum;
        printf("%0.5lf",sum);
        return 0;
    } 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
  
#define MAX 1000
  
int main(){
  int i,j,m,q,x,y,c[MAX+1][MAX+1];
  char X[MAX],Y[MAX];
  
  scanf("%d",&q);
  
  for(i=0;i<strlen(X);i++)
    c[i][0] = 0;
  for(j=0;j<strlen(Y);j++)
    c[0][j] = 0;
  
  for(m=0;m<q;m++){
    scanf("%s",X);
    scanf("%s",Y);
    x = strlen(X);
    y = strlen(Y);
    for(i=0;i<x;i++)
      c[i][0] = 0;
    for(j=0;j<y;j++)
      c[0][j] = 0;
  
    for(i=1;i<=x;i++){
      for(j=1;j<=y;j++){
    if(X[i-1] == Y[j-1])c[i][j] = c[i-1][j-1] + 1;
    else if(c[i-1][j] >= c[i][j-1])c[i][j] = c[i-1][j];
    else c[i][j] = c[i][j-1];
      }
    }
    printf("%d\n",c[x][y]);
  }
  
  return 0;
}

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

#define int long long


template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class T> ostream &operator<<(ostream &os, set<T> V) {
    os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
    os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class K, class X> ostream &operator<<(ostream& os, map<K,X> V) {
    os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail...T) { cerr << " " << H; debug_out(T...); }

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> arr(2 * n);
    for(int i = 0; i < 2 * n; i++) {
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    int ans = 0;
    for(int i = 0; i < 2 * n; i += 2) {
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
    int N,K,X,Y,P;
    cin >> N >> K >> X >> Y;
    P = 0;
    if(N<=K){
        P = X * N;
    }
    else{
        P = X * K + ((N - K) * Y);
    }
    cout << P << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cstdio>

using namespace std;

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

static const double eps = 1e-8;

const int tx[4] = {+0,+1,+0,-1};
const int ty[4] = {-1,+0,+1,+0};

bool visited[501][501];
int rooms[2][501][501];
int required_auth_level[2][250001];

struct State {
  int x;
  int y;
  int auth;
  bool operator<(const State& s) const {
    return auth < s.auth;
  }
  bool operator>(const State& s) const {
    return auth > s.auth;
  }
  State(int x,int y,int auth) : x(x), y(y), auth(auth) {}
};

void bfs(int sx,int sy,int W,int H,int office_i){
  memset(visited,false,sizeof(visited));
  priority_queue<State,vector<State>, greater<State> > que;
  que.push(State(sx,sy,1));
  int current_auth_level = 0;
  int count = 0;
  while(!que.empty()){
    State s = que.top();
    que.pop();
    if(visited[s.y][s.x]) continue;
    visited[s.y][s.x] = true;

    count++;
    current_auth_level = max(s.auth,current_auth_level);
    required_auth_level[office_i][count] = current_auth_level;

    for(int i = 0; i < 4; i++){
      int dx = s.x + tx[i];
      int dy = s.y + ty[i];
      if(dx < 0 || dx >= W || dy < 0 || dy >= H) continue;
      if(visited[dy][dx]) continue;
       que.push(State(dx,dy,rooms[office_i][dy][dx]));
    }
  }
}

int main(){
  int have_to_visit_rooms;
  while(~scanf("%d",&have_to_visit_rooms)){
    if(have_to_visit_rooms == 0) break;
    memset(required_auth_level,0x3f,sizeof(required_auth_level));
    required_auth_level[0][0] = 0;
    required_auth_level[1][0] = 0;
    int elevator_x[2];
    int elevator_y[2];
    int W[2];
    int H[2];
    for(int office_i = 0; office_i < 2; office_i++){
      scanf("%d %d %d %d",&W[office_i],&H[office_i],
            &elevator_x[office_i],&elevator_y[office_i]);
      elevator_x[office_i]--;
      elevator_y[office_i]--;

      for(int y = 0; y < H[office_i]; y++){
        for(int x = 0; x < W[office_i]; x++){
          scanf("%d",&rooms[office_i][y][x]);
        }
      }

      bfs(elevator_x[office_i],
          elevator_y[office_i],
          W[office_i],H[office_i],office_i);
    }
    int res = 0x3f3f3f3f;
    for(int i = have_to_visit_rooms; i >= 0; i--){
      int j = have_to_visit_rooms - i;
      res = min(required_auth_level[0][i] + required_auth_level[1][j],res);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include<map>

using namespace std;

int main(){
    map<string,int>mp;
    string s,k;
    int i=0,n;
    cin >>n;
    while(i!=n){
        cin >> s>>k;
        if(s=="insert"){
            
            mp[k]+=1;

        }
        else{
            if(mp[k]>=1){
                cout << "yes" << endl;
            }

            else{
                cout << "no" << endl;
            }
        }
        i++;
    }
    
return 0;
}


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

#define int long long

int N;
int x[111], y[111], h[111];

// 中心座標の高さが求められたら高さを返す。求められなかったら-1を返す
int check(int cx, int cy) {
   set<int> cand;
   int Max = 1e10;
   for (int i = 0; i < N; i++) {
      int dist = abs(x[i] - cx) + abs(y[i] - cy); // 現在見ている座標から中心座標までの距離
      if (h[i] <= 0) {
         Max = min(Max, dist);
      } else {
         cand.insert(h[i]+dist);
      }
   }

   // 矛盾が無いなら中心座標の高さを返す
   if (cand.size() == 1 && *cand.begin() <= Max) {
      return *cand.begin();
   }

   return -1;
}

signed main() {
   // 入力
   cin >> N;
   for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> h[i];
   }

   // 答えとなる(x, y, h)
   int ax = 0, ay = 0, ah = 0;

   // 多重ループを抜けやすくするためにラムダ式を使っている
   [&]() {
      // (cx, cy)を全列挙
      for (int cy = 0; cy <= 100; cy++) {
         for (int cx = 0; cx <= 100; cx++) {
            int t = check(cx, cy); // (cx, cy)が中心座標かどうかをcheck()で評価する
            if (t == -1) continue; // 返り値が-1なら処理を飛ばす

            // 答えが見つかった、変数に代入してループを抜ける
            ax = cx, ay = cy, ah = t;
            return;
         }
      }
   }();

   printf("%lld %lld %lld\n", ax, ay, ah); // 答えを出力

   return 0;
}

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

int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double L;
    double a;
    a = pow(x2-x1, 2)+pow(y2-y1, 2);
    L=pow(a, 1/2.0);
    cout<<fixed<<setprecision(10)<<L<<endl;
    return 0;
}


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

const int MOD = 1000000007;

int ncr[8005][8005];
int dp[4005][4005];
int a[200005];
int b[200005];
int ans, n;

int main()
{
	ncr[0][0] = 1;
	for (int i = 1;i < 8002;i++)
	{
		ncr[i][0] = ncr[i][i] = 1;
		for (int j = 1;j < i;j++) ncr[i][j] = (ncr[i-1][j-1]+ncr[i-1][j])%MOD;
	}
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d%d", a+i, b+i);
		dp[2001-a[i]][2001-b[i]]++;
	}
	for (int i = 1;i < 4002;i++) for (int j = 1;j < 4002;j++) dp[i][j] = (dp[i][j]+dp[i-1][j]+dp[i][j-1])%MOD;
	for (int i = 0;i < n;i++) ans = (ans+dp[2001+a[i]][2001+b[i]])%MOD;
	for (int i = 0;i < n;i++) ans = ((ans-ncr[a[i]+a[i]+b[i]+b[i]][a[i]+a[i]])%MOD+MOD)%MOD;
	ans = (500000004ll*ans)%MOD;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 219392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n;cin>>n;
  reps(i,1,10){
    reps(j,1,10){
      if(n==i*j){
        cout<<"Yes";return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a, b;
        for (int i=0 ;; i++) {
            a = sc.nextInt();
            b = sc.nextInt();
            sc.nextLine();
            if ((a == 0) && (b == 0)) break;
            if (a > b) {
                System.out.println(b+" "+a);
            }else{
                System.out.println(a+" "+b);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 43712
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll dp[n+1];
    for(int i=1;i<=n;i++){
    	dp[i]=1e18;
    }
    dp[0]=0;
    ll a;
    for(int i=0;i<m;i++){
    	cin>>a;
    	for(int i=a;i<=n;i++){
    		dp[i]=min(dp[i-a]+1,dp[i]);
    	}
    }
    cout << dp[n] <<endl;
    return 0;
}




Measured memory_bytes: 3496
///Coder ---->>>> Kael (Joan Marcos Rivera)
///Team ACM : CyberSpace ____ IPVCE FEDERICO ENGELS
///KingOfString
///Copyright

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

typedef long long ll;
typedef pair < string , int > par;

#define pb push_back
#define s second
#define mp make_pair
#define f first
#define maxn 3010
#define eps 1e-9
#define mod 50010
#define less(n) order_of_key(n)
#define en_pos(n) find_by_order(n) /// --- >> iterador --- >> empieza en 0

ll dp[maxn][maxn];
int pi[maxn][maxn],pj[maxn][maxn];
string s,d;
string sol="";
void print(int n , int m){
    if(s[n] == d[m]){
        sol += s[n];
    }
    int x=pi[n][m];
    int y=pj[n][m];
    if(x < 1 or y < 1)return ;
    print(x,y);
}
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s >> d;
    int n=s.size(),m=d.size();
    s=" " + s;
    d = " " + d;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i] == d[j]){
                pi[i][j]=i-1;
                pj[i][j]=j-1;
                dp[i][j]=dp[i-1][j-1]+1;
            }
            if(dp[i][j-1] > dp[i][j]){
                pi[i][j]=i;
                pj[i][j]=j-1;
                dp[i][j]=dp[i][j-1];
            }
            if(dp[i-1][j]>dp[i][j]){
                pi[i][j]=i-1;
                pj[i][j]=j;
                dp[i][j]=dp[i-1][j];
            }
        }
    }

    print(n,m);

    reverse(sol.begin(),sol.end());
    cout << sol;


}


Measured memory_bytes: 141568
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            for(int i = 0; i<x.Length;i++){
                if(x[i]==0){
                    Console.WriteLine(i+1);
                    break;
                }
            }
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27492
import sys
input=sys.stdin.readline

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

V = [0]*N

A = []
for i in range(N-1):
    a,b = map(int, input().split())
    A.append((a,b))
A.sort()
P = []
for i in range(Q):
    x,y = map(int, input().split())
    P.append((x,y))
P.sort()

#print("V", V)
#print("A", A)
#print("P", P)

for p in P:
    V[p[0]-1] += p[1]
for a in A:
    V[a[1]-1] += V[a[0]-1]

print(*V)


Measured memory_bytes: 71124
#include <iostream>
#include <map>
using namespace std;
int n,k,x[3005],y[3005],ans;
struct li{
  int a,b;
  bool operator <(const li &q)const{
      return b*q.a<q.b*a;
  }
};
map<li,int>o;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    for(int i=0;i<n;i++,o.clear())for(int j=0;j<n;j++)if(i!=j&&++o[li{x[i]-x[j],y[i]-y[j]}]>k-2)ans=1;
    cout<<ans<<endl;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
ll gcd(ll a, ll b){
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll bai=lcm(c,d);
  ll count=0;
  count+=b/c; count+=b/d;
  count-=b/bai;
  count-=(a-1)/c; count-=(a-1)/d;
  count+=(a-1)/bai;
  cout<<b-a+1-count<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define FI first
#define SE second
typedef pair< int, pair<int, pair<int, int> > > P3;
typedef pair<int, pair<int, int> > P2;
typedef pair<int, int> P1;
typedef tuple<int, int, int, int> T3;
typedef tuple<int, int, int> T2;
typedef tuple<int, int> T1;
static const int INF = 1ll << 60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N;
int A[100005];
vector<P1> V;

signed main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 0; i < N; ++i) {
		if (A[i] == A[i + 1])continue;
		int l = lower_bound(A, A + N, A[i]) - A;
		int r = upper_bound(A, A + N, A[i]) - A;
		V.PB(P1(r - l, A[i]));
	}
	sort(V.begin(), V.end(), greater<P1>());
	int ans = 0;
	int t = 0;
	for (int i = 0; i < V.size(); ++i) {
		//cout << t << endl;
		if (V[i].first % 2 == 1) {
			V[i].first = 1;
		}
		else V[i].first = 2;
	}
	sort(V.begin(), V.end(), greater<P1>());
	int it = 0;
	for (int i = 0; i < V.size(); ++i) {
		//cout << V[i].first << endl;
		if (V[i].first == 2) {
			if (V[i + 1].first == 2) {
				V[i].first = V[i + 1].first = 1;
			}
			else {
				V[i].first = 1;
				V[i + 1].first = 0;
			}
		}
	}
	for (int i = 0; i < V.size(); ++i)if (V[i].first == 1)ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,d;
    cin>>n>>d;
    for(int i=0;;i++){
        if(n<=0){
            cout<<i<<endl;
            return 0;
        }
        n=n-2*d-1;
    }
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &v : a) cin >> v;
    sort(a.rbegin(), a.rend());
    int one = 0, two = 0;
    for (int i = 0; i < n; i += 2) one += a[i];
    for (int i = 1; i < n; i += 2) two += a[i];
    cout << abs(one - two) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=2e5+5;
vi v[N],e;
int n,m,x[N],ans[N];
void dfs(int now,int fa)
{
	int rem=-1,num;
	if(e.empty()||x[now]>e.back())
		e.pb(x[now]);
	else{
		num=lower_bound(e.begin(),e.end(),x[now])-e.begin();
		rem=e[num];
		e[num]=x[now];
	}
	ans[now]=e.size();
	for(int i=0;i<v[now].size();i++)
	{
		int to=v[now][i];
		if(to==fa)continue;
		dfs(to,now);
	}
	if(rem==-1)
		e.pop_back();
	else
		e[num]=rem;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	dfs(0,-1);
	for(int i=0;i<n;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 27600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<pair<int,int>> G[23][23];
char s[23][23];

signed main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>s[i][j];
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                if(s[i+1][j]=='.') G[i][j].push_back(P(i+1,j));
                if(s[i][j+1]=='.') G[i][j].push_back(P(i,j+1));
                if(s[i-1][j]=='.') G[i][j].push_back(P(i-1,j));
                if(s[i][j-1]=='.') G[i][j].push_back(P(i,j-1));
            }
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                V<V<int>> dist(h,V<int>(w,-1));
                queue<P> que;
                dist[i][j]=0;
                que.push(P(i,j));
                while(!que.empty()){
                    P p=que.front();que.pop();
                    int x=p.ft,y=p.sc;
                    for(P v:G[x][y]){
                        int s=v.ft,t=v.sc;
                        if(dist[s][t]!=-1) continue;
                        dist[s][t]=dist[x][y]+1;
                        que.push(P(s,t));
                        chmax(ans,dist[s][t]);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	string s,t,u;
	cin >> s >> t >> u;
	if(s[s.length() - 1] == t[0] && t[t.length() - 1] == u[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int cnt = 0;
	int n; cin>>n;
	for(int i = 0; i < n; i++)
	{
		int x; cin>>x;
		if(x&1) cnt++;
	}
	if(cnt&1) cout<<"NO\n";
	else cout<<"YES\n";
}


Measured memory_bytes: 256
-- C "Rectangle Cutting"
import Data.Bool
main = do
  [w, h, x, y] <- map read . words <$> getLine
  let (a, b) = solve w h x y
  putStrLn $ show a ++ " " ++ show b

solve w h x y = (a, b)
  where
    a = w*h / 2
    b = bool 0 1 ((w == 2*x) && (h == 2*y))

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  FOR(i, 1, 10) FOR(j, 1, 10) {
    cout << i << "x" << j << "=" << i*j << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  ll n;
  cin >>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a);
  sort(c);
  ll ans = 0;
  rep(i,n){//b[i]
    
    //aを処理
    ll l = -1;
    ll r = n;
    while(l<r-1){//lとrが2以上離れている間繰り返す
      ll m = (l+r)/2;//m = middle
      if(a[m] < b[i]) l = m;
      if(a[m] >= b[i]) r = m;//疑わしきは左に
    }//while
    ll arange = r;
    
    //cを処理
    l = -1;
    r = n;
    while(l<r-1){//lとrが2以上離れている間繰り返す
      ll m = (l+r)/2;//m = middle
      if(c[m] <= b[i]) l = m;//疑わしきは右に
      if(c[m] > b[i]) r = m;
    }//while
    ll crange = n-r;
    
    ans += arange*crange;
  }//i
  cout << ans << endl;
}


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

int main(void){
	int N,M,a,b;
	cin>>N>>M;
	vector<int> v(N+1);
	rep(i,M){
		cin>>a>>b;
		v[a]++;
		v[b]++;
	}
	rep1(i,N)cout<<v[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]

cnt = 0

for i in range(1, n + 1):
    if i % 2 == 1 and a[i - 1] % 2 == 1:
        cnt += 1
print(cnt)

Measured memory_bytes: 61688
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

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

// 最小公倍数を求める関数
// The Least Common Multiple
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b; // 桁溢れに注意
							  // この順番で計算するべし
}

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

	ll A, B, C, D; cin >> A >> B >> C >> D;

	ll co = lcm(C, D);

	ll num1 = (A - 1) / C + (A - 1) / D - (A - 1) / (co); // A未満の数でCまたはDで割り切れる数の個数
	ll num2 = B / C + B / D - B / (co);

	cout << (B - num2) - (A - 1 - num1) << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define PII pair<ll,int>
#define PB push_back
const int maxn=4e3+9;
const int mod=998244353;
int main()
{
	int n;
	scanf("%d",&n);
	n%=1000;
	if(!n)n=1000;
	printf("%d\n",1000-n);
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
double dis(double x,double y){
	return sqrt(x*x+y*y);
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll x[n],y[n];
    for(int i=0;i<n;i++){
    	cin>>x[i]>>y[i];
    }
    double a=0,b=0;
    for(int i=0;i<n;i++){
    	a+=x[i];
    	b+=y[i];
    }
    a/=(double)n;
    b/=(double)n;
    double d=0,c=0.1,q=100000;
    while(q--){
    	int f=0;
    	d=dis(a-x[0],b-y[0]);
    	for(int i=1;i<n;i++){
    		double maki=dis(a-x[i],b-y[i]);
    		if(maki>d){
    			d=maki;
    			f=i;
    		}
    	}
    	a+=(x[f]-a)*c;
    	b+=(y[f]-b)*c;
    	c*=0.999;
    }
    doublecout(d);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
i = 0
start = 0
end = 0
ans = 0

if h.count(0) == n:
    print(0)
else:
    while True:
        i = 0
        for y in range(n):
            if h[y] != 0:
                start = y
                break
        for x in range(start,n):
            if h[x] != 0:
                h[x] -= 1
                if x == n-1:
                    ans += 1
            else:
                start = 0
                i = 0
                ans += 1
                break
        if h.count(0) == n:
            break
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 int main()
{
  long long int i,j,k=0,l,m,n;
   cin>>n;
   long long int arr[n];
   for(i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   l=arr[0];
   for(i=1;i<n;i++)
   {
       if(l>=arr[i])
       {
           k++;
       }
       if(arr[i]<l)
       {
           l=arr[i];
       }

   }
   cout<<k+1;

}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"math"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
func max(x,y int) int {
	if x>y {
		return x
	} else {
		return y
	}
}
func min(x,y int) int {
	if x<y {
		return x
	} else {
		return y
	}
}
var cin *bufio.Reader
var cout *bufio.Writer
const MAXN=200000
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,x:=IO.ReadInt(),IO.ReadInt()
	var a,sum [MAXN+10]int
	for i:=1; i<=n; i++ {
		a[i]=IO.ReadInt()
		sum[i]=sum[i-1]+a[i]
	}
	ans:=math.MaxInt64/3
	for k:=1; k<=n; k++ {
		now:=0
		for i,r:=1,n; r>0 && now+k*x<=ans; i++ {
			l:=max(1,r-k+1)
			t:=i*2+1
			if i==1 {
				t+=2
			}
			now+=t*(sum[r]-sum[l-1])
			r-=k
		}
		ans=min(ans,now+k*x)
	}
	fmt.Println(ans+n*x)
	cout.Flush()
}


Measured memory_bytes: 8064
# import re
s = input()
# m = re.fullmatch(hi{1,10},s):
# if m = "None":
#     print("No")
# else:
#     print("Yes")

if s == "hi" or s =="hihi"or s == "hihihi"  or s=="hihihihi" or s== "hihihihihi":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940