akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	for (auto& x : A) cin >> x;
	if (N <= 3) {
		cout << *max_element(A.begin(), A.end()) << endl;
		return 0;
	}
	ll res = 0;
	for (int i = 1; i < N; i += 2) res += A[i];

	vector<map<int,ll>> a(N);
	a[0][1] = A[0];
	a[1][1] = A[1];
	int n = N/2;
	for (int i = 2; i < N; ++ i) {
		map<int, ll> aa;
		if (i == 2) aa[1] = A[i];
		for (int j = i-4; j <= i-2; ++ j) if (j >= 0) {
			for (auto p : a[j]) {
				int k = p.first + 1;
				if (k < i/2-2) continue;
				if (!aa.count(k)) {
					aa[k] = p.second + A[i];
					if (k == n) res = max(res, aa[k]);
				} else {
					aa[k] = max(aa[k], p.second + A[i]);
					if (k == n) res = max(res, aa[k]);
				}
			}
		}
		a[i] = aa;
	}
	cout << res << endl;
}


Measured memory_bytes: 64248
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, M, count = 0, A1, ans;
    cin >> N >> M;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    A1 = A.at(0);
    for (int i = 0; A1 % 2 == 0; i++) {
        A1 /= 2;
        count = i + 1;
    }
    if (count == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        if (A.at(i) % int64_t(pow(2,count)) != 0 || (A.at(i) / int64_t(pow(2,count))) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
        A.at(i) /= 2;
        if (i == 0) {
            ans = A.at(i);
        }
        else {
            ans = ans * A.at(i) / __gcd(ans, A.at(i));
        }
    }
    int64_t Ans = M / ans;
    cout << (Ans + 1) / 2 << endl;




}



Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stack>
using namespace std;
int a[300005];
bool cmp(int x,int y)
{
	if(x>y)
	return true;
	else
	return false;
}
int main()
{
	int n,i,m;
	long long int sum;
    while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<3*n;i++)
		scanf("%d",&a[i]);
		sort(a,a+3*n,cmp);
		sum=0;m=n;
		for(i=0;i<3*n;i++)
		{
			if((i+1)%2==0)
			{
				sum+=a[i];
				m--;
			}
			if(!m)
			break;
		}
		printf("%lld\n",sum);
	}
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define PB push_back
#define LL long long
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int a[105];
map<int , int> m;
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		m[a[i]]++;
	}
	sort(a , a + n);
	int diam = a[n - 1];
	if(a[0] < (diam + 1) / 2)
	{
		cout << "Impossible";
		return 0;
	}
	for(int i = (diam + 1) / 2; i <= diam; i++)
	{
		if(i == diam / 2)
		{
			m[i]--;
			if(m[i] < 0)
			{
				cout << "Impossible";
				return 0;
			}
		}
		else
		{
			m[i] -= 2;
			if(m[i] < 0)
			{
				cout << "Impossible";
				return 0;
			}
		}
	}
	if(m[(diam + 1) / 2])
	{
		cout << "Impossible";
		return 0;
	}
	cout << "Possible";
}

Measured memory_bytes: 256
line1 = input()
line2 = input()
price, k = line1.split(" ")
num = line2.split(" ")
ans = ""

for i in range(int(price),100000):
    num2 = [str(x) for x in str(i)]
#     print(len(set(num)&set(num2)))
    if len(set(num)&set(num2))==0:
        print(i)
        break
        

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, h, w;
    cin >> n >> h >> w;
    
    cout << (n - h + 1) * (n - w + 1) << endl;
}


Measured memory_bytes: 256
//API???????????????
import java.util.Scanner;
class Main{
      	public static void main(String[] args){
	//???????????\???
    	Scanner scan = new Scanner(System.in);
    	//???????????´??°?????????????????£??\
    	int n = scan.nextInt();
    	int a;
    	int min = 0;
    	int max = 0;
	//?????????long????????????????????£??\
    	long sum = 0;
    	
	//n??????????????????????????§??°?????????
    	for(int i = 0; i < n; i++){
    	    a = scan.nextInt();
    	    if(i == 0) {
    	    	min = a;
    	    	max = a;
    	    }
	    if(min > a){
		min = a;
	    }
    	    //min = Math.min(min, a);
	
	    if(max < a){
		max = a;
	    }
    	    //max = Math.max(max, a);
    	    sum += a;
    	}
    	//????????????
    	System.out.println(min + " " + max + " " + sum);
    	
     }
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    string str;
    cin >> str;
    if(n%2 == 1) cout << "No" << endl;
    else {
        string s1 = str.substr(0, n/2);
        string s2 = str.substr(n/2, n);
        if(s1 == s2) cout << "Yes" <<endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let n = parse_line::<usize>();
    let a = parse_values::<usize>(n);
    let mut result = true;
    for item in a {
        if item % 2 == 0 && item % 3 != 0 && item % 5 != 0 {
            result = false;
        }
    }
    if result {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}

/// Parse line from io::stdin into T Value
fn parse_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

/// Parse whitespace split into T values from io::stdin
fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        double r = sc.nextDouble();
 
        System.out.printf("%.10f %.10f\n",r*r*Math.PI,(2*r)*Math.PI);
    }
}


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

#define ll long long
#define str string

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

