akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long
#define float double
const int INF = 100000000000000000;

signed main(void){
  int n;
  int ret = -INF;
  vector<int> a;
  cin >> n;
  for(int i = 0; i < 3*n; i++){
    a.push_back(0);
    cin >> a[i];
  }

  vector<int> buf1;
  vector<int> buf2;
  int sum1 = 0;
  int sum2 = 0;
  priority_queue <int> max1,max2;
  priority_queue<int, vector<int>, greater<int> > min1,min2;
  for(int i = 0; i < n; i++){
    sum1 += a[i];
    sum2 += a[3*n-i-1];
    max1.push(a[i]);min1.push(a[i]);
    max2.push(a[3*n-i-1]);min2.push(a[3*n-i-1]);
  }
  buf1.push_back(sum1);
  buf2.insert(buf2.begin(), sum2);
  for(int i = 0; i < n; i++){
    int max1_,min1_,max2_,min2_;
    min1_ = min1.top();
    max2_ = max2.top();

    if(min1_ < a[n+i]){
      min1.pop();
      min1.push(a[n+i]);
      sum1 -= min1_;
      sum1 += a[n+i];
    }
    buf1.push_back(sum1);

    if(max2_ > a[2*n-i-1]){
      max2.pop();
      max2.push(a[2*n-i-1]);
      sum2 -= max2_;
      sum2 += a[2*n-i-1];
    }
    buf2.insert(buf2.begin(), sum2);
  }

  for(int i = 0; i <= n; i++){
    ret = max(ret, buf1[i]-buf2[i]);
  }
  cout << ret << "\r\n";
}


Measured memory_bytes: 11244
n   = gets.to_i
ary = gets.split.map(&:to_i)
dp  = [0, (ary[1] - ary[0]).abs]

for i in 2 .. n - 1
  dp[i] = [dp[i - 2] + (ary[i] - ary[i - 2]).abs, dp[i - 1] + (ary[i] - ary[i - 1]).abs].min
end

puts dp[-1]


Measured memory_bytes: 11396
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
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;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    long double t,x;cin >> t >> x;
    cout << fixed << t/x << endl;
    return 0;
}

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

const ll INF = 1LL << 60;

string S;

