akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
int A;
  cin>>A;
  double b=0;
  vector<int> a(A);
  for(int i=0;i<A;i++){
  cin>>a.at(i);
    
  }
  for(int i=0;i<A;i++){
   b+=(double)1/(a.at(i));
  
  }
  cout<<(double)1/b<<endl;
}


Measured memory_bytes: 256
/*高桥决定将N AtCoder饼干尽可能均匀发给K个用户。
当所有的饼干都被分发时，
找出用户收到的最大饼干数量和用户收到的最小数量之间的最小差异。
条件：1≤N，K≤100
输入中的所有值都是整数。*/ 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int a[101];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	int n,k,i;
	cin>>n>>k;
	if(n%k==0){
		cout<<0;
		return 0;
	}
	int y=n%k;
	int x=n/k;
	for(i=1;i<=k;i++){
		a[i]=x;
	}
	for(i=1;i<=y;i++){
		a[i]+=1;
	}
	sort(a+1,a+n+1,cmp);
	cout<<a[1]-x;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
void Solve(int a)
{
	const double pi = 3.14;
	float ans;
	ans = 2 * pi * a;
	cout << ans;
}
int main()
{
	int x;
	cin >> x;
	Solve(x);
	return 0;
}

Measured memory_bytes: 3156
def roof(i, j):
    if i % j == 0:
        return i//j
    else:
        return (i//j) + 1

N = int(input())
A, B = 1, 1
for i in range(N):
    x, y = map(int, input().split())
    n = max(roof(A, x), roof(B, y))
    A, B = n*x, n*y

print(A + B)

Measured memory_bytes: 3060
using System;
class Program
{
	static void Main()
	{
    String[] a = Console.ReadLine().Split(' ');
    int b = int.Parse(a[0]);
    int c = int.Parse(a[1]);

    String[] d = Console.ReadLine().Split(' ');
    int[] e = Array.ConvertAll(d, int.Parse);

    Array.Sort(e);
    int f = 0;
    for(int i=0; i<c; i++) f+= e[i];
    
    Console.WriteLine(f);
	}
}

Measured memory_bytes: 27736
#include <stdio.h>

int main()
{
  int a[100001],n,i,n1,j,flag;
  for(i=0;i<=10001;i++)
  {
    a[i]=0;
  }
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d",&n1);
    a[n1]++;
  }
  for(i=0;i<=10001;i++)
  {
    if(i==0)flag=0;
    for(j=a[i];j>0;j--)
    {
      if(flag==1)
      {
        printf(" ");
      }
      else flag=1;
      printf("%d",i);
    }
  }
  printf("\n");
  return 0;
}


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

using namespace std;

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