vector <ll> v;
ll Y[10000000] = {}, X[10000000] = {},m = 0,a = 0,b = 0,n = 0, x = 0,y = 0,sum = 0;
str H[100][100] = {};
str S,Sa;
bool ans = true;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
		//Code Line
cin >> x;
for(int i = 9;i <= x;i += 2){
	int e = 0;
for(int j = 1;j <= x / 2;j++){
if(i % j == 0)e++;

}
if(e + 1 == 8)a++;
}
cout << a << endl;
		//Code Line
return 0; 
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
//i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> a;
//vector <i64> b;
//vector <i64> dp;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);


    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        i64 h, w;
        cin >> h >> w >> m;

        vector<i64> hor;
        hor.assign(h+1, 0);

        vector<i64> ver;
        ver.assign(w+1, 0);

        set<pair<i64, i64>> sx;

        for (i64 i = 0; i < m; ++i) {
            i64 hi, wi;
            cin >> hi >> wi;
            sx.emplace(hi, wi);
            hor[hi] += 1;
            ver[wi] += 1;
        }

        i64 max1 = 0;
        for (i64 i = 1; i <= h; ++i) {
            if (hor[i] > max1) {
                max1 = hor[i];
            }
        }
        vector<i64> hind;
        for (i64 i = 1; i <= h; ++i) {
            if (hor[i] == max1) {
                hind.push_back(i);
            }
        }


        i64 max2 = 0;
        for (i64 i = 1; i <= w; ++i) {
            if (ver[i] > max2) {
                max2 = ver[i];
            }
        }
        vector<i64> vind;
        for (i64 i = 1; i <= w; ++i) {
            if (ver[i] == max2) {
                vind.push_back(i);
            }
        }

        i64 res = max1 + max2;
        if (min(max1, max2)) {
            res -= 1;
        }

        bool fl = true;
        for (auto hi : hind) {
            if (!fl) {
                break;
            }
            for (auto vi : vind) {
                if (sx.count({ hi, vi }) == 0) {
                    res += 1;
                    fl = false;
                    break;
                }
            }
        }

        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 34580
"""

https://atcoder.jp/contests/agc034/tasks/agc034_c

cをどうやって決めるか考える
差分で考えることとする
負けることにする場合、cが大きいほど負けがかさむので l
そうでない場合、重要度を uにするべき

勝ちを増やす or 負けを減らすの、どっちの方が良い…？

bが小さいほうを勝ち、大きいほうを負けにした方がいい説
bが小さいほうで負け、大きいほうで勝つ場合を考えてみる
a1 < b1 < b2 < a2 とする。
この時、寄与は (a2-b2)*u2-(b1-a1)*l1 = X
aの値を交換してみると、寄与は
(a2-b1)*u1 - (b2-a1) * l2 = Y
となる。
Y-X = 
となり改善するので示された

bが小さいほうからi個を勝ちにする場合の最小を考えればいい
→あとは全探索すれば終わり

うわー luは固定じゃないんかい
とりあえず勝ち負けを決めた場合のスコア計算を考えてみる
最初全部負けで考え、損失の和Pを計算しておく→Σbi*li
N個のコインタワーがあり、上からbi個の価値はli、残りはuiである
Pを超える価値を取るための最小の枚数を求めよ
上を取っておいて下を取らない意味がないので、取ると決めたら山全部取るのが最適
→山の総和が大きい順にソート
→最大の山を全部取っても足りない場合、取りつくす
→最後の1山は残りから全探索する

なぜWA?
分からん…
山を上からとらない理由がない

4,4,93 →和101
2,2,96 →和100
104
→大きいほうからとっていいなんてことはなかった
→総和が大きい山を必ずすべて使うという未証明命題を使おうとしたのが敗因

"""

from sys import stdin

N,X = map(int,stdin.readline().split())

P = 0
sblu = [] #山の総和s,b,l,u

for i in range(N):
    b,l,u = map(int,stdin.readline().split())
    s = b * l + (X-b) * u
    P += b * l
    sblu.append((s,b,l,u))

sblu.sort()
sblu.reverse()

ans = float("inf")
slis = []
for i in range(N):
    if i == 0:
        slis.append(sblu[i][0])
    else:
        slis.append(slis[-1] + sblu[i][0])

for i in range(N): #iは中途半端に取る場所

    #iも含めた和がPを超える最小のindexを求める
    L = -1
    R = N-1
    while R-L != 1:
        
        M = (R+L)//2
        if M < i:
            if slis[M] + sblu[i][0] >= P:
                R = M
            else:
                L = M
        else:
            if slis[M] >= P:
                R = M
            else:
                L = M

    if R < i:
        rem = P - slis[R]
        nans = X * (R+1)
    else:
        rem = P - (slis[R]-sblu[i][0])
        nans = X * R

    if rem < 0 or sblu[i][0] < rem:
        continue

    s,b,l,u = sblu[i]
    if rem <= b*l:
        nans += (rem+l-1) // l
    else:
        rem = rem - b * l
        nans += b + (rem+u-1)//u

    ans = min(ans,nans)

print (ans)
    
    


Measured memory_bytes: 96436
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] s = new int[3];
		int sum=0;
	        for(int i=0 ; i<3 ; i++) {
	        	do {
	        	s[i] = stdIn.nextInt();
	        	}while(s[i]<1||s[i]>14);
        	sum += s[i];
        }
	        if(sum>=22) {
	        	System.out.println("bust");
	        }else {
	        	System.out.println("win");
	        }
	}
}


