akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<pair<ll, int> > arr;
  map<ll, ll> amap;
  ll tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) arr.push_back(mp(tmp, i));
    amap[tmp]++;
  }
  priority_queue<tuple<ll, int, ll> > que;
  for(int i=0;i<arr.size();++i) {
    que.push(mt(arr[i].fi, arr[i].se, amap[arr[i].fi]));
  }
  ll ans[N];
  for(int i=0;i<N;++i) ans[i] = 0;
  tuple<ll, int, ll> state1, state2;
  while(!que.empty()) {
    if(que.size()==1) {
      state1 = que.top();que.pop();
      ans[get<1>(state1)] += get<2>(state1)*get<0>(state1);
    }
    else {
      state1 = que.top();que.pop();
      state2 = que.top();que.pop();
      ans[get<1>(state1)] += get<2>(state1)*(get<0>(state1)-get<0>(state2));
      if(get<1>(state1)>get<1>(state2)) {
        state1 = mt(get<0>(state2), get<1>(state2), get<2>(state1)+get<2>(state2));
      }
      else {
        state1 = mt(get<0>(state2), get<1>(state1), get<2>(state1)+get<2>(state2));
      }
      que.push(state1);
    }
  }
  for(int i=0;i<N;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 15776
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
int main()
{
	int X;
	std::cin >> X;
	if (X >= 30) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;

	}
	return 0;
}

