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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int mpow(int x, int y) {
	int res = 1;
	while(y>0) {
		if(y&1) {
			res = (res*x)%MOD;
		}
		x = (x*x)%MOD;
		y/=2;
	}
	return res;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	int ans = 0;
	int x;
	int sq = 0;
	while(n--) {
		cin>>x;
		ans+=x;
		ans%=MOD;
		sq = (sq+(x*x)%MOD)%MOD;
	}	
	ans= (ans*ans+MOD-sq)%MOD;
	cout<<(ans*mpow(2,MOD-2))%MOD;

	return 0;
}

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

const int MAX = 2e5;
int c[MAX], x[MAX], y[MAX], cnt[MAX];

int main()
{
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d", c + i, x + i);
		y[i] = x[i];
	}
	sort(y, y + q);
	int var = unique(y, y + q) - y;
	for (int i = 0; i < q; i++) {
		x[i] = lower_bound(y, y + var, x[i]) - y;
	}
	int size = 0;
	for (int i = 0; i < q; i++) {
		if (c[i] == 0) {
			if (!cnt[x[i]]) {
				cnt[x[i]] = 1;
				++size;
			}
			printf("%d\n", size);
		}
		else if (c[i] == 1) {
			puts(cnt[x[i]] ? "1" : "0");
		}
		else if (cnt[x[i]]) {
			cnt[x[i]] = 0;
			--size;
		}
	}
	return 0;
}



Measured memory_bytes: 6196
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, w;
		int arrow[];
		int kk[];
		boolean flag;
		int max;

		while (true) {
			n = sc.nextInt();
			w = sc.nextInt();
			if ((n | w) == 0) {
				break;
			}
			arrow = new int[n + 1];
			kk = new int[(n + 1) * (n + 1)];
			max = 0;

			arrow[0] = 0;
			for (int i = 1; i <= n; i++) {
				arrow[i] = sc.nextInt();
			}

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					kk[i * (n + 1) + j] = arrow[i] + arrow[j];
				}
			}

			Arrays.sort(kk);
			int index = 0;
			for (int i = 0; i < kk.length - 1; i++) {
				if (kk[i] != kk[i + 1]) {
					kk[index++] = kk[i];
				}
			}
			kk[index++] = kk[kk.length - 1];

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					int k = search(kk, 0, index - 1, arrow[i] + arrow[j], w);
					if (max < k) {
						max = k;
					}
				}
			}
			System.out.println(max);
		}
	}

	public static int search(int kk[], int low, int high, int k1k2, int w) {
		if (high < low) {
			if (k1k2 <= w) {
				return k1k2;
			} else {
				return 0;
			}
		}

		int mid = (low + high) / 2;
		int max = 0;

		if (w < k1k2 + kk[mid]) {
			int k = search(kk, low, mid - 1, k1k2, w); 
			return k;
		} else if (w == k1k2 + kk[mid]) {
			return w;
		} else if (k1k2 + kk[mid] < w) {
			max = k1k2 + kk[mid];
			int k = search(kk, mid + 1, high, k1k2, w);
			if (max < k) {
				max = k;
			}
		}
		return max;
	}
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll N, M;
    cin >> N >> M;
    if (N == M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t; 
  return a;
}