Measured memory_bytes: 23380
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;

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

	cin >> N;
	if (N & 1) {
		cout << "NA\n";
		return 0;
	}
		vector<pair<double, double>>v(N);
		for (auto &i : v)cin >> i.first >> i.second;
		for (int i = 0; i < N / 2; i++) {
			if (v[i].first + v[i + N / 2].first != v[0].first + v[N / 2].first|| v[i].second + v[i + N / 2].second != v[0].second + v[N / 2].second) {
				cout << "NA\n";
				return 0;
			}
		}
		cout <<setprecision(20)<< (v[0].first + v[N / 2].first) / 2 << " " << (v[0].second + v[N / 2].second) / 2 << endl;
}



Measured memory_bytes: 3296
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

const int N=2005;
const int inf=1000000000;

int n,mn,sm,cnt,m,mx,ans;
int ls[N],rs[N],a[N],b[N],pk[N],c[N];
char s1[N],s2[N];

void init(){
	int i,j;
	for (i=1;i<=n;i++){
		for (j=i;;){
			if (b[j]) break;
			j--; ls[i]++;
			if (!j) j=n;
		}
		for (j=i;;){
			if (b[j]) break;
			j++; rs[i]++;
			if (j>n) j=1;
		}
	}
}

bool cmp1(int x,int y){
	return ls[x]<ls[y];
}

bool cmp2(int x,int y){
	return rs[x]<rs[y];
}