int main() {

    // ll c = 0;

    // ll tmp = 5;
    // ll tmp2 = 3;

    // c += tmp * (tmp + 1) / 2;
    // tmp2--;
    // c += tmp2 * (tmp2 + 1) / 2;

    // cout << c << endl;
    // return 0;
    cin >> S;

    // 圧縮
    vector<pair<char, int>> v;

    queue<pair<char, int>> que;
    rep(i, S.size()) {
        // 1こめ
        if (i == 0) {
            que.push(make_pair(S[i], 1));
        } else {
            pair<char, int> q2 = que.front();
            que.pop(); 

            if (q2.first == S[i]) {
                q2.second++;
                que.push(q2);

            } else {
                v.push_back(q2);

                // 新しい文字
                que.push(make_pair(S[i], 1));
            }
        }

        // 最後の1つ
        if (i == S.size() - 1 && que.size() >= 1) {
            v.push_back(que.front());
        }
    }
    // cout << v[0].first << " " << v[0].second << endl;

    // vector<ll> a;
    ll ans = 0;

    bool close = false;
    ll left = 0, right = 0;
    rep(i, v.size()) {
        if (v[i].first == '>') {
            right = v[i].second;
            close = true;
        } else {
            left = v[i].second;

            // open
            close = false;
        }

        if (close) {
            // cout << left << " " << right << endl;
            if (min(right, left) <= 1) {
                ll tmp = max(right, left);
                ans += tmp * (tmp + 1) / 2;
            } else {
                ll tmp = max(right, left);
                ans += tmp * (tmp + 1) / 2;

                ll tmp2 = min(right, left);
                tmp2--;
                ans += tmp2 * (tmp2 + 1) / 2;
            }
        }

        // 最後のケース 開きっぱなしで終わるケース
        if (i == v.size() - 1 && v[v.size() - 1].first == '<') {
            // cout << "last:" << v.size() << " " << v[i].second << endl;
            ll a = v[i].second;
            ans += a * (a + 1) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3068
from collections import defaultdict
n = int(input())
dx = defaultdict(list)
dy = defaultdict(list)
pts = set()
for _ in range(n):
    x, y = map(int, input().split())
    dx[x].append(y)
    dy[y].append(x)
    pts.add((x, y))

vx, vy = set(), set()
cnt = 0
for x, y in pts:
    if x in vx or y in vy: continue
    sx, sy = [x], [y]
    xs, ys = set(), set()
    while sx or sy:
        while sx:
            x = sx.pop()
            if x not in xs:
                xs.add(x)
                for y in dx[x]:
                    if y not in ys:
                        sy.append(y)
        while sy:
            y = sy.pop()
            if y not in ys:
                ys.add(y)
                for x in dy[y]:
                    if x not in xs:
                        sx.append(x)
    vx.update(xs)
    vy.update(ys)
    cnt += len(xs) * len(ys)
print(cnt - len(pts))

Measured memory_bytes: 46864
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=1e3+5, OO=1e18;
using namespace std;
char g[N][N];
int mem[N][N];
int n,m;
int solve(int h, int w)
{
    int cnt=0;
    if(h>=n || w>=m || h<0 || w<0) return 0;
    if (mem[h][w]!=-1) return mem[h][w];
    if (h==n-1 && w==m-1) cnt++;
    if (g[h][w+1]!='#') cnt+=solve(h,w+1),cnt%=1000000007,mem[h][w]=cnt;
    if (g[h+1][w]!='#') cnt+=solve(h+1,w),cnt%=1000000007,mem[h][w]=cnt;
    return cnt;
}
int main()
{
    ahmocs
    cin>>n>>m;
     for (int i=0; i<n; ++i)
        for (int j=0; j<m; ++j)
            mem[i][j]=-1;
    for (int i=0; i<n; ++i)
        for (int j=0; j<m; ++j)
            cin>>g[i][j];
    cout<<solve(0,0);
    return 0;
}


Measured memory_bytes: 5248
#include<iostream>

using namespace std;

int main( )
{	
    int n;
    
    cin>>n;
    
    int maxProfit = 1-1000000000;
    int Rj, Ri = 1000000000;
    cin>>Ri;
    n--;
    while( n-- ) {
    	cin>>Rj;
       	maxProfit = max( maxProfit, Rj - Ri  );
    	Ri = min( Ri, Rj );
    }
    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL a,b,c,n;
	string s;
	cin >>a>>b;
	cout <<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> s,t;
  int n,q;

  cin >> n;
  s.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> s[ii];
  }
  
  cin >> q;
  t.resize(q);

  for(ii=0;ii<q;ii++){
    cin >> t[ii];
  }
  int target;
  int sum = 0;

  for(ii=0;ii<q;ii++){
    target = t[ii];

    for(jj=0;jj<n;jj++){
      if(s[jj] == target){
        sum ++;
        break;
        //cout << target << " " << sum << endl;
        
      }
    }
    
  }
  
  cout << sum << endl;
  
  return 0;
}



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

int main(void){
  int M,D,count=0;
  cin >> M >> D;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      if(j/10==1||j%10==1) continue;
      else{
      if((j/10)*(j%10)==i){
        count ++;
      }
      }
    }
  }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key)i++;
	return i != n;
}
int main() {
	int i, n, A[10000 + 1], q, key, sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key))sum++;
	}
	printf("%d\n", sum);
	return 0;
}


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

int main(){
    bool cards[4][14];
    int n, rank;
    char suit;
    
    for(int s = 0; s < 4; s++)
        for(int r = 1; r <= 13; r++)
            cards[s][r] = 0;
            
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> suit >> rank;
        if(suit == 'S') cards[0][rank] = 1;
        if(suit == 'H') cards[1][rank] = 1;
        if(suit == 'C') cards[2][rank] = 1;
        if(suit == 'D') cards[3][rank] = 1;
    }
    
    for(int s = 0; s < 4; s++){
        for(int r = 1; r <= 13; r++){
            if(cards[s][r]) continue;
            if(s == 0) suit = 'S';
            if(s == 1) suit = 'H';
            if(s == 2) suit = 'C';
            if(s == 3) suit = 'D';
            cout << suit << " " << r << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3088
n = gets.to_i
height = gets.split.map(&:to_i)
dp = []
for i in 0..(n-1)
  dp[i] = 100
end
dp[0] = 0
dp[1] = (height[1] - height[0]).abs

for i in 2..(n-1)
  dp[i] = [dp[i-1]+(height[i]-height[i-1]).abs,dp[i-2]+(height[i]-height[i-2]).abs].min
end

puts dp[n-1]

Measured memory_bytes: 11340
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	long[][] sums = new long[][](8, N);
	foreach(k; 0..N) {
		auto ip2 = readAs!(long[]), x = ip2[0], y = ip2[1], z = ip2[2];
		long[] arr;
		foreach(i, v; [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]]) {
			sums[i][k] = x * v[0] + y * v[1] + z * v[2];
		}
	}
	
	long res = long.min;
	foreach(i; 0..8) {
		auto arr = sums[i].sort!"a > b";
		res = max(res, arr[0..M].sum);
	}
	res.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 764
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);
bool broken[100004];
int dp[100004];

