akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) {
    for(T &a : v) is >> a; return is;
}

bool solve() {
    int N, K, T, U, V, L; cin >> N >> K >> T >> U >> V >> L;
    vector<int> D(N); cin >> D;
    sort(all(D));
    int carrot = 0;
    int left_time = 0;
    int high_speed_range = 0;
    int di = 0;
    rep(l, L) {
        if(di < N and D[di] == l) {
            if(carrot == K) left_time = T * V;
            else carrot++;
            di++;
        }
        if(carrot > 0 and left_time == 0) {
            carrot--;
            left_time = T * V;
        }

        high_speed_range += (left_time > 0);
        left_time = max(0, left_time - 1);
    }
    printf("%.10f\n", (double)(L - high_speed_range) / U + (double)(high_speed_range) / V);
    
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

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

#define endl '\n'

using namespace std;

struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n; 
void read()
{
	cin >> n; 
}

void solve()
{
	bool is = false;
	if (n % 10 == 7)
		is = true;

	else 
		if (n / 10 % 10 == 7)
			is = true;

		else
			 if (n / 100 == 7)
			 	is = true;

    if (is)
    	cout << "Yes" << endl; 

    else 
    	cout << "No" << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int n;
	cin >> n;
	int num=7;
	int ans=-1;
	for(int i=1;i<=1e6;i++)
	{
		if(num%n==0)
		{
			ans=i;
			break;
		}
		num=(num*10+7)%n;
	}
	cout << ans ;
}




Measured memory_bytes: 3480
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    
    if(N%2 == 1)
    {
        printf("%lf\n",(double)((N+1)/2)/N);
    }
    else
    {
        printf("%lf\n",(double)1/2);
    }
}


Measured memory_bytes: 128
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    tmp = ["dream", "dreamer", "erase", "eraser"]
    key_words = [e[::-1] for e in tmp]
    #print(key_words)

    target = input()[::-1]
    #print(target)

    i = 0

    while True:
        matched_any = False
        #print("i:{}".format(i))
        for k in key_words:
            k_len = len(k)
            #print(target[i:i + k_len])
            #exit()
            if k == target[i:i + k_len]:
                i += k_len
                matched_any = True
                break

        if not matched_any:
            print("NO")
            exit()

        if i == len(target):
            print("YES")
            exit()

    #print("NO")


Measured memory_bytes: 5452
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let v = (0..n).map(|_| input()).collect::<Vec<i64>>();
    let c = (0..n).map(|_| input()).collect::<Vec<i64>>();

    let ans = v
        .iter()
        .zip(c.iter())
        .filter_map(|(&v, &c)| if v - c > 0 { Some(v - c) } else { None })
        .sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            int x = in.nextInt();
            for (int i = x - k + 1; i < x + k; i++) {
                out.print(i);
                out.print(' ');
            }
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;

int main(){
	ll n,m;
	cin>>n>>m;
	vector<mp> d(n);
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		d[i] = mp(a,b);
	}
	sort(d.begin(),d.end());
	ll s = 0;
	for(ll i=0;i<n;i++){
		if(m==0) break;
		if(m >= d[i].second){
			s += d[i].first*d[i].second;	
			m -= d[i].second;
		}else{
			s += d[i].first*m;
			m = 0;
		}
	}
	cout<< s <<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int x, y, i;
	int t, sum;
	
	sum = 0;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &t);
		sum += t;
	}
	
	x = sum / 60;
	y = sum % 60;
	
	printf("%d\n%d\n", x, y);
	
	return (0);
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
int main()
{
    string S;
    cin >> S;
    int N = S.size();
    long long dp[4];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    rep(i, 1, N + 1)
    {
        long long tp[4];
        rep(r, 0, 4)
        {

            tp[r] = dp[r];
        }

        if (S[i - 1] == 'A')
        {
            dp[0] = tp[0] + tp[3];
            dp[1] = tp[1];
            dp[2] = tp[2];
            dp[3] = tp[3];
        }
        else if (S[i - 1] == 'B')
        {
            dp[0] = tp[0];
            dp[1] = tp[1] + tp[0];
            dp[2] = tp[2];
            dp[3] = tp[3];
        }
        else if (S[i - 1] == 'C')
        {
            dp[0] = tp[0];
            dp[1] = tp[1];
            dp[2] = tp[2] + tp[1];
            dp[3] = tp[3];
        }
        else
        {
            dp[0] = tp[0] * 3 + tp[3];
            dp[1] = tp[1] * 3 + tp[0];
            dp[2] = tp[2] * 3 + tp[1];
            dp[3] = tp[3] * 3;
        }
        rep(r, 0, 4)
        {

            dp[r] = dp[r] % 1000000007;
        }

        // cout << dp[0] << "," << dp[1] << "," << dp[2] << endl;
    }
    cout << dp[2] << endl;
}

