akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5, inf = 1e9 + 7 ;
using namespace std ;

int na, mo, n = 0, d[N], tr[N << 2] ;
ll fl[N], fr[N] ;
struct poi {
	int l, r ; 
} a[N] ;

int find(int x) {
	int l = 1, r = d[0] ;
	for ( ; l <= r ; ) {
		int mid = (l + r) / 2 ;
		if (d[mid] == x) return mid ;
		if (x < d[mid]) r = mid - 1 ; else l = mid + 1 ;
	}
	return 0 ;
}

void pre() {
	d[0] = 0 ;
	rep(i, 0, n - 1) d[++ d[0]] = a[i].l, d[++ d[0]] = a[i].r ;
	sort(d + 1, d + d[0] + 1) ;
	d[0] = unique(d + 1, d + d[0] + 1) - (d + 1) ;
	rep(i, 0, n - 1) a[i].l = find(a[i].l), a[i].r = find(a[i].r) ;
}

void build(int p, int l, int r) {
	tr[p] = inf ;
	if (l == r) return ;
	int mid = (l + r) / 2 ;
	build(p << 1, l, mid), build(p << 1 | 1, mid + 1, r) ;
}

void modify(int p, int l, int r, int lx, int rx, int ave) {
	if (l == lx && r == rx) {
		tr[p] = min(tr[p], ave) ;
		return ;
	}
	int mid = (l + r) / 2 ;
	if (rx <= mid) modify(p << 1, l, mid, lx, rx, ave) ; else
	if (lx > mid) modify(p << 1 | 1, mid + 1, r, lx, rx, ave) ; else
		modify(p << 1, l, mid, lx, mid, ave), modify(p << 1 | 1, mid + 1, r, mid + 1, rx, ave) ;
}

int query(int p, int l, int r, int pos) {
	int ret = tr[p] ;
	if (l == r) return ret ;
	int mid = (l + r) / 2 ;
	if (pos <= mid) ret = min(ret, query(p << 1, l, mid, pos)) ; 
		else ret = min(ret, query(p << 1 | 1, mid + 1, r, pos)) ;
	return ret ;
}

int main() {
	scanf("%d%d", &na, &mo) ;
	int x, y, las = 0 ; ll sum = 0 ;
	rep(i, 1, na) {
		scanf("%d%d", &x, &y) ;
		las = (las + x) % mo, sum += x ;
		if (x * 2 > mo && (y & 1)) { puts("-1") ; return 0 ; }
		if (y & 1) a[n].l = (- 2 * (las - x) % mo + mo) % mo, a[n].r = (- 2 * las % mo + mo) % mo, ++ n ; else
			a[n].l = 0, a[n].r = mo - 1, ++ n ;
	}
	pre() ;
	build(1, 1, d[0]) ;
	for (int i = n - 1 ; i >= 0; -- i) {
		int u = query(1, 1, d[0], a[i].l) ;
		if (u == inf) fl[i] = 0 ; else fl[i] = fl[u] + (d[a[u].l] - d[a[i].l] + mo) % mo ;
		u = query(1, 1, d[0], a[i].r) ;
		if (u == inf) fr[i] = 0 ; else fr[i] = fl[u] + (d[a[u].l] - d[a[i].r] + mo) % mo ;
		fl[i] = min(fl[i], fr[i] + (d[a[i].r] - d[a[i].l] + mo) % mo) ;
		fr[i] = min(fr[i], fl[i] + (d[a[i].l] - d[a[i].r] + mo) % mo) ;
		if (a[i].l <= a[i].r) {
			if (a[i].r < d[0]) modify(1, 1, d[0], a[i].r + 1, d[0], i) ;
			if (a[i].l > 1) modify(1, 1, d[0], 1, a[i].l - 1, i) ;
		} else {
			if (a[i].r < a[i].l - 1) modify(1, 1, d[0], a[i].r + 1, a[i].l - 1, i) ;
		}
	}
	ll ans = 1e17 ;
	rep(i, 0, n - 1) {
		int u = query(1, 1, d[0], a[i].l) ;
		if (u == inf) ans = min(ans, 0LL) ; else ans = min(ans, fl[u] + (d[a[u].l] - d[a[i].l] + mo) % mo) ;
		u = query(1, 1, d[0], a[i].r) ;
		if (u == inf) ans = min(ans, 0LL) ; else ans = min(ans, fl[u] + (d[a[u].l] - d[a[i].r] + mo) % mo) ;
	}
	printf("%lld\n", ans + sum * 2) ; 
	return 0 ; 
}