signed main() 
{   
    IOS;
    int n,m;
    cin >> n >> m;

    for(int i = 1;i<=m;i++){
        int x;
        cin >> x;
        broken[x] = true;
    }


    dp[0] = 0;
    dp[1] = broken[1]==1?0:1;
    //cout << dp[1] << endl;
    dp[2] = broken[2]==1?0:1 + dp[1];
    //cout << dp[2] << endl;

    for(int i = 3;i<=n;i++){
        if(broken[i])continue;
        dp[i] = dp[i-1] + dp[i-2];
        dp[i]%=mod;
        //if(!broken[i-1] ) dp[i]+=dp[i-2];
        //dp[i]%=mod;
    }

    cout << dp[n] << endl;


    return 0;
} 

 

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string o, e;
    cin >> o >> e;
    deque<char> O(o.begin(), o.end()), E(e.begin(), e.end());
    while (!O.empty() || !E.empty()){
        cout << O.front();
        O.pop_front();
        if (E.empty())break;
        cout << E.front();
        E.pop_front();
    }
    return 0;
}

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

def main():
  n = int(input())
  S = input()[:-1]
  q = int(input())
  K = map(int, input().split())
  for k in K:
    d = 0
    m = 0
    dm = 0
    dmc = 0
    for s in S[:k-1]:
      if s == "D":
        d += 1
      elif s == "M":
        m += 1
        dm += d
      elif s == "C":
        dmc += dm
    for s,e in zip(S[k-1:],S):
      if s == "D":
        d += 1
      elif s == "M":
        m += 1
        dm += d
      elif s == "C":
        dmc += dm
      if e == "D":
        d -= 1
        dm -= m
      elif e == "M":
        m -= 1
    print(dmc)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 137976
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    private static int MAX = 10000;
    private static int MIN = 1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if (a > b || a > MAX || a < MIN || b > MAX || b < MIN
                    || c > MAX || c < MIN) {
                throw new InvalidTestCaseException("Condition is invalid.");
            }
            System.out.println(IntStream.rangeClosed(a, b)
                    .filter(i -> c % i == 0)
                    .count());
        } catch (InvalidTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    static class InvalidTestCaseException extends RuntimeException {
        InvalidTestCaseException(String m) {
            super(m);
        }
    }
}




Measured memory_bytes: 32536
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
#define endl "\n"
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
vector<int> ar[100001];
int vis[100001];
int n,m;
void dfs(int v)
{
	vis[v]=1;
	for(int child:ar[v])
	{
		if(vis[child]==0)
		{
			dfs(child);
		}
	}
}
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
cin>>n>>m;
int x,y;
for(int i=0;i<m;i++)
{
	cin>>x>>y;
	x--;
	y--;
	ar[x].pb(y);
	ar[y].pb(x);
}
int cnt=0;
   for(int i=0;i<n;i++)
   {
   	if(vis[i]==0)
   	{
   		dfs(i);
   		cnt++;
	   }
	 
	} 
	cout<<cnt-1<<endl;
}



 

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

using namespace std;