ll N, M, Q, K, A, B, C, X, Y, Z;
string s, t;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	cin >> N >> K;
	N = N%K;
	cout << min(N,K-N) << '\n';
}

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

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

            string[] strA = Console.ReadLine().Split(' ');

            if (strA.Length == 1) {
                Console.WriteLine(1);
                return;
            }

            double dblW = Math.Pow(3, strA.Length); // 3の累乗

            int intEvenCnt = 0; // 偶数の数
            for (int i = 0; i < strA.Length; i++) {
                if (int.Parse(strA[i]) % 2 == 0) intEvenCnt++;
            }

            double dblWK = Math.Pow(2, intEvenCnt); // 2の累乗

            Console.WriteLine(dblW - dblWK);



        }
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main() {
    int n;
    int A[210];
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int res = 0;
    while (true) {
        bool is_odd = false;
        for (int i = 0; i < n; i++) {
            if (A[i] %2 != 0) is_odd = true;
        }
        if (is_odd) break;

        for (int i = 0; i < n; ++i) {
            A[i] /= 2;
        }

        ++res;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn divisors(n: usize) -> Vec<usize> {
    let mut m = 1;
    let mut divs = vec![];
    while m * m <= n {
        if n % m == 0 {
            divs.push(m);
            if n != m * m {
                divs.push(n / m);
            }
        }
        m += 1;
    }
    divs.sort();
    divs
}

fn main() {
    input!{
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let a_sum: usize = a.iter().sum();
    let mut divs = divisors(a_sum);
    divs.reverse();

    for div in divs {
        let mut diffs: Vec<usize> = a.iter().map(|&x| x % div).collect();
        diffs.sort();
        let diffs_sum: usize = diffs.iter().sum();
        let mut acc = 0;
        for i in 0..(n - diffs_sum/div) {
            acc += diffs[i];
        }
        if acc <= k {
            return println!("{}", div)
        }
    }
}


Measured memory_bytes: 4352
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[i]!=l[j]!=l[k]:
                ans+=1
print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int a[n],b[n],at=0,bt=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			if(a[i]>b[i]){
				at=at+a[i]+b[i];
			}
			else if(a[i]==b[i]){
				at=at+a[i];
				bt=bt+b[i];
			}
			else{
				bt=bt+a[i]+b[i];
			}
		}
		cout<<at<<" "<<bt<<endl;
	}
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    string s;
    cin >> n >> s;
    string t = "No";
    if (n % 2 == 0) {
        int k = n/2;
        if (s.substr(0,k) == s.substr(k,k)) t = "Yes";
    }
    cout << t << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt
  val d = sc.nextInt
  val e = sc.nextInt
  val k = sc.nextInt
  if (e - a > k) {
    println(":(")
  } else {
    println("Yay!")
  }
}

Measured memory_bytes: 25672
S=input()
if S[0]!='A':
    print("WA")
    exit()
s=S[2:len(S)-1]
#print(s)
if s.count('C')!=1:
    print("WA")
    exit()
S1=list(S)
S1.remove('A')
S1.remove('C')
alpha="abcdefghijklmnopqrstuvwxyz"
for s in S1:
    if s not in alpha:
        #print(s)
        print("WA")
        exit()
print("AC")


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

#define int long long
#define ALL(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)
#define B(i, a, n) for(i=n-1;i>=0;i--)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int MAXN = 1e5 + 50;
const int INF = 1e18 + 10;

int32_t main(void)
{
    FASTER;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n, w;
    DI(n, w);
    vii items;
    F(i, 0, n)
    {
        int w, v;
        DI(w, v);
        items.pb(mp(w, v));
    }
    int totVal = 0;
    int dp[MAXN];
    fill(dp, dp + MAXN, INF);
    dp[0] = 0;
    F(i, 0, n)
    {
        for(j = MAXN - 1; j >= 0; j--)
        {
            if(j + items[i].second > MAXN - 1)
                continue;
            dp[j + items[i].second] = min(dp[j + items[i].second], dp[j] + items[i].first);
        }
        totVal += items[i].second;
    }
    
    int ans = 0;
    for(j = totVal; j >= 0; j--)
    {
        if(dp[j] <= w)
        {
            ans = max(ans, j);
        }
    }
    SO(ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <time.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int num = 1;
	int ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] != num){
			ans++;
		}else num++;
	}
	if(num == 1) ans = -1;
	
	cout << ans << endl;
}