Measured memory_bytes: 8064
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    X, Y, Z, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()] 
    B = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()] 
  else:
    A = [1,10,100]
    B = [2,20,200]
    C = [1,10,100]
    #A = [4,6]
    #B = [1,5]
    #C = [3,8]
    X = len(A)
    Y = len(B)
    Z = len(C)
    K = 5
    #K = 8

  # Processing
  AB = []
  A.sort(reverse=True)
  B.sort(reverse=True)
  for i in A[0:K]:
    for j in B[0:K]:
      AB.append(i+j)
  
  AB.sort(reverse=True)
  
  ABC = []
  C.sort(reverse=True)
  
  for i in AB[0:K]:
    for j in C[0:K]:
      ABC.append(i+j)  
  
  ABC.sort(reverse=True)

  for i in ABC[0:K]:
    print(i)      

main()

Measured memory_bytes: 207160
n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int, input().split())))

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 1000:
    ii = n
    jj = n+1
else:
    ii = 1000
    jj = 1000

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2])*(tmp1[-j][1]-tmp1[i][1]) >= 0:
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2])*(tmp2[-j][1]-tmp2[i][1]) <= 0:
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 154348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    rep(i, n-2) {
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
        if (p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;        
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import numpy as np

n, k = map(int, input().split())
MOD = int(1e9+7)
rem = (10*100)%MOD 
ans = 0 

for i in range(k, n+2):
    if i == k:
        minimum = np.arange(i).sum()
        maximum = np.arange(n, n-i, -1).sum()
    else:
        minimum += i-1 
        maximum += n-i+1
    ans += (maximum-minimum+1)%MOD

print(ans%MOD)


Measured memory_bytes: 28600
using System;
namespace AtCoder
{
  class Program
  {
	static void Main(string[] args)
	{
		var v = Console.ReadLine();
        var money = int.Parse(v);
        var happiness = 0;
        happiness +=  (money / 500) * 1000;
        happiness += ((money % 500) / 5) * 5;
        Console.WriteLine(happiness.ToString());
	}
  }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define max 256

int main()
{
	int n, tmp, i;
	char s[max], t_1[max], t_2[max];
	char *p;

	scanf("%d", &n);
	scanf("%d", &tmp);

	fgets(s, max, stdin);
	p = strrchr(s, '\n');
	*p = '\0';

	if (n % 2 == 1)
	{
		printf("No\n");
	}

	else
	{
		for (i = 0; i < (n / 2); i++)
		{
			t_1[i] = s[i];
			t_2[i] = s[i + (n / 2)];
		}

		t_1[n / 2] = '\0';
		t_2[n / 2] = '\0';


		if (strcmp(t_1, t_2) == 0)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}


	}
	return 0;


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N, K; cin >> N >> K;
  double res = 0.0;
  for (int i = 1; i <= N; i++) {
    int c = i;
    //double v = 1 / N;
    double v = 1.0;
    while (c < K) {
      c *= 2;
      v /= 2;
    }
    res += v;
  }
  cout << fixed << setprecision(15);
  cout << res / N << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define readInt(x) scanf("%d", &x)
#define readStr(x) scanf("%s", x)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1 << 29;
const int MAX = 1e5 + 10;

ll A, B, C, X, Y;

int main()
{
    cin >> A >> B >> C >> X >> Y;

    ll ans = 1ll << 60;
    for (int nAB = 0; nAB <= max(2 * X, 2 * Y); nAB++) {
        int tmp = max(0ll, X * A - nAB / 2 * A);
        ll price = C * nAB + max(0ll, X * A - nAB / 2 * A) + max(0ll, Y * B - nAB / 2 * B);
        if (price < ans) ans = price;
    }
    write(ans);
}

Measured memory_bytes: 256
//#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
//#include <sstream>
// #include <string>
using namespace std;

int n;
vector<int> A;


int slove(int i, int m) {
    //mを作ることができる
    if(m == 0) {
        return 1;
    }

    //mを作れない(全ての組み合わせを試した後)
    if(i >= n) {
        return 0;
    }

    //まだ計算中
    //         A[i]を使わない  |  A[i]を使う
    int res = slove(i+1, m) || slove(i+1, m - A[i]); //m - A[i]がA[i]を使うことを表現している
    return res;
}


int main() {
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    
    int q;
    cin >> q;

    for (int i = 0; i < q; ++i)
    {
        int m;
        cin >> m;

        //再帰で調べる
        if(slove(0, m)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }



    return 0;
}




Measured memory_bytes: 3168
import java.util.Scanner;

/**
 * @author varun on 7/1/2018
 * @project CompetitiveProgramming
 */
public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m  = scanner.nextInt();
        int[] cities = new int[n];
        for (int i = 0; i < m; i++) {
            int c1 = scanner.nextInt(), c2 = scanner.nextInt();
            cities[c1-1]++;
            cities[c2-1]++;
        }
        for (int city : cities) System.out.println(city);
    }
}


Measured memory_bytes: 21716
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x,y,z,copy;
		x=sc.nextInt();
		y=sc.nextInt();
		z=sc.nextInt();
		if(x>y){
			copy=x;
			x=y;
			y=copy;
		}
		if(y>z){
			copy=y;
			y=z;
			z=copy;
		}
		if(x>y){
			copy=x;
			x=y;
			y=copy;
		}
		System.out.println(x+" "+y+" "+z);
		sc.close();
	}
}