int main(){
	int i,j,k;
	scanf("%s",s1+1);
	scanf("%s",s2+1); n=strlen(s1+1);
	for (i=1;i<=n;i++) a[i]=s1[i]-'0';
	for (i=1;i<=n;i++) b[i]=s2[i]-'0';
	for (i=1;i<=n;i++) cnt+=b[i];
	if (!cnt){
		for (i=1;i<=n;i++) cnt+=a[i];
		if (cnt) printf("-1\n");
		else printf("0\n");
		return 0;
	}
	init();
	ans=inf;
	for (i=1;i<=n;i++){
		memset(pk,0,sizeof(pk));
		if (i==1) cnt=0;
		else cnt=n-i+1;
		k=i; sm=0; mn=inf; mx=0; m=0;
		for (j=1;j<=n;j++){
			if (a[j]!=b[k]) pk[j]=1,sm++;
			k++;
			if (k>n) k=1;
		}
		for (j=1;j<=n;j++) if (pk[j]&&ls[j]>cnt) c[++m]=j;
		sort(c+1,c+1+m,cmp1);
		if (!m) ans=min(ans,sm+cnt);
		else{
			mn=min(mn,ls[c[m]]*2+cnt);
			for (j=m;j>1;j--){
				mx=max(mx,rs[c[j]]);
				mn=min(mn,ls[c[j-1]]*2-cnt+mx*2);
			}
			mx=max(mx,rs[c[1]]);
			mn=min(mn,mx*2+cnt);
			ans=min(ans,mn+sm);
		}
	}
	for (i=1;i<=n;i++){
		memset(pk,0,sizeof(pk));
		cnt=i-1;
		k=i; sm=0; mn=inf; m=0; mx=0;
		for (j=1;j<=n;j++){
			if (a[j]!=b[k]) pk[j]=1,sm++;
			k++;
			if (k>n) k=1;
		}
		for (j=1;j<=n;j++) if (pk[j]&&rs[j]>cnt) c[++m]=j;
		sort(c+1,c+1+m,cmp2);
		if (!m) ans=min(ans,sm+cnt);
		else{
			mn=min(mn,rs[c[m]]*2+cnt);
			for (j=m;j>1;j--){
				mx=max(mx,ls[c[j]]);
				mn=min(mn,rs[c[j-1]]*2-cnt+mx*2);
			}
			mx=max(mx,ls[c[1]]);
			mn=min(mn,mx*2+cnt);
			ans=min(ans,mn+sm);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void){
	int t,c,i,r,cc[31],team[100];
	for(i=0;i<31;i++)cc[i]=0;
	while(scanf("%d,%d",&t,&c)){
		if(t==0 && c==0)break;
		team[t-1]=c;
		cc[c]=1;
	}
	r=1;
	for(i=30;i>=0;i--){
		if(cc[i]==1)cc[i]=r++;
		//printf("%d,%d\n",i,cc[i]);
	}
	while(scanf("%d",&t)!=EOF){
		printf("%d\n",cc[team[t-1]]);
	}
	return 0;
}

Measured memory_bytes: 600
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

co = 0
cco = 0

for i in range(1,1000):
    co += 105
    cco += 1
    if n <= co:
        break

kkk = co - n

if kkk == 0:
    print(1)
else:
    if kkk <= cco * 5:
        print(1)
    else:
        print(0)






Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    vector<int> v(3);
    for(int i=0; i<3; ++i)
        cin >> v[i];

    sort(v.begin(), v.end());
    if(v[0] == v[1])
        cout << v[2] << endl;
    else
        cout << v[0] << endl;

    return 0;
}


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

int main(){
    vector<string> a(21);
    int l;
    while(cin>>a[0]>>l,l){
            while(a[0].length()!=l)
            a[0]="0"+a[0];
        for(int i=1;i<21;i++){
            string b=a[i-1];
            int x=0;
            sort(b.begin(),b.end(),greater<char>());
            x=stoi(b);
            sort(b.begin(),b.end());
            x-=stoi(b);
            a[i]=to_string(x);
                     while(a[i].length()!=l)
                     a[i]="0"+a[i];



        }
        int resi,resj;
        for(int i=0;i<21;i++)
            for(int j=0;j<i;j++)
                if(a[i]==a[j]){
                    resi=i;
                    resj=j;
                    goto aa;



                }
        aa: cout<<resj<<" "<<stoi(a[resj])<<" "<<resi-resj<<endl;
    }

    return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e5+10;
string s[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s[i],sort(s[i].begin(),s[i].end());
    sort(s+1,s+n+1);
    ll sum=0;
    int now=1;
    for(int i=1;i<=n;i++){
        if(s[i]==s[i-1])now++;
        else{
            sum+=now*1ll*(now-1)/2;
            now=1;
        }
    }
    sum+=now*1ll*(now-1)/2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<cstring>
#include<stack>
using namespace std;
stack<char>st;
int main()
{
	char s[1005],tmp[1005],tmp1[1005],tmp2[1005];
	scanf("%s",s);
	int n=strlen(s);
	for(int i=n;i>=1;i--)
	{
		s[i]=s[i-1];
		//printf("%c",s[i]);
		tmp[n-i+1]=s[i];
	}
	//printf("\n");
	for(int i=1;i<=n;i++)
	{
		if(s[i]!=tmp[i])
		{
			printf("No\n");
			return 0;
		}
	}
	for(int i=1;i<=(n-1)/2;i++)
	{
		tmp2[i]=s[(n-1)/2-i+1];
	}
	for(int i=1;i<=(n-1)/2;i++)
	{
		if(s[i]!=tmp2[i])
		{
			printf("No\n");
			return 0;
		}
	}
	for(int i=(n+3)/2;i<=n;i++)
	{
		tmp1[i]=s[n-i+(n+3)/2];
	}
	for(int i=(n+3)/2;i<=n;i++)
	{
		if(tmp1[i]!=s[i])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
} 

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

public class Program
{

    public void Proc()
    {
        int inputCount = int.Parse(Reader.ReadLine());
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long ans = Math.Abs(inpt.Max() - inpt.Min());
        Console.WriteLine(ans);
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



2
1000000000 1




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    string O, E;
    
    cin >> O >> E;
    
    if (O.size() == E.size()) {
        for (int i = 0; i < O.size(); i++) {
            cout << O[i] << E[i];
        }
        cout << endl;
    } else {
        for (int i = 0; i < E.size(); i++) {
            cout << O[i] << E[i];
        }
        cout << O[O.size() - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(222222);
int lo[N], hi[N], a[N], b[N];
int modulo(1e9 + 7);
int main() {
	int n;
	cin >> n;
	for(int i(0); i < n; i++) {
		cin >> a[i];
	}
	for(int i(0); i < n; i++) {
		cin >> b[i];
	}
	for(int i(0); i < n; i++) {
		lo[i] = 1;
		hi[i] = 1e9 + 1;
		if(i == 0 || a[i] != a[i - 1]) {
			lo[i] = max(lo[i], a[i]);
			hi[i] = min(hi[i], a[i]);
		}else {
			hi[i] = min(hi[i], a[i]);
		}
	}
	int ans(1);
	for(int i(n - 1); i >= 0; i--) {
		if(i == n - 1 || b[i] != b[i + 1]) {
			lo[i] = max(lo[i], b[i]);
			hi[i] = min(hi[i], b[i]);
		}else {
			hi[i] = min(hi[i], b[i]);
		}
		ans = (long long)ans * max(0, hi[i] - lo[i] + 1) % modulo;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
use proconio::input;
use proconio::marker::Chars;
use std::cmp::{max, min};
const alpha: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

const Alpha: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(a: usize);
    println!("{}", a + a * a + a * a * a);
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n=0;
      cin>>n;
  
      unsigned long long ans=0;
    int count =n;
      
      int i=1;
      while(count--)
    {
      if(i%3!=0 && i%5!=0)
      {
        ans+=i;
        
      }
      i++;
      
    }
  
  cout<<ans<<endl;
      

    
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e5+10;
int w,h,n;
int dx[maxn],dy[maxn];
struct point{int x,y;}p[maxn];
int uplim[maxn],dwlim[maxn];
int sor[maxn],top;
int ustk[maxn],ucnt=0;
int dstk[maxn],dcnt=0;
int Max[maxn<<2],tag[maxn<<2];
int Ans=0;
void pushup(int rt){Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);}
void pushdown(int rt)
{
	if(!tag[rt])return;
	Max[rt<<1]+=tag[rt],Max[rt<<1|1]+=tag[rt];
	tag[rt<<1]+=tag[rt],tag[rt<<1|1]+=tag[rt];
	tag[rt]=0;
}
void build(int rt,int l,int r)
{
	tag[rt]=0,Max[rt]=0;
	if(l==r)return;
	int mid=l+r>>1;
	build(rt<<1,l,mid);
	build(rt<<1|1,mid+1,r);
}
void update(int rt,int l,int r,int L,int R,int v)
{
	if(L==0)L++;
	if(L<=l&&r<=R){Max[rt]+=v,tag[rt]+=v;return;}
	int mid=l+r>>1;
	pushdown(rt);
	if(L<=mid)update(rt<<1,l,mid,L,R,v);
	if(R>mid)update(rt<<1|1,mid+1,r,L,R,v);
	pushup(rt);
}
int query(int rt,int l,int r,int L,int R)
{
	if(L<=l&&r<=R)return Max[rt];
	int mid=l+r>>1,ans=0;
	pushdown(rt);
	if(L<=mid)ans=max(ans,query(rt<<1,l,mid,L,R));
	if(R>mid)ans=max(ans,query(rt<<1|1,mid+1,r,L,R));
	return ans;
}
void solve()
{
	top=0;
	for(int i=1;i<=n;i++)p[i].x=dx[i],p[i].y=dy[i],sor[++top]=p[i].y;
	sort(sor+1,sor+1+top);
	top=unique(sor+1,sor+1+top)-sor-1;
	for(int i=1;i<=n;i++)p[i].y=lower_bound(sor+1,sor+1+top,p[i].y)-sor;
	for(int i=1;i<=top;i++)uplim[i]=0,dwlim[i]=w;
	for(int i=1;i<=n;i++)
	{
		if(p[i].x<=w/2)uplim[p[i].y]=max(uplim[p[i].y],p[i].x);
		else dwlim[p[i].y]=min(dwlim[p[i].y],p[i].x);
	}
	ucnt=dcnt=0;
	build(1,1,top);
	for(int i=1;i<=top;i++)
	{
		//cout<<uplim[i]<<' '<<dwlim[i]<<' '<<sor[i]<<endl;
		if(i!=1)
		{
			update(1,1,top,i-1,i-1,w*2-sor[i-1]*2);
			Ans=max(Ans,query(1,1,top,1,i-1)+sor[i]*2);
			//cout<<Ans<<endl;
			update(1,1,top,i-1,i-1,(dwlim[i]-uplim[i])*2-w*2);
		}
		while(uplim[ustk[ucnt]]<uplim[i]&&ucnt>1)update(1,1,top,ustk[ucnt-1],ustk[ucnt]-1,-(uplim[i]-uplim[ustk[ucnt]])*2),ucnt--;
		ustk[++ucnt]=i;
		while(dwlim[dstk[dcnt]]>dwlim[i]&&dcnt>1)update(1,1,top,dstk[dcnt-1],dstk[dcnt]-1,-(dwlim[dstk[dcnt]]-dwlim[i])*2),dcnt--;		
		dstk[++dcnt]=i;
		
	}
}
int main()
{
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&dx[i],&dy[i]);
	dx[++n]=0,dy[n]=0;
	dx[++n]=w,dy[n]=h;
	solve();
	for(int i=1;i<=n;i++)swap(dx[i],dy[i]);
	swap(w,h);
	solve();
	printf("%d\n",Ans);
}

Measured memory_bytes: 25984
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
res=1
cnt=[0]*3
for i in range(N):
    res=res*cnt.count(A[i])%MOD
    for j in range(3):
        if cnt[j]==A[i]:
            cnt[j]+=1
            break
print(res)

Measured memory_bytes: 20748
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll cnt[110];

int main(){
    /*
        75 = 3 * 5 * 5
        yakusu = (2, 4, 4), (2, 24), (4, 14)
    */
    int n;
    cin >> n;
    REP(i, 2, n+1) {
        ll x = i;
        for(ll y = 2; y*y <= x; ++y) {
            while(x%y==0) {
                x /= y;
                ++cnt[y];
            }
        }
        if(x != 1) ++cnt[x];
    }
    ll ans = 0;
    REP(i, 2, 110) REP(j, 2, 110) REP(k, 2, j) {
        if(i == j || j == k || k == i || cnt[i] < 2 || cnt[j] < 4 || cnt[k] < 4) continue;
        ans++;
        // cout << i << " " << j << " " << k << endl;
    } 
    REP(i, 2, 110) REP(j, 2, 110) {
        if(i == j || cnt[i] < 2 || cnt[j] < 24) continue;
        ans++;
        // cout << i << " " << j << endl;
    }
    REP(i, 2, 110) REP(j, 2, 110) {
        if(i == j || cnt[i] < 4 || cnt[j] < 14) continue;
        ans++;
        // cout << i << " " << j << endl;
    }
    REP(i, 2, 110) {
        if(cnt[i] >= 74) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

def PrimeJudge(a):
    if a == 2:
        return 1
    if a < 2 or a % 2 ==0:
        return 0
    i = 3
    while i <= int(math.sqrt(a)):
        if a % i == 0:
            return 0
        i += 2
    return 1

count = 0
for i in range(n):
    if PrimeJudge(A[i])==1:
        count += 1
print(count)



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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;

	vector<pair<int, int>> ans;
	if(N%2){
		for(int i=0; i<N/2; i++){
			ans.push_back({i+1, N-i-1});
		}
	} else {
		set<int> diff;
		int k=0;
		for(int i=0; i<N/2-1; i++){
			while(true){
				if(diff.count(2*i+k+1)==0&&2*(N-2*i-k-1)!=N) break;
				k++;
			}
			ans.push_back({i+1, N-i-k});
			diff.insert(N-2*i-k-1);
		}
	}

	for(int i=0; i<M; i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}

	return 0;
}


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

int main() 
{
    long N;
    cin >> N;
    vector <long> H(N);
    for(int i = 0; i < N; i++)
        cin >> H[i];

    int move_count = 0;
    int move_max_count = 0;

    for(int i = 0; i < N - 1; i++)
    {
        if(H[i] >= H[i + 1])
            move_count++;
        else
        {
            move_max_count = max(move_max_count, move_count);
            move_count = 0;
        }        
    }
    move_max_count = max(move_max_count, move_count);


    cout << move_max_count << endl;

    return 0;  

}

Measured memory_bytes: 1024
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};
macro_rules! max {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: max ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: max ($ a , max ! ($ ($ rest ) ,+ ) ) } } ; }
macro_rules! min {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr $ (, ) * ) => {{std :: cmp :: min ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: min ($ a , min ! ($ ($ rest ) ,+ ) ) } } ; }
macro_rules! chmin {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_min = min ! ($ ($ cmps ) ,+ ) ; if $ base > cmp_min {$ base = cmp_min ; true } else {false } } } ; }
macro_rules! chmax {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_max = max ! ($ ($ cmps ) ,+ ) ; if $ base < cmp_max {$ base = cmp_max ; true } else {false } } } ; }


#[fastout]
fn main() {
    input!{
        N: usize,
        l: [(i64, i64); N]
    }
    let mut maxx = std::i64::MIN;
    let mut maxy = std::i64::MIN;
    let mut minx = std::i64::MAX;
    let mut miny = std::i64::MAX;
    for &(x, y) in &l {
        chmin!(minx, x + y);
        chmin!(miny, x - y);
        chmax!(maxx, x + y);
        chmax!(maxy, x - y);
    }
    println!("{}", max!(maxx-minx, maxy-miny));
}


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

int main(){
    int n;
    int a;
    int buka[200010]={0};
    cin >> n;
    for(int i=1; i<=n-1; i++){
        cin >> a;
        buka[a]++;
    }
    
    for(int i=1; i<=n; i++){
        cout << buka[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int t, n, m, dp[100003], w[10003], v[10003];

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	t = gi(), n = gi();
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= n; i+=1) v[i] = gi(), w[i] = gi();
	for (int i = 1; i <= n; i+=1) 
	{
		for (int j = 0; j <= t; j+=1)
		{
			int xx = max(1ll * 0, j - v[i]);
			dp[j] = min(dp[j], dp[xx] + w[i]);
		}
	}
	//for (int i = 1; i <= t; i+=1) cout << dp[i] << endl;
	printf("%lld\n", dp[t]);
	return 0;
}



Measured memory_bytes: 1024
N = int(input())

H = list(map(int, input().split()))

DP = [0]*N
DP[1] = abs(H[1]-H[0])

for i in range(2, N):
    DP[i] =  min(abs(H[i-1]-H[i])+DP[i-1], DP[i-2]+abs(H[i-2]-H[i]))

print(DP[N-1])

Measured memory_bytes: 13980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int b[] = new int[n + 1];
		long ans = 0;
		b[0] = 1000000;
		b[n] = b[0];
		for (int i = 1; i < n; ++i)
			b[i] = sc.nextInt();
		sc.close();
		for (int i = 1; i <= n; ++i)
		ans += Math.min(b[i - 1], b[i]);
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
# coding: utf-8
# Your code here!

while True:
   n, x = map(int, input().split())
   if n + x == 0:
      break
   
   c = 0
   li = []
   for i in range(1, n + 1):
      for j in range(i + 1, n + 1):
         for k in range(j + 1, n + 1):
            if i + j + k == x:
                  c += 1
   print(c)


Measured memory_bytes: 5600
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <set>
#include <queue>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <map>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace gnu_pbds;

#define F first
#define S second
#define ll long long
#define pb push_back
#define ppb pop_back
#define pii pair<int, int>
#define piii pair<int, pii>
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
//#define int long long
// #define ld long double


const int N = 1e5 + 20, mod = 1e9 + 7, inf = 2e9 + 9;
const ll INF = 1e18 + 20;

int n, k, dp[N], h[N];

signed main() { __
    // freopen("a.in", "r", stdin);
    // freopen("a.out", "w", stdout);
    cin>>n>>k;
    for(int i = 1; i <= n; i++) {
        cin>>h[i];
        dp[i] = inf;
    }
    dp[1] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if(i + j > n) break;
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	long long n;
	cin>>n;
	long long ans=0;
	for(long long i=1;i<=n;i++){
		long long a=i;
		long long b=n/i*i;
		long long c=(b-a)/i+1;
		ans+=(a+b)*c/2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
def main():

    N, A, B = map(int, input().split())
    if (B-A) % 2 == 0:
        return  (B-A) // 2
    else:
        a = A-1 + (B-A+1)//2
        b = N-B+1 + (B-A-1) // 2
        return min([a, b])

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


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main()
{ 
     int d[100] , n, sum =0;
     cin>>n;
     for(int i=0 ; i<n;i++)
     { 
          cin>>d[i];
     } 
    for(int i=0 ; i<n-1;i++)
    { 
         for(int j=i+1 ; j<n;j++)
         
          sum  =  sum +(d[i]*d[j]);
    }
    cout<<sum;
return 0;
} 


Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {


	int N, A, B;
	scanf("%d%d%d", &N, &A, &B);

	printf("%d", min(A*N, B));







}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 1100000;

int n, ch[N][3], to[3], ind[N], pw[15], tot, root, ans[N];
char s[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void build(int &k, int dep, int x) {
	k = ++tot;
	if (dep == n) {
		ind[k] = x;
		return;
	}
	for (R int i = 0; i <= 2; ++i)
		build(ch[k][i], dep + 1, x + i * pw[dep]);
	return;
}

void modify(int k, int dep) {
	if (dep == n) return;
	modify(ch[k][to[2]], dep + 1);
	int tmp = ch[k][to[0]];
	ch[k][to[0]] = ch[k][to[2]], ch[k][to[2]] = ch[k][to[1]], ch[k][to[1]] = tmp;
	return;
}

void dfs(int k, int dep, int x) {
	if (dep == n) {
		ans[ind[k]] = x;
		return;
	}
	for (R int i = 0; i <= 2; ++i)
		dfs(ch[k][to[i]], dep + 1, x + i * pw[dep]);
	return;
}

int main() {
	read(n), scanf("%s", s + 1);
	pw[0] = 1, to[1] = 1, to[2] = 2;
	for (R int i = 1; i <= n; ++i) pw[i] = pw[i - 1] * 3;
	build(root, 0, 0);
	for (R int i = 1, m = strlen(s + 1); i <= m; ++i) {
		if (s[i] == 'S')
			swap(to[1], to[2]);
		else
			modify(root, 0);
	}
	dfs(root, 0, 0);
	for (R int i = 0; i < pw[n]; ++i)
		cout << ans[i] << ' ';
	return 0;
}

Measured memory_bytes: 18760
K = int(input())
count = 1
n = 0
if K % 2 == 0 or K % 5 == 0:
    count = -1
    print(count)
else:
    while True:
        n = (n*10+7)%K
        if n == 0:
            break
        count += 1
    print(count)

Measured memory_bytes: 9112
#!/usr/bin/env python3
from math import cos, sin, pi
n, L = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = [0, 0]
for i in range(n):
    for j in range(i + 1, n):
        k = (n - 1 - j + i) - (j - i - 1)
        ans[0] += cos(pi * (t[i] + t[j]) / L) * k
        ans[1] += sin(pi * (t[i] + t[j]) / L) * k
for i in range(2):
    ans[i] /= n * (n - 1) * (n - 2) / 6
print(*ans, sep=' ')


Measured memory_bytes: 45656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<vector<int>>V(N,vector<int>(3));
    vector<int>A(3);
    for(int i=0;i<N;i++){
        cin>>A[0]>>A[1]>>A[2];
        sort(A.begin(),A.end());
        V[i][0]=A[0];V[i][1]=A[1];V[i][2]=A[2];
    }
    int count=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(V[i][0]==V[j][0] && V[i][1]==V[j][1] && V[i][2]==V[j][2]){
            count++;
            break;
            }
        }
    }
    cout<<count<<endl;
}


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

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

	vector<int> h(n), h_max(n);
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		h[i] = tmp;
		if (i == 0) {
			h_max[i] = tmp;
			continue;
		}
		h_max[i] = max(h_max[i - 1], tmp);
	}

	bool can = true;
	for (int i = 0; i < n; i++) {
		if (2 <= h_max[i] - h[i]) can = false;		
	}	
	
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.BigInteger;

class Main {

    static void solve(BigInteger num1, BigInteger num2) {

        String result = num1.add(num2).toString();

        if (result.length() > 80) {
            result = "overflow";
        }

        System.out.println(result);

    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        sc.nextLine();

        while (sc.hasNext()) {
            BigInteger number1 = new BigInteger(sc.nextLine());
            BigInteger number2 = new BigInteger(sc.nextLine());

            solve(number1, number2);
        }

    }
}

Measured memory_bytes: 12000
#include <stdio.h>

int calc_height(int index){
  return index*(index+1)/2;
}
int solve_index(int rest_a,int rest_b){
  return rest_b-rest_a-1;
}

int main(void){
  int rest_a,rest_b,left_index,depth;
  scanf("%d %d",&rest_a,&rest_b);
  left_index = solve_index(rest_a,rest_b);
  depth = calc_height(left_index) - rest_a;
  printf("%d\n",depth);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int>v[5];
int main(){
	int a;
	long long b;
	scanf("%d%lld",&a,&b);
	int w=0;
	for(int i=0;i<a;i++){
		int p,q;scanf("%d%d",&p,&q);
		if(i==0)w=p;
		v[p-w].push_back(-q);
	}
	for(int i=0;i<4;i++){
		std::sort(v[i].begin(),v[i].end());
	}
	long long ret=0;
	long long aw=0;
	long long at=0;
	for(int i=0;i<=v[0].size();i++){
		if(i){
			aw+=w;
			at-=v[0][i-1];
		}
		if(aw>b)continue;
		long long bw=0;
		long long bt=0;
		for(int j=0;j<=v[1].size();j++){
			if(j){
				bw+=w+1;
				bt-=v[1][j-1];
			}
			if(aw+bw>b)continue;
			long long cw=0;
			long long ct=0;
			for(int k=0;k<=v[2].size();k++){
				if(k){
					cw+=w+2;
					ct-=v[2][k-1];
				}
				if(aw+bw+cw>b)continue;
				long long dw=0;
				long long dt=0;
				for(int l=0;l<=v[3].size();l++){
					if(l){
						dw+=w+3;
						dt-=v[3][l-1];
					}
					if(aw+bw+cw+dw>b)continue;
					ret=max(ret,at+bt+ct+dt);
				}
			}
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[101000];long long b;
	cin>>b;
	int ans=0;int maxn=-1;
	for(int i=1;i<n;i++)
	{
		long long  k;
		cin>>k;
		if(b>=k)
		{
			ans++;
			b=k;
		}
		else
		{
			b=k;
			ans=0;
		}
		if(maxn<ans)
		maxn=ans;
	}
	if(n==1)cout<<0;
	else
	cout<<maxn;
}

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

ans = 0
for i in range(K, N + 2):
    max_num = i * (N + N + 1 - i) // 2
    min_num = i * (0 + i - 1) // 2
    ans += max_num - min_num + 1

print(ans % (10**9 + 7))

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	string s;cin>>s;
	int n=s.size()+1;
	vi a(n);
	rep(i,n-1)
		if(s[i]=='<')
			chmax(a[i+1],a[i]+1);
	per(i,n-1)
		if(s[i]=='>')
			chmax(a[i],a[i+1]+1);
	cout<<accumulate(all(a),int(0))<<endl;
}


Measured memory_bytes: 4764
// 基本テンプレート (縮小版)

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, a[100010], cnt[100010], loc[100010], f[100010], idx = -1;
int ta[100010], tb[100010];

// ModInt begin

ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
struct ModInt {
    ll v;
    ModInt(ll a = 0) : v(((a%MOD) + MOD) % MOD) {}
    ModInt  operator+ ( const ModInt& b ) const {return (v + b.v) % MOD;}
    ModInt  operator- ( const ModInt& b ) const {return (v - b.v + MOD) % MOD;}
    ModInt  operator* ( const ModInt& b ) const {return (v * b.v) % MOD;}
    ModInt  operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, MOD-2)) % MOD;}
};