Measured memory_bytes: 4400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner( System.in );
		int n = sc.nextInt();
		for( int i = 1; i <= n; i++ ) {
			int x = i;
            if (x % 3 == 0) {
                System.out.print(" " + i);
                continue;
            }
            if (x % 10 == 3) {
                System.out.print(" " + i);
                continue;
            }
             
            for (x /= 10; x != 0; x /= 10) {
                if (x % 10 == 3) {
                    System.out.print(" " + i);
                    break;
                }
            }
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 22412
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.11 02:36:14
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int q;cin >> q;
    while(q--) {
        ll a,b;cin >> a >> b;
        if (a < b) swap(a,b);
        ll k = a * b - 1;
        ll l = 1, r = 1000000001;
        while(r - l > 1) {
            ll mid = l + (r - l) / 2;
            if (k >= mid * mid) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        while(k / l != k / (l+1)) l++;
        ll p = k / l;
        if (l == b) {
            cout << p + l - 1 << endl;
        }
        else {
            cout << p + l - 2 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3568
using System;
using System.Linq;

namespace AtCoderMake.ABC163
{
    class ABC163C
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select((x) => int.Parse(x));
            int[] mane = new int[n];
            mane.Select((x)=>0);
            foreach(int ai in a)
            {
                mane[ai-1] = mane[ai-1] + 1;
            }
            foreach(int m in mane)
            {

                Console.WriteLine(m);
            }

        }
    }
}



Measured memory_bytes: 42904
#include<stdio.h>
#include<string.h>
int main() {
	int t;
	char sent[10];
	int num[4] = { 0 };
	scanf("%d", &t);

	while (t--) {
		scanf("%s", sent);
		if (strcmp(sent, "AC") == 0)
			num[0]++;
		else if (strcmp(sent, "WA") == 0)
				num[1]++;
		else if (strcmp(sent, "TLE") == 0)
			num[2]++;
		else if (strcmp(sent, "RE") == 0)
			num[3]++;
	}
	printf("AC x %d\n", num[0]);
	printf("WA x %d\n", num[1]);
	printf("TLE x %d\n", num[2]);
	printf("RE x %d\n", num[3]);
	return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> v1(101);
    vector<int> v2;
    for (int i = 0; i <= n - 1; i++) {
        int a;
        cin >> a;
        v1[a] = 1;
    }
    //printVector(v1);
    v2.push_back(0);
    for (int i = 1; i <= 100; i++) {
        if (!v1[i]) v2.push_back(i); 
    }
    v2.push_back(101);
    //printVector(v2);
    auto lb = lower_bound(v2.begin(), v2.end(), x) - v2.begin();
    auto gb = upper_bound(v2.begin(), v2.end(), x) - v2.begin();
    // x fora de v2
    if (lb == gb) {
        if (v2[lb] - x < x - v2[lb - 1]) cout << v2[lb] << '\n';
        else cout << v2[lb - 1] << '\n';
    }
    // x em v2
    else {
        cout << x << '\n';
    }
    return 0;
}

Measured memory_bytes: 3600
N = int(input())
t = [[[],[]] for _ in range(N)]
for i in range(N):
	a = int(input())
	for _ in range(a):
		x,y = map(int, input().split())
		t[i][y].append(x)

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

ans = 0

for i in range(2**N):
	c = Base_10_to_n(i,2).rjust(N,"0")
	c = list(map(int, c))
	cnt = [-1] * N
	cond = True
	for j in range(N):
		if c[j] == 1:
			for kind in t[j][1]:
				if cnt[kind-1] == 0:
					cond = False
				cnt[kind-1] = 1
			for unk in t[j][0]:
				if cnt[unk-1] == 1:
					cond = False
				cnt[unk-1] = 0
	if cond:
		for k in range(N):
			if cnt[k] != -1:
				cond = (cnt[k] == c[k])
				if cond == False:
					break
	if cond:
		ans = sum(c)

print(ans)


Measured memory_bytes: 3064
import math
n,k = map(int,input().split())
mod = 10**9+7
def comb(p,q):
    if p >= q:
        a = math.factorial(p)%mod
        b = math.factorial(q)%mod
        c = math.factorial(p-q)%mod
        return ((a*pow(b*c, mod-2, mod))%mod)
    else:
        return 0
for i in range(1,k+1):
    print((comb(n-k+1, i)*comb(k-1, i-1))%mod)


Measured memory_bytes: 3316
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    string a,b;
    int n;
    fi>>n;
    static char c[1 << 20];
    fi>>a>>b;
    for (int i = max(a.length(),b.length());i <= a.length() + b.length();++i)
    {
        for (int j = 1;j <= a.length();++j)
            c[j] = a[j - 1];
        for (int j = i - b.length() + 1;j <= i;++j)
            c[j] = b[j - (i - b.length() + 1)];
        int ok = 1;
        for (int j = 1;j <= a.length();++j)
            ok &= c[j] == a[j - 1];
        for (int j = i - b.length() + 1;j <= i;++j)
            ok &= c[j] == b[j - (i - b.length() + 1)];
        if (ok) return fo << i << '\n',0;
    }
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,S[10000];
bool same(int x,int y){
    if(S[x]==S[y])
        return true;
    else
        return false;
}
void unite(int x,int y){
    if(same(x,y))return;
    int temp=S[y];
    for(int i=0;i<n;i++)
        if(S[i]==temp)
            S[i]=S[x];
}
int main()
{
    int q,c,x,y;
    cin>>n;
    for(int i=0;i<n;i++)
        S[i]=i;
    cin>>q;
    while((q--)>0){
        cin>>c>>x>>y;
        switch(c){
            case 0:unite(x,y);
                    break;
            case 1:if(same(x,y))cout<<1<<endl;
                    else cout<<0<<endl;
                    break;
            default:
                    break;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N, M; cin >> N >> M;
	V<int> a(M),b(M);
	REP(i, M) cin >> a[i] >> b[i];
	V<P<int, int>> p(M);
	REP(i, M) p[i] = { b[i],a[i] };
	sort(ALL(p));
	int s = 0,ans = 0;
	REP(i,M){
		if(s<=p[i].second){
			ans++;
			s = p[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
using Graph = vector<vector<int>>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  if(s[1]=='S'){
    if(s[0]=='R' || s[2]=='R'){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    if(s[0]=='R' && s[2]=='R'){
      cout << 3 << endl;
    }else if(s[0]=='R' || s[2]=='R'){
      cout << 2 << endl;
    }else{
      cout << 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3644
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn],dp[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	REP(i,n) cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j<0) continue;
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

//桁数指定　cout << fixed << setprecision(2)
int main() {
  int x;
  cin>>x;
  int ans=-1;
  int i=2;
  for(i=0;i<50010;i++){ 
    if(x<=(i*1.08)&&(i*1.08)<x+1){cerr<<"!";
      ans=i;break;
     }
    cerr<<"LOOP"<<i<<endl;
  }
  cerr<<ans;
  if(ans+1)cout<<ans;
  if(ans==-1) cout<<":("<<endl;
}

Measured memory_bytes: 384
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=t.inr();for(var i=0,o=0,s=0,u=0,c=0;c<e;c++){for(var a=0;a<r[c].length-1;a++)"A"==r[c][a]&&"B"==r[c][a+1]&&i++;var f=r[c][0],l=r[c][r[c].length-1];"B"!=f||"A"!=l?("B"==f&&s++,"A"==l&&o++):u++}i+=0==u?Math.min(o,s):s+o>0?u+Math.min(o,s):u-1,console.log(i)}}]);

Measured memory_bytes: 11852
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 99999999
const long int M = 1000000007;

int allmask;
map<int,vector<int> > m;
int dp[(1<<21) + 1];
lli solve(int mask, int i, int n)
{
    if(mask == allmask) return 1;
    if(i > n) return 0;
    if(dp[mask] != -1) return dp[mask];
    lli ways = 0;
    int si = m[i].size();
    for(int j = 0;j < si;j++)
    {
        if(mask & (1 << m[i][j])) continue;
        else ways += solve(mask |(1<<m[i][j]),i+1,n);
        ways %= M;
    }
    return dp[mask] = ways;
}

int main()
{
    int n;
    cin >> n;
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            int a;
            cin >> a;
            if(a)
            {
                m[i+1].push_back(j);
            }
        }
    }
    allmask = (1 << n) - 1;
    memset(dp,-1,sizeof(dp));
    cout << solve(0,1,n);
    /*for(i=1;i<=3;i++)
    {
        cout << i<< ": ";
        for(j=0;j<m[i].size();j++)
        {
            cout  << m[i][j] << ",";
        }
        cout << endl;
    }*/
    /*cout << endl;
    for(i=0;i<(1<<n);i++)
    {
        //for(j=0;j<n;j++)
        {
            cout << dp[i] << "\t";
        }
        cout << endl;
    }*/
}



Measured memory_bytes: 11788
s = list(map(int, input()))

count_even = 0
count_odd = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] == 1:
        count_even += 1
    if i % 2 == 1 and s[i] == 1:
        count_odd += 1

if len(s) % 2 == 0:
    ans = (int(len(s)/2) - max(count_even, count_odd)) + min(count_even, count_odd)
else:
    if count_even >= (len(s)+1)/4:
        ans = (((len(s)+1)/2) - count_even) + count_odd
    else:
        ans = count_even + (len(s)-1)/2 - count_odd

print(int(ans))

Measured memory_bytes: 4084
#include <stdio.h>
int main (void)
{
    int N;
    scanf("%d", &N);
    
    int i;
    float A[10000];
    for(i=0; i<N; i++)
    {
        scanf("%f", &A[i]);
    }

    float B[10000];
    for(i=0; i<N; i++)
    {
        B[i] = 1/A[i] ;
    }

    float S;
    for(i=0; i<N; i++)
    {
        S += B[i];
    }
    printf("%f", 1/S);

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        N: usize,
    }
    let MOD = 1_000_000_007;
    let mut p = 1;
    for i in 0..N {
        p *= i + 1;
        p %= MOD;
    }
    println!("{}", p);
}


Measured memory_bytes: 4352
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  ll ans=0;
  int l, r, d;

  cin >> l >> r >> d;

  for(int i=l; i<=r; i++) {
    if (i%d==0) ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    ll n,ans;
    cin >> n;
    vector<ll>a(n);
    rep(i, n) cin >> a[i];
    ans = 0;
    ll m = 0;
    rep(i,n) {
        if (m > a[i]) {
            ans += m - a[i];
        }else {
            m = a[i];
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4836
from sys import stdin
readline = stdin.readline



def main():
    q = int(readline())
    for i in range(q):
        xy = map(int, readline().split())
        p0, p1, p2, p3 = [x + y * 1j for x, y in zip(*[xy] * 2)]
        print('{:.10f}'.format(distance(p0, p1, p2, p3)))

def lt(a, b):
    if a.real != b.real:
        return a.real <= b.real
    return a.imag < b.imag
import itertools
def distance(p0, p1, p2, p3):
    if is_intersected_ls(p0, p1, p2, p3):
        return 0
    p = []
    for i, j in itertools.product([p0, p1], [p2, p3]):
        p.append(abs(i - j))
    for i,j,k in [(p0,p1,p2),(p0,p1,p3),(p2,p3,p0),(p2,p3,p1)]:
        tmp = intersection_of_perpendicular(i,j,k)
        if (lt(i, tmp) and lt(tmp, j)) or (lt(j, tmp) and lt(tmp, i)):
            p.append(abs(tmp - k))

    return min(p)

# line(p1, p2) point(p3)
def intersection_of_perpendicular(p1, p2, p3):
    return p1 + (p2 - p1) * projecter(p2 - p1, p3 - p1)
 
 
def projecter(a, b):
    return dot(a, b) / dot(a, a)
 
 
def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def is_intersected_ls(a1, a2, b1, b2):
    eps = 0
    if max(a1.real, a2.real) < min(b1.real, b2.real)\
      or max(b1.real, b2.real) < min(a1.real, a2.real)\
      or max(a1.imag, a2.imag) < min(b1.imag, b2.imag)\
      or max(b1.imag, b2.imag) < min(a1.imag, a2.imag):
        return False
    return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) <= eps)\
        and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) <= eps)

# http://imagingsolution.blog107.fc2.com/blog-entry-137.html
def intersection(p1, p2, p3, p4):
    a1 = p4 - p2
    b1 = p2 - p3
    b2 = p1 - p2
    s1 = cross(a1, b2) / 2
    s2 = cross(a1, b1) / 2
    c1 = p1 + (p3 - p1) * s1 / (s1 + s2)
    return c1


def cross(a, b):
    return a.real * b.imag - a.imag * b.real
main()

Measured memory_bytes: 6872
dormitory = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
info = int(input())

for i in range(info):
    b, f, r, v = [int(i) for i in input().split()]
    dormitory[b-1][f-1][r-1] += v
    
for i, b in enumerate(dormitory):
    for f in b:
        for r in f:
            print(' '+str(r), end="")
        print()
    if i != 3:
        print('#'*20)
        


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int N, K;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> N >> K;
	int ans = 1;
	rep (i, N) {
		ans *= K - (i != 0);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define mod 998244353
using namespace std;
void solve()
{
	ll k,n;
	cin >> k >> n;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin >> arr[i];
	ll ans = arr[n-1]-arr[0];
	for(ll i=0;i<n;i++)
	{
		if(i > 0)
		ans = min(ans,k-abs(arr[i]-arr[(i-1+n)%n]));
		if(i < n-1)
		ans = min(ans,k-abs(arr[i]-arr[(i+1+n)%n]));
	}
	cout << ans;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<char> a(n);
  for(auto &i:a) cin >> i;
  int ans = 0;
  rep(i,n-1){
    if(a[i]!=a[i+1]) ans++;
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var q= scan.nextLine().toInt()
    val ab  = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()

    var s=ab.distinct().size

    if(s==ab.size)
        print("YES")
    else
        print("NO")
}


Measured memory_bytes: 87248
#include<iostream>
#include<stack>
#include<queue>
using namespace std;
int main()
{
    int n,i;
    int a;
    while(cin>>n)
    {
        
        
        queue<int> b;
        stack<int> c;
        if(n%2==0)
        {
            for(i=1;i<=n;i++)
            {
                cin>>a;
             if(i%2==0)
             c.push(a);
             else 
             b.push(a);
            }
             
            while(!c.empty())
        {
            int k=c.top();
            cout<<k<<" ";
            c.pop();

        }
         while(b.size()>1)
        {
            int k=b.front();
            cout<<k<<" ";
            b.pop();

        }
        cout<<b.front()<<endl;


        }
        else if(n>1)
        {
            for(i=1;i<=n;i++)
            {
                cin>>a;
             if(i%2==0)
             b.push(a);
             else 
             c.push(a);
            }
             
             while(!c.empty())
            
            {
                int k=c.top();
                cout<<k<<" ";
                c.pop();
            }
            while(b.size()>1)
        {
            int k=b.front();
            cout<<k<<" ";
            b.pop();

        }
        cout<<b.front()<<endl;

        }
        if(n==1)
        {
            cin>>a;
            cout<<a<<endl;
        }
        
        
         } 
        
    
    return 0;
}

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

typedef long long ll;

ll n,k;

int main(){
    cin >> n >> k;
    ll cc=0;

    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                if((i+j)%m==0 && (j+k)%m==0 && (k+i)%m==0)
                    cc++;
            }
        }
    }*/

    for(int i=1;i<=n;i++){
        if((2*i)%k==0)
            cc+=pow((i+n)/k - i/k,2);
    }

    cout << cc << endl;

    return 0;
}




Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
lcsTable2 :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Word16
lcsTable2 s t = runSTUArray $ do
  let !m = BS.length s
      !n = BS.length t
      !n' = n+1
  !arr <- newArray ((0,0),(m,n)) 0
  forM_ [m-1,m-2..0] $ \ !i -> do
    let !x = BSW.index s i
        loopY !j !v
          -- v = readArray arr (i,j+1)
          | j >= 0 = do
              let !y = BSW.index t j
              if x == y
                then do l2 <- readArray arr (i+1,j+1)
                        let !l = l2 + 1
                        writeArray arr (i,j) l
                        loopY (j-1) l
                else do l0 <- readArray arr (i+1,j)
                        let !l = max l0 v
                        writeArray arr (i,j) l
                        loopY (j-1) l
          | otherwise = return ()
    loopY (n-1) 0
  return arr

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable2 s t
      !m = BS.length s
      !n = BS.length t
      !n' = n+1
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | table ! (i+1,j) >= table ! (i,j+1) = recon (i+1) j
                  | otherwise = recon i (j+1)
        where x = BSW.index s i
              y = BSW.index t j
      (result, _) = BSW.unfoldrN (fromIntegral $ table ! (0,0)) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


