akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int a,b,c,lar,ans;
	scanf("%d %d %d",&a,&b,&c);
	lar=max(a,max(b,c));
	ans=abs(lar-a)+abs(lar-b)+abs(lar-c);
	if (ans%2) printf("%d\n",(ans+3)/2);else printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl d(N); rep(i, N) cin >> d[i];
    ll ans = 0;
    rep(i, N) FOR(j, i+1, N){
        ans += d[i]*d[j];
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
int main(){
  
  int N, K, X, Y;
  int sum = 0;
  
  scanf("%d%d%d%d", &N, &K, &X, &Y);

  for(int cnt = 1; cnt <= N; cnt++){
    if(cnt <= K){
      sum = sum + X;
    }else{
      sum = sum + Y;
    }
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    string s; cin >> s;

    string ans = "";
    rep(i,s.length()) if(i % 2 == 0) ans += s.substr(i, 1);

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

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


Measured memory_bytes: 7000
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,n,i;
    cin>>k>>n;
    vector<int> a(n);
    for(i=0;i<n;++i)    cin>>a[i];
    int temp = a[0], ans = 0;
    for(i=1;i<n;++i)
    {
        ans = max(ans,a[i]-temp);
        temp = a[i];
    }
    ans = max(ans,a[0]+(k-temp));
    cout<<k-ans;
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    while (true) {
        int d, e;
        cin >> d >> e;
        if (d == 0 and e == 0) {
            break;
        }

        double err = numeric_limits<double>::max();
        for (int i = 0; i <= d; i++) {
            const double dis = std::sqrt(i * i + (d - i) * (d - i));
            const double error = std::abs(dis - e);
            if (err > error) {
                err = error;
            }
        }
        cout << err << endl;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int a,b,c;  cin>>a>>b>>c;
  int k;  cin>>k;
  rep(i,0,k){
    if(a>=b) b *= 2;
    else if(b>=c) c *= 2;
  }
  if(a<b && b<c) cout<<"Yes"<<endl;
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3580
def main():
    x, y = [int(x) for x in input().split()]
    if (x + y) % 3 != 0:
        return 0
    moves = (x + y) // 3
    a, b = x - moves, y - moves
    if a < 0 or b < 0:
        return 0
    return combinations_mod(a + b, a)


def combinations_mod(n, r, mod=1000000007):
    """Returns nCr in mod."""
    r2 = n - r
    r = min(r, r2)
    combs = 1
    for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):
        combs = combs % mod * i % mod * pow(j, mod - 2, mod) % mod
    return combs


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

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

		int b = sqrt(a);
		bool bl = true;
		for (int j = b; j > 1; j--) {
			if (a % j == 0) {
				bl = false;
			}
		}

		if (bl) c++;
	}

	cout << c << endl;
}


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

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf);
    let mut it = buf.split_whitespace();
    let tmp_s: String = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = tmp_s.chars().collect();
    let mut cnt = 0;
    for c in &s {
        if *c=='o' {
            cnt += 1;
        }
    }
    println!("{}", 700+100*cnt);
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    int N = next<int>(), num[200][3] = {}, score[200] = {};
    times(N, i) times(3, j) num[i][j] = next<int>();

    times(3, j) {
        int used[101] = {};
        times(N, i) used[num[i][j]]++;
        times(N, i) if(used[num[i][j]] == 1) score[i] += num[i][j];
    }

    times(N, i) cout << score[i] ln;

    return 0;
}