int main () {
	int n, k;
	cin >> n >> k;
	int mx = 0, gcd = 0;
	for (int i = 1;i <= n;i ++) {
		int x;
		cin >> x;
		mx = max (mx, x);
		gcd = __gcd (gcd, x);
	}
	if (k > mx || k % gcd != 0) cout << "IMPOSSIBLE";
	else cout << "POSSIBLE";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int mod = 1e9+7;
int main() {
    fast_cin();
    int n,f=0,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a%2==0)
        {
            if(!(a%3==0||a%5==0))
            f=1;
        }
    }
    if(f==0)
    cout<<"APPROVED";
    else
    cout<<"DENIED";
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  string s;
  cin >>n;
  cin >> s;
  int ans = 0;
  rep(i,n-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++ans;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
N,X = map(int,input().split())

def dp(n,x):
    if x == 0:
        return 0
    if n == 0:
        return 1
    if x <= 2**(n+1)-2:
        return dp(n-1,x-1)
    else:
        return 2**n+dp(n-1,x-2**(n+1)+1)

print(dp(N,X))

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    vector<double> v(n);
    for (int i=0;i<n;i++)
        cin >> v[i];
    sort(v.begin(),v.end());
    for (int i=1;i<n;i++)
        v[i]=(v[i-1]+v[i])/2;
    cout << v[n-1];
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[201],p[101];
    int i,j,ls,lp;

    gets(s);
    gets(p);

    ls=strlen(s);
    lp=strlen(p);

    for(i=0;i<lp-1;i++){
        s[ls+i]=s[i];
    }
    s[ls+lp]='\0';

    i=0;
    for(i=0;i<ls;i++){
        for(j=0;j<lp;j++){
            if(s[i+j]!=p[j]) break;
            if(j==lp-1){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");

    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order
#define N 10000001
int  m[1000001];
int32_t main() {
	fast;
	int n;
	cin >> n;
	int a[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		m[a[i]]--;
		//cout << m[a[i]] << " ";
		bool fl = 0;
		for (int j = 1; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				if (m[j] > 0) {
					fl = 1;
					break;
				}
				if (m[a[i] / j] > 0) {
					fl = 1;
					break;
				}
			}
		}
		m[a[i]]++;
		if (fl == 0)
			cnt++;
	}
	cout << cnt;









}

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

int main(){

long int a,b,sum = 0;
int cou = 1;

while(cin >> a >> b){
sum = a + b;
	while(sum >= 10){
		sum = sum/10;
		cou++;
	}
	cout << cou << "\n";
	cou = 1;
}
    return 0;
}

Measured memory_bytes: 1160
main = do
  s <- getLine
  let toInt x = read x :: Int
  let sort a b = putStrLn $ if a < b then (show a) ++ " " ++ (show b) else (show b) ++ " " ++ (show a)
  let [a,b] = map toInt . words $ s
  if a == 0 && b == 0 then return ()
  else do
    sort a b
    main

Measured memory_bytes: 4132
#include <stdio.h>
#define N 100000
#define NIL -1

struct Node
{int p;
  int l;
  int r;
};

struct Node T[N];
int n,D[N];

void print(int u){
  int i,c;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if (T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i!=0) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u, int p){
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r, p);
  if(T[u].l!=NIL) rec(T[u].l, p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
    scanf("%d",&c);
    if(j==0) T[v].l=c;
    else T[l].r=c;
    l=c;
    T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 6428
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), sum = 0;
    int[] W = new int[N];
    for (int i = 0; i < N; i++) {
      W[i] = sc.nextInt();
      sum += W[i];
    }
    int ans = 1000000000;
    for (int i = 0, tmp = 0; i < N; i++) {
      tmp += W[i];
      ans = Math.min(ans, Math.abs(tmp * 2 - sum));
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
#define ls(x) ( x << 1 )
#define rs(x) ( x << 1 | 1 )
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 5e5 + 5 ; 
const int M = 2e4 + 5 ; 
char s[N] ; 
int n, m, a[N], b[N] ;
int tree[N] ;  
struct Tree {
	int w ; 
} tr[N << 2] ;
void build( int x, int l, int r ) {
	if( l == r ) {
		tr[x].w = ( 1ll << a[l] ) ;
		return ; 
	}
	int mid = ( l + r ) >> 1 ; 
	build( ls(x), l, mid ), build( rs(x), mid + 1, r ) ;
	tr[x].w = ( tr[ls(x)].w | tr[rs(x)].w ) ;
}
int query( int x, int l, int r, int ql, int qr ) {
	if( l >= ql &&  r <= qr ) return tr[x].w ;
	if( l > qr || r < ql ) return 0 ; 
	int mid = ( l + r ) >> 1 ;
	return ( query( ls(x), l, mid, ql, qr ) | query( rs(x), mid + 1, r, ql, qr ) ) ;
}
void change( int x, int l, int r, int wh, int c ) {
	if( l == r ) {
		tr[x].w = ( 1ll << c ) ;
		return ; 
	}
	int mid = ( l + r ) >> 1 ; 
	if( mid >= wh ) change( ls(x), l, mid, wh, c ) ;
	else change( rs(x), mid + 1, r, wh, c ) ;
	tr[x].w = ( tr[ls(x)].w | tr[rs(x)].w ) ;
}
signed main()
{
	n = gi(), scanf("%s", s + 1 ) ;
	m = gi() ; int opt, l, r ;
	char c ; 
	rep( i, 1, n ) a[i] = s[i] - 'a' ;
	build( 1, 1, n ) ;
	rep( i, 1, m ) {
		opt = gi(), l = gi() ; 
		if( opt == 1 ) {
			scanf("%c", &c ) ; 
			r = c - 'a', 
			change( 1, 1, n, l, r ) ;
		}
		else {
			r = gi() ; int ans = 0 ;
			int u = query( 1, 1, n, l, r ) ;
			rep( i, 0, 26 ) if( ( u >> i ) & 1 ) ++ ans ;
			printf("%lld\n", ans ) ;
		}
	}
	return 0 ;
} 

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


int main() {
  int n,a,b;
  cin >> n>>a>>b;
  if((b-a)%2==0){
    cout<<"Alice"<<endl;
  }
  else{
    cout<<"Borys"<<endl;
  }
  
}

Measured memory_bytes: 256
// Created by Manmeet Singh Parmar
// name of snippet-> temp.sublime-snippet
// path -> sublime text 3/packages/user/temp.sublime-snippet

#include <cmath>
#include <iostream>
using namespace std;

int32_t main()
{
   	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

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

    int a;
    scanf("%d", &a);
    float ans = 2*M_PI*a;
    printf("%0.2f", ans);
    return 0;
}

Measured memory_bytes: 3228
s = input()
if len (s) % 2 == 1:
    l = r = (len(s) + 1) // 2
    k = l-1
else:
    l = len(s) // 2
    r = len(s) // 2 + 1
    k = l
center = s[l-1]

while s[l-1] == center and s[r-1] == center:
    k += 1
    l -= 1
    r += 1
    if l - 1 < 0:
        break

print(k)

Measured memory_bytes: 3188
fun main(arg: Array<String>) {
    val (N, A, B) = listOfInt()
    val V = listOfDouble().sortedDescending()
    val avr = V.subList(0, A).sum() / A
    println(avr)
    var num = 0
    var pos = 0
    repeat(N) { n ->
        if (V[n] == V[A - 1]) {
            num += 1
            if (n < A) pos += 1
        }
    }
    var cnt = 0L
    val pas = PascalTriangle(N)
    if (pos != A) cnt += pas.combi(num, pos)
    else for (n in A .. B) cnt += pas.combi(num, n)
    println(cnt)
}

data class PascalTriangle(private val N: Int) {
    private val table = Array(N + 1) { LongArray(N + 1) }
    init {
        for (n in 0 .. N)
        for (m in 0 .. n) {
            if (m == 0 || m == n) table[n][m] = 1L
            else table[n][m] = table[n - 1][m - 1] + table[n - 1][m]
        }
    }
    constructor(n: Long): this(n.toInt())
    fun combi(n: Int, m: Int) = table[n][m]
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


Measured memory_bytes: 37868
#include <stdio.h>

int main(){
  int n, a[200005];
  long long int k;
  scanf("%d %lld", &n, &k);
  for(int i=1; i<=n; i++)
    scanf("%d", &a[i]);
  int visited[200005] = {0};
  int route[200005] = {0};
  int heiro[200005] = {0};
  int nowplace = 1;
  int flag = 0;
  visited[1] = 1;
  while(route[0] < k){
    route[++route[0]] = nowplace;
    nowplace = a[nowplace];
    if(visited[nowplace]){
      int count = 0;
      heiro[++heiro[0]] = route[route[0]];
      while(route[route[0]-count] != nowplace){
	count++;
	heiro[++heiro[0]] = route[route[0]-count];
      }
      flag = 1;
      break;
    }else{
      visited[nowplace] = 1;
    }
  }
  if(flag)
    printf("%d\n", heiro[heiro[0] - (k - route[0])%heiro[0]]);
  else
    printf("%d\n", nowplace);
  return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K, X, Y;
  cin >> N >> K >> X >> Y;
  ll ans = 0;
  ans += min(N, K) * X;
  ans += max(0ll, N - K) * Y;
  cout << ans << "\n";
}


Measured memory_bytes: 256
N, M = map(int,input().split())
AB = []
for _ in range(M):
    t = tuple(map(int,input().split()))
    AB.append(t)
AB.sort()

left = 0
right = N
cnt = 0
for i,(a,b) in enumerate(AB):
    if right <= a:
        cnt += 1
        right = N
        left = 0

    left = max(a,left)
    right = min(b,right)

print(cnt+1)

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ba(m);
  for (int i = 0; i < m; i++) {
    cin >> ba[i].second >> ba[i].first;
  }
  sort(ba.begin(), ba.end());
  int x = 0;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (ba[i].second >= x) {
      x = ba[i].first;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", if a - 2 * b > 0 { a - 2 * b } else { 0 });
}


Measured memory_bytes: 4352
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class InputConsole {
public:
	template<typename T>
	static void inputs(vector<T> &vec) {
        string inputString;
        getline(cin, inputString);

        while (!inputString.empty()) {
            int i = 0;
            for (i = 0; i < inputString.length(); i++) {
                if (inputString[i] == ' ') {
                    break;
                }
            }
            stringstream ss;
            ss<< inputString.substr(0, i);
            T data;
            ss >> data;
            vec.push_back(data);
            inputString.erase(0, i + 1);
        }
	}
};

void Main()
{
    int x;
    cin >> x;
    cout << !x << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}




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

int main() {
  string s;
  string max_s1;
  string max_s2;
  int max_len = 0;
  int max_n = 0;
  map<string, int> m;

  while( cin >> s ) {
    m[s] ++;
    if( m[s] > max_n ) {
      max_n = m[s];
      max_s1 = s;
    }
    if( s.size() > max_len ) {
      max_len = s.size();
      max_s2 = s;
    }
  }

  cout << max_s1 << " " << max_s2 << endl;
}

Measured memory_bytes: 1196
//
//  main.cpp
//  ABC163_C
//
//  Created by Kosei on R 2/04/19.
//  Copyright © Reiwa 2 Kosei. All rights reserved.
//

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#define rep(i, n) for (int i = 1; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
typedef long long ll;
signed main() {
    int n;
    int a[200000] = {0};
    int b[200000] = {0};
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        b[a[i] - 1]++;
    }
    
    for (int i = 0; i < n; i++) {
        cout << b[i] << endl;
    }
    r0
}


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

int N;
vector<vector<int>> h, dp;

int main() {
  cin >> N;

  h.resize(N, vector<int>(3));
  rep(i, N) rep(j, 3) { cin >> h[i][j]; }

  dp.resize(2, vector<int>(3, 0));

  rep(i, N) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;

        dp[(i + 1) & 1][k] = max(dp[(i + 1) & 1][k], dp[i & 1][j] + h[i][k]);
      }
    }
  }

  cout << *max_element(all(dp[N & 1])) << endl;

  return 0;
}


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

int main(){
    char a,b,x;
    cin >> a >> b;
    if(a=='H') x=b;
    else if(a=='D'&&b=='H') x='D';
    else x='H';
    cout << x << endl;
}


Measured memory_bytes: 256
// MOHIT KUMAR
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i, a, b) for ( ll i = (b)-1; i >= a; i--)
#define ffr(i, a, b) for ( ll i = b ; i >= a; i--)
#define vl vector < ll >
#define vp vector < pl >
#define endl "\n"
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ld pi = acos(-1) ;
const ll maxn = 5e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll INF = 1e18 ;
const int MX = 2000000001 ; // check the limits, dummy