Measured memory_bytes: 19324
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define INF 1001001001

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    vector<pair<int,int>> adj[100001];
    int V,E,r;
    int dst[100001];
    pair<int,int> d;
    Fill(dst,INF);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> Q;

    cin>>V>>E>>r;

    dst[r]=0;

    int s,t,w;

    //??£??\??????????????????
    for(int i=0;i<E;++i){
        cin>>s>>t>>w;
        adj[s].push_back(make_pair(t,w));
    }

    
    for(int i=0;i<adj[r].size();++i){
        Q.push(adj[r][i]);
    }

    while(!Q.empty()){
        d=Q.top(); //?????¢????°??????????
        Q.pop();
        //cerr<<"min is "<<d.first<<" "<<d.second<<"\n";
        if(dst[d.first]>d.second){
            dst[d.first]=d.second;
        }
        
        for(int i=0;i<adj[d.first].size();++i){
            if(dst[adj[d.first][i].first]>d.second+adj[d.first][i].second){
                //cerr<<"new element\n";
                dst[adj[d.first][i].first]=d.second+adj[d.first][i].second;
                pair<int,int> next=make_pair(adj[d.first][i].first,dst[adj[d.first][i].first]);
                Q.push(next);
            }
        }
    }

    for(int i=0;i<V;++i){
        if(dst[i]!=INF){
            cout<<dst[i]<<"\n";
        }
        else{
            cout<<"INF\n";
        }
    }

}