bool    operator==(ModInt  a, ModInt b) {return a.v == b.v;}
ModInt& operator+=(ModInt& a, ModInt b) {return a = a + b;}
ModInt& operator-=(ModInt& a, ModInt b) {return a = a - b;}
ModInt& operator*=(ModInt& a, ModInt b) {return a = a * b;}
ModInt& operator/=(ModInt& a, ModInt b) {return a = a / b;}
ostream& operator<<(ostream& out, ModInt  a) {return out << a.v;}
istream& operator>>(istream& in,  ModInt& a) {
    ll v; in >> v;
    a = ModInt(v);
    return in;
}

// ModInt end

// 組み合わせ nCr を求める (modあり)
ll combination_mod(ll n, ll r, ll mod=MOD) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    ll a = f[n];
    ll b = 1;
    (b *= f[n-r]) %= MOD;
    (b *= f[r]) %= MOD;
    ll ret = (a * mod_pow(b, mod-2)) % MOD;
    return ret;
}

signed main() {
    f[0] = 1;
    rep(i,1,100010) {
        f[i] = (f[i-1] * i) % MOD;
    }
    cin >> N;
    int rng = 0;
    rep(i,0,N+1) {
        cin >> a[i];
        cnt[ a[i] ]++;
        if(cnt[ a[i] ] == 2) {
            idx = i+1;
            rng = idx - loc[ a[i] ];
        }
        else loc[ a[i] ] = i;
    }

    repq(i,1,N+1) {
        ModInt ans = combination_mod(N+1, i);
        ans -= combination_mod(N+1-rng, i-1);
        cout << ans << endl;
    }
    return 0;
}

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