Measured memory_bytes: 1196
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  const double  pi=3.1415926535; 
  const ll M=1e9+7;
  struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i;
	cin>>n;
	ll v[n],dp[n+1]={};
	for(i=0;i<n;i++){
		cin>>v[i];
		dp[i+1]=dp[i]+v[i];
		dp[i+1]%=M;
	}
	ll sum=0;
	for(i=1;i<n;i++){
		sum=(sum+((dp[i]*v[i])%M))%M;
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 6740
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;

const ll INF = 1e9+5;
const ll MOD = 1e9+7;

int a[200005];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i=0 ; i<n ; i++) {
		scanf("%d", a+i);
	}
	for (int i=k ; i<n ; i++) {
		if (a[i] >  a[i-k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4540
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std; 
int h,w;

//int saiki(int x,int y,int n,vector< vector<int> > board){
int saiki(int x,int y,int n,int board[][100]){
    int ret = n;
    REP(i,4){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(nx < 0 || w <= nx || ny < 0 || h <= ny){
	    continue;
	}
	if(board[ny][nx] == 1){
	    board[ny][nx] = 0;
	    ret = max(ret,saiki(nx,ny,n+1,board));
	    board[ny][nx] = 1;
	}
    }
    return ret;
}

int main(){
    while(true){
	scanf("%d %d",&w,&h);
	if(w == 0 && h == 0) break;
	//vector< vector<int> > board(h,vector<int>(w,0));
	int board[100][100];
	REP(i,h)REP(j,w){
	    scanf("%d",&board[i][j]);
	}
	int ans =0 ;
	REP(i,h)REP(j,w){
	    if(board[i][j] == 1){
		board[i][j] = 0;
		ans = max(ans,saiki(j,i,1,board));
		board[i][j] = 1;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


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

    cout << n*(n-1)/2 - n/2 << endl;
    int exclude = n/2 * 2;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            if(j==exclude){
                exclude--;
            }else{
                cout << i << " " << j << endl;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
def maxdis(cx,cy):
    global x, y
    dmax = d = 0
    xf, yf = 0, 0
    for i in range(len(x)):
        d = max(d ,((x[i] - cx) ** 2 + (y[i] -cy) ** 2) ** 0.5)
        if dmax < d:
            dmax = d
            xf, yf =x[i], y[i]
    return xf, yf

N = int(input())
x = []; y = []
for i in range(N):
    xi, yi = map(int,input().split())
    x.append(xi);y.append(yi)

cx, cy = 500, 500
r = 500 * 1.5
i=0
while (r > 10 ** -10):
    xf, yf = maxdis(cx,cy)
    df = ((xf - cx) ** 2 + (yf - cy) ** 2) ** 0.5
    r *= 0.999
    dx = r * (xf - cx) / df
    dy = r * (yf - cy) / df
    cx += dx; cy += dy
    i += 1

    # print(i, cx, cy, df, r, xf, yf)

print(df)

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

int main()
{
    int x,y,z;
    cin >> x >> y >> z;

    int t = x;
    x = y;
    y = t;

    t = x;
    x = z;
    z = t;

    cout << x << " " << y << " " << z;


    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long A, B, C, K;
  cin >> A >> B >> C >> K;

  if ( K % 2 == 0 ) 
    cout << A - B << endl;
  else 
    cout << B - A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K, ans=0;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (h[i] >= K) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  int i,j=0;
  for(i=1;i<=n;i+=2)
      {
        j++;
      }
      double d=(double)j/n;
      cout<<setprecision(10)<<d;
      }

Measured memory_bytes: 256
# 入力
B, W = map(int, input().split())

# ModInt定義
MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    def __repr__(self):
        return str(self.x)

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__
    __rsub__ = __sub__
    __rmul__ = __mul__
    __rtruediv__ = __truediv__
    __rpow__ = __pow__


p = ModInt(0)
q = ModInt(0)
cp = ModInt(0)
cq = ModInt(0)
for i in range(1, B + W + 1):
    # i番目の解は i-1番目までに白チョコレートが枯渇している確率 +
    # i-1番目までにどちらのチョコレートも枯渇しない確率 / 2
    ans = (1 + q - p) / 2
    # 出力
    print(ans)
    cp = (
        ModInt(0) if i < B else
        ModInt(1) if i == B else
        cp * (i - 1) / (i - B)
    )
    p = (
        ModInt(0) if i < B else
        ModInt(1) / ModInt(2)**i if i == B else
        p + cp / ModInt(2)**i
    )
    cq = (
        ModInt(0) if i < W else
        ModInt(1) if i == W else
        cq * (i - 1) / (i - W)
    )
    q = (
        ModInt(0) if i < W else
        ModInt(1) / ModInt(2)**i if i == W else
        q + cq / ModInt(2)**i
    )


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

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

    int row, col, ans = 0;
    std::cin >> row >> col;
    std::vector<std::vector<int>> mass(205, std::vector<int>(205)), c(10, std::vector<int>(10));

    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            std::cin >> c[i][j];
        }
    }

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            std::cin >> mass[i][j];
        }
    }

    for (int k = 0; k < 10; k++){
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < 10; j++){
                c[i][j] = std::min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            if (mass[i][j] != -1){
                ans += c[mass[i][j]][1];
            }
        }
    }

    std::cout << ans << std::endl;
}

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

int main() {
	int n;cin >> n;
	string s,t;
	cin >> s >> t;
	int ans = n * 2;
	for (int i = 0;i < n;i++) {
		if (s.substr(i,n-i) == t.substr(0,n-i)) {
			ans = i + n;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll x,y;

void run() {
	scanf("%lld%lld",&x,&y);
	if(x%y==0) printf("-1\n"); else printf("%lld\n",x);
}

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


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec;
//use std::vec::Vec;
//use std::collections::HashSet;


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn calc(mut x: i32) -> i32 {
    let mut res: i32 = 0;
    while x > 0 {
        res += x % 10;
        x /= 10;
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let mut ans = 0;
    for m in 1..n+1 {
        let sum = calc(m);
        if a <= sum && sum <= b {
            ans += m;
        }
    }
    println!("{}", ans);
}

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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF (1e9+7)

using namespace std;

int main(){
  int n;
  while(cin >> n and n){
    vector<int> data(n);
    REP(i, n){
      string imput; cin >> imput;
      if(imput == "x") data[i] = i%2 ? INF : -INF;
      else data[i] = stoi(imput);
    }
    bool enable = true;
    int maxim = INF;
    int minim = -INF;
    for(int i=1; i<n-1; i+=2){
      if(data[i-1] == -INF and data[i] == INF) enable = false;
      if(data[i-1] >= data[i]) enable = false;
      if(!enable) break;
      if(data[i-1] == -INF or data[i+1] == -INF) maxim = min(maxim, data[i]-1);
      if(data[i] == INF) minim = max(max(data[i-1]+1, data[i+1]+1), minim);
    }
    if(n%2 == 0){
      if(data[n-1] == INF and data[n-2] == -INF) enable = false;
      if(data[n-1] <= data[n-2]) enable = false;
      if(data[n-1] == INF) minim = max(minim, data[n-2]+1);
      if(data[n-2] == -INF) maxim = min(maxim, data[n-1]-1);
    }
    if(!enable or maxim < minim) cout << "none" << endl;
    else if(maxim > minim) cout << "ambiguous" << endl;
    else cout << maxim << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner scan = new Scanner(System.in);
    	int[] sel = new int[4];
    	int[] esel = new int[4];
    	while(scan.hasNext()){
        	for(int i = 0 ; i < 4 ; i ++){
        		sel[i]=scan.nextInt();
        	}
        	Data d = new Data(sel);
    		for(int i = 0 ; i < 4 ; i ++){
    			esel[i] = scan.nextInt();
    		}
    		d.check(esel);
    	}
    }
}
class Data{
	private int[] select = new int[4];
	Data(int[] sel){
		select=sel;
	}
	void check(int[] esel){
		int hit = 0;
		int blow = 0;
		for(int i = 0 ; i < 4 ; i ++){
			for(int j = 0 ; j < 4 ; j++){
				if(i==j){ 
					if(select[i]==esel[j]){
						hit++;
					}
				}
				else if(select[i]==esel[j]){
					blow++;
				}
			}
		}
		System.out.println(hit+" "+blow);
	}
}

Measured memory_bytes: 18272
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;

  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  if(K >= 100){
    rep(i,N){
      if(i>0) cout << " ";
      cout << N;
    }
    cout << endl;
    return 0;
  }

  rep(i,K){
    vector<int> w(N+10, 0);
    rep(j,N){
      int d = v[j];
      int mn = max(0, j-d);
      int mx = min(N+5, j+d+1);
      w[mn]++;
      w[mx]--;
    }
    vector<int> ww(N+10, 0);
    int base = 0;
    rep(j,N){
      base += w[j];
      ww[j] = base;
    }
    rep(j,N){
      v[j] = ww[j];
    }
  }

  rep(i,v.size()){
    if(i>0) cout << " ";
    cout << v[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define fi first
#define sec second
#define pr priority_queue
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll d, t, s; cin >> d >> t >> s;
	ll v = (d % s == 0) ? d / s : d / s + 1;
	if (t >= v) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3648
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main(){
	ll n , k ;
	cin >> n >> k ;
	ll x = pow(k-1 , n-1);
	x*=k;
	cout << x << endl;
}



Measured memory_bytes: 3996
function Main(input) {
    var S = input.toString();
    var s1 = S.charAt(0);
    var s2 = S.charAt(1);
    var s3 = S.charAt(2);
    var s4 = S.charAt(3);

    if (s1 === s2) {
        if (s1 !== s3 && s3 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s3) {
        if (s1 !== s2 && s2 === s4) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else if (s1 === s4) {
        if (s1 !== s2 && s2 === s3) {
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else {
        console.log('No');
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

struct UnionFind{
  vector<int> d;
  UnionFind(int n){
    d.resize(n,-1);
  }
  int find(int x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return;
  }
  int size(int x){return -d[find(x)];}
};

int main(){
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  int ans = n-1;
  for(int i=0; i<m; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    if(uf.find(a) != uf.find(b)){
      --ans;
      uf.unite(a,b);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c=0;cin>>a>>b;
    if((double(a)+double(b))/2>(a+b)/2){
        std::cout << (a+b)/2+1 << std::endl;
    }
    else{
    std::cout << (a+b)/2 << std::endl;
}}


Measured memory_bytes: 3592
#include <stdio.h>

int main (void)
{
  int h , m;
  scanf("%d %d",&h,&m);
  
  char a[h][m];
  
  for(int i = 0;i < m+2;i++){
    printf("#");
  }
  putchar('\n');
  
  for(int i = 0;i < h;i ++){
  scanf("%s",&a[i]);
  printf("#");
  printf("%s",a[i]);
  printf("#\n");
  }
  
  for(int i = 0;i < m+2;i++){
    printf("#");
  }
  
  return 0;
}

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

int main() {
    string S; cin >> S;

    for(int i=0; i<S.size(); i++){
        if(i%2){
            if(S.at(i) == 'L' || S.at(i) == 'U' || S.at(i) == 'D') continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(S.at(i) == 'R' || S.at(i) == 'U' || S.at(i) == 'D') continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k,h[100000],dp[100000];
  
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  
  dp[0]=0;
  
  for(int i=1; i<n; i++){
    int tmp=INT_MAX;
    for(int j=1; j<=i && j<=k; j++){
      tmp = min( tmp, dp[i-j]+abs(h[i]-h[i-j]) );
    }
    dp[i] = tmp;
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1024
<?php
class main {
    function run () {
        fscanf(STDIN, "%d", $n);
        $d = 1000000007;
        $ans = 1;
        for ($i = $n; $i > 0;$i--) {
            $ans *= $i;
            if ($ans > $d) {
                $ans %= $d;
            }
        }
        echo $ans;
    }

}

$obj = new main();
$obj->run();

Measured memory_bytes: 3828
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define MAX 200

int top=0;
int a[MAX];

void push(int x){
  
  if(top >= MAX - 1){
    printf("overflow\n");
    exit(1);
  }

  top++;
  a[top] = x;
  
}

int pop(){

  if(top == 0){
    printf("overflow\n");
    exit(1);
  }

  top--;
  return a[top+1];
  
}

int main(){

  int a,b,x,n;
  char s[MAX];

  while(scanf(" %s",s) != EOF){

    if(s[0] == '+'){
      b=pop();
      a=pop();
      push(a+b);
    } else if(s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    } else if(s[0] == '*'){
      b=pop();
      a=pop();
      push(a*b);
    } else {
      x=atoi(s);
      push(x);
    }
    
  }//while

  n=pop();
  printf("%d\n",n);

  return 0;

}




Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

int numOfDigits(int n) {
    int cnt = 0;
    while (n != 0) {
        cnt += 1;
        n = n / 10;
    }
    return cnt;
}


int main() {
    int N;
    std::cin >> N;
    int cnt = 0;
    for (int i = 1; i <= N; ++i) {
        if (numOfDigits(i) % 2 == 1) {
            cnt += 1;
        };
    }
    std::cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
#define rep(i,n,m) for(int i=n;i<m;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define desc_sort(v) sort(v.rbegin(),v.rend())
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define M 1000000007 
#define pushll(head,d) push_into_linkedlist(&head,d)
#define popll(head) dp_delete_first(&head)
#define eol cout<<"\n"
// #define N 1000000
#define int long long
 
typedef long long ll;
 
 
ll zero=0,one=0,two=0;
string s;
vector<int> v;
int h,w;
void input()
{
	cin>>h>>w;
}

int countOdd(int L, int R){  
  
    int N = (R - L) / 2; 
  
    // if either R or L is odd  
    if (R % 2 != 0 || L % 2 != 0)  
        N += 1; 
  
    return N; 
}
void  solve()
{
    
    // int odds = countOdd(L, R);  
    // int evens = (R - L + 1) - odds;  
   if(h==1||w==1)
   {
       cout<<1;
       return;
   }
   int odd1=countOdd(1, h);
   int even1=h-odd1;
   int odd2=countOdd(1, w);
   int even2=w-odd2;
   cout<<odd1*odd2+even1*even2;
   
}
 
 
signed main()
{   
    ios
    int T=1;
    // cin>>T;
    while(T--)
    {
		input();
// 		for(int i=0;i<q;i++)
		solve();
// 		cout<<endl;
 
    }
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
W = [['', ''] for i in range(Q)]
for i in range(Q):
  t, d = input().split()
  W[i] = [t, d]
W.reverse()
cnt = 0
l = 0
r = 0
for t, d in W:
  if t == S[l] and d == 'L':
    l += 1
  elif l > 0 and t == S[l - 1] and d == 'R':
    l -= 1
  if t == S[N - 1 - r] and d == 'R':
    r += 1
  elif r > 0 and t == S[N - r] and d == 'L':
    r -= 1
  if l + r >= N:
    break
print(N - l - r)

Measured memory_bytes: 23732
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define Alint(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1ll << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, MAX = 1e18, INF = -1e9;
typedef long double ld;

lint N, arr[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	bool flag = false;
	REP(i, N) {
		cin >> arr[i];
		if (arr[i] == 0) {
			flag = true;
		}
	}
	if (flag) {
		cout << 0;
		return 0;
	}

	lint sum = 1;
	REP(i, N) {
		if (sum > (lint)1e18 / arr[i]) {
			cout << -1;
			return 0;
		}
		sum *= arr[i];
	}
	cout << sum;
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
//const int N=2e5+5;
bool visited[100005] = {false};
vector<int> graph[100005];
string tranform(string s){
	for(int i=0;i<s.length();i++) {  
    if(s[i]>=65 && s[i]<=92){
		s[i]=s[i]+32;
    }
}
return s;
}
signed main(){
	FAST
	string s,r,ans="";
	cin>>s>>r;
	int n=s.length(),m=r.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			dp[i][j]=0;
		}
	}
	//dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==r[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	int i=n,j=m;
	while(1){
		if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==r[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1]){
				i--;
			}
			else{
				j--;
			}
		}
		if(i==0 || j==0)break;
	}
	//cout<<ans<<endl;
	reverse(ans.begin(),ans.end());	
	cout<<ans;
}

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


int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; i++){cin >> t.at(i);}
  int c = 1;
  int count = 0;
  for (int i = 0; i < n; i++){
    if (t.at(i) == c){c++;}
  }
  if (c==1){cout << -1 << endl;}
  else{cout << n - c + 1 << endl;}
  }


Measured memory_bytes: 1024
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort(reverse=True)

if N % 2 == 0:
  k = N // 2
  print(A_list[0] + 2*sum(A_list[1:k]))
else:
  k = N // 2
  print(A_list[0] + 2*sum(A_list[1:k]) + A_list[k])

Measured memory_bytes: 31388
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC134
{
    class Program3
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var max1 = 0;
            var index1 = 0;
            var max2 = 0;
            var index2 = 0;
            for (int i = 0; i < N; i++)
            {
                var num = int.Parse(Console.ReadLine());
                if (num > max1)
                {
                    max1 = num;
                    index1 = i;
                }
                else if (num == max1 || num > max2)
                {
                    max2 = num;
                    index2 = i;
                }
            }

            for (int i = 0; i < N; i++)
                Console.WriteLine(i != index1 ? max1 : max2);
        }
    }
}


Measured memory_bytes: 16584
import java.util.*;

public class Main {

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

        boolean[]goods = new boolean[N];
        int[]H = new int[N];
        for (int i = 0;i < N; i++) {
            H[i] = sc.nextInt();
            goods[i] = true;
        }

        for (int i = 0;i < M; i++) {
            int A = sc.nextInt() - 1;
            int B = sc.nextInt() - 1;

            if (H[A] > H[B]) {
                goods[B] = false;
            } else if (H[B] > H[A]) {
                goods[A] = false;
            } else {
                goods[A] = false;
                goods[B] = false;
            }
        }

        int count = 0;
        for (int i = 0;i < N; i++) {
            if(goods[i]) {
                count++;
            }

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

Measured memory_bytes: 59444
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<vector<int>> G;
int V;
vector<int> color;

bool dfs(int v, int c) {
    color[v] = c;
    for(int i = 0; i < G[v].size(); i++) {
        if(color[G[v][i]] == c) {
            return false;
        } else if(color[G[v][i]] == 0 and !dfs(G[v][i], -c)) {
            return false;
        }
    }
    //すべての頂点をぬれたらtrue
    return true;
}

vector<vector<ll>> d;
int N;
void warshall_floyd() {
    for(int k = 0; k < N; k++) {
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if(d[i][k] + d[k][j] < d[i][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
}

int main() {
    cin >> N;
    vector<vector<char>> S(N, vector<char>(N));
    REP(i, N) {
        REP(j, N) { cin >> S[i][j]; }
    }
    // cout << "hoge" << endl;
    G.resize(N);
    d.resize(N);
    REP(i, N) { d[i].resize(N); }
    REP(i, N) {
        REP(j, N) {
            if(i == j) {
                d[i][j] = 0LL;
            } else {
                d[i][j] = INF;
            }
        }
    }

    REP(i, N) {
        REP(j, N) {
            if(S[i][j] == '1') {
                G[i].push_back(j);
                d[i][j] = 1LL;
            }
        }
    }
    color.resize(N);
    REP(i, N) { color[i] = 0; }
    // cout << "hoge" << endl;
    if(!dfs(0, 1)) {
        cout << -1 << endl;
        return 0;
    };
    warshall_floyd();
    ll m = 0LL;
    REP(i, N) {
        REP(j, N) { m = max(d[i][j], m); }
    }
    cout << m + 1 << endl;
    //二部グラフ判定をしてから
    // warshall_floyd
    return 0;
}

Measured memory_bytes: 768
a, b = map(int, input().split())
if (a <= 0) and (b >= 0):
    print("Zero")
elif (a < 0) and (b < 0):
    if (b - a + 1) % 2:
        print("Negative")
    else:
        print("Positive")
else:
    print("Positive")


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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

int main()
{
  int H, W, N;
  vector< pair< int, int > > g[200000];
  bool v[200000] = {};
  int64 cost[200000];

  scanf("%d %d", &H, &W);
  scanf("%d", &N);
  while(N--) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    --x, --y;
    g[x].emplace_back(H + y, z);
    g[H + y].emplace_back(x, z);
  }

  for(int i = 0; i < H + W; i++) {
    if(v[i]) continue;

    queue< int > que;
    int64 L = INF, R = INF;
    que.emplace(i);
    v[i] = true;
    cost[i] = 0;

    while(!que.empty()) {
      int idx = que.front();
      que.pop();
      if(idx < H) L = min(L, cost[idx]);
      else R = min(R, cost[idx]);
      for(auto& e : g[idx]) {
        if(v[e.first]++) {
          if(cost[idx] + cost[e.first] != e.second) {
            puts("No");
            return (0);
          }
        } else {
          que.emplace(e.first);
          cost[e.first] = e.second - cost[idx];
        }
      }
    }
    if(L + R < 0) {
      puts("No");
      return (0);
    }
  }

  puts("Yes");
}


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


def solve(a: int, b: int, c: int, d: int, e: int, k: int):
    print('Yay!' if e - a <= k else ':(')



# Generated by 1.1.7.1 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()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    e = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(a, b, c, d, e, k)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
N = int(input())
S = input()
s = S
l=0
r=0
tmp=0
flag = True
for i in range(N):
    #始めて(が出てくるインデックス
    if S[i]=="(":
        tmp=i
        r=1
        flag = False
        break
    else:
        l += 1
#tmp=N-1の場合は別でやる必要あり
"""
if tmp==(N-1):
    s = s+")"
"""
if not flag:
    for i in range(tmp+1,N):
        if S[i]=="(":
            r+=1
        else:
            if r>0:
                r-=1
            else:
                l+=1

if r>0:
    for _ in range(r):
        s = s + ")"

if l>0:
    for _ in range(l):
        s = "(" + s

print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define getsize(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



int main()
{
    ll N;
    string S;
    cin >> N >> S;
    ll r_cnt, g_cnt, b_cnt;
    r_cnt = count(all(S), 'R');
    g_cnt = count(all(S), 'G');
    b_cnt = count(all(S), 'B');
    ll cnt = r_cnt * g_cnt * b_cnt;

    ll sm = 0;
    rep(i, 0, N) {
        rep(j, i+1, N) {
            ll k = 2*j-i;
            if (k >= N) continue;
            if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) {
                ++sm;
            }
        }
    }
    cnt -= sm;
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

import heapq

def main():
    n = int(input())
    nodes = []
    for i in range(n):
        xi, yi = map(int, input().split())
        nodes.append((i, xi, yi))

    adj = [[] for i in range(n)]
    nodes.sort(key=(lambda x: x[1]))
    for j in range(n):
        i = nodes[j][0]
        if j - 1 >= 0:
            i1 = nodes[j - 1][0]
            adj[i].append(i1)
        if j + 1 < n:
            i1 = nodes[j + 1][0]
            adj[i].append(i1)
    nodes.sort(key=(lambda x: x[2]))
    for j in range(n):
        i = nodes[j][0]
        if j - 1 >= 0:
            i1 = nodes[j - 1][0]
            adj[i].append(i1)
        if j + 1 < n:
            i1 = nodes[j + 1][0]
            adj[i].append(i1)
    nodes.sort(key=(lambda x: x[0]))

    res = 0
    q = [(0, 0)]
    visited = [False for i in range(n)]
    while q:
        d, i = heapq.heappop(q)
        if visited[i]:
            continue
        visited[i] = True
        res += d
        for j in adj[i]:
            if visited[j]:
                continue
            heapq.heappush(q, (dist(i, j, nodes), j))
    print(res)

def dist(i, j, nodes):
    _, xi, yi = nodes[i]
    _, xj, yj = nodes[j]
    res = min(abs(xi - xj), abs(yi - yj))
    return res

if __name__ == "__main__":
    main()


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

int n, l[10], sum;

int main() {
    cin >> n;
    rep(i, n) cin >> l[i];
    sort(l, l + n);
    rep(i, n - 1) sum += l[i];
    string ans = "No";
    if (sum > l[n-1])  ans = "Yes";
    cout << ans << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    string s, t;
    cin >> s >> t;

    cout << t << s << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256