Measured memory_bytes: 26136
#include<stdio.h>
 
int main()
{
	int A, B;
	scanf("%d", &A);
	scanf("%d", &B);
 
	if (A + B > 16 || A > 8 || B > 8 || A + B < 2)
	{
		printf("\n:(");
	}
	else
	{
		printf("\nYay!");
	}
   return 0;
}

Measured memory_bytes: 128
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 = sc.nextInt();
		int[] array = new int[N];

		for(int i=0;i<N;i++) {
			array[i]=sc.nextInt();
		}
		Arrays.parallelSort(array);
		System.out.println(array[N-1]-array[0]);
	}
	public static int sample() {
		return 1;
	}

}


Measured memory_bytes: 21716
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a,b,c,d,e,f;
		double x,y;
		
		while(sc.hasNext()){
			a = sc.nextDouble();
			b = sc.nextDouble();
			c = sc.nextDouble();
			d = sc.nextDouble();
			e = sc.nextDouble();
			f = sc.nextDouble();
			
			y = (f*a-c*d)/(a*e-b*d);
			x = (c-b*y)/a;
			if(x==(-0.0)) Math.abs(x);
			if(y==(-0.0)) Math.abs(y);
			System.out.printf("%.3f %.3f\n", x,y);
		}
	}

}

Measured memory_bytes: 20568
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;
int main() {
	string s;
	int i;
	cin >> s;
	i = s.length();
	cout << s[0] << i - 2 << s[i - 1] << endl;
	return 0;
}



Measured memory_bytes: 256
i=3;main(n,j){scanf("%d",&n);if(n==3)return!printf("2 3 25");for(;j=n-i,j+=j&1,1>j||j>5000;i+=3);for(i=n-j;i;printf("%d ",2*i--));for(;j--;printf("%d ",6*j+3));}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int l=a+b,r=c+d;
    string message;
    if(l<r){
        message="Right";
    }else if(l>r){
        message="Left";
    }else{
        message="Balanced";
    }
    cout << message << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	ll ans = 0;
	ans += min(A, K);
	K = max(K - A, 0ll);
	K = max(K - B, 0ll);
	ans -= min(C, K);
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  string s;
  cin >> s;
  rep(i,s.size()) {
    cout << 'x';
  }
  cout << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int n , m;
    cin>>n>>m;
    cout<<n*(n-1)/2 + m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int A;