Measured memory_bytes: 512
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    string S;
    in(S);

    ll ans = 0;

    rep(i, S.size() - 2)
    {
        if (S.substr(i, 3) == "ABC") ans++;
    }

    outl(ans);

    return 0;
}

Measured memory_bytes: 3612
N,X,Y=map(int,input().split())
ans=[0 for i in range(N+1)]
L=[[]for i in range(N+1)]
for i in range(2,N+1):
    L[i].append(i-1)
    L[i-1].append(i)
L[X].append(Y)
L[Y].append(X)
import heapq
for i in range(1,N+1):
    C=[10**5 for i in range(N+1)]
    C[i]=0
    Q=[]
    for a in L[i]:
        Q.append((1,a))
    heapq.heapify(Q)
    for b in range(10**4):
        if len(Q)==0:
            break
        d,p=Q[0]
        heapq.heappop(Q)
        if C[p]==10**5:
            C[p]=d
            ans[d]+=1
            for c in L[p]:
                if C[c]==10**5:
                    heapq.heappush(Q,(d+1,c))
for i in range(1,N):
    print(ans[i]//2)
    

Measured memory_bytes: 65884
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int K, X;
    cin >> K >> X;
    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())

bom=[]

for i in range(H):
    bom.append(list(input()))

#print(bom)

for h in range(H):
    for w in range(W):
        if bom[h][w]=="#":
            continue
        cnt=0
        for x in range(-1,2):
            for y in range(-1,2):
                if h+x>=0 and w+y>=0 and h+x<H and w+y<W:
                    if bom[h+x][w+y]=="#":
                        cnt+=1
        bom[h][w]=str(cnt)
for i in bom:
    print("".join(i))


Measured memory_bytes: 3188
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
      	if (N%10 == 3) {
          System.out.println("bon");
        } else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) {
          System.out.println("pon");
        } else {
          System.out.println("hon");
        }
    }

}

Measured memory_bytes: 27076
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
    map<string,int> freq;
    int amx = 0, bmx = 0;
    string s, a, b;
    while (cin >> s) {
        freq[s] ++;
        if (amx < freq[s]) {
            amx = freq[s];
            a = s;
        }
        if (bmx < s.size()) {
            bmx = s.size();
            b = s;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define pii pair<int, int>
#define LL long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
using namespace std;
const int maxn = 2e3 + 10;
int dp[maxn][maxn], ans, add, g[maxn];
vector<pair<pii, int>> vec;
int n, m, v[maxn * 3]; 

void singleInsert(int a, int b, int c) {
	vec.pb(mp(mp(b, c), dp[a][a] + 1));
	for (int i = 1; i <= n; ++i)
		vec.pb(mp(mp(i, a), g[i]));
}

void doubleInsert(int a, int b, int c) {
	if (a == b) {
		for (int i = 1; i <= n; ++i)
			vec.pb(mp(mp(i, c), dp[a][i] + 1));
	}
	vec.pb(mp(mp(a, b), ans)); 
}

void upd(int i, int j, int k) {
	dp[i][j] = max(dp[i][j], k);
	g[i] = max(g[i], k);
	ans = max(ans, k);
}

int main() {
	#ifdef DEBUG
	freopen("text.in", "r", stdin);
	freopen("wa.out", "w", stdout);
	#endif
	scanf("%d", &n);
	m = n * 3;
	for (int i = 1; i <= m; ++i)
		scanf("%d", &v[i]);
	for (int i = 1; i <= n; ++i) {
		g[i] = -m;
		for (int j = 1; j <= n; ++j)
			dp[i][j] = -m;
	}
	dp[v[1]][v[2]] = dp[v[2]][v[1]] = 0; g[v[1]] = g[v[2]] = 0;
	for (int i = 3, a, b, c; i + 2 <= m; i += 3) {
		vec.clear();
		a = v[i]; b = v[i + 1]; c = v[i + 2];
		if (a == b && a == c) { ++add; continue; } //allInsert
		singleInsert(a, b, c); singleInsert(b, a, c); singleInsert(c, a, b);
		doubleInsert(a, b, c); doubleInsert(a, c, b); doubleInsert(b, c, a);
		for (auto s : vec) {
			upd(s.x.x, s.x.y, s.y);
			upd(s.x.y, s.x.x, s.y);
		}
	}
	printf("%d\n", max(ans, dp[v[m]][v[m]] + 1) + add);
	return 0;
}


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

namespace _1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var v = 0;
            var data = Console.ReadLine().Split(' ');
            var j = 0;
            
            for(var i = 0; i < data.Length; i++)
            {
                v = int.Parse(data[i]);
                j = i - 1;
                while(j >= 0 && int.Parse(data[j]) > v)
                {
                    data[j + 1] = data[j];
                    j--;
                }
                data[j + 1] = v.ToString();
                Console.WriteLine(string.Join(" ", data));
            }
        }
    }
}