int main() {
  ios_base::sync_with_stdio(0) , cin.tie(0);
  ll t, q, n, a, b, c, d, k, l, m, r,  x = 0, y = 0, z = 0 , sum = 0, ans = 0, temp = 0, res = 0 ;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> a;
    if (i) {
      ans = (ans + ((sum * a) % mod)) % mod;
    }
    sum = (sum + a) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  vector<int> n(4);
  rep(i, 4) n[i] = s[i] - '0';

  rep(i, (1 << 3)) {
    int res = i, sum = n[0];
    FOR(j, 1, 4) {
      if (res & 1) sum += n[j];
      else sum -= n[j];
      res /= 2;
    }

    if (sum == 7) {
      res = i;
      rep(j, 3) {
        cout << n[j];
        if (res & 1) cout << '+';
        else cout << '-';
        res /= 2;
      }
      cout << n[3] << "=7" << endl;
      return 0;
    }
  }


  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a[3], i, sum=0;
    for(i=0; i<3; i++) {
        cin >> a[i];
        sum += a[i];
    }

    for(i=0; i<3; i++) {
        if(((sum/2)==a[i]) && ((sum%2)==0)) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl '\n'
#define maxl __LONG_LONG_MAX__
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define rep(i, n) for(int i = 0; i < n; i++)
#define rev(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i=1; i < n; i++)
#define rev1(i, n) for(int i=n ; i > 0; i--)
#define FOR(i, a, b) for(int i=a ; i < b; i++)
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define n_ones(x) __builtin_popcountll(x)
#define n_trailzero(x) __builtin_ctzll(x)
#define n_leadingzero(x) __builtin_clz(x)
#define sz(a) (ll)(a.size())

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef stack<ll> stk;
typedef queue<ll> que;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setll;
typedef tree<char,null_type,less<char>,rb_tree_tag,
tree_order_statistics_node_update> indexed_setc;

ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}

ll mod = 1e9 + 7;
void solve()
{
	ll n;
	cin>>n;
	ld p[n+1];
	rep1(i, n+1)
		cin>>p[i];
	ld dp[n+1][n+1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep1(i, n+1)
	{
		dp[0][i] = (1 - p[i]) * dp[0][i-1];
		for(ll j = 1; j <= i; j++)
		{
			dp[j][i] = p[i] * dp[j-1][i-1] + (1 - p[i]) * dp[j][i-1];
		}
	}
	ld ans = 0;
	for(ll i = n/2 + 1; i <= n; i++)
		ans += dp[i][n];
	cout<<setprecision(9)<<ans<<endl;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	ll t = 1;
	//cin>>t;
	rep(i, t)
		solve();
	return 0;
	
}

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

int main() {
  int array[2];
  for (int i = 0; i < 3; i++) {
    cin >> array[i];
  }
  
  int tmp_zero = array[0];
  array[0] = array[1]; // 20[1] -> 20[0]
  array[1] = tmp_zero; // 20[1] -> 10[0]
  int tmp_two = array[2];
  array[2] = array[0]; // 30
  array[0] = tmp_two;
  
  for (int i2 = 0; i2 < 3; i2++) {
	cout << array[i2] << " ";
  }
}  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N; cin >> N;
    Int sum = 0;
    vector<vector<int>> A(N), B(N);
    REP(i, N) A[i].resize(N), B[i].resize(N);
    REP(i, N) REP(j, N) cin >> A[i][j];
    REP(i, N) REP(j, N) {
        int m = A[i][j];
        REP(k, N) {
            if (i == k || j == k) continue;
            if (A[i][k] + A[k][j] < m) goto FAILED;
            if (A[i][k] + A[k][j] == m) B[i][j] = 1;
        }
        if(m != A[i][j]) goto FAILED;
        if(i == j && A[i][j] != 0) goto FAILED;
        if(A[i][j] != A[j][i]) goto FAILED;
    }
    for (int i=0; i<N; i++) for (int j=i+1; j<N; j++) if (!B[i][j]) sum += A[i][j];
    cout << sum << endl;
    return 0;
FAILED:
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int h, w;

int a[88][88];
int b[88][88];
int d[88][88];

bool dp[88][88][26000];
ll ans =0;

int main(){
    cin >> h >> w;

    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }

    rep(i,h){
        rep(j,w){
            cin >> b[i][j];
            d[i][j] = abs(a[i][j] - b[i][j]);
        }
    }
    //以上入力

    dp[0][0][d[0][0]] = 1;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            rep(k,26000){

                if(dp[i][j][k]){
                    if(i+1 < h){
                        dp[i+1][j][k+d[i+1][j]] = 1;
                        dp[i+1][j][abs(k-d[i+1][j])] = 1;
                    }
                    if(j+1 < w){
                        dp[i][j+1][k+d[i][j+1]] = 1;
                        dp[i][j+1][abs(k-d[i][j+1])] = 1;
                    }
                }
            } 
        }
    }

    rep(i,26000){
        if(dp[h-1][w-1][i]) {
            dunk(i);
            break;
        }
    }
}