namespace ConsoleApp90 {
    class Program {
        static long N;
        static long[] A;

        static void Main(string[] args) {
            N = long.Parse(Console.ReadLine());
            
            A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var A_new = new long[N];

            for (int i = 0; i < N; i++) {
                A_new[i] = A[i] + i + 1;
            }

            var minMaxList = new List<long>();


            for (int i = 0; i < N; i++) {
                minMaxList.Add(A[i] - (i + 1));
            }
            long min = minMaxList.Min();
            long max = minMaxList.Max();

            minMaxList.Sort();

            Console.WriteLine(Calculate(minMaxList[(int)N / 2]));

            //答え(正確にはb)はminとmaxの間にある！！→二分探索！

            //Console.WriteLine("min : " + min);
            //Console.WriteLine("max : " + max);

            //long ans = Calculate(max);

            //for (long i = min; i <= max; i++) {
            //    ans = Math.Min(ans, Calculate(i));
            //}

            //Console.WriteLine(ans);
        }

        //static bool CheckRightOrLeft(int min_, int max_) {
        //    int middle = (min_ + max_) / 2;




        //}

        //悲しさを計算する
        static long Calculate(long b_) {
            long value = 0;
            for (int i = 0; i < N; i++) {
                value += Math.Abs(A[i] - (b_ + i + 1));
            }

            return value;
        }
    }
}

Measured memory_bytes: 39940