int B;
int main(){
  int i, k, res=0;
  rd(A);
  rd(B);
  for(i=100;i<1000;i++){
    k = 100*i + ((i/10)%10) * 10 + i/100;
    if(A<=k && k<=B){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int A, B;
// {
//   int i, k, res = 0;
//   rd(A,B);
//   rep(i,100,1000){
//     k = 100i + ((i/10)%10) * 10 + i/100;
//     if(A<=k<=B) res++;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

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

	if(n)
		cout << 0 << endl;
	else
		cout << 1 << endl;
	
	return 0;
}


Measured memory_bytes: 3608
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans =0
def main(x,y,z,c):
    p =0
    for i in range(z):
        p +=x[i]*y[i]
    return p + c

for i in range(n):
    #print(main(a[i],b,m,c))
    if main(a[i],b,m,c)>0:
        ans +=1
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    cout << (n == m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    ll N,K; cin >> N >> K;
    vector<int> A(N),F(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());
    
    ll ok = 1e12;
    ll ng = -1;
    
    while(abs(ok-ng)>1){
        ll mid = (ok+ng) / 2;
        auto f = [&](ll mid){
            ll count = 0;

            rep(i,N){
                count += max(0LL, A[i] - mid/F[i]);
            }
        
            return K >= count;
        };
        if(f(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
}

Measured memory_bytes: 4820
#include<iostream>

using namespace std;

int main(){

	int n;
	cin >> n;
	bool test = false;
	
	while( n-- ) {
		
		int A[10] = {0};
		int B[10] = {0};
	
		int j = 0, k = 0;
		int a;
		
		for(int i=0;i<10;i++) {
			
			cin >> a;
			
			if( a > A[j] ) {
				
				A[j+1] = a;
				j++;
				
			}
			else {
				if( a > B[k]) {
					
					B[k+1] = a;
					k++;
					
				}
			}
		}
		if ( j + k == 10)
			cout << "YES\n";
		else
			cout << "NO\n"; 
		
	}
	
    return 0;
}


Measured memory_bytes: 2876
import sys
input=sys.stdin.readline
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
l=L()
if sum(l)<=21:
    print("win")
else:
    print("bust")

Measured memory_bytes: 9220
#include<stdio.h>
#define N 100
#define INF 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim(void);

int n,ret,e;
int A[N][N];

int main()
{
  int i,j;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&e);
      if(e == -1)A[i][j] = INF;
      else A[i][j] = e;
    }
  }
  ret = prim();
  printf("%d\n",ret);

  return 0;
}

int prim(void){
  int u,minv,i,v,sum;
  int d[N],p[N],color[N];

  for(i = 0; i < n; i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && A[u][v] != INF){
	if(d[v] > A[u][v]){
	  d[v] = A[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  sum = 0;
  for(i = 0; i < n; i++){
    if(p[i] != -1)sum += A[i][p[i]];
  }

  return sum;
}



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

const int mod=1000000007;

int n,m;
bool b[100005];
long long dp[100005];

int main(){

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

    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int t;
        cin>>t;
        b[t]=1;
    }
    dp[0]=1;
    dp[1]=!b[1];
    for(int i=2;i<=n;i++){
        if(b[i])continue;
        dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[n]<<endl;

    return 0;
}

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

int main(void)
{
    using namespace std;

    int n;
    cin >> n;

    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> y.at(i);
    }

    double p1 = 0;
    double p2 = 0;
    double p3 = 0;
    double p4 = 0;
    for (int i = 0; i < n; i++) {
        double abs_value = abs(y.at(i) - x.at(i));
        p1 += abs_value;
        p2 += pow(abs_value, 2);
        p3 += pow(abs_value, 3);
        p4 = max(p4, abs_value);
    }
    p2 = sqrt(p2);
    p3 = cbrt(p3);
    

    printf("%lf\n", p1);
    printf("%lf\n", p2);
    printf("%lf\n", p3);
    printf("%lf\n", p4);

    return 0;
}


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

int main() {
    double A, B, H, M;
    const double pi = 3.141592653589793;
    double pi_180 =  pi / 180.0;

    cin >> A >> B >> H >> M;
    // A tangle
    double A_tangle = H * 30.0 + M * 0.5;
    double B_tangle = M * 6.0;
    double tangle_diff = abs(A_tangle - B_tangle);
    tangle_diff = min(tangle_diff, (360.0 - tangle_diff));
    // cout << tangle_diff << endl;
    double cos_t = cos(tangle_diff * pi_180);
    double m = 2 * A * B * cos_t;
    // cout << cos_t << endl;
    // cout << m << endl;
    double c2 = (A * A) + (B * B) - m;
    double ret = sqrt(c2);
    cout << fixed << setprecision(15) << ret << endl;
}

Measured memory_bytes: 4208
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
using pint = pair<int,int>;

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

int H, W;
string fi[110];
int dist[110][110]; // BFS 用

int main() {
    // 入力
    cin >> H >> W;
    int wnum = 0;
    for (int i = 0; i < H; ++i) {
        cin >> fi[i];
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '.') ++wnum;
        }
    }

    // BFS
    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0, 0));
    while (!que.empty()) {
        pint cur = que.front();
        que.pop();
        int x = cur.first;
        int y = cur.second;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (fi[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else  cout << wnum - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d\n",&n);
  int arr[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d ",&arr[i]);
  }
  int t;
  scanf("%d\n",&t);
  int temp[n];
  while(t--){
    for(i=0;i<n;i++){
      temp[i]=arr[i];
    }
    int k,m;
    scanf("%d %d\n",&k,&m);
    temp[k-1]=m;
    int time=0;
    for(i=0;i<n;i++){
      time = time+temp[i];
    }
    printf("%d\n",time);
  }
  return 0;
}

Measured memory_bytes: 1700
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(Decimal, sys.stdin.readline().split()))


s = sum([1 / a for a in A])
print(float(1 / s))


Measured memory_bytes: 23012
#include <iostream>
using namespace std;
int main(void){
    int n, i, j, num;
    int cards[4][13];
    char ill;
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            cards[i][j] = 0;
        }
    }
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> ill >> num;
        if(ill == 'S'){
            cards[0][num-1] = 1;
        }
        if(ill == 'H'){
            cards[1][num-1] = 1;            
        }
        if(ill == 'C'){
            cards[2][num-1] = 1;            
        }
        if(ill == 'D'){
            cards[3][num-1] = 1;            
        }
    }
    for(i = 0; i < 4; i++){
        for(j = 0; j < 13; j++){
            if(cards[i][j] == 0){
                if(i == 0)  cout << "S " << j+1 << endl;
                if(i == 1)  cout << "H " << j+1 << endl;
                if(i == 2)  cout << "C " << j+1 << endl;
                if(i == 3)  cout << "D " << j+1 << endl;
            }
        }
    }
    return 0;
    
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
vector<int>v[100005];
int vis[100005];
int dist[100005];
int ind[100005];
int gct;
void dfs(int x)
{
    vis[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
            if(!vis[v[x][i]])
            dfs(v[x][i]);
            dist[x]=max(dist[x],1+dist[v[x][i]]);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,i,x,y;
    cin>>n>>m;
    memset(vis,0,sizeof(vis));
    memset(dist,0,sizeof(dist));
    memset(ind,0,sizeof(ind));
    while(m--)
    {
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    int ans=INT_MIN;
    for(i=1;i<=n;i++)
    ans=max(ans,dist[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8960
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
A = LIST()
ans = [0]*n
for i in range(n-1,-1,-1):
    res = 0
    j = 0
    while (j+1) *(i+1) <= n:
        res += ans[(j+1)*(i+1)-1]
        j += 1
    if res%2 != A[i]:
        ans[i] = 1
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(str(i+1)+' ', end = '')
    


Measured memory_bytes: 63592
#[allow(unused)]
use std::io::Write;
use std::f64;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (a, b, x): (f64, f64, f64) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        let c = ws.next().unwrap().parse().unwrap();
        (a, b, c)
    };

    let area = x / a;
    let half = a * b / 2.0;

    if area >= half {
        let rest = area - half;
        let c = 2.0 * rest / a;
        let d = b - c;
        let e = (a.powi(2) + d.powi(2)).sqrt();
        let sin = d / e;
        let rad = sin.asin();
        let angle = rad * 180.0 / f64::consts::PI;
        println!("{}", angle);
    } else {
        let c = 2.0 * area / b;
        let d = (b.powi(2) + c.powi(2)).sqrt();
        let sin = c / d;
        let rad = sin.asin();
        let angle = rad * 180.0 / f64::consts::PI;
        println!("{}", 90.0 - angle);
    }
}


Measured memory_bytes: 4352
N, M = [int(_) for _ in input().split()]
S = [[int(_)-1 for _ in input().split()][1:] for _ in range(M)]
P = [int(_) for _ in input().split()]

ans = 0
for i in range(2**N):
    f = True
    for s, p in zip(S, P):
        c = 0
        for k in s:
            if i & 1 << k == 1 << k:
                c += 1
        if(c % 2 != p):
            f = False
            break
    if f:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v = enum_div(n);
    int ans = INF2;
    rep(i, v.size()) ans = min(ans, n / v[i] + v[i]);
    cout << ans - 2 << endl;


    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> v,o[2], a[2]; int64_t sum[2] = {}, c[2]={};
signed main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    v.pb(x);
  }
  auto it = max_element(v.begin(), v.end());
  if(*it <= 0){
	  cout << *it << endl << n-1 << endl;
	  for(int i = n; i > it-v.begin()+1;i--)cout << i << endl;
	  while(it != v.begin())cout << 1 << endl, it--;
  		return 0;
  }

  for(int i = 0; i < n; i++){
    int x = v[i];
    if(x > 0)sum[i%2]+=x;
    else o[i%2].pb(i), c[i%2]++;
    a[i%2].pb(i-c[1-i%2]*2);
  }
  int xx = sum[0] > sum[1];
  //cout << o[1^xx].size() << endl;
  bool jizz = xx && (v[1^xx] <= 0);
  a[xx].erase(unique(a[xx].begin(), a[xx].end()), a[xx].end());
  cout << sum[1^xx] << endl << (a[xx].size()+o[1^xx].size()) << endl;
  for(int i = o[1^xx].size()-1; i >= 0; i--)cout << o[1^xx][i]+1 << endl;
  for(int i = a[xx].size()-1; i >= 0; i--)cout << a[xx][i]+1+jizz << endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    vector<int> l;
    int tmp;
    cin >> n;
    rep(i, n){
        cin >> tmp;
        l.push_back(tmp);
    }

    sort(l.begin(), l.end());
    ll res = 0;
    rep(i, n-1){
        reps(j, i+1, n){
            auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
            int ind = distance(l.begin(), itr);
            res += ind-(j+1);
        }
    }

    cout << res << endl;

    return 0;
}


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

int main(){

    int isThere=false;

    int k , a , b;
    cin>>k>>a>>b;

    for(int i=a;i<=b;i++){
        if(i%k==0){
            isThere=true;
            break;
        }
    }

    if(isThere) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
    // (m + n) C 2 - m C 1 * n C 1
    int m, n;
    cin >> m >> n;
    cout << (m + n) * (m + n - 1) / 2 - m * n << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut q2: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    // let mut cnt = 1;
    while !rems.is_empty() {
        q2.pop_front();
        while let Some(s_idx) = q.pop_front() {
            r2.remove(&s_idx);
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = r2.iter().next() {
            q2.push_back(r);
        }
    }
    // if cnt > 1e18 as usize{
    //     println!("{}", "hoge");
    // }
    println!("{}", ans);
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int ruiseki[100005];
bool sosu_bool[100005];
bool sosu_judge(int n)
{
    bool res = true;
    for (int i = 2; i*i <= n; i++)
    {
        if(n%i==0)
        {
            res = false;
            break;
        }
    }
    return res;
}
int main()
{
    int q;cin >>q;
    vector<int> l(q);
    vector<int> r(q);
    rep(i,q)
    {
        cin >> l[i] >> r[i];
    }
    for (int i = 2; i <=100005; i++)
    {
        sosu_bool[i] = sosu_judge(i);
    }
    int temp = 0;
    for (int i = 2; i <= 100005; i++)
    {
        if(i%2==0)
        {
            ruiseki[i] = temp;
            continue;
        }
        if(sosu_bool[i] && sosu_bool[(i+1)/2])
        {
            temp++;
            
        }
        ruiseki[i] = temp;
    }
 

    rep(i,q)
    {
        cout << ruiseki[r[i]]-ruiseki[l[i]-1] << endl;
    }
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lint;
int const N=2e5+10;
int const S=1<<19;
int n,V;
lint d[N];
int logV,a[25][N];
int U,f1[S],f2[S];
int upFind(int a[],int x)
{
    int L=1,R=a[0];
    while(L<R-1)
    {
        int mid=(L+R)>>1;
        if(a[mid]<=x) L=mid+1;
        if(a[mid]>x) R=mid;
    }
    if(a[L]>x) return a[L];
    else return a[R];
}
int lowFind(int a[],int x)
{
    int L=1,R=a[0];
    while(L<R-1)
    {
        int mid=(L+R)>>1;
        if(a[mid]<x) L=mid;
        if(a[mid]>=x) R=mid-1;
	}
    if(a[R]<x) return a[R]+1;
    else return a[L]+1;
}
int main()
{
    scanf("%d%d",&n,&V);
    logV=0;
    while((1<<logV)<=V) logV++;
    logV++;
    for(int i=1;i<=n;i++) scanf("%lld",&d[i]),d[i-1]=d[i]-d[i-1];
    d[n]=0;
    for(int i=1;i<=logV;i++)
    {
        a[i][0]=1;
        for(int j=1;j<=n;j++)
        {
            a[i][a[i][0]]=j;
            if(d[j]>(V>>(i-1))) a[i][0]++;
        }
    }
    if(a[1][0]>logV)
    {
        for(int i=1;i<=n;i++) puts("Impossible\n");
        return 0;
    }
    U=(1<<logV)-1;
    for(int s=0;s<=U;s++) f1[s]=0,f2[s]=n+1;
    for(int s=0;s<=U;s+=2)
        for(int i=2;i<=logV;i++)
        {
            int s0=1<<(i-1);
            if(s&s0) continue;
            f1[s|s0]=max(f1[s|s0],upFind(a[i],f1[s]));
            f2[s|s0]=min(f2[s|s0],lowFind(a[i],f2[s]-1));
        }
    for(int i=1;i<=a[1][0];i++)
    {
        bool f=false;
        int fr=a[1][i-1]+1,to=a[1][i];
        if(i==1) fr=1;
        for(int s=0;s<=U&&!f;s+=2)
            if(fr<=f1[s]+1&&f2[U-s-1]-1<=to) f=true;
        if(f) for(int j=fr;j<=to;j++) puts("Possible\n");
        else for(int j=fr;j<=to;j++) puts("Impossible\n");
    }
    return 0;
}

Measured memory_bytes: 25728
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <climits>
#include <limits>
#include <queue>
#include <utility>

using namespace std;



#define ll long long

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

		sort(prices.begin(), prices.end());

		int sum = 0;
		for (int i = 0; i < k; i++) {
			sum += prices[i];
		}

		cout << sum << endl;
	}




Measured memory_bytes: 3588
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1)return dp[n] = 1;
  if(dp[n] != -1)return dp[n];
  return dp[n] = fib(n-1) + fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
typedef long long ll;
#define intv vector<int>
#define llv vector<long long>
#define intvv vector<vector<int>>
#define llvv vector<vector<long long>>
using namespace std;


int main(){
    int n;
    cin >> n;
    llv a(100000);
    rep(i, n) cin >> a[i];
    llv l(100000), r(100000);
    l[0] = 0;
    r[n] = 0;
    rep(i, n){
        l[i+1] = __gcd(l[i], a[i]);
    }
    irep(i, n){
        r[i] = __gcd(r[i+1], a[i]);
    }
    ll ans = 0;
    int j = 0;
    while( j <= n-1){
        ans = max(ans, __gcd(l[j], r[j+1]));
        j++;
    }
    cout << ans << endl;
}


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

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

int main(void){
    int n, k;

    cin >> n >> k;

    double ans = 0;

    rep(i, n){
        double ans_tmp = 0;
        ans_tmp += 1.0 / (double)n;
        for(int j = i + 1; j < k; j *= 2){
            ans_tmp *= 1.0 / 2.0;
        }
        ans += ans_tmp;
    }

    printf("%.15f", ans);
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

S = stdin.readline().rstrip().split()[0]
T = stdin.readline().rstrip().split()[0]

count = 0
maxc = 0
for i in range(len(S) - len(T) + 1):
    for j,t in enumerate(T):
        if t == S[i + j]:
            count += 1
    if count >= maxc:
        maxc = count
    count = 0
print(len(T) - maxc)

Measured memory_bytes: 9132
//
// Created by yamunaku on 2020/03/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> str(N);
  
  for(int i=0;i<N;i++){
    cin >> str[i];
  }
  
  sort(str.begin(),str.end());
  
  string ans;
  for(auto x : str){
    
   ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        for(int i=0;i<3;i++){
            if(s1.charAt(i)!=s2.charAt(2-i)){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");

    }
}

Measured memory_bytes: 21588
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s.size() % 2)
	{
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < s.size(); i += 2)
	{
		if (s.substr(i, 2) != "hi")
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    fastIO
    string s;
    cin >> s;
    
    if(s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";

    return 0;
}



Measured memory_bytes: 3572
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let hh: usize = sc.read();
    let ww: usize = sc.read();
    let h: usize = sc.read();
    let w: usize = sc.read();
    if hh % h == 0 && ww % w == 0 {
        println!("No");
    } else if hh % h == 0 {
        sc.write("Yes\n");
        let ans = solve(ww, w);
        for _ in 0..hh {
            for i in 0..ww {
                if i > 0 {
                    sc.write(" ");
                }
                sc.write(ans[i].to_string());
            }
            sc.write("\n");
        }
    } else {
        sc.write("Yes\n");
        let ans = solve(hh, h);
        for i in 0..hh {
            for j in 0..ww {
                if j > 0 {
                    sc.write(" ");
                }
                sc.write(ans[i].to_string());
            }
            sc.write("\n");
        }
    }
}

fn solve(hh: usize, h: usize) -> Vec<i64> {
    // sum[hh] - sum[hh-h] < 0
    // sum[i+h] < sum[i]
    // sum[hh] > 0
    // sum[0] = 0
    let mut sum: Vec<i64> = vec![0; hh + 1];
    sum[hh] = 1;
    for i in (0..hh).rev() {
        if (hh - i) % h == 0 && i + h <= hh {
            sum[i] = sum[i + h] + 1;
        }
    }
    for i in 0..hh {
        if i + h <= hh {
            sum[i + h] = sum[i] - 1;
        }
    }
    let mut a = vec![0; hh];
    for i in 0..hh {
        a[i] = sum[i + 1] - sum[i];
    }
    a
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5372
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp((1 << V), vector<int>(V, INF));
	dp[(1 << V) - 1][0] = 0;
	for (int bits = (1 << V) - 1 - 1; bits >= 0; bits--) {
		rep(i, 0, V)rep(j, 0, V)
			if (!(bits&(1 << j)))
				chmin(dp[bits][i], dp[bits | (1 << j)][j] + G[i][j]);

	}
	cout << (dp[0][0]==INF?-1:dp[0][0]) << endl;
	return 0;
}

Measured memory_bytes: 6232
fun main(args: Array<String>){
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toInt()}
    var temp = n - 1
    var count = 0
    while(temp > 0){
        temp -= k - 1
        count += 1
    }
    println(count)
}

Measured memory_bytes: 47884
def add(l1,s1,s2):
	plus=s1+s2
	if plus in l1:
		return
	l1.append(plus)
	#print tui," ADD!!"
	#print tui


num=int(raw_input())


for i in range(num):
	l1=[]
	word=raw_input()


	n=1
	while n<len(word):

		s1=word[0:n]
		s2=word[n:]

		add(l1,s1,s2)
		add(l1,s1[::-1],s2)
		add(l1,s1,s2[::-1])
		add(l1,s1[::-1],s2[::-1])
		add(l1,s2,s1)
		add(l1,s2[::-1],s1)
		add(l1,s2,s1[::-1])
		add(l1,s2[::-1],s1[::-1])
		#print
		

		n+=1


	print len(l1)

Measured memory_bytes: 4252
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const int MAXN = 1001;
const int MAXV = MAXN * MAXN;

int id_map[MAXN][MAXN];
int num_v;
void init_id_map(int n)
{
    num_v = 0;
    rep(i, 0, n)
        rep(j, 0, n)
        if (i < j)
        {
            id_map[i][j] = num_v;
            ++num_v;
        }
}

int get_id(int i, int j)
{
    if (i > j) swap(i, j);
    return id_map[i][j];
}


int day[MAXV];
int active[MAXV];
vector<int> to_graph[MAXV];
int dfs(int i)
{
    if (day[i] > 0)
        return day[i];
    
    if (active[i])
        return -1;
    active[i] = 1;
    int d = 1;
    for (auto next: to_graph[i])
    {
        int prev = dfs(next);
        if (prev == -1)
            return -1;
        d = max(d, prev + 1);
    }    
    day[i] = d;
    return d;
}

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

    init_id_map(n);

    vector<vector<int>> a(n, vector<int>(n - 1));
    rep(i, 0, n)
        rep(j, 0, n - 1)
        {
            cin >> a[i][j];
            --a[i][j];
        }
    rep(i, 0, n)
        rep(j, 0, n - 2)
        {
            int from, to;
            from = get_id(i, a[i][j]);
            to = get_id(i, a[i][j + 1]);
            to_graph[from].push_back(to);
        }

    int ans = 0;
    rep(i, 0, num_v)
    {
        int cand = dfs(i);
        if (cand == -1)
        {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, cand);
    }
    cout << ans << endl;
    return 0;
}

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

int z(int x)
{
  if(x<0)
    return x*-1;
  else
    return x;
}

int main()
{
  int a,b,h,m;
  double rad,ans;
  cin>>a>>b>>h>>m;
  rad=z(h*60-m*11)*M_PI/360;
  cout<<fixed<<setprecision(15);
  cout<<sqrt(a*a+b*b-2*b*a*cos(rad))<<endl;
}

Measured memory_bytes: 4108