Measured memory_bytes: 179200
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False
        self.ds_memo = {}
        self.ds_memo[1] = set([1])

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d.items()

    # メモ化で高速化?
    def divisions(self, n):
        if n in self.ds_memo:
            return self.ds_memo[n]

        for c in self.T:
            if n % c == 0:
                rs = set([c])
                for cc in self.divisions(n // c):
                    rs.add(cc)
                    rs.add(cc * c)
                self.ds_memo[n] = rs
                return rs

        rs = set([n])
        self.ds_memo[n] = rs
        return rs

    def sowa(self, n):
        r = 1
        for k,v in self.division(n):
            t = 1
            for i in range(1,v+1):
                t += math.pow(k, i)
            r *= t
        return r


def main():
    n = I()
    a = sorted(LI())
    pr = Prime(10**9)
    p = collections.defaultdict(int)

    for b in a:
        for k in pr.divisions(b):
            p[k] += 1

    r = 1
    for k,v in p.items():
        if v >= n-1 and r < k:
            r = k

    return r


print(main())




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

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

  double e[n];  // 各サイコロの期待値
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    e[i] = (p + 1) / 2.0;  // 1~pの和をpで割る
  }

  double s[n + 1];  // 期待値の累積和
  s[0] = 0;         // サイコロ0個
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + e[i - 1];
  }

  double mx = 0.0;
  for (int i = 0; i + k <= n; i++) {
    mx = max(mx, s[i + k] - s[i]);
  }

  cout << fixed << setprecision(10) << mx << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