Measured memory_bytes: 15948
N=int(raw_input())
ab=[]
cd=[]
for i in xrange(N):
 ab.append(map(int,raw_input().split()))
for i in xrange(N):
 cd.append(map(int,raw_input().split()))
ab.sort(key=lambda x:x[1],reverse=True)
cd.sort()
for c,d in cd:
 for a,b in ab:
  if a<c and b<d:
   ab.remove([a,b])
   break
print N-len(ab)

Measured memory_bytes: 2568
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] aArray = new int[N];

    for (int i=0; i < N; i++) {
      aArray[i] = sc.nextInt();
    }

    Arrays.sort(aArray);

    int sumAlice = 0;
    int sumBob = 0;

    for (int i=1; i <= N; i++) {
      if (i % 2 != 0) {
        sumAlice += aArray[N-i];
      } else {
        sumBob += aArray[N-i];
      }
    }

    System.out.println(sumAlice - sumBob);
  }
}


Measured memory_bytes: 21460
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

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

int main()
{
  int n;
  cin >> n;
  int sum=sumDigit(n);
  if(n%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                    cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)             cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll h,w;
    cin >> h >> w;
    for(ll i=0; i<w+2; i++) cout << "#";
    cout << "\n";
    for(ll i=0; i<h; i++){
        string s;
        cin >> s;
        cout << "#";
        cout << s;
        cout << "#\n";
    }
    for(ll i=0; i<w+2; i++) cout << "#";
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; i++){
    cin >> X[i];
  }
  int ans = 1e9;
  for(int i=1; i<=100; i++){
    int sum = 0;
    for(int j=0; j<N; j++){
      sum += (X[j]-i)*(X[j]-i);
    }
    chmin(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define lrep(i,b) for(ll int i=0;i<(b);++i)
#define all(c) c.begin(),c.end()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

void Acout(int A[],int N){
    rep(i,N){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
}

int check(ll int a[],ll int k,ll int P, ll int n){
    ll int j=0;

    lrep(i,k){
        ll l=0;
        while(a[j]+l<=P){
            l+=a[j];
            j++;
            if(j==n) return j;
        }
    }
    return j;
}

int bisearch(ll int a[],ll int k, ll int n){
    ll int f=0;
    ll int b=100000*10000;
    ll mid;

    while(b-f>1){
        mid=(f+b)/2;
        int v=check(a,k,mid,n);
        if(v>=n)b=mid;
        else f=mid;
    } 
    return b;
}

int main(){
    int ans =0;
    ll int k,P,n;
    cin>>n>>k;
    ll int a[n];
    rep(i,n)cin>>a[i];

    cout<<bisearch(a,k,n)<<endl;
}


Measured memory_bytes: 3876
n = int(input())
N =[1, 1, 2]
if n < 3:
    print(N[n])
else:
    i = 2
    while i < n:
        n0, n1, n2 = N
        N[2] = n1 + n2
        N[1] = n2
        N[0] = n1
        i += 1
    print(N[2])


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

using i64 = long long;

i64 gcd(i64 a, i64 b) { return a ? gcd(b % a, a) : b; }

const int MOD = 1000000007;

i64 pow64(i64 a, i64 b) {
    a %= MOD;
    i64 result = 1;
    while(b) {
        if(b & 1) result = result * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return result;
}
i64 inv64(i64 x) { return pow64(x, MOD - 2); }

const int MAXN = 201000;

int n;
std::vector<int> edges[MAXN];
int size[MAXN];
std::vector<int> vec[MAXN];

int dfs(int u, int p) {
    int result = 1;
    for(int v : edges[u]) {
        if(v == p) continue;
        int x = dfs(v, u);
        result += x;
        vec[u].push_back(x);
    }
    if(p != -1) vec[u].push_back(n - result);
    return size[u] = result;
}

int main() {
    std::scanf("%d", &n);
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        std::scanf("%d%d", &u, &v);
        --u, --v;
        edges[u].emplace_back(v);
        edges[v].emplace_back(u);
    }
    dfs(0, -1);
    /*for(int i = 0; i < n; ++i) {
        std::cout << i << " ->";
        for(int x : vec[i])
            std::cout << ' ' << x;
        std::cout << std::endl;
    }*/
    i64 result = 0;
    for(int i = 0; i < n; ++i) {
        for(int x : vec[i])
            result = (result + (pow64(2, x) - 1 + MOD) % MOD) % MOD;
        result += 1;
    }
    result = ((n * pow64(2, n - 1) - result) % MOD + MOD) % MOD;
    result = result * pow64(inv64(2), n) % MOD;
    std::printf("%lld\n", result);
}

Measured memory_bytes: 36352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;


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


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n){
    cin >> h[i];
  }
  vector<int> dp(n + 1);
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  int mi = INT_MAX;
  for(int i = 2; i < n; ++i){
    mi = INT_MAX;
    for(int j = 1; j <= k; ++j){
      if(i - j < 0) break;
      mi = min(mi, dp[i - j] + abs(h[i] - h[i - j]));
    }
    dp[i] = mi;

  }

  cout << dp[n-1] << endl;

}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int N;
    int im1, i, ip1 , k = 0;
    cin >> N;
    cin >>im1 >> i;
    for (int n = 2;n < N;n++){
        
        cin >> ip1;
        if( (im1 > i && ip1 < i)  || (im1 < i && i < ip1)){
            k++;
        }
        im1 = i;
        i = ip1;
    }
    cout << k << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n[12], a;
  for(int i = 0; i < 3; scanf("%d", &a), n[a]++, i++);
  printf("%s\n", (n[5] == 2 && n[7] == 1) ? "YES" : "NO");
  return 0;
}

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

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  string buf;
  string code="...B.AD..E..C";
  int brd[8][8];
  char ans;
  
  while (cin>>buf){
    int l=8,r=-1,t=8,b=-1, w, h;
    for (int i=0; i<8; i++){
      brd[i][0] = buf[i]-'0';
      if (brd[i][0]==1){
        l = MIN(i,l); r = MAX(i,r);
        t = MIN(0,t); b = MAX(0,b);
      }
    }
    for (int j=1; j<8; j++){
      cin >> buf;
      for (int i=0; i<8; i++){
        brd[i][j] = buf[i]-'0';
        if (brd[i][j]==1){
          l = MIN(i,l); r = MAX(i,r);
          t = MIN(j,t); b = MAX(j,b);
        }
      }
    }
    w = r-l+1; h = b-t+1;
    ans = code[((w-1)<<2)|(h-1)];
    if (ans=='D' && brd[l][t]==1) ans = 'F';
    if (ans=='E' && brd[l][t]==0) ans = 'G';
//    cout << l << " " << r << " " << t << " " << b << " ";
//    cout << w << " " << h << " ";
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3020
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	map<int, ll> count;
	vector<int> A(N);

	rep(i, N)
	{
		cin >> A[i];

		count[A[i]]++;
	}

	map<int, ll> comb1;
	map<int, ll> comb2;

	ll sum = 0;

	for (auto a : count)
	{
		ll c = a.second;
		comb1[a.first] = c * (c - 1) / 2;
		comb2[a.first] = (c - 1) * (c - 2) / 2;

		sum += c * (c - 1) / 2;
	}

	map<int, ll> comb3;
	for (auto a : count)
	{
		comb3[a.first] = sum - comb1[a.first] + comb2[a.first];
	}

	rep(i, N)
	{
		cout << comb3[A[i]] << endl;
	}

	return 0;
}

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