Measured memory_bytes: 20372
#include<iostream>
#include<cstdio>
using namespace std;
int n,sxor,s,a[200005];
long long ans;
int main(){
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	s=a[1];
	sxor=a[1];
	for(i=j=1;i<=n;i++){
		s-=a[i-1];
		sxor^=a[i-1];
		while(sxor==s&&j<=n){
			++j;
			s+=a[j];
			sxor^=a[j];
		}
		ans+=j-i;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 1024
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
//ll dp[200000];
 int dp[3001][3001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
	//freopen ("test.txt","r",stdin);
	string a,b;
	cin>>a>>b;
	int n = a.size();
	int m = b.size();

	
	for (int i = 0; i <= n; ++i)
	{
		for(int j=0;j <= m ;j++)
		{
			if(i == 0 || j ==0 )
			{
				dp[i][j] = 0;
			}
			else if(a[i-1] == b[j-1])
			{
				dp[i][j] =  dp[i-1][j-1] + 1;
			}

			else
			{
				dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);

			}
		}
	}
	//cout<<dp[n][m]<<endl;
	string ans = "";
	int d = 0;

	

	
	int i = n,j = m;
	while(i>0 && j>0)
	{
		if(a[i-1] == b[j-1])
		{
			i--;
			j--;
			ans.pb(a[i]);
			//cout<<a[i];
		}
		else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}
		else
		{
			j--;
		}
	}

	for (int i = ans.size() -1; i >=  0; i--)
	{
		cout<<ans[i];
	}
}