int main() {
	char str[222];
	scanf("%s", str);
	int n = strlen(str);
	for (int i = n - 2; i; i -= 2) {
		if (strncmp(str, str + i / 2, i / 2) == 0) {
			printf("%d\n", i);
			return 0;

		}

	}
	return 0;

}


Measured memory_bytes: 128
import math
import copy
import fractions
import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

w, h, x, y = map(int, input().split())

ans = w*h/2

flg = 0
if w/2 == x and h/2 == y:
    flg = 1

print(ans, flg)

Measured memory_bytes: 13668
bn = int(input())
bd = []; bdd = {}
for i in range(bn):
    bd = input().split()[0]
    try:
        bdd[str(bd)] += 1
    except:
        bdd[str(bd)] = 1

rn = int(input())
rd = []
for i in range(rn):
    rd = input().split()[0]
    try:
        bdd[str(rd)] -= 1
    except:
        continue
    
l = [s for s in bdd.values()]
l.append(0)
print(max(l))


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)

{

int a,b,d,r ;

double f ;

scanf("%d",&a) ;

scanf("%d",&b) ;

d = a/b ;

r = a%b ;

f = (double)a/b ;

printf("%d %d %.5lf",d,r,f) ;

return 0 ;

}
 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
#define ld long double
int main()
{
    int n,w;
    cin>>n>>w;
    ll arr[n+1][2];
    forl(i,1,n+1) forl(j,0,2) cin>>arr[i][j];
    ll dp[n+1][w+1];
    forl(i,0,n+1) forl(j,0,w+1) dp[i][j]=0;
    forl(i,1,n+1)
    {
        forl(j,0,w+1)
        {
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
            if(j-arr[i][0]>=0) dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i][0]]+arr[i][1]);
        }


    }
    ll maxi=0;
    forl(i,0,w+1)
    {
        maxi=max(maxi,dp[n][i]);
    }
    cout<<maxi<<endl;
    
}

Measured memory_bytes: 79104
#include <stdio.h>

int main(void){
   
   int N;
   scanf("%d",&N);
   
   int i;
   int A[N];
   
   for (i = 0;i < N;i++) {
      scanf("%d",&A[i]);
   }
   
   double x = 0;
   
   for (i = 0;i < N;i++) {
      x = x + 1.0/A[i];
   }
   
   printf("%lf\n",1/x);
   
   return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[3001][3001];
int main(){
    int n,A[30001];
    cin>>n;
    rep(i,n) cin>>A[i];
    fill(dp[0],dp[0]+n+1,0);
    rep(i,n){
        rep(j,n-i){
            dp[i+1][j]=max(A[j+i]-dp[i][j],A[j]-dp[i][j+1]);
        }
    }
    cout<<dp[n][0]<<"\n";
}

Measured memory_bytes: 70016
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()){
    s[i] = ((s[i] - 'A' + n) % 26) + 'A';
  }
  cout << s << endl;
}


Measured memory_bytes: 256