akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	long long a,v,b,w,t;
  	cin >> a >> v >> b >> w >> t;
  
  	if(w >= v){
      cout <<"NO";
      return 0;
    }
  
  	if(abs(a-b) <= abs(v - w) * t)
      cout << "YES";
  	else
      cout << "NO";
  	return 0;
}

Measured memory_bytes: 3636
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    cnt = 0
    for i in range(n):
        a,b = i_map()
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print("Yes")
            exit()
    print("No")




if __name__=="__main__":
    main()


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* simple bfs rolling dp */

const int maxn = 3010;
double dp[2][maxn];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        int cur = 0, nxt = 1;
        memset(dp,0,sizeof(dp)); dp[cur][0] = 1;
        FOR(i,0,n) {
            double p; cin >> p;
            memset(dp[nxt],0,sizeof(dp[nxt]));
            FOR(j,0,n+1) {
                dp[nxt][j+1] += dp[cur][j]*p;
                dp[nxt][j]   += dp[cur][j]*(1-p);
            }
            swap(cur,nxt);
        }
        double ans = 0;
        FOR(j,0,n+1) if (j > n-j)
            ans += dp[cur][j];
        printf("%.10f\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define div 1e9+7
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;
int main(){
	int n;
	cin>>n;
	int a[n];
	int se[n]={};
	for(int i=1;i<n;i++){
		cin>>a[i];
		se[a[i]-1]++;
	}
	rep(i,n){
		puts(se[i]);
	}
}

Measured memory_bytes: 5208
while True:
    H,W=map(int,input().split())
    if (H==0 and W==0):break
    for i in range(H):
        for j in range(W):
            if (i==0 or i==H-1 or j==0 or j==W-1):
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
N = int(input())
A = list(map(int, input().split()))

dp = [0 for _ in range(N+1)]
dp[0] = 1000
for i in range(1, N):
    dp[i] = dp[i-1]
    for j in range(0, i):
        stock = dp[j] // A[j]
        money = dp[j] % A[j] + A[i] * stock
        # j日目に余ったお金とi日目に得たお金を足すとi日目に持っているお金になる
        dp[i] = max(dp[i], money)

print(dp[N-1])

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  Int N = s.size();
  for(Int i=0;i<N;i++) if(s[i] == '?') s[i] = 'D';
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 3740
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine();
      final var regex = Pattern.compile("[AGCT]+");

      int count = 0;
      for (int i = 0; i < s.length(); i++) {
        for (int j = i + 1; j <= s.length(); j++) {
          final var sub = s.substring(i, j);
          if (regex.matcher(sub).matches()) {
            count = Math.max(sub.length(), count);
          }
        }
      }

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


Measured memory_bytes: 33884
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s;
  cin>>s;
  int n = s.size();
  string ans = s;
  if(s[n - 1] == 's'){
    ans += "es";
  }else{
    ans += "s";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

lint dp[101][105000];
lint w[100],v[100];
lint N,W;

lint calc(lint i,lint j){
    if(dp[i][j]>=0) return dp[i][j];
    lint res;
    if(i==N) res=0;
    else if(j<w[i]) res=calc(i+1,j);
    else res=max(calc(i+1,j),calc(i+1,j-w[i])+v[i]);
    return dp[i][j]=res;
}

int main(void){
    cin >> N >> W;
    rep(i,N) cin >> w[i] >> v[i];
    rep(i,101) rep(j,105000) dp[i][j]=LINF;
    dp[0][0]=0;
    lint ans=0;
    for(int i=0;i<N;i++) for(int j=0;j<=100000;j++){
        dp[i+1][j+v[i]]=min(dp[i][j]+w[i],dp[i+1][j+v[i]]);
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
    rep(i,100001) if(dp[N][i]<=W) ans=i;
    cout << ans << endl;
}

Measured memory_bytes: 83072
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int r,g,b;

	cin >> r >> g >> b;

	int a;

	a = 100 * r + 10 * g + b;

	if (a % 4 == 0) {
		cout << "YES" << endl;

	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
if n < 10:
  print(n)
elif n < 100:
  print(9)
elif n < 1000:
  print(n - 90)
elif n < 10000:
  print(909)
elif n < 100000:
  print(n - 90 - 9000)
else:
  print(90909)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf 10000000000000000ll
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 1e-7
#define endl "\n"
/*ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b%a,a);}
ll modexp(ll x,ll y,ll p)
{ll res=1;x%=p;while(y){if(y&1){res=(res*x)%p;}y=y>>1;x=(x*x)%p;}return res;}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,d;cin>>n>>d;
    int x=2*d+1;
    cout<<(n+x-1)/x<<"\n";



    return 0;

    /*check for long long or int*/
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define vint vector<signed>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;

signed main(){
  int n;
  cin>>n;
  str s,t;
  cin>>s;
  int sumw[s.length()],sume[s.length()];
  sumw[0]=0;
  sume[0]=0;
  if(s[0]=='W')sumw[0]++;
  else sume[0]++;
  for(int i=1;i<s.length();++i){
    sumw[i]=sumw[i-1];
    sume[i]=sume[i-1];
    if(s[i]=='W')sumw[i]++;
    else sume[i]++;
  }
  vint ans;
  for(int i=1;i<=s.length();++i){
    ans.pb( (sumw[i-1])+(sume[s.length()-1]-sume[i-1]) );
  }
  ans.pb(sumw[s.length()-1]);
  ans.pb(sume[s.length()-1]);
  //for(auto i:sumw)cout<<i<<" ";cout<<endl;
  //for(auto i:sume)cout<<i<<" ";cout<<endl;
  //for(auto i:ans)cout<<i<<" ";cout<<endl;
  sort(all(ans));
  cout<<ans[0];
  
  return 0;
}


Measured memory_bytes: 7548
S = input()[::-1]
W = ('dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1])

i = 0
while i < len(S):
    for w in W:
        if S[i:].startswith(w):
            i += len(w)
            break
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main()
{
    const int inf = 1e9;
    int n, m;
    cin >> n >> m;
    
    int a[1000], b[1000], c[1000], dist[100][100];
    
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = inf;
        }
        dist[i][i] = 0;
    }
    
    for (int i = 0; i < m; ++i) {
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
        dist[b[i]][a[i]] = min(dist[a[i]][b[i]], c[i]);
    }
    
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    
    int ans = 0;
    
    for (int i = 0; i < m; ++i) {
        if (dist[a[i]][b[i]] < c[i]) ++ans;
    }
    
    cout << ans << endl;
                       
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

#define int long long

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

#define int long long

const int N = 2e5 + 5;
ll d1[N], d2[N];
ll pre_d1[N], pre_d2[N];

void solve() {
	int L, n;
	cin >> L >> n;
	for(int i = 1; i <= n; i++) {
		cin >> d1[i];
		d2[i] = L - d1[i];
	}
	reverse(d2 + 1, d2 + n + 1);
	for(int i = 1; i <= n; i++) {
		pre_d1[i] = pre_d1[i - 1] + d1[i];
	}
	for(int i = 1; i <= n; i++) {
		pre_d2[i] = pre_d2[i - 1] + d2[i];
	}
	ll ans = 0;
	for(int c1 = 0; c1 <= n; c1++) {
		int c2 = n - c1;
		if(c1 == 0 || c1 == n) {
			ans = max(ans, d1[c1] + d2[c2]);
			continue;
		}
		for(int i = 0; i < 2; i++) {
			int cc1 = c1, cc2 = n - c1;
			ll val = 0;
			if(i == 0 && !cc1) continue;
			if(i == 1 && !cc2) continue;
			if(i == 0) val += d1[cc1--];
			else val += d2[cc2--];
			int cnt1 = cc1, cnt2 = cc2;
			if(i == 0) {
				cnt2 = min(cnt2, cnt1 + 1);
				cnt1 = min(cnt1, cnt2);
			}
			else {
				cnt1 = min(cnt1, cnt2 + 1);
				cnt2 = min(cnt2, cnt1);
			}
			val += 2 * (pre_d1[cc1] - pre_d1[cc1 - cnt1] + pre_d2[cc2] - pre_d2[cc2 - cnt2]);
			ans = max(ans, val);
		}
	}
	// print(pre_d1 + 1, pre_d1 + n + 1);
	// print(pre_d2 + 1, pre_d2 + n + 1);
	cout << ans;
}

signed main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    v.push_back(a);
  }
  vector<int> dp;
  dp.push_back(0);
  dp.push_back(abs(v[0]-v[1]));
  for(int i=2;i<n;i++)
  {
    dp.push_back(min(abs(v[i]-v[i-2])+dp[i-2],abs(v[i]-v[i-1])+dp[i-1]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys


def solve(s: str):
    ret = s[0] + str(len(s) - 2) + s[-1]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import re
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b = iim()
s = input()
#print(a,b,s[:a],s[a],s[a+1:])
ma = re.match(r'\d{%s}' %a, s[:a])
mb = re.match(r'\d{%s}' %b, s[a+1:])
#print(ma,mb)
if s[a] == '-' and ma and mb:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#Doubling lca
class Node
  attr_accessor :child, :depth, :parent
  def initialize
    @child = []
    @depth = 0
    @parent = []
  end
end

def dfs(root, g)
  stack = [root]
  g[root].depth = 0
  g[root].parent[0] = -1
  while stack.size > 0
    s = stack[-1]
    t = g[s].child.shift
    if t
      stack << t
      g[t].depth = g[s].depth + 1
      g[t].parent[0] = s
    else
      stack.pop
    end
  end
end

n = gets.to_i
g = Array.new(n){Node.new}
n.times{|i|
  g[i].child = gets.split.map(&:to_i)
  g[i].child.shift
}

dfs(0, g)
k = 0
while k < Math.log2(n)
  v = 0
  while v < n
    if g[v].parent[k] < 0
      g[v].parent[k+1] = -1
    else
      g[v].parent[k+1] = g[g[v].parent[k]].parent[k]
    end
    v += 1
  end
  k += 1
end

q = gets.to_i
q.times{
  u, v = gets.split.map(&:to_i)
  u, v = v, u if g[u].depth > g[v].depth
  k = 0
  while k < Math.log2(n) + 1
    if (g[v].depth - g[u].depth) >> k & 1 == 1
      v = g[v].parent[k]
    end
    k += 1
  end
  if u == v
    puts u
    next
  end
  k = (Math.log2(n) - 1).to_i
  while k >= 0
    if g[u].parent[k] != g[v].parent[k]
      u = g[u].parent[k]
      v = g[v].parent[k]
    end
    k -= 1
  end
  puts g[u].parent[0]
}

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

int main() {
    for(int i=1; i<=5; i++){
        int x;
        cin >> x;
        if(x==0) cout << i << endl;
    }
    
}

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

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var inputInt = int.Parse(Console.ReadLine());

            int ans = 0;
            if (inputArr[0] > 9 || inputArr[1] > 9) Console.WriteLine(-1);

            else
            {
                ans = inputArr[0] * inputArr[1];
                Console.WriteLine(ans);
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main(){
    long long int a,b,c,d,maior;

    scanf("%lli %lli %lli %lli",&a,&b,&c,&d);
    //x>=a && x<=b;
    //y>=c && y<=d;


        maior = a*c;
        if(maior<a*d){
            maior = a*d;
        }

        if(maior<b*c){
            maior = b*c;
        }
        if(maior<b*d){
            maior = b*d;
        }

    printf("%lli\n",maior);







    return 0;
}


Measured memory_bytes: 1724
#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;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int L, R, D, C = 0;
	cin >> L >> R >> D;
	for (int i = L; i <= R; i++)
		if (i % D == 0) C++;
	cout << C << '\n';
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
char c[1010][1010];
ll d[1010][1010];
ll md=1e9+7;
int main()
{
	scanf("%d%d",&n,&m);
	//cout <<n<<" "<<m<<" ##\n"; 
	for (int i=0;i<n;i++) scanf("%s",&c[i]);
	d[0][0]=1;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			//cout <<d[i][j]<<" ";
			if (c[i][j]=='#') continue;
			if (i!=n-1 && c[i+1][j]=='.')
				d[i+1][j]=(d[i+1][j]+d[i][j])%md;
			if (j!=m-1 && c[i][j+1]=='.')
				d[i][j+1]=(d[i][j+1]+d[i][j])%md;
		}
		//cout <<"\n";
	}
	printf("%lld",d[n-1][m-1]);
	return 0;
}

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

using namespace std;

int main() {
    int n;
  	vector<int> v1, v2;
  
  	cin >> n;
  	
  	int tmp;
  	int ct = 0;
  	for (int i = 0; i < n; i++) {
      	cin >> tmp;
      	if (tmp != i + 1) {
          	ct++;
        }
    }
  	
  	if (ct > 2) {
      	cout << "NO" << endl;
    } else {
      	cout << "YES" << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a,b,c;
	cin >> a; cin >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		c = "YES";
	}
	else {
		c = "NO";
	}
	cout << c<<endl;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = []
p = [k-q]*n
for i in range(q):
    ai = int(input())
    a.append(ai)
    
for i in range(q):
    p[a[i]-1] += 1
    
for i in range(n):
    if p[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 56024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

int main(){
    ll K, N; cin >> K >> N;
    vector<ll> A(N), D(N); for(int i = 0; i < N; i++) cin >> A[i]; 
    D[0] = K-A[N-1] + A[0];
    for(int i = 1; i < N; i++) D[i] = A[i]- A[i-1];
    sort(D.begin(), D.end());
    cout << K - D[N-1] << endl;

}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int V,E;scanf("%d%d",&V,&E);
    vector<vector<int>> G(V,vector<int>(V,2e9+10));
    for(int i=0;i<V;i++)G[i][i]=0;
    for(int i=0;i<E;i++){
        int a,b,c;scanf("%d%d%d",&a,&b,&c);
        G[a][b]=c;
    }
    for(int k=0;k<V;k++){
        for(int i=0;i<V;i++){
            for(int j=0;j<V;j++){
                if(G[i][k]==2e9+10 or G[k][j]==2e9+10)continue;
                G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
            }
        }
    }
    for(int i=0;i<V;i++){
        if(G[i][i]<0){
            puts("NEGATIVE CYCLE");
            return 0;
        }
    }
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            if(j)printf("%s"," ");
            if(G[i][j]==2e9+10)printf("%s","INF");
            else printf("%d",G[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
int n,len,pos;
string s;
  
vec mul(vec a,vec b){
  vec res(n*n);
  for(int i=0;i<n*n;i++)res[i]=b[a[i]];
  return res;
}
  
vec mpow(vec a,int t){
  if(t==0){
    vec res(n*n);
    for(int i=0;i<n*n;i++)res[i]=i;
    return res;
  }  
  vec res=mpow(mul(a,a),t/2);
  if(t%2==1)res=mul(res,a);
  return res;
}
  
vec calc();
  
vec getNum(){
  
  if(s[pos]=='('){
    pos++;
    vec res=calc();
     
    int num=0;
    while(pos<len&&'0'<=s[pos]&&s[pos]<='9')
      num=num*10+s[pos++]-'0';
    vec Ra= mpow(res,num);
    return Ra;
  }
   
  char ch=s[pos++];
  int num=0;
  while(pos<len&&'0'<=s[pos]&&s[pos]<='9'){
    num=num*10+s[pos]-'0';
    pos++;
  }
   
  vec res(n*n);  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int ni=i,nj=j;
      if(ch=='D'&&j+1==num){
        ni=(i+1)%n;
        nj=j;
      }else if(ch=='L'&&i+1==num){
        ni=i;
        nj=(j+n-1)%n;
      }else if(ch=='U'&&j+1==num){
        ni=(i+n-1)%n;
        nj=j;
      }else if(ch=='R'&&i+1==num){
        ni=i;
        nj=(j+1)%n;
      }
      res[i*n+j]=ni*n+nj;
    }
  }
  return res;
}
  
int C=0;
vec calc(){
  vec res=getNum();
   
  while(pos<len){
    if(s[pos]==')'){
      pos++;
      break;
    }
    vec num=getNum();
    res=mul(res,num);
  }
  return res;
}
  
int main() {
  while(cin>>n>>len) {
    cin>>s;
    pos=0;
    vec ans(n*n),ans2=calc();
    for(int i=0;i<n*n;i++){
      ans[ ans2[i]]=i;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(j)cout<<' ';
        cout<<ans[i*n+j]+1;
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7336
N, M = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(M)]
minN = 0 if N == 1 else 10 ** (N - 1)

for t in range(minN, 10 ** N):
    for s, c in C:
        if (t // (10 ** (N - s))) % 10 != c:
            break
    else:
        ans = t
        break
else:
    ans = -1

print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
 
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using ll = long long;
using ld = long double;
 
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const int L = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = (1LL << 61);
 
int n, k;
ll s;

vector <int> a;

bool f(int x, int y) {
    return x > y;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin >> n >> k;
    a.resize(n);
    for (int &i : a) cin >> i;
    sort(all(a), f);
    
    for (int i = k; i < n; ++i) s += a[i];
    
    cout << s;
 
    return 0;
}
 
/// ACTUAL CODE STARTS HERE:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */

Measured memory_bytes: 1024
//**************************
//*** author  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

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

int deg[101000],q[101000],head,tail,n,m,d[101000];
vi e[101000];
int a,b;

int main()
{
	cin>>n>>m;
	rept(i,0,m)
	{
		cin>>a>>b;
		e[a].pb(b);
		deg[b]++;
	}
	rept(i,1,n+1) if (!deg[i]) q[++tail]=i;
	int res=0;
	while (head<tail)
	{
		int x=q[++head];
		res=max(res,d[x]);
		for (auto &y:e[x])
		{
			deg[y]--;
			d[y]=max(d[y],d[x]+1);
			if (!deg[y]) q[++tail]=y;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
typedef long double ld;

const int INF = 1e9 + 7;
const double TT = 3.141592653589793238462643383279;

pi a[105];

int quarter(pi a) {
	if(a.F >= 0 && a.S >= 0) return 1;
	if(a.F < 0 && a.S >= 0) return 2;
	if(a.F < 0 && a.S < 0) return 3;
	if(a.F >= 0 && a.S < 0) return 4;
}
int cross(pi a, pi b) {
	return a.F * b.S - a.S * b.F;
}

ld go(ld x, ld y) {
	return x * x + y * y;
}

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) 
		cin >> a[i].F >> a[i].S;
	sort(a+1, a+n+1, [](pi a, pi b) {
		if(quarter(a) == quarter(b)) {
			return cross(a, b) > 0;
		} else {
			return quarter(a) < quarter(b);
		}
	});
	for(int i=1;i<=n;i++) {
		a[i].F += a[i-1].F;
		a[i].S += a[i-1].S;
	}
	ld ans = 0;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++) {
			ans = max(ans, go(a[j].F - a[i-1].F, a[j].S - a[i-1].S));
			ans = max(ans, go(a[n].F - a[j].F + a[i].F, a[n].S - a[j].S + a[i].S));
		}
	ans = sqrtl(ans);
	cout << fixed << setprecision(15) << ans << endl;
}





Measured memory_bytes: 256
N=input()

if len(N)==1:
  print(int(N))
elif len(N)==2:
  print(9)
elif len(N)==3:
  print(9+int(N)-99)
elif len(N)==4:
  print(909)
elif len(N)==5:
  print(909+int(N)-9999)
elif len(N)==6:
  print(90909)

Measured memory_bytes: 3060
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

ll mul(ll x, ll y)
{
	return (ll) (x * y) % MOD;
}

ll power(ll x, ll y)
{
	ll sol = 1;
	while(y)
	{
		if(y&1)
		{
			sol = mul(sol,x);
		}
		x = mul(x,x);
		y >>=1;
	}
	return sol;
}

ll inv_mod(ll x)
{
	return power(x, MOD-2);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n;
	cin >> n;
	ll lcm = 1;
	vector<int> v(n);
	map<int,int> ans;
	for(int i =0; i< n; ++i)
	{
		ll x;
		cin >> x;
		v[i] = x;
		map<int,int> cnt;
		for(int i = 2; i*i <= x; ++i)
		{
			while(x % i == 0)
			{
				++cnt[i];
				x/=i;
			}
		}
		if(x!=1)
		{
			++cnt[x];
		}

		for(auto &p : cnt)
		{
			ans[p.first] = max(ans[p.first], p.second);
		}
	}
	for(auto &p : ans)
	{
		ll prime = p.first;
		ll k = p.second;
		for(int i = 0; i < k; ++i)
		{
			lcm = mul(lcm,prime);
		}
	}
	
	ll sum = 0;
	for(ll x : v)
	{
		sum = (sum + mul(lcm, inv_mod(x))) % MOD;
	}

	cout << sum;

    return 0;
}

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

int main() {
 int a,b,c,d,e,k;
  int p[5];
  for(int i=0;i<5;i++){
    cin>>p[i];
  }
  cin>>k;
  
  if(p[4]-p[0]>k) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
                          
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {
    int N;
    double ans = 0;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N;++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    ans = v[0];
    for(int i = 1; i < N; ++i)
        ans = (ans + v[i]) / 2;
    printf("%.8lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200100
using namespace std;
int tmp[18];
bool cmp(int i,int j){
	return tmp[i]<tmp[j];
}
int main(){
	int n,a[2][18],b[18];
	int ans=-1;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[0][i]);
	for(int i=0;i<n;i++) scanf("%d",&a[1][i]);
	for(int i=0;i<(1<<n);i++){
		vector<int> s[2];
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				tmp[j]=a[1][j];
				s[(j&1)^1].push_back(j);
			}
			else{
				tmp[j]=a[0][j];
				s[j&1].push_back(j);
			}
		}
		if(s[1].size()!=n/2) continue;
		for(int j=0;j<2;j++){
			stable_sort(s[j].begin(),s[j].end(),cmp);
		}
		bool flag=false;
		for(int j=1;j<n;j++){
			if(tmp[s[j&1][j>>1]]<tmp[s[(j-1)&1][(j-1)>>1]]) flag=true;
		}
		int tans=0;
		if(!flag){
			for(int j=0;j<n;j++){
				for(int k=j+1;k<n;k++){
					if(s[j&1][j>>1]>s[k&1][k>>1]) tans++;
				}
			}
			if(tans<ans||ans<0) ans=tans;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//my import
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7; 

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	
	for(int i=1;i<=60000;i++)
	{
		if((int)((double)i*1.08)==n)
			return cout<<i<<endl,0;
	}
	
	return cout<<":("<<endl,0;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a,b;
int main()
{
    scanf("%d%d",&a,&b);
    if(a==0||b==0||(a<0&&b>0)) puts("Zero");
    else if(a>0) puts("Positive");
    else if((b-a)&1) puts("Positive");
    else puts("Negative");
    return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<int> L(N,0);
    for(int i=0;i<N;i++){
        cin>>L[i]
    ;}
    sort(L.begin(), L.end());
    int counter=0;
    for(int i=0;i<N-2;i++){
     for(int j=i+1;j<N-1;j++){
         for(int k=j+1;k<N;k++){
             if(L[k]-L[j]<L[i])counter++
         ;}
     ;}
    ;}
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c,n1,n2;
	n1=0;n2=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
			if((a*a+b*b)==c*c){n1++;}else if(a==b){n2++;}
	}
	printf("%d\n%d\n",n1,n2);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
template <typename T>
struct Heap {
    Heap *l, *r;
    T val;
    Heap() {}
    Heap(T v) : l(nullptr), r(nullptr), val(v) {}
    void Init(int v) {
        l = nullptr; r = nullptr; val = v;
    }
};
Heap<int> pool[2000000];
int it;
 
class Priority_Queue {
    Heap<int>* root;
    Heap<int>* meld(Heap<int>* a, Heap<int>* b) {
        if (a == nullptr) return b;
        if (b == nullptr) return a;
        if (a->val < b->val) swap(a, b);
        a->r = meld(a->r, b);
        swap(a->l, a->r);
        return a;
    }
    Heap<int>* pop_(Heap<int>* a) {
        return meld(a->l, a->r);
    }
public:
    Priority_Queue() : root(nullptr) {}
    void push(int val) {
        pool[it].Init(val);
        root = meld(root, &pool[it++]);
    }
    int top() {
        return root->val;
    }
    void pop() {
        root = pop_(root);
    }
    void meld(Heap<int>* a) {
        root = meld(root, a);
    }
};
 
int main()
{
    cin.sync_with_stdio(false);
    int val;
    string S;
    Priority_Queue pq;
 
    while (cin >> S, S != "end") {
        if (S == "extract") {
            printf("%d\n", pq.top());
            pq.pop();
        }
        else {
            cin >> val;
            pq.push(val);
        }
    }
    return 0;
}

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

struct Process {
  string name;
  int time;
};

struct Queue {
  const int length = 100005;
  int head;
  int tail;
  Process processes[100005];

  void enqueue(Process x) {
    processes[tail] = x;
    tail = (tail + 1) % length;
  }

  Process dequeue() {
    Process x = processes[head];
    head = (head + 1) % length;
    return x;
  }
};

int main() {
  int elaps = 0, c;
  int n, q;
  Process u;
  cin >> n >> q;
  Queue queue;
  for (int i = 1; i <= n; ++i) {
    cin >> queue.processes[i].name;
    cin >> queue.processes[i].time;
  }
  queue.head = 1;
  queue.tail = n + 1;

  while (queue.head != queue.tail) {
    u = queue.dequeue();
    c = min(q, u.time);
    u.time -= c;
    elaps += c;
    if (u.time > 0) {
      queue.enqueue(u);
    } else {
      cout << u.name << ' ' << elaps << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6992
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = scanString()
	}

	c := make([]pii, n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		for _, e := range ss[i] {
			if e == ')' {
				a++
			} else {
				b++
			}
			c[i].a = max(c[i].a, a-b)
		}
		a, b = 0, 0
		for j := 0; j < len(ss[i]); j++ {
			if ss[i][len(ss[i])-1-j] == ')' {
				a++
			} else {
				b++
			}
			c[i].b = max(c[i].b, b-a)
		}
	}
	sort.Slice(c, func(i, j int) bool {
		a := c[i].b - c[i].a
		b := c[j].b - c[j].a

		if a >= 0 && b >= 0 {
			return c[i].a < c[j].a
		} else if a < 0 && b < 0 {
			return c[i].b > c[j].b
		} else {
			return a > b
		}
	})

	// debug(c)

	a := 0
	for i := 0; i < n; i++ {
		if a < c[i].a {
			fmt.Fprintln(wr, "No")
			return
		}
		a -= c[i].a
		a += c[i].b
	}
	if a != 0 {
		fmt.Fprintln(wr, "No")
	} else {
		fmt.Fprintln(wr, "Yes")
	}
}

type pii struct{ a, b int }


Measured memory_bytes: 34096
import io.{StdIn => in}

object Main extends App {
  val table = Array.ofDim[Int]('z'-'a' + 1)
  in.readLine.foreach(ch => table(ch - 'a') += 1)
  val ans = if(table.forall(_ % 2 == 0)) "Yes" else "No"
  println(ans)
}

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

using namespace std;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> amax(n, 0);
	for (int i = 1; i < n; i++) amax[i] = max(amax[i - 1], a[i - 1]);
	vector<P> ap(n);
	for (int i = 0; i < n; i++) {
		ap[i].first = a[i];
		ap[i].second = -i;
	}
	sort(ap.rbegin(), ap.rend());
	
	int cnt = 0;
	vector<ll> ans(n, 0);
	for (int i = 0, j = 0; i < n; ) {
		int idx = -ap[i].second;
		cnt++;
		ans[idx] += (a[idx] - amax[idx]) * cnt;
		j = i + 1;
		while (j < n) {
			if (amax[idx] < ap[j].first) {
				ans[idx] += (ap[j].first - amax[idx]);
				cnt++;
				j++;
			} else break;
		}
		i = j;
	}

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

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long N, K, A[1 << 18];
    cin >> N >> K;
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    
    for(int i = 0 ; i < N - K; i++){
        // cout << A[i] << " " << A[i + K] << endl;
        if(A[i] >= A[i + K]){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5168
#include <stdio.h>
int main(void){
    int N; scanf("%d", &N);
    int Ai[N];
    int i, tempmax, tempmin;
        for (i = 0; i <= N; i++){
            scanf("%d",&Ai[i]);
        }
        tempmax = Ai[0];
        tempmin = Ai[0];
        for (i = 0; i < N; i++){
            if (Ai[i] > tempmax)
            tempmax = Ai[i];
        }
        for (i = 0; i < N; i++){
            if (Ai[i] < tempmin)
            tempmin = Ai[i];
        }
        printf("%d\n",tempmax - tempmin);
    return 0;
    
}    

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    # if N > K:
    print(min(N % K,abs(N % K-K)))
    # else :
    #     N = K - N
    #     print(min(N % K,abs(N % K-K)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

def main():
    h,w,m=map(int,input().split())
    hw=[list(map(int,input().split())) for i in range(m)]

    hlst=[[0,i] for i in range(h)]    
    wlst=[[0,i] for i in range(w)]
    dic={}
    for i in range(m):
        hh,ww=hw[i]
        hlst[hh-1][0]-=1
        wlst[ww-1][0]-=1
        dic[(hh-1,ww-1)]=1

    hlst.sort()
    wlst.sort()
    hkouho=[]
    wkouho=[]
    mi=0
    for i in range(h):
        if mi<hlst[i][0]:
            break
        hkouho.append(hlst[i][1])
        mi=hlst[i][0]
    mi=0
    for i in range(w):
        if mi<wlst[i][0]:
            break
        wkouho.append(wlst[i][1])
        mi=wlst[i][0]
    # print(hkouho)
    # print(wkouho)
    # print(hlst)
    for i in range(len(hkouho)):
        for j in range(len(wkouho)):
            if not (hkouho[i],wkouho[j]) in dic:
                print(-hlst[0][0]-wlst[0][0])
                exit()
    print(-hlst[0][0]-wlst[0][0]-1)
    # print(hkouho[0],wkouho[0])
main()

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

using namespace std;
using ll = long long;

ll solve(ll A, ll B)
{
    if (A == B)
        return 2*(A - 1);

    auto a = min(A, B);
    auto b = max(A, B);

    auto ans = (a - 1);

    // Todos que ficaram em posições (a - i) no primeiro contest paream com (b + i)
    // para um melhor score que ab
    ll s =  sqrtl(a*b);

    if ((s + 1)*(s + 1) <= a*b)
        ++s;

    // a + i = s tem que combinar com b + k
    auto b_k = (a*b - 1)/s;
    ans += (s - (a + 1) + 1);

    // todos os b in [1, b_k - 1] combinam com alguém
    ans += (b_k - 1);

//cout << "==============\n";
//cout << "a = " << a << ", b = " << b << '\n';
//cout << "s = " << s << ", s * s = " << s * s << ", ab = " << a*b << '\n';
//cout << "a in [" << a + 1 << ", " << s << "] (" << s - (a + 1) + 1 << " elementos), última combinação: b = " << b_k << "\n";
//cout << "b in [" << 1 << ", " << b_k - 1 << "] (" << b_k - 1 << " elementos)\n";

/*    auto ans = (a - 1);
cout << "ans = " << ans << "\n";
    // (a + 1) deve combinar com (b - i) para um score menor que ab

    auto i = 1;
    ll b_i, prev = b;

    while ((b_i = (a*b - 1)/(a + i)) > 0)
    {
        if (b_i == prev)
        {
            ++i;
            continue;
        }

        cout << "i = " << i << ", a + i = " << (a + i) << ", b - j = " << b_i << ", prod = " << (a + i)*b_i << ", ab = " << a*b << '\n';
        ++ans;
        ++i;
        prev = b_i;
    }
*/
/*    auto b_i = (a*b - 1)/(a + 1);
cout << "a = " << a << ", b = " << b << '\n';
cout << "b_i = " << b_i << ", (" << (double) (a*b)/(a + 1) << "), ab = " << a*b << ", (a + 1)*(b - i) = " << (a + 1)*b_i << "\n";

    // 1 deve combinar com (a + k) para um score menor que ab
    auto a_k = a*b - 1;
cout << "a + k = " << a_k << ", ab = " << a*b << '\n';

cout << "a in [" << (a + 1) << ", " << a_k << "] (" << a_k - a << " valores)\n";
cout << "b in [" << 1 << ", " << b_i << "] (" << b_i << " valores)\n";
cout << "min = " << min(b_i - 1 + 1, a_k - (a + 1) - 1) << "\n";
cout << "===\n";
    ans += min(b_i - 1 + 1, a_k - (a + 1) + 1);
*/
    return ans;
}

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

    int Q;
    cin >> Q;

    while (Q--)
    {
        int A, B;
        cin >> A >> B;

        auto ans = solve(A, B);
        cout << ans << '\n';
    }

    return 0;
}


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

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        vector <int> h(n + 1, 0), w(m + 1, 0);
        rep (i, n) cin >> h[i + 1];
        rep (i, m) cin >> w[i + 1];

        rep (i, n) h[i + 1] += h[i];
        rep (i, m) w[i + 1] += w[i];

        map <int, int> lengthToCnt;

        rep (i, n + 1) range (j, i + 1, n + 1) lengthToCnt[h[j] - h[i]]++;

        int cnt = 0;
        rep (i, m + 1) range (j, i + 1, m + 1) cnt += lengthToCnt[w[j] - w[i]];
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 20860
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> D(0,0);
  for(int i=0; i<N; i++){
    int d;
    cin >> d;
    D.push_back(d);
  }
  stable_sort(D.begin(), D.end());
  N/=2;
  int ans=D[N]-D[N-1];
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
ll h, w, n;
set<ll> s;
set<ll> loc;

void push(ll x, ll y) {
	ll i, j;
	for (i=x-2;i<=x;i++) {
		if (i<0||i>=h-2) continue;
		for (j=y-2;j<=y;j++) {
			if (j<0||j>=w-2) continue;
			loc.insert(i*w+j);
		}
	}
	s.insert(x*w+y);
}

ll ans[10];
int main() {
	int i, j;

	scanf("%lld%lld%lld",&h,&w,&n);
	for (i=0;i<n;i++) {
		ll a, b;
		scanf("%lld%lld",&a,&b); --a;--b;
		push(a,b);
	}
	ans[0] = 1LL*(h-2)*(w-2);
	auto it = loc.begin();
	while(it!=loc.end()) {
		ll x = (*it)/w, y = (*it)%w, cnt = 0;
		for (i=x;i<=x+2;i++) {
			for (j=y;j<=y+2;j++) if (s.find(i*w+j)!=s.end()) cnt++;
		}
		ans[cnt]++; ans[0]--; it++;
	}
	for (i=0;i<10;i++) printf("%lld\n",ans[i]);

    return 0;
}


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

int main(){
	int w, n, a, b, temp;
	vector<int> array;
	cin >> w >> n;
	for(int i=1; i<=w; i++){
		array.push_back(i);
	}
	for(int i=0; i<n; i++){
		a = 0;
		b = 0;
		temp = 0;
		scanf("%d,%d",&a,&b);
		a--;
		b--;
		temp = array[a];
		array[a] = array[b];
		array[b] = temp;
	}
	for(int i=0; i<w; i++){
		cout << array[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <string>

using namespace std;

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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    string xg1(dx, 'R');
    string yg1(dy, 'U');
    string xs1(dx, 'L');
    string ys1(dy, 'D');

    string xg2(dx + 1, 'R');
    string yg2(dy + 1, 'U');
    string xs2(dx + 1, 'L');
    string ys2(dy + 1, 'D');

    string ansS = xg1 + yg1 + xs1 + ys1 + 'D' + xg2 + yg2 + 'L' + 'U' + xs2 + ys2 + 'R';
    cout << ansS << endl;
}

Measured memory_bytes: 256