Measured memory_bytes: 35456
#include<stdio.h>
int main(void){
    int a,b,c,d,e;
    scanf("%d%d%d", &a, &b, &c);
    d=a+b+c;
    e=a*b*c; 
    if(d==17&&e==175){printf("YES\n");}
    else{printf("NO\n");}
    
    return 0;
}

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

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

    vector<int> s;
    vector<int> ord(n+1,-1);
    int c =1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] =s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }
    if(k<l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5832
// Abhishek Katara
// Indian Institute of Information Technology, Vadodara

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
 
int main(){
	ll n, q;
	cin >> n >> q;
	string str;
	cin >> str;
	vector<string> t, d;

	for(ll i=0;i<q;i++){
		string t1, d1;
		cin >> t1 >> d1;
		t.push_back(t1);
		d.push_back(d1);
	}
	ll l = 0, r = n-1;
    for(ll i=q-1;i>=0;i--){
    	if(d[i][0] == 'L'){
      		if(l < n && str[l] == t[i][0]){
    			l++;
      		}
      		if(r < n-1 && str[r+1] == t[i][0]){
      			r++;
      		}
    	}
    	else{
    			if(r >= 0 && str[r] == t[i][0]){
      				r--;
    			}
      			if(l >= 1 && str[l-1] == t[i][0]){
      				l--;
      			}
    		}
 		}
 	cout << max(0ll, r-l+1) << endl;
}

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

using db = double;
const db eps = 1e-12;

struct poi {
	db x, y;
	void r() { cin >> x >> y; }
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
};

int main() {
	ios :: sync_with_stdio(false);
	int t; cin >> t;
	while(t --) {
		poi a, b, c, d;
		a.r(); b.r(); c.r(); d.r();
		db t = (b - a).cross(d - c);
		if(t > -eps && t < eps)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll b=1000000000000;
ll a[100005];
ll ans=0;
ll n;
	

int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
ll n;
cin>>n;

cout<<(n-2)*180<<endl;

}		





Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    vector<pair<int,string>> S(N);
    map<string,int> mp;
    int MAX = 0;
    for(int i=0;i<N;i++){
        cin >> S[i].second;
        mp[S[i].second]++;
        S[i].first = mp[S[i].second];
        MAX = max(mp[S[i].second],MAX);
    }
    
    sort(S.begin(),S.end());
    
    for(int i=0;i<N;i++){
        if(S[i].first == MAX) cout << S[i].second << endl;
    }
    
    return 0;
}



Measured memory_bytes: 28416
//package ABC172;
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		
		long ans=0;
		
		long[] div=new long[n+1];
		
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j*i<=n;j++)
			{
				div[i*j]++;
			}
		}
		
		for(int i=1;i<=n;i++)
		{
			ans=ans+(long)(i*div[i]);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 116020
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double[] a = new double[10];
			double a1 = sc.nextDouble();
			double s = 0;
			a[0] = a1;
			for(int i = 0; i < 10; i++){
				if(i%2 !=0 && i !=0){
					a[i] = a[i-1] * 2;
				}
				if(i%2==0 && i!=0){
					a[i] = a[i-1] / 3;
				}
				s += a[i];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 27752
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        _n: usize,
        s: chars,
    }
    let modulo = 1000000007;
    let mut cnt = vec![0; 26];
    for c in s {
        cnt[c as usize - 'a' as usize] += 1;
    }
    let mut ans = 1i64;
    for i in cnt {
        if i == 0 { continue; }
        ans = (ans * (i + 1)) % modulo;
    }
    println!("{}", ans - 1);
}

Measured memory_bytes: 4352
#ifdef FAIRLY_LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <vector>
using namespace std;

int main() {
#ifdef FAIRLY_LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, all = 0;
    vector<int> a;

    cin >> n;
    a.resize(n);
    for (int &elem : a) {
        cin >> elem;
        all = all ^ elem;
    }

    for (int i = 0; i < n; ++i) {
        cout << (all ^ a[i]) << ' ';
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define int long long 
#define rep(i,x,n) for(int i=x;i<n;i++)
#define reprev(i,n,x) for(int i=n;i>=x;i--)
#define mp(a,b) make_pair(a,b)
#define mod 998244353
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#pragma GCC target ("sse4.2")
using namespace std; 
void grayserge()
{
   int n;
   cin>>n;
   int h[n];
   for(int i=0;i<n;i++){
    cin>>h[i];
   }
   int dp[n];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++){
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
   }
   cout<<dp[n-1];
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    int t=1;
    // cin>>t;
    while(t--){
      grayserge();
    }
    cerr<<"time taken: "<<(float)clock()/CLOCKS_PER_SEC<<endl;
  return 0;
}

Measured memory_bytes: 1792