int main(void) {
  ll i, j, k, n, ans = 1e10;
  scanf("%lld", &n);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  sort(a, a + n);
  for(i = 1; i < n; ++i) if(gcd(a[0], a[i]) < ans) ans = gcd(a[0], a[i]);
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 896
/*
  AUTHOR:SOURABH
  CREATED:27:08:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

vll a(200001),si(200001);

void initalize(ll n)
{
    ll i;
    fs(i,1,n+1)
    {a[i]=i;si[i]=1;}
}
ll root(ll i)
{
    W(a[i]!=i)
    {
        a[i]=a[a[i]];
        i=a[i];
    }
    return i;
}
bool find(ll x,ll y)
{
    if(root(x)==root(y))
        return true;
    else
        return false;
}
void U(ll x,ll y)
{
    ll root_x=root(x);
    ll root_y=root(y);
    if(si[root_x]>si[root_y])
    {
        a[root_y]=a[root_x];
        si[root_x]+=si[root_y];
        si[root_y]=0;
    }
    else
    {
        a[root_x]=a[root_y];
        si[root_y]+=si[root_x];
        si[root_x]=0;
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,m,i,u,v,ans=0;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>m;
        initalize(n);
        fn(i,m)
        {
            cin>>u>>v;
            if(!find(u,v))
                U(u,v);
        }
        fs(i,1,n+1)
        ans=max(ans,si[i]);
        cout<<ans;
    }
    return 0;
}






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

int main(){
    int n;
    cin>>n;
    vector<int> dp(3,0);
    for(int i=0;i<n;++i){
        vector<int> A(3),dp_new(3,0);
        cin>>A[0]>>A[1]>>A[2];
        for(int j=0; j<3; ++j){
            for(int k=0; k<3; ++k){
                if(k!=j){
                    dp_new[k]=max(dp_new[k], dp[j]+A[k]);
                }
            }
        }
        dp=dp_new; 
    }
    cout<<*max_element(dp.begin(),dp.end())<<"\n";
}

Measured memory_bytes: 256
// code written by kshitij_coder
#include<bits/stdc++.h>
using namespace std;
 
#define ll int64_t
#define pii pair<ll,ll>
#define psi pair<string,ll> 
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pb push_back
#define lim 100000
#define f(k) k.first
#define s(k) k.second
#define bcnt __builtin_popcount
#define endl "\n"
#define PI 3.1415926535

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const{ 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

ll power(ll a,ll b){ ll ans = 1; ll k = a;while(b > 0){ if(b & 1){ ans *= k; ans %= MOD; } k = (k*k)%MOD; b = b >> 1;} return ans;}

// ll ncr(ll n,ll r,ll*arr){
//     if(r==0) return 1;
//     ll res = 1;
//     return (arr[n]*(power(arr[n-r],MOD-2))%MOD*(power(arr[r],MOD-2))%MOD)%MOD;
// }

ll gcd(ll a,ll b){ if(a == 0) return b; if(b == 0) return a; return gcd(b,a%b); }
ll add_mod(ll a,ll b,ll m){return ((a%m) + (b%m))%m;}
ll sub_mod(ll a,ll b,ll m){return ((a%m) - (b%m) + m)%m;}
ll mul_mod(ll a,ll b,ll m){return ((a%m)*(b%m))%m;}
void print(double val,int k){ cout<<fixed<<setprecision(k)<<val<<endl;}
ll toint(string s) {stringstream ss; ss << s; ll x; ss >> x; return x;}

void solve(){
    int n,k;
    cin >> n >> k;
    
    int *arr = new int[n+1];
    for(int i = 1;i <= n;i++) cin >> arr[i];
    
    int *score = new int[n+1];
    score[1] = 0;
    score[2] = abs(arr[2] - arr[1]);
    
    for(int i = 3;i<=n;i++){
        int mini = INT_MAX;
        for(int j = i-1; j >= 1 and (i - j) <= k;j--){
            int d = score[j] + abs(arr[i] - arr[j]);
            mini = min(mini,d);
        }
        
        score[i] = mini;
    }
    
    cout<<score[n]<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
    return 0;
}

Measured memory_bytes: 4368
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        xs: [isize; m],
    };

    let mut xs = xs;
    xs.sort();

    let mut dxs = xs.iter().zip(&xs[1..]).map(|(x1, x2)| x2 - x1).collect::<Vec<_>>();
    dxs.sort_by(|a, b| b.cmp(a));

    let len_one = xs[m - 1] as isize - xs[0] as isize;

    println!("{}", len_one - dxs.iter().take(n - 1).sum::<isize>());
}


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


string s;


int main() {
	cin >> s;

	bool ok = false;
	for (int i = 0; i < s.length() - 1; i++) {
		if ((s[i] == 'A' && s[i + 1] == 'B') || (s[i] == 'B' && s[i + 1] == 'A')) {
			ok = true;
		}
	}

	if (ok) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
// A B C D H F E I G K L M N P S O Q R J U Z Y X T V W
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pq priority_queue<int> 
#define pqs priority_queue<int,vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)  // no of ones in setbit
#define zrobits(x) __builtin_ctzll(x)       //101000 here 3..no of 0 aftrer 1sr right one 
#define mod 1000000007
#define inf 1e18
#define ps(x,y)  fixed<<setprecision(y)<<x  // ans upto 5 decimal place 
#define mk(ar,n,type) type *arr=new type[n];
#define w(x) int x;cin>>x;while(x--)
int arr[100001][4] ; 
int dp[100001][4]; 
 

 
int32_t main()
{
	int n, k ; 
	cin>>n  ; 
	 
 
	for(int i=0 ; i<n ; i++)
	{
		for(int j=0 ; j<3; j++)
		{
			cin>>arr[i][j] ; 

		}
	}


	dp[0][0]=arr[0][0]; 
	dp[0][1]=arr[0][1]; 
	dp[0][2]=arr[0][2] ; 

	for(int i=1 ; i<n; i++)
	{
		for(int j=0 ; j<3; j++)
		{

			int a=dp[i-1][(j+3-1)%3]; 
			int b=dp[i-1][(j+3+1)%3] ; 
			int z=max(a, b); 
			dp[i][j]=arr[i][j]+z; 

		}
	}

	// for(int i=0 ; i<n; i++)
	// {
	// 	for(int j=0 ; j<3; j++)
	// 	{

	// 		cout<<dp[i][j]<<" "; 
	// 	}
	// 	cout<<endl ; 
	// }
	int ans=max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) ; 
	cout<<ans ; 
	
 
}

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

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

using namespace std;
using namespace __gnu_pbds;

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

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

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

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=1000005;

void solve()
{
    
    int n,a,b;
    cin>>n>>a>>b;
    int ans=power(2,n,hell)-1;
    int pr=1;
    for(int i=1;i<=a;i++)
        pr=(pr*i)%hell;
    pr=power(pr,hell-2,hell);
    for(int i=0;i<a;i++)
        pr=(pr*(n-i))%hell;
    ans=(ans-pr+hell)%hell;
    a=b;
    pr=1;
    for(int i=1;i<=a;i++)
        pr=(pr*i)%hell;
    pr=power(pr,hell-2,hell);
    for(int i=0;i<a;i++)
        pr=(pr*(n-i))%hell;
    ans=(ans-pr+hell)%hell;
    cout<<ans<<endl;
    
}

int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main()
{
    int n, v[100];
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v, v + n);
    float numar = v[0] * 1.0;
    for (int i = 1; i < n; i++)
    {
        numar = (numar + v[i] * 1.0) / 2.0;
    }
    cout << numar;
    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,n,k,ans;
int main()
{
	int minn=100001;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a);
	}
	k--;
	ans=(n-1)/k;
	if ((n-1)%k!=0) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars
t = gets.chomp.chars
ans = 0
(1+s.size-t.size).times do |num|
  cnt = 0
  t.each_with_index do |i, index|
    if i == s[index + num]
      cnt +=1
    end
  end
  ans = cnt if ans < cnt
end

puts t.size - ans

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;

	cin >> N;
	cerr << endl;

	llong sum = 0;
	for(int i = 1; i <= N; i++){
		sum += i;
		if(sum >= N){
			int no = sum - N;
			for(int j = 1; j <= i; j++)
				if(j != no)
					cout << j << endl;
			break;
		}
	}

	return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int d=0;
  for(int i=0;i<B+1;i++){
    if(A*i%B==C)
      d=1;
  }
  if(d==1){
    cout << "YES" << endl;
  }
else
  cout << "NO" << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    par = [i for i in range(N)]
    rank = [1 for i in range(N)]

    def find_root(x):
        if par[x] == x:
            return x
        else:
            par[x] = find_root(par[x])
            return par[x]

    def is_same_group(x, y):
        return find_root(x) == find_root(y)

    def unite(x, y):
        x = find_root(x)
        y = find_root(y)
        if x == y:
            return
        if rank[x] < rank[y]:
            x, y = y, x
        rank[x] += rank[y]
        par[y] = x

    def size(x):
        return rank[find_root(x)]

    for i in range(M):
        a, b, _ = (int(i)-1 for i in input().split())
        unite(a, b)
    ans = set()
    for i in range(N):
        ans.add(find_root(i))
    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65972
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.valueOf(sc.next());
    int M = Integer.valueOf(sc.next());
    int[] array = new int[N];

    int p;
    String S;
    int ans = 0;
    int pena = 0;
    for (int i = 0; i < M; i++) {
      p = Integer.valueOf(sc.next());
      S = sc.next();
      if (array[p-1] != -1) {
        if (S.equals("WA")) {
          array[p-1]++;
        } else {
          ans++;
          pena += array[p-1];
          array[p-1] = -1;
        }
      }
    }

    System.out.println(ans + " " + pena);
  }
}

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

int main() 
{
  string s;
  cin >> s;
  bool tap = true;
  for (int i = 0; i < s.size(); i += 2){
    if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
      tap = false;
      break;
    }
  }

  for (int i = 1; i < s.size(); i += 2){
    if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
      tap = false;
      break;
    }
  }
  if (tap == true) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  int Po=1;
  int Qo=1;
  for(int i=0; i<N; i++) cin >> P.at(i);
  for(int i=0; i<N; i++) cin >> Q.at(i);
  vector<int> R = {1,2,3,4,5,6,7,8};
  vector<int> S = {1,2,3,4,5,6,7,8};
  for(int i=0; i<N; i++){
    R.at(P.at(i)-1)=0;
    int cnt=0;
    for(int j=0; j<P.at(i); j++){
      if(R.at(j)!=0) cnt++;
    }
    int temp=1;
    for(int j=1; j<N-i; j++) temp*=j;
    Po+=cnt*temp;
    
  }
  for(int i=0; i<N; i++){
    S.at(Q.at(i)-1)=0;
    int cnt=0;
    for(int j=0; j<Q.at(i); j++){
      if(S.at(j)!=0) cnt++;
    }
    int temp=1;
    for(int j=1; j<N-i; j++) temp*=j;
    Qo+=cnt*temp;
  }
  int ans = abs(Po-Qo);
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DFennecVSSnuke {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, a, b;
        in >> n;
        vector<int> g[100010];
        rep(i, n-1){
            in >> a >> b;
            a--; b--;
            g[a].push_back(b);
            g[b].push_back(a);
        }

        vector<int> fennec(n, 1e6);

        queue<int> q;
        q.push(0);
        fennec[0] = 0;
        while(!q.empty()){
            int u = q.front(); q.pop();
            for(auto const& e : g[u]){
                if(fennec[e] != 1e6 || e == n-1) continue;
                fennec[e] = fennec[u] + 1;
                q.push(e);
            }
        }

        q.push(n-1);
        vector<int> snuke(n, 1e6);
        snuke[n-1] = 0;
        while(!q.empty()){
            int u = q.front(); q.pop();
            for(auto const& e : g[u]){
                if(snuke[e] != 1e6 || e == 0) continue;
                snuke[e] = snuke[u] + 1;
                q.push(e);
            }
        }

        int res = 0;
        rep(i, n){
            if(fennec[i] <= snuke[i]) res++;
        }

//        vdeb(fennec);
//        vdeb(snuke);

        if(res > n/2) out << "Fennec" << endl;
        else out << "Snuke" << endl;
	}
};


int main() {
	DFennecVSSnuke solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6656
/*input
2 1 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int n;
vector<int> ans;
int idx[maxn];

bool f(int t){
	bool ret=0;
	while(t){
		if(t&1) ret=!ret;
		t>>=1;
	}
	return ret;
}

void dfs(int s,int t,int *mask,int l,int r){
	if(l==r-2){
		ans[l]=s;
		ans[l+1]=t;
		return;
	}
	int sz=0;
	REP(i,n){
		if(!mask[i]){
			idx[sz]=i;
			sz++;
		}
	}
	int OAO=0;
	REP(i,n) if(!mask[i]){
		if((s&(1<<i))!=(t&(1<<i))){
			OAO=i;
			break;
		}
	}
	int mid=(l+r)/2;
	vector<int> ret;
	REP(i,1<<sz){
		int cur=s;
		REP(j,sz){
			if(i&(1<<j)) cur|=(1<<idx[j]);
			else{
				if(cur&(1<<idx[j])) cur^=(1<<idx[j]);
			}
		}

		if((s&(1<<OAO))!=(cur&(1<<OAO))) cur^=(1<<OAO);

		if( f(cur)!=f(s) && cur!=s && (t!=(cur^(1<<OAO))) ){
			mask[OAO]=1;
			dfs(s,cur,mask,l,mid);
			dfs(cur^(1<<OAO),t,mask,mid,r);
			mask[OAO]=0;
			break;
		}
	}
}

int main()
{
	time_t START=clock();
	IOS;
	int a,b;
	cin>>n>>a>>b;
	int st[n]={0};
	if(f(a)==f(b)){
		cout<<"NO\n";
		return 0;
	}
	ans.resize(1<<n);
	dfs(a,b,st,0,(1<<n));
	cout<<"YES\n";
	// cout<<(double)(clock()-START)/CLOCKS_PER_SEC<<'\n';
	REP(i,SZ(ans)) cout<<ans[i]<<" \n"[i==SZ(ans)-1];
	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
const int maxm=1e5+10;
int n,m,now[maxm],top=0;
struct Edge{
	int a;
	int b;
}edge[maxm];
bool cmp(const Edge&a,const Edge&b){
	if(a.b<b.b)return 1;
	if(a.b>b.b)return 0;
	if(a.a<b.a)return 1;
	return 0;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		edge[i].a=read();
		edge[i].b=read();
	}
	sort(edge+1,edge+m+1,cmp);
	for(int i=1;i<=m;i++){
		bool flag=0;
		for(int j=1;j<=top;j++)
			if(now[j]>edge[i].a&&now[j]<=edge[i].b){
				flag=1;
				break;
			}
		if(!flag){
			top++;
			now[top]=edge[i].b;
		}
	}
	cout<<top;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(), c.end()
int l = 11;
vector<string> v;

bool cp(string &s1, string &s2) {
  if (s1.length() != s2.length()) return s1.length() < s2.length();
  return s1 < s2;
}

void dfs(string st) {
  if (st.length() > l) return;
  v.push_back(st);
  for (int i = -1; i <= 1; ++i) {
    if (st.back()+i < '0' || st.back()+i > '9') continue;
    char c = st.back() + i;
    dfs(st + c);
  }
}
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  dfs("1");
  dfs("2");
  dfs("3");
  dfs("4");
  dfs("5");
  dfs("6");
  dfs("7");
  dfs("8");
  dfs("9");
  sort(all(v), cp);
  cout << v[n-1] << endl;
}

Measured memory_bytes: 42856
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

string s;
int n;
int dp[5005][5005];

int solve(int x, int y, int cap){
    if(x>n-1 || y>n-1 || x>cap) return 0;

    if(dp[x][y]) return dp[x][y];
    else{
        if(s[x] == s[y]) return dp[x][y] = 1 + solve(x+1, y+1, cap);
        else return dp[x][y] = 0;
    }
}
 
signed main()
{
    tezz
    
    cin>>n;
    cin>>s;

    int mx = 0;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i] == s[j]){
                // cout<<i<<' '<<j<<" --> ";
                int curr = solve(i, j, j-1);
                // cout<<curr<<endl;
                mx = max(mx, curr);
            }
        }
    }

    cout<<mx;
} 

Measured memory_bytes: 195072
N = int(input())
S = input()

left = [0] * 10
right = [0] * 10
zero = ord("0")

l_set = set([])
r_set = set([])
center = S[0]
for s in S[1:]:
    right[ord(s) - zero] += 1
    r_set.add(s)

res = set([])
for s in S[1:]:
    l_set.add(center)
    left[ord(center)-zero] += 1
    
    center = s
    right[ord(center)-zero] -= 1
    if right[ord(center)-zero] == 0:
        r_set.remove(center)
    
    for r in r_set:
        for l in l_set:
            res.add(r+center+l)
    
    
print(len(res))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> a(n), b(n);
  //b[i]: a[j] = i  を満たすj
  REP(i, n){
    cin >> a[i];
    a[i]--;
    b[a[i]] = i;
  }

  set<ll> st;
  st.insert(-1);
  st.insert(n);
  ll ans = 0;
  REP(i, n){
    st.insert(b[i]);
    auto it = st.lower_bound(b[i]);
    ll tmp = b[i] - (*prev(it));
    //DUMP(tmp);
    tmp *= (*next(it)) - (b[i]);
    //DUMP(tmp);
    ans += (i+1) * tmp;
    //DUMP(ans);
  }
  cout << ans << endl;
}



Measured memory_bytes: 12800
def resolve():
    n, m = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    is_safe = [True] * (n + 1)
    broken = list(int(input()) for _ in range(m))
    for b in broken:
        is_safe[b] = False

    steps = [1] + [0] * n
    if is_safe[1]:
        steps[1] = 1
    for i in range(2, n + 1):
        if is_safe[i - 1]:
            steps[i] += steps[i - 1]
        if is_safe[i - 2]:
            steps[i] += steps[i - 2]
        steps[i] %= mod
    print(steps[n])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9584
#include<iostream>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll fac[200009];
ll inv[200009];
ll nCr(int i , int j)
{
    return ((fac[i]*inv[j])%mod*inv[i-j])%mod;
}
int main()
{
    fac[0]=1;
    for(int i=1;i<=200000;i++) fac[i]=(i*fac[i-1])%mod;
    inv[0]=inv[1]=1;
    for(int i=2;i<=200000;i++) inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
    for(int i=2;i<=200000;i++) inv[i]=(inv[i]*inv[i-1])%mod;
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    ll ans=(((fac[h+w-2])*(inv[h-1]))%mod*inv[w-1])%mod;
    //cout<<ans<<"\n";
    for(int i=1;i<=b;i++) {ans=((ans-(nCr(h-a-1+i-1,i-1)*nCr(a-1+w-i,w-i))%mod)%mod+mod)%mod;}// cout<<ans<<"\n";}
    cout<<ans;
}


Measured memory_bytes: 6708
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int t[64];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}

void Solve() {

	int n;
	cin >> n;
	ll a[100010];
	ll b = 0;
	int up =-1;
	int res = 0;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] == b) continue;
		if (b < a[i]) {
			if (up == -1) {
				up = 0;
				res++;
			}
			else if(up == 0){
				up = 1;
			}
		}
		else if (b > a[i]) {
			if (up == 1) {
				up = 0;
				res++;
			}
			else if (up == 0) {
				up = -1;
			}
		}

		b = a[i];
	}
	cout << res << endl;

}


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



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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    int n, a, b, c, d;
    string e;

    cin >> n >> a >> b >> c >> d >> e;

    --a; --b; --c; --d;

    for(int i = a; i <= c; ++i){
        if(e[i] == e[i - 1] && e[i] == '#'){
            cout << "No";
            return 0;
        }
    }

    for(int i = b; i <= d; ++i){
        if(e[i] == e[i - 1] && e[i] == '#'){
            cout << "No";
            return 0;
        }
    }

    if((a < b && c > d) || (b < a && c < d)){
        for(int i = max(a, b) - 1; i < min(c, d); ++i){
            if(e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.'){
                cout << "Yes";
                return 0;
            }
        }
        cout << "No";
        return 0;
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

int main() {
    int k,x;
    cin >> k >> x;
    for(int i = x-k+1; i < x+k; i++) {
        cout << i << " ";
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp10 {
    class Program {
        static void Main(string[] args) {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            var X = new List<int> { 1, 2, 3};

            X.Remove(A);
            X.Remove(B);

            Console.WriteLine(X[0]);

           

        }
    }
}


Measured memory_bytes: 13268
N=input()
A=[ map(int, raw_input().split())  for i in range(N) ]
C=[ map(int, raw_input().split())  for i in range(N) ]

A.sort(key=lambda x: x[1],reverse=True)
C.sort(key=lambda x: x[0])

V=[0 for i in range(N+1)]

ans=0

for bx,by in C:
	for i,u  in enumerate(A):
		rx=u[0]
		ry=u[1]
		if bx>rx and by>ry and V[i]==0:
			ans+=1
			V[i]=1
			break

print ans

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

int N,K,inf = 2e9;
int A[100010],B[100010],even[100010] = {0},visited[100010] = {0},ans[100010];
vector<vector<int>> v(100010);
bool judge = true;


void dfs1(int n,int mod){
	visited[n] = 1;
	even[n] = mod;
	if(A[n]!=-inf && A[n]%2!=mod) judge = false;
	for(int i=0;i<v[n].size();i++){
		int s = v[n][i];
		if(visited[s]==0){
			dfs1(s,1-mod);
		} 
	}
}

void dfs2(int n){
	visited[n] = 1;
	int ma = B[n],mi = A[n];
	for(int i=0;i<v[n].size();i++){
		int s = v[n][i];
		if(visited[s]==0){
			int s = v[n][i];
			dfs2(s);
			if(ma<A[s]-1 || B[s]+1<mi) judge = false;
			else if(A[s]-1<=mi && ma<=B[s]+1) continue;
			else if(mi<=A[s]-1 && B[s]+1<=ma){
				ma = B[s]+1;
				mi = A[s]-1;
			}
			else if(ma>=B[s]+1 && B[s]+1>=mi){
				ma = B[s]+1;
			}else{
				mi = A[s]-1;
			}
		}
	}
	if(ma==mi && ma%2!=even[n]) judge = false; 
	B[n] = ma;
	A[n] = mi;
}

void write(int n,int t){
	visited[n] = 1;
	if(t+1<=B[n]) ans[n] = t+1;
	else ans[n] = t-1;
	for(int i=0;i<v[n].size();i++){
		int s = v[n][i];
		if(visited[s]==0){
			write(s,ans[n]);
		}
	}
}

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		A[i] = -inf;
		B[i] = inf;
		even[i] = -1;
	}
	int a,b;
	for(int i=0;i<N-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	cin >> K;
	for(int i=0;i<K;i++){
		cin >> a >> b;
		A[a] = b;
		B[a] = b;
		even[a] = b%2;
	}
	dfs1(a,even[a]);
	if(!judge){
		cout << "No" << endl;
		return 0;
	}
	for(int i=1;i<=N;i++) visited[i] = 0;
	dfs2(1);
	if(!judge) cout << "No" << endl;
	else{
		for(int i=1;i<=N;i++) visited[i] = 0;
		if(A[1]==-inf){
			write(1,even[1]-1);
		}
		else if(A[1]%2==even[1]){
			write(1,A[1]-1);
		}
		else if(A[1]%2!=even[1]){
			write(1,A[1]);
		}
		cout << "Yes" << endl;
		for(int i=1;i<=N;i++){
			cout << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 14592
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){
      double W,H,x,y;
      cin>>W>>H>>x>>y;
      cout<<(double)(W*H/2.000000)<<" ";
      if((W==(x*2))&&(H==(y*2)))cout<<"1"<<endl;
      else cout<<"0"<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void) {
	char n[4];
	int i=0;
	scanf("%s",n);
	while(n[i]!='\0') {
		i++;
	}
	switch(n[i-1]) {
		case '2':
		case '4':
		case '5':
		case '7':
		case '9':
			printf("hon\n");
			break;
		case '0':
		case '1':
		case '6':
		case '8':
			printf("pon\n");
			break;
		case '3':
			printf("bon\n");
			break;
	}
	return 0;
}
	

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

using namespace std;


int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    if(s == "SAT")
        cnt = 1;
    else if(s == "SUN")
        cnt = 7;
    else if(s == "MON")
        cnt = 6;
    else if(s == "TUE")
        cnt = 5;
    else if(s == "WED")
        cnt = 4;
    else if(s == "THU")
        cnt = 3;
    else if(s == "FRI")
        cnt = 2;

    cout << cnt << '\n';
    return 0;
}


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

using namespace std;

int main(){
    long long A, B, H, M;
    cin >> A >> B >> H >> M;
    long double angle = (30.0 * (long double)H) - ((11 / 2.0) * (long double)M);
    angle = min(360 - angle, angle);
    angle = (3.141592653589793238 * angle) / 180.0;
    long double ans = sqrt((long double)A * (long double)A + (long double)B * (long double)B - 2.0 * (long double)A * (long double)B * cos(angle));
    cout << setprecision(18) << ans << endl;
    return 0;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  ll bt, ba; cin >> bt >> ba;

  rep(i, N-1) {
    ll t, a; cin >> t >> a;
    //ll mag = max((ll)ceil((double)bt/t), (ll)ceil((double)ba/a));
    ll mt = (bt + t - 1LL) / t;
    ll ma = (ba + a - 1LL) / a;
    ll mag = max(mt, ma);

    bt = mag * t;
    ba = mag * a;
  }

  cout << bt + ba << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int b = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    int h;
    cin >> h;
    if (b <= h) cnt++;
    b = max(b, h);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
p=input().rstrip().split(' ')
L=[]
for i in range(0,1000):
    L.append(i**2)
l=[]
q=[]
w=[]
S=[]
D=[]
V=0;
for i in range(0,int(p[0])):
    u=input().rstrip().split(' ')
    l.append(u)
for i in range(0,len(l)-1):
    A=l[i]
    for j in range(i+1,len(l)):
        B=l[j]
        T=0;
        for k in range(0,len(A)):
            T+=(abs(int(A[k])-int(B[k]))**2)
        if T in L:
            V+=1;
print(V)


Measured memory_bytes: 3064
def resolve():
    from bisect import bisect
    n,k=map(int,input().split())
    x=list(map(int,input().split()))
    g=bisect(x,0)
    if x[n-1]<=0:
        print(abs(x[n-k]))
    elif x[0]>=0:
        print(x[k-1])
    else:
        if g>=k:
            s=g-k
        else:
            s=0
        t=0
        while s<=n-k:
            if x[s]<0 and x[s+k-1]>0:
                if t==0:
                    t=min(2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
                else:
                    t=min(t,2*abs(x[s])+x[s+k-1],abs(x[s])+2*x[s+k-1])
            else:
                t=min(t,max(abs(x[s]),abs(x[s+k-1])))
            s+=1
        print(t)
resolve()

Measured memory_bytes: 14252
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cctype>
#include <algorithm>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5, M = 4e6+5;
int n, s; bitset<M> f;
int main()
{
    n = read(), f[0] = 1;
    for(int i = 1, w; i <= n; ++i) w = read(), s += w, f |= f<<w;
    s = (s-1)/2+1;
    for(int i = s; i < M; ++i) if(f[i]) return printf("%d\n", i), 0;
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
mymap = {}
maxi = 1
for x in range(n):
	inp = input()
	if inp in mymap:
		mymap[inp] += 1
		if mymap[inp] > maxi:
			maxi = mymap[inp]
	else:
		mymap[inp] = 1

answer = []

for x in mymap:
	if mymap[x] == maxi:
		answer.append(x)

answer.sort()

for x in answer:
	print(x)

Measured memory_bytes: 32096
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = sc.nextInt();
        int p = sc.nextInt();

        pw.println((a * 3 + p) / 2);
        pw.close();
    }
}


Measured memory_bytes: 23124
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut ns = io.readn::<usize>(4);

    ns.sort();

    if ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9 {
        io.writeln("YES")
    } else {
        io.writeln("NO")
    }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
        mp[A[i]]++;
    }
    int Q;
    cin >> Q;
    while(Q--){
        ll B, C;
        cin >> B >> C;
        sum -= B * mp[B];
        sum += C * mp[B];
        mp[C] += mp[B];
        mp[B] = 0;
        cout << sum << endl;
    }
}

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

int main(void) {
  int N, R;
  cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



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

  if(x==2||y==2){
    cout<<"No"<<"\n";
  }else if(x==4||x==6||x==9||x==11){
    if(y==4||y==6||y==9||y==11){
      cout<<"Yes"<<"\n";
    }else{
      cout<<"No"<<"\n";
    }
  }else{
    if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
      cout<<"Yes"<<"\n";
    }else{
      cout<<"No"<<"\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = INF; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N >> M;
	vl A;  vl B(N);
	for (i = 0; i < M; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == 1) A.push_back(b);
		if (b == N) {
			B[a - 1] = 1;
		}
	}
	for (i = 0; i < A.size(); i++) {
		if (B[A[i] - 1]) { 
			cout << "POSSIBLE";
			exit(0);
		}

	}
	cout << "IMPOSSIBLE";
}

Measured memory_bytes: 2936