Measured memory_bytes: 3632
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let s: String = read();
    let t: String = read();
    let str_s: &str = &s;
    let str_t: &str = &t;

    let mut ans = 0;
    for i in 0..3 {
      if str_s[i..i+1] == str_t[i..i+1] {
        ans += 1;
      }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
S = input()

BW = '01' * (10**6)
WB = '10' * (10**6)

ans = 0
if S[0] == '0':
    for i in range(len(S)):
        if S[i] != BW[i]:
            ans += 1
else:
    for i in range(len(S)):
        if S[i] != WB[i]:
            ans += 1
            
print(ans)

Measured memory_bytes: 7120
#include <bits/stdc++.h>
 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#define fi first
#define se second
#define pb push_back
#define last(s) (s)[(s).length()-1]
#define all(a) (a).begin(),(a).end()
#define elif else if
#define left asdasd
#define next zaza
#define prev azaz
#define cclear cout<<flush;
#define x0 kerker
#define y0 lolik
#define kchay ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
using namespace std;
 
using llong = long long;
using ld = long double;
using ii = pair<int,int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
 
const llong over999 = 1e12;
const llong md = 1e9+7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
 
/*watch the sunlight*/

//q - 0.25, h - 0.5, s - 1, d - 2

string s;
llong cnt[400];
llong ans;
int32_t main()
{
    kchay;
    
    cin >> s;
    
    llong n = s.length();
    
    ans = n*(n-1)/2;
    // cout << ans << endl;
    for(int i = 0; i < n; i++)
    {
        cnt[s[i]]++;
    }
    
    for(int i = 'a'; i <= 'z'; i++)
    {
        ans-=cnt[i]*(cnt[i]-1)/2;
    }
    
    cout << ans+1;
    

    return 0;
}

Measured memory_bytes: 720
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

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

ll D[100010];
ll cum_sum[100010];

int main()
{
	int N, M;
	cin >> N >> M;

	for (int i = 2; i <= N; i++) 
		cin >> D[i];

	cum_sum[1] = 0;
	for (int i = 2; i <= N; i++) 
		cum_sum[i] = cum_sum[i - 1] + D[i];

	ll pos = 1;
	ll ans = 0;
	for (int i = 0; i < M; i++) {
		ll A; cin >> A;
		if (A > 0) {
			ans +=  cum_sum[pos+A] - cum_sum[pos];
			ans %= 100000;
			pos += A;
		}
		else {
			ans += cum_sum[pos] - cum_sum[pos + A];
			ans %= 100000;
			pos += A;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4652
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt(scanner)
	y := getNextInt(scanner)

	fmt.Fprintln(writer, x+y/2)
	writer.Flush()
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) 
{
    int A,X,a = 0,b =10;
    scanf("%d %d",&X,&A);
    if(X < A){
        printf("%d",a);
    }
    else if(X >= A)
    {
        printf("%d",b);
    }
    return 0;
}

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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int N, _W;
int W[101], V[101];
ll dp[101][100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    for1(i, N) {
        for1(w, _W) {
            if(W[i] > w) dp[i][w] = dp[i-1][w];
            else dp[i][w] = max(dp[i-1][w], dp[i-1][w - W[i]] + V[i]);
        }
    }

    cout << dp[N][_W] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


Measured memory_bytes: 78336
// In the name of ALLAH

#include <stdio.h>

int main()
{
    
    int a, b;
    scanf ( "%d%d", &a, &b );
    
    if ( ( a == 1 && b == 2 ) || ( a == 2 && b == 1 ) ) printf ( "3" );
    if ( ( a == 2 && b == 3 ) || ( a == 3 && b == 2 ) ) printf ( "1" );
    if ( ( a == 1 && b == 3 ) || ( a == 3 && b == 1 ) ) printf ( "2" );


    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())

yp = []
for i in range(m):
    pi, yi = map(int, input().split())
    yp.append([yi, pi, i])

y_dict = {}
tmps = []
for i, ypi in enumerate(sorted(yp)):
    if ypi[1] in y_dict.keys():
        y_dict[ypi[1]] += 1
    else:
        y_dict[ypi[1]] = 1
    tmps.append([ypi[2], str(ypi[1]).zfill(6)+str(y_dict[ypi[1]]).zfill(6)])

for tmp in sorted(tmps):
    print(tmp[1])


Measured memory_bytes: 47900
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  int count=0;

  for(int i=1; i<=n; i++) {
    int t;
    cin >> t;
    if(t != i) count++;
  }

  cout << (count>2 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 888
def main():
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        ref = a * b - 1
        rng = int(ref ** 0.5) - 2
        while rng ** 2 < a * b:
            rng += 1
        rng -= 1
        if a == b or abs(a - b) == 1:
            print(2 * min(a, b) - 2)
        elif rng * (rng + 1) >= a * b:
            print(2 * rng - 2)
        else:
            print(2 * rng - 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 63544
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n = ni()
V = np.array(nl())
C = np.array(nl())
T = V - C
ans = 0
for t in T:
    if t > 0:
        ans += t
print(ans)


Measured memory_bytes: 27176
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=0;
  for(int i=0;i<n-1;i++)
  {
    if(a[i]==i+1)
    {
        int t=a[i];
        a[i]=a[i+1];
      	a[i+1]=t;
      	ans++;
    }
  }
  if(a[n-1]==n)ans++;
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n, d; cin>>n>>d;
    double x[n][d];
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin>>x[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double dist = 0;
            for(int k=0; k<d; k++){
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            dist = sqrt(dist);

            if(ceil(dist) == floor(dist)){
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const ll p=998244353;
ll fp(ll a,ll b)
{
	ll s=1;
	for(;b;b>>=1,a=a*a%p)
		if(b&1)
			s=s*a%p;
	return s;
}
ll fac[4010],ifac[4010];
int n,k;
void init()
{
	fac[0]=1;
	for(int i=1;i<=4000;i++)
		fac[i]=fac[i-1]*i%p;
	ifac[4000]=fp(fac[4000],p-2);
	for(int i=4000;i>=1;i--)
		ifac[i-1]=ifac[i]*i%p;
}
ll binom(int x,int y)
{
	return x>=y&&y>=0?fac[x]*ifac[y]%p*ifac[x-y]%p:0;
}
ll calc(int n,int k,int y)
{
	ll res=0;
	for(int i=0;i<=k;i++)
		res=(res+binom(y+n-1,y+i-1)*binom(k,i)%p*fp(2,i))%p;
	return res;
}
ll gao(int x)
{
	int l=max(1,x-k);
	int r=min(k,x-1);
	int s=k-(r-l+1);
	int z=r-l+1;
	if(!(z&1))
		return calc(n,z/2,s);
	else
		return (calc(n,z/2,s)+calc(n-1,z/2,s))%p;
}
int main()
{
	scanf("%d%d",&k,&n);
	init();
	for(int i=2;i<=2*k;i++)
		printf("%lld\n",gao(i));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B; 
  cin >> A >> B;

  cout << A*B << "\n";


  return 0;
}


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

#ifdef LOCAL
    #include "debug.h"
    #define input \
        freopen("input.txt", "r", stdin); \
        freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define input 4
#endif

const int mod = 1e9 + 7;
using ll = long long;
const int N = 2e5 + 5;



int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    for(int i = 0; i < s.size(); i++) {
        int cnt = 0;
        if(i + t.size() - 1 < s.size()) {
            for(int j = 0; j < t.size(); j++) {
                if(t[j] != s[i + j]) {
                    cnt++;
                }
            }
            ans = min(cnt, ans);
        }
    }
    cout << ans;

}






Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    int v[2][N / 2];
    for (int i = 0; i < N; i++) {
        cin >> v[i % 2][i / 2];
    }
    sort(v[0], v[0] + N / 2);
    sort(v[1], v[1] + N / 2);
    int num[2][2] = {{0, 0}, {0, 0}};
    int mark[2][2] = {{-1, -1}, {-1, -1}};
    for (int i = 0; i < 2; i++) {
        int tmp = 1;
        int now = v[i][0];
        for (int j = 1; j < N / 2; j++) {
            if (now == v[i][j]) {
                tmp++;
            } else {
                if (num[i][0] < tmp) {
                    num[i][1] = num[i][0];
                    mark[i][1] = mark[i][0];
                    num[i][0] = tmp;
                    mark[i][0] = now;
                } else if (num[i][1] < tmp) {
                    num[i][1] = tmp;
                    mark[i][1] = now;
                }
                tmp = 1;
                now = v[i][j];
            }
        }
        if (num[i][0] < tmp) {
            num[i][1] = num[i][0];
            mark[i][1] = mark[i][0];
            num[i][0] = tmp;
            mark[i][0] = now;
        } else if (num[i][1] < tmp) {
            num[i][1] = tmp;
            mark[i][1] = now;
        }
    }
    ll ans = N;
    if (mark[0][0] != mark[1][0]) {
        ans -= num[0][0] + num[1][0];
    } else {
        ll dif = max(num[0][0] + num[1][1], num[0][1] + num[1][0]);
        ans -= dif;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll power(ll x, ll y, ll p)
{ll res = 1;x = x % p;while (y > 0){if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
ll modInverse(ll n, ll p)
{return power(n, p-2, p);}
ll nCr(ll n, ll r, ll p)
{if (r==0) return 1;ll fac[n+1];fac[0] = 1;for(ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p;return (fac[n]*modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p;}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll i, j, k, n, m, t, p, temp, flag, x, y, z, count, a, b, c, d, sum, ans;
	cin >> n;
	ll arr[n];
	cin >> arr[0];
	ans=arr[0];
	for(i=1; i<n; i++)
	{
		cin>> arr[i];
		ans=ans^arr[i];
	}
	for(i=0; i<n; i++)
	{
		arr[i]=ans^arr[i];
		cout << arr[i] << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 5212
#include <stdio.h>

int main(){
	
	int a, b;
	scanf("%d %d", &a, &b);
	
	if(b%a == 0){
		printf("%d\n", a+b);
	}
	else if(a == b){
		printf("%d\n", a+b);
	}
	else if(b%a != 0){
		printf("%d\n", b-a);
	}
	
	
	return 0;
}

Measured memory_bytes: 1732
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	a := int64(getNextInt(scanner))
	b := int64(getNextInt(scanner))

	xx := make([]int64, n+1)
	var ans, walk int64
	for i := 1; i <= n; i++ {
		xx[i] = int64(getNextInt(scanner))
		if i == 1 {
			xx[0] = xx[i]
		}
		walk = (xx[i] - xx[i-1]) * a
		if b < walk {
			ans += b
			continue
		}
		ans += walk
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;



int main() {
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0;i < s.size();i++) {
		if (s.at(i) == 'o')ans += 100;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3600
import fractions

#入力
A,B,C,D = map(int,input().split())

l = C * D / fractions.gcd(C, D)
l = int(l)

#条件を満たすB以下の整数の個数
Bn = B -  (B//C + B//D - B//l) 

#条件を満たすA-1以下の整数の個数
An = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//l) 

print(Bn-An)


Measured memory_bytes: 5048
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d",__LINE__)
using namespace std;
int main()
{
	int n;
	cin >> n;
	if(n >= 400 && n <= 599) cout << 8;
	else if(n >= 600 && n <= 799) cout << 7;
	else if(n >= 800 && n <= 999) cout << 6;
	else if(n >= 1000 && n <= 1199) cout << 5;
	else if(n >= 1200 && n <= 1399) cout << 4;
	else if(n >= 1400 && n <= 1599) cout << 3;
	else if(n >= 1600 && n <= 1799) cout << 2;
	else cout << 1;
	return 0;
}


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

int main(){
  int w,a,b;
  cin >>w >>a >>b;
  if(a+w<b) cout << b-(a+w) << endl;
  else if (b+w<a) cout << a-(b+w) << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
int main() {
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A,B)<<" "<<max(A+B-N,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PA pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e16+7;
const ll MOD=1e9+7;

int main(){
	string s,t;
	cin >> s;
	if(s[0]==s[1]){
		cout << 1 << " " << 2 << endl;
		return 0; 
	}
	FOR(i,0,s.size()-2){
		t = s.substr(i,3);
		if(t[0]==t[1]||t[0]==t[2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    int ans = 0;

    while (input.ready())
    {
      String INPUT_STR = input.readLine();
      ans += getSeacretNumber(INPUT_STR);
    }
    System.out.println(ans);
  }

  private static int getSeacretNumber(String str)
  {
    char[] charArray = str.toCharArray();
    String numString = "";
    int ans = 0;

    for (char c : charArray)
    {
      if (isNumberChar(c))
      {
        numString += String.valueOf(c);
      }
      else
      {
        if (numString.length() > 0)
        {
          ans += Integer.valueOf(numString);
          numString = "";
        }
      }
    }
    if (numString.length() > 0)
    {
      ans += Integer.valueOf(numString);
    }
    return ans;
  }

  private static boolean isNumberChar(char c)
  {
    if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7'
        || c == '8' || c == '9')
    {
      return true;
    }
    return false;
  }
}

Measured memory_bytes: 24172
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n,m,h[100005],a[100005],b[100005],ct=0;
    bool ans[100005];
    cin >> n >> m;
    rep(i,1,n){
    	ans[i]=true;
    }
    rep(i,1,n){
    	cin >> h[i];
    }
    rep(i,1,m){
    	cin >> a[i] >> b[i];
    	if(h[a[i]]>=h[b[i]]) ans[b[i]]=false;
    	if(h[a[i]]<=h[b[i]]) ans[a[i]]=false;
    }
    rep(i,1,n){
    	if(ans[i]) ct++;
    }
    cout << ct << endl;
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

//-----------------------------------------------------------------------------

char x,y;

int f(char x) {
	switch (x) {
		case 'A': return 10;
		case 'B': return 11;
		case 'C': return 12;
		case 'D': return 13;
		case 'E': return 14;
		case 'F': return 15;
	}
}

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

	cin>>x>>y;
	int xx=f(x),yy=f(y);
	if(xx<yy) cout<<'<'<<endl;
	else if(xx>yy) cout<<'>'<<endl;
	else cout<<'='<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;


int a[maxN];
int b[maxN];
int c[maxN];

int main() {
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		for(int j= i+1;j<=n;j++)
		{
			ans += a[i]*a[j];
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
function char(s, n)
  return string.sub(s, n, n)
end

n=io.read("*n")
io.read()
s=io.read("*l")

if n%2~=0 then
  print("No")
  os.exit(0)
end

p1={}
for i=1,math.floor(n/2) do
  table.insert(p1, char(s, i))
end

c=1
for i=math.floor(n/2)+1,n do
  if p1[c]~=char(s,i) then
    print("No")
    os.exit(0)
  end
  c=c+1
end

print("Yes")

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

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

    ll n;
    cin >> n;

    ll a[3*n];
    rep(i, 3*n){
        cin >> a[i];
    }

    sort(a, a+3*n);

    ll sum = 0;
    for(int i = n; i < 3*n; i += 2){
        sum += a[i];
    }

    ppp(sum);


    return 0;
}


Measured memory_bytes: 2560
// ABC 153-F
// 2020.1.26 bal4u

#include <stdio.h>
#include <string.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

// セグメント木
#define MAXN (1<<18)      // セグメント木のサイズ。2のべき乗にすべし

int size;
ll segVal[2 * MAXN];
ll segLazy[2 * MAXN];

void segInit(int n)
{
	size = 1; while (size < n) size <<= 1;
//	memset(segVal, 0, sizeof(segVal));
//  memset(segLazy, 0, sizeof(segLazy));
}

void lazy(int k, int width)
{
	int k2 = k << 1;
	if (k2 < (size << 1) - 2) {
		segLazy[k2 + 1] += segLazy[k];
		segLazy[k2 + 2] += segLazy[k];
	}
	segVal[k] += segLazy[k] * width;
	segLazy[k] = 0;
}

ll add(int a, int b, ll x, int k, int l, int r)
{
	ll ans;

	lazy(k, r - l);
	if (r <= a || b <= l) return segVal[k] + segLazy[k] * (r - l);
	if (a <= l && r <= b) {
		segLazy[k] += x;
		return segVal[k] + segLazy[k] * (r - l);
	}
	lazy(k, r - l);
	ans = add(a, b, x, (k << 1) + 1, l, (l + r) >> 1);
	ans += add(a, b, x, (k << 1) + 2, (l + r) >> 1, r);
	return segVal[k] = ans;
}

ll getSum(int a, int b, int k, int l, int r)
{
	ll ans;

	lazy(k, r - l);
	if (r <= a || b <= l) return 0;
	if (a <= l && r <= b) return segVal[k];
	ans = getSum(a, b, (k << 1) + 1, l, (l + r) >> 1);
	ans += getSum(a, b, (k << 1) + 2, (l + r) >> 1, r);
	return ans;
}

typedef struct { int X, H; } T;
T a[200005]; int N;

void Qsort(T *a, int l, int r) {
	int i, j, m; T t;
	
	i = l, j = r, m = a[(l+r) >> 1].X;
	while (1) {
        // 昇順
		while (a[i].X < m) i++;
		while (m < a[j].X) j--;

		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

// 見つからなければ、一つ小さい要素を返す
int bs(int x) {
	int m, l = 0, r = N;

    while (l < r) {
        m = (l+r) >> 1;
        if (a[m].X <= x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int i, A, D;
	ll ans;
	
	N = in(), D = in(), A = in();
	for (i = 0; i < N; ++i) a[i].X = in(), a[i].H = in();
	Qsort(a, 0, N-1);
	
	segInit(N);
	for (i = 0; i < N; ++i) add(i, i+1, a[i].H, 0, 0, N);
	if ((ll)D*2 > a[N-1].X) D = a[N-1].X; else D *= 2;
	
	ans = 0;
	for (i = 0; i < N; ++i) {
		ll h = getSum(i, i+1, 0, 0, N);
		if (h > 0) {
			ll t = (h-1)/A + 1;
			ans += t;
			int j = bs(a[i].X + D);
			add(i, j+1, -t*A, 0, 0, N);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9984
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    int zero=0,one=0,two=0;
    for (i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if (x%4==0) two++;
        else if (x%2==0) one++;
        else zero++;
    }
    if ((one==0)&&(zero<=two+1))
    {
        puts("Yes");
    }
    else if (zero<=two)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
} 


Measured memory_bytes: 256
# Aizu Problem 0053: Sum of Prime Numbers
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(110000)
S = []
s = 0
for p in primes:
    s += p
    S.append(s)

while True:
    n = int(input())
    if n == 0:
        break
    print(S[n-1])

Measured memory_bytes: 8352
#include <iostream>
#include <cmath>
#include <cstring>
#include <limits>

const int nax = 1e5+5;
int dp[nax];

int main() {

	std::ios_base::sync_with_stdio(false);

	int N, K;
	std::cin >> N >> K;

	int arr[N];
	for (int i=0; i<N; i++) {
		std::cin >> arr[i];
	}

	// set default values
	std::fill(dp, dp+N, std::numeric_limits<int>::max());
	dp[0] = 0;

	for (int i=0; i<N; ++i) {
		for (int j=0; j<=K; ++j) {
			if (i-j>=0) dp[i] = std::min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j])); 
		}
	}

	std::cout << dp[N-1];

	return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
string sd, t, s;
char c;
bool ck;
void check(int n){
    string nt = t;
    bool ng = false;
    for(int i = 0; i < t.size(); i++){
        if(s.at(n + i) == t.at(i) || s.at(n + i) == '?'){//それぞれの文字に付いて当てはめられるか確認
            nt.at(i) = t.at(i);
        }
        else{
            ng = true;
            break;
        }
    }
    if(!ng){//もし当てはめることができるなら
        ck = true;
        for(int i = 0; i < t.size(); i++){
            sd.at(i + n) = nt.at(i);//sdを当てはめたように書き換える
        }
    }
}
void solve(){
    s = sd;
    c = t.at(0);//スタートの文字
    for(int i = 0; i < sd.size(); i++){
        if(ck){//すでに指定語句を支えているなら
            if(sd.at(i) == '?'){//?はできるだけ早いaで埋める
                s.at(i) = 'a';
            }
            else{
                s.at(i) = sd.at(i);//もともと決まっているのはそのまま
            }
        }
        else {
            if(!ck && (sd.at(i) == c || sd.at(i) == '?') && i < sd.size() - t.size() + 1){//確認の余地があるなら確認する
            check(i);
            }
            if(sd.at(i) == '?'){
                s.at(i) = 'a';
            }
            else{
                s.at(i) = sd.at(i);
            }
        }
    }
    if(!ck){
        cout << "UNRESTORABLE" << endl;
    }
    else{
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}
int main(){
    cin >> sd >> t;
    reverse(sd.begin(), sd.end());
    reverse(t.begin(), t.end());
    ck = false;
    solve();
    return 0;
}



Measured memory_bytes: 256
S = input()

divide_count = 0
previous_s = S[0]
current_s = ''
result = [S[0]]
s_len = len(S)

for i in range(1, s_len):
    current_s += S[i]
    if previous_s == current_s:
        continue
    else:
        result.append(current_s)
        previous_s = current_s
        current_s = ''  
print(len(result))

Measured memory_bytes: 8064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		outer: while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			double[] x = new double[n + m];
			double[] y = new double[n + m];
			for (int i = 0; i < n + m; ++i) {
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}

			for (int i = 0; i < n; ++i) {
				for (int j = n; j < n + m; ++j) {
					/*
					 * y-y1=(y2-y1)/(x2-x1)(x-x1) (y-y1)(x2-x1)=(x-x1)(y2-y1)
					 * 0=(y2-y1)*x-(x2-x1)*y+y1(x2-x1)-x1(y2-y1)
					 */

					double a = y[j] - y[i];
					double b = -(x[j] - x[i]);
					double c = -x[i] * (y[j] - y[i]) + y[i] * (x[j] - x[i]);

					/*
					 * ax+by+c=0;
					 */

					ArrayList<Integer> positive = new ArrayList<>();
					ArrayList<Integer> negative = new ArrayList<>();
					ArrayList<Integer> zero = new ArrayList<>();
					zero.add(i);
					zero.add(j);
					for (int k = 0; k < n; ++k) {
						if (k == i)
							continue;
						double sign1 = Math.signum(a * x[k] + b * y[k] + c);
						if (sign1 > 0)
							positive.add(k);
						else if (sign1 == 0)
							zero.add(k);
						else if (sign1 < 0)
							negative.add(k);

					}
					for (int k = n; k < n + m; ++k) {
						if (k == j)
							continue;
						double sign2 = Math.signum(a * x[k] + b * y[k] + c);
						if (sign2 > 0)
							positive.add(k);
						else if (sign2 == 0)
							zero.add(k);
						else if (sign2 < 0)
							negative.add(k);
					}

					if (positive.size() > 0 && positive.get(0) < n && positive.get(positive.size() - 1) >= n) {
						continue;
					}
					if (negative.size() > 0 && negative.get(0) < n && negative.get(negative.size() - 1) >= n) {
						continue;
					}
					if (zero.size() > 0) {
						class cor implements Comparable<cor> {
							double x;
							double y;

							public cor(double x, double y) {
								this.x = x;
								this.y = y;
							}

							public int compareTo(cor o) {
								if (x != o.x)
									return Double.compare(x, o.x);
								else
									return Double.compare(y, o.y);
							};
						}
						ArrayList<cor> lis1 = new ArrayList<>();
						ArrayList<cor> lis2 = new ArrayList<>();
						for (int k : zero) {
							if (k < n) {
								lis1.add(new cor(x[k], y[k]));
							} else {
								lis2.add(new cor(x[k], y[k]));
							}
						}
						Collections.sort(lis1);
						Collections.sort(lis2);
						if (lis1.get(0).compareTo(lis2.get(lis2.size() - 1)) != lis1.get(lis1.size() - 1)
								.compareTo(lis2.get(0))) {
							continue;
						}
					}
					System.out.println("YES");
					continue outer;
				}

			}
			System.out.println("NO");
		}
	}
}

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

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()

#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((b-a) & 1) {
        cout << "Borys\n";
    } else {
        cout << "Alice\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,a[100000],b,c,e;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    b=a[n-1];
    e=a[n-1]-a[0];
    for(int i=0;i<n;i++){
        int d=a[i];
        if(d>b/2){
            d=b-d;
        }
        d = b/2-d;
        if(d<e){
            e=d;
            c=a[i];
        }
    }
    cout<<b<<" "<<c<<endl;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<long long, long long> counter(vector<long long> a){
    map<long long, long long> freq;
    for (auto i : a){
        freq[i]+=1;
    }
    return freq;
}

int main(){
    long long n, k, q; cin >>n>>k>>q;
    vector<long long> answers(q); for(long long i=0;i<q;i++){cin>>answers[i];}

    auto answer_freq = counter(answers);

    long long border = (q - k) + 1;
    for (long long i=1;i<n+1;i++){
        if (answer_freq[i] >= border){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll n;
    cin>>n;
    string str;
    cin>>str;
    stack<char> st;
    fr(i,0,n)
    {
        if(st.empty())
        {
            st.push(str[i]);
        }
        else
        {
            if(str[i]=='(')
            {
                st.push(str[i]);
            }
            else
            {
                if(st.top()=='(')
                    st.pop();
                else
                    st.push(str[i]);
            }
        }
    }
    ll a=0,b=0;
    while(!st.empty())
    {
        if(st.top()=='(')
            a++;
        else
            b++;
        st.pop();
    }
    string b1(b,'(');
    string b2(a,')');
    string ans=b1+str+b2;
    cout<<ans<<endl;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static long factMax = 200000;//nCkにおけるnの最大値
static long[] factorials = new long[factMax+1];//i!(mod p)をO(n)で先にメモ。
static long[] factorialRs = new long[factMax+1];//i!^-1(mod p), pは素数でO(n)。

	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');
    long n = long.Parse(input[0]);
    long m = long.Parse(input[1]);
    long p = 1000000007;
  
    factorials[0] = 1;
    factorialRs[factMax] = DivideModFactorial(factMax,p);
    for(long i = 1; i <= factMax; i++)
    {
      factorials[i] = (factorials[i-1]*i)%p;//i!(mod p)
      factorialRs[factMax-i] = (factorialRs[factMax+1-i]*(factMax+1-i))%p;//逆元も先にメモ
    }

    long answer = BallBoxDistinction(n,m,p);
    answer *= factorialRs[m];
    answer %= p;
    
    Console.WriteLine(answer);
	}

  static long BallBoxDistinction(long n, long m, long mod)
  {//区別するn個の玉をm個の箱に少なくとも1個入れる方法の個数(mod)をO(mlogn)で返す。
  //求める方法は、m^n通りから、(一番左の箱に1個もいれない)または…で包除原理。
    long answer = DivideMod(m,n,mod);

    for(int i = 1; i <= m; i++)
    {
      if(i % 2 == 1)
      {
        answer -= Comb(m,i,mod)*DivideMod(m-i,n,mod);
      }else
      {
        answer += Comb(m,i,mod)*DivideMod(m-i,n,mod);
      }
      answer %= mod;
      if(answer < 0) answer += mod;
    }

    return answer;
  }

  static long MathPow(long x, long a)//戻り値はx^a。O(loga)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x;
  
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
      }
    memo *= memo;
    num *= 2;
    }
    return answer;
  }

  static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p)。O(loga)
  {
    long num = 2;
    long answer = 1;
    long check = a;
    long memo = x%p;
    
    while(check > 0)
    {
      if(check % num == num / 2)
      {
        check -= num / 2;
        answer *= memo;
        answer %= p;
      }
    memo *= memo;
    memo %= p;
    num *= 2;
    }
    return answer;
  }

  static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数。O(logp)
  {
    long answer = DivideMod(x, p-2, p);
    return answer;
  }

  static long ModFactorial(long x, long p)//戻り値はx!(mod p)
  {
    long answer = 1;
    for(int i = 2; i <= x; i++)
    {
      answer *= i;
      answer %= p;
    }
    return answer;
  }

  static long DivideModFactorial(long x, long p)//戻り値はx!^-1(mod p), pは素数
  {
    long answer = 1;
    for(long i = x; i >= 2; i--)
    {
      answer *= DivideModReverse(i, p);
      answer %= p;
    }
    return answer;
  }

  static long Comb(long a, long b, long p)//組み合わせC(a,b)(mod p)をO(1)で返す
  {
    if(a-b < 0) return 0;//引数a-bが負なら0を返す
    long answer = 1;
    answer *= factorials[a];
    answer %= p;
    answer *= factorialRs[a-b];
    answer %= p;
    answer *= factorialRs[b];
    answer %= p;
    return answer;
  }
  
}



Measured memory_bytes: 21160