int main(){
	long long H,W;
	cin >> H >> W;

	long long ans=1e9;
	if(W%3==0)	ans=0;
	else	ans=min(ans,H);
	if(H%3==0)	ans=0;
	else ans=min(ans,W);

	for(int i=1;i<H;i++){
		long long a=i*W;
		long long b,c;
		if(W%2==0){
			b=(H-i)*(W/2);
			c=b;
		}
		else{
			b=(H-i)*(W/2);
			c=(H-i)*((W+1)/2);
		}
		long long mi=min({a,b,c});
		long long ma=max({a,b,c});
		ans=min(ans,ma-mi);
	}
	for(int i=1;i<W;i++){
		long long a=i*H;
		long long b,c;
		if(H%2==0){
			b=(W-i)*(H/2);
			c=b;
		}
		else{
			b=(W-i)*(H/2);
			c=(W-i)*((H+1)/2);
		}
		long long mi=min({a,b,c});
		long long ma=max({a,b,c});
		ans=min(ans,ma-mi);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	char a, b, c, d, e, f;
	cin >> a >> b >> c;
	int ans = 0;
	if (a == '1') {
		ans++;
	}
	if (b == '1') {
		ans++;
	}
	if (c == '1') {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;

vector<ll> x;
vector<ll> y;
vector<ll> h;

ll check(ll xx, ll yy)
{
    ll cur = -1;
    for (int i = 0; i < x.size(); ++i)
    {
        ll hh = h[i] + abs(x[i] - xx) + abs(y[i] - yy);
        if (h[i] != 0)
        {
            cur = hh;
            break;
        }
    }
    for (int i = 0; i < x.size(); ++i)
    {
        ll hh = h[i] + abs(x[i] - xx) + abs(y[i] - yy);
        if (h[i] != 0)
        {
            if (hh != cur)
            {
                return -1;
            }
        }
        else
        {
            if (max(cur - abs(x[i] - xx) - abs(y[i] - yy), 0ll))
            {
                return -1;
            }
        }
    }
    return cur;
}

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    x = vector<ll>(n);
    y = vector<ll>(n);
    h = vector<ll>(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i] >> h[i];
    }
    
    for (int i = 0; i <= 100; ++i)
    {
        for (int j = 0; j <= 100; ++j)
        {
            ll ret = check(i, j);
            if (ret != -1)
            {
                cout << i << " " << j << " " << ret << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <bitset>
using namespace std;
struct node{
    int r , c , val;
};
bitset<1000> visited[1000];
string area[1000];
queue<node> q;
int R , C;
int x[] = {-1 , 0 , 1 , 0},
    y[] = {0 , 1 , 0 , -1};

void dfs(int , int , int);
int main(){
    cin >> R >> C;
    int awal_r , awal_c , akhir_r , akhir_c;

    cin >> awal_r >> awal_c >> akhir_r >> akhir_c;
    --awal_r , --awal_c , --akhir_r , --akhir_c;

    for (int i = 0 ; i < R ; i++)
        cin >> area[i];

    dfs(awal_r , awal_c , 0);

    //untuk jalan biasa taruh di depan , klo magic taruh dibelakang
    while(!q.empty()){
        node now = q.front();
        q.pop();
        if (now.r == akhir_r && now.c == akhir_c){
            cout << now.val << endl;
            return 0;
        }
        for (int i = max(0 , now.r - 2) ; i <= min(R - 1 , now.r + 2) ; i++){
            for (int j = max(0 , now.c - 2) ; j <= min(C - 1 , now.c + 2) ; j++){
                if (!visited[i][j] && area[i][j] == '.')
                    dfs(i , j , now.val + 1);
            }
        }
    }
    cout << "-1\n";
}
void dfs(int i , int j , int val){
    if (i >= 0 && i < R && j >= 0 && j < C && !visited[i][j] && area[i][j] == '.'){
        visited[i][j] = 1;
        q.push({i , j , val});
        dfs(i + 1 , j , val);
        dfs(i , j + 1 , val);
        dfs(i , j - 1 , val);
        dfs(i - 1 , j , val);
    }
}


Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,s,e) for(ll i=s;i<e;++i)
#define MOD 1000000007
using Graph=vector<vector<ll>>;

int main(){
    ll n,m;
    cin >> n >> m;
    Graph G(n);
    ll a,b;
    F(i,0,m){
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    queue<ll> q;
    F(i,0,G[0].size()) q.push(G[0][i]);

    while(!q.empty()){
        ll p=q.front(); q.pop();
        F(i,0,G[p].size()){
            if(G[p][i]==n-1){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  ll n;
  cin >> n;
  vector<ll>a (n);
  ll sum = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  vector<ll>ans (n);
  for (ll i = 0; i < n - 1; i += 2) {
    sum -= 2 * a[i];
  }
  ans[n - 1] = sum;
  ans[0] = 2 * a[n - 1] - sum;
  for (ll i = 1; i < n - 1; i++) {
    ans[i] = 2 * a[i - 1] - ans[i - 1];
  }
  for (ll i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
  return 0;

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     string s;
     cin>>s;
     vi v(26,0);
     for(auto x:s)
     	v[x-'a']++;
     for(int i=0;i<26;i++)
     {
     	  if(v[i]&1)
     	  {
     	  	  cout<<"No"<<endl;
     	  	  return 0;
     	  }
     }
     cout<<"Yes"<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int order;
    int num;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<P> v(n);
    rep(i,n) {
        cin >> v[i].num;
        v[i].order = i + 1;
    }
    sort(ALL(v),[](P a, P b){return a.num < b.num;});
    rep(i,n) cout << v[i].order << endl;
    

    return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,k,j;
    cin >> n;
    vector< ll >v(n);
    for(i = 0; i < n; i++)cin>>v[i];
    vector<pii>answer(61,{0,0});
    rep(i,0,n){
        rep(j,0,61){
            if(v[i] & (1LL << j) )answer[j].ff++;
            else answer[j].ss++;
        }
    }
    ll ans = 0,mod = 1e9+7;
    rep(i,0,61){
        ll k1 = (answer[i].ff * answer[i].ss)%mod ;
        ll k2 = (1LL << i)%mod;
        k1 = (k1*k2)%mod;
        ans = ((ans % mod) + (k1 % mod)) % mod;
    }
    cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 5524
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 1e6 + 10;
bitset <MAXN> mark;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        bitset <MAXN> isprime;
        vector <int> factor(MAXN);
        isprime.set();
        isprime[0] = isprime[1] = 0;
        for(int i = 2; i < MAXN; i++){
                if(!isprime[i])
                        continue;
                factor[i] = i;
                for(ll j = (ll) i * i; j < MAXN; j += i){
                        isprime[j] = 0;
                        factor[j] = i;
                }
        }
        bool pc = 1;
	int n;
        cin >> n;
        vector <int> a(n);
        for(int i = 0; i < n; i++){
                int x;
                cin >> x;
                a[i] = x;
                set <int> prime;
                while(x != 1){
                        prime.insert(factor[x]);
                        x /= factor[x];
                }
                for(int j : prime){
                        if(mark[j])
                                pc = 0;
                        mark[j] = 1;
                }
        }
        if(pc){
                cout << "pairwise coprime\n";
                return 0;
        }
        int res = a[0];
        for(int i = 1; i < n; i++){
                res = gcd(res, a[i]);
        }
        if(res == 1){
                cout << "setwise coprime\n";
        }
        else{
                cout << "not coprime\n";
        }
}


Measured memory_bytes: 11244
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
vector<int> G[maxn];
ll dp[maxn][2];
void dfs(int rt,int fa)
{
    dp[rt][0]=1;
    dp[rt][1]=1;
    for(int i=0;i<G[rt].size();i++)
    {
        int to=G[rt][i];
        if(to==fa) continue;
        dfs(to,rt);
        dp[rt][0]=(dp[rt][0]*(dp[to][1]+dp[to][0]))%Mod;
        dp[rt][1]=(dp[rt][1]*dp[to][0])%Mod;
    }
}
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1,-1);
    printf("%lld\n",(dp[1][0]+dp[1][1])%Mod);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 14208
int main(){
	int w, h;
	int i, j;
	
	while (1){
		scanf("%d %d", &h ,&w);
		if (w == 0 && h == 0) break;

		for (i = 0;i < h; i++){
			for (j = 0; j < w; j++){
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
	}
	return 0;
}

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

int abs(int x){
  return x>0 ? x : -x;
}

int main(){
  int a, b, k;
  cin >> a >> b;
  k = (a+b) / 2;
  if(abs(a-k)==abs(b-k)) cout << k << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "stdio.h"
using namespace std;

void func(int x, int y);


int main()
{
  int x,y;
  scanf("%d%d",&x,&y );
  func(x,y);
  return 0;
}

void func(int x, int y)
{
  if(x > y) cout << "a > b" << endl;
  if(x < y) cout << "a < b" << endl;
  if(x == y) cout << "a == b" << endl;
}


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

long    Cal(vector<long> &A, long b) {
        long S=0;
        for (int i=1; i<A.size(); i++) {
                S += abs(A.at(i)-(b+i));
        }
        return S;
}

int     main() {
        int N;
        cin >>N;
        vector<long> A(N+1, 0);
        for (int i=1; i<=N; i++) {
                cin >>A.at(i);
        }
        vector<long> B(N);
        for (int i=1; i<=N; i++) B.at(i-1)=A.at(i)-i;
        sort(B.begin(), B.end());
        long b1=B.at(N/2);
        while (true) {
                long b0=b1-1;
                long b2=b1+1;
                long S0=Cal(A, b0);
                long S1=Cal(A, b1);
                long S2=Cal(A, b2);
                if (S1==min(S0, min(S1, S2))) break;
                if (S2<S1) b1=b2;
                else b1=b0;
        }
        cout <<Cal(A, b1) <<endl;
        return 0;
};

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  sort(begin(a), end(a), greater<>());
  int ans(0);
  for (int i = 0; i < n; i++) {
    ans += i % 2 == 0 ? a[i] : -a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

p = []
for i, v in enumerate(A):
  p.append((v, i))
  
p.sort(reverse=True)

dp = [[0] * (n + 1) for _ in range(n + 1)]

for i in range(n):
  k = p[i][0]
  r = p[i][1]
  for x in range(i + 1):
    y = i - x
    dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + abs(r - x) * k)
    dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + abs(r - (n - 1 - y)) * k)

ans = 0
for i in range(n):
  ans = max(ans, dp[i][n-i])
  
print(ans)

Measured memory_bytes: 106096
#if defined(LOCAL)
// #define RANDOM_TEST
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#endif
#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max(); // TODO
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
bool local = true;
#define L(x...) debug(x)
#else
bool local = false;
#define L(x, ...) (x)
#endif
struct VoidStream { void operator&(std::ostream&) { } };
#define LOG !(local) ? (void) 0 : VoidStream() & cerr

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  l sum = accumulate(all(v), l(0));
  l answer = INF;
  l left = v[0];
  F(i, 1, n) {
    answer = min(answer, abs(left - (sum - left)));
    left += v[i];
  }
  cout << answer << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll n,l[90];
int main(){
	cin>>n;
	l[0]=2;
	l[1]=1;
	for(int i=2;i<=n;i++)
	    l[i]=l[i-1]+l[i-2];
	cout<<l[n];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll ans = 1;
    bool ansf = true;
    bool zero = false;
    rep(i, n){
        ll in; cin >> in;
        if(in == 0) zero = true;
        ll tmp = ans;
        ans *= in;
        if(tmp>ans || ans >= 1000000000000000001) ansf = false;
    }
    if(zero) cout << 0 << endl;
    else if(ansf) cout << ans << endl;
    else cout << -1 << endl;

}

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

int main(){
  int N,A,ans=0,jdg=0;
  vector<int> v;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A;
    v.push_back(A);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    if(v[i]==v[i+1]){
      jdg+=1;
      continue;
    }
    if(jdg%2==0){
      ans+=1;
    }
    jdg=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 892