akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
MOD = 998244353
N = int(input())
D = list(map(int,input().split()))
d = defaultdict(int)
for i in D:
    d[i] += 1
ans = 1
if d[0] != 1 or D[0] != 0:
    print(0)
else:
    for i in range(1,N):
        ans = ans*pow(d[i-1],d[i],MOD)
    print(ans%MOD)

Measured memory_bytes: 29444
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

vector<pair<int,int> > g[5000];
vector<int> pred[5000];
int n,m;
set<pair<int,int> > st;

void dijk(int s){
	set<pair<int,int> > heap;
	vector<int> dist(n+1,1e8);
	dist[s] = 0;
	heap.insert(mp(0,s));
	while(!heap.empty()){
		int u = heap.begin()->Y;
		heap.erase(heap.begin());
		for(auto x:g[u]){
			int v = x.X;
			int w = x.Y;
			if(dist[v] > dist[u] + w){
				heap.erase(mp(dist[v],v));
				dist[v] = dist[u] + w;
				pred[v].clear();
				pred[v].pb(u);
				heap.insert(mp(dist[v],v));
			}
			if(dist[v] == dist[u] + w){
				pred[v].pb(u);
			}
		}
	}
}

void solve(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		g[u].pb(mp(v,w));
		g[v].pb(mp(u,w));
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			pred[j].clear();
		}
		dijk(i);

		for(int j=1;j<=n;j++){
			for(int k:pred[j]){
				// cout<<i<<" "<<j<<" "<<k<<endl;
				st.insert({min(j,k), max(j,k)});
			}
		}
	}
	// for(auto x:st){
	// 	cout<<x.X<<" "<<x.Y<<endl;
	// }

	cout<<m-(int)st.size()<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    ll h[n];rep(i,n){cin>>h[i];}
    ll dp[n]={};
    dp[1]=abs(h[0]-h[1]);
    repr(i,2,n){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1]<< endl;

    return 0;
}


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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000] = {},X[1000] = {},coun[60] = {},bcou[60] = {};
pair<ll,ll> rui[100000] = {},ruin[100002] = {};
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 1,n = 0,su = 0, ma = INF,mi=-1;
pair<str,ll> S[1000];
bool an = false,bn = false;



int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
cin >> n >> a;
for(int i = 0;i < n;i++){
  cin >> A[i];

}
if(b <= a)su++;
for(int i = 0;i < n;i++){
  b += A[i];
  if(b <= a)su++;
}
cout << su << endl;
  //Code Line
        return 0;
}


Measured memory_bytes: 3456
import math
import os
import sys

import numpy as np

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

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

N = int(sys.stdin.readline())

cnt = math.ceil(math.sqrt(N * 2))
if cnt * (cnt - 1) != N * 2:
    print('No')
    exit()

ans = np.zeros((cnt, cnt - 1), dtype=int)
ans[np.triu_indices(cnt - 1)] = np.arange(1, N + 1)
ans[1:] = np.maximum(ans[:-1].T, ans[1:])
print('Yes')
print(cnt)
for r in ans:
    print(cnt - 1, *r)


Measured memory_bytes: 18044
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
ll gcd(int a, int b){return b ? gcd(b, a%b) : a;}
ll lcm(int a, int b){return a*b / gcd(a, b);}
const ll MAX = 1e9+7;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m);
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
    }

    vector<int> cnt(n, 1);
    vector<bool> red_in(n, false);
    red_in[0] = true;
    for(int i = 0; i < m; i++){
        if(red_in[x[i]-1] == true){
            red_in[y[i]-1] = true;
        }
        cnt[x[i]-1]--;
        cnt[y[i]-1]++;
        if(cnt[x[i]-1] == 0){
            red_in[x[i]-1] = false;
        }
    }
        
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(red_in[i] == true) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B,C;
  cin >> A >> B >> C; 
  char T = 'a';
  int a=0,b=0,c=0;
  while (true){
    if (T == 'a'){
      if (a>=A.size()) break;
      T = A[a];
      a++;
    } else if (T == 'b'){
      if (b>=B.size()) break;
      T = B[b];
      b++;
    } else {
      if (c>=C.size()) break;
      T = C[c];
      c++;
    }
  }
  cout << (char)toupper(T);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool dpX[8000][16100] = {};
bool dpY[8000][16100] = {};

#define OFFSET 8000
#define MAX_S 8000

int main() {
    string S;
    cin >> S;
    int x, y;
    cin >> x >> y;

    vector<int> a;
    int cnt = 0;
    for(int i=0; i < S.size(); ++i) {
        if(S[i] == 'F') {
            ++cnt;
            if(i+1 == S.size()) a.push_back(cnt);
        } else {
            a.push_back(cnt);
            cnt = 0;
        }
    }

    int n = a.size();
    if(n == 1) {
        if(x == a[0] && y == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }

    dpX[0][a[0] + OFFSET] = true;
    for(int i=2; i<n; i += 2) {
        for(int j=-MAX_S; j<=MAX_S; ++j) {
            if(j - a[i] >= -MAX_S) dpX[i][j + OFFSET] |= dpX[i-2][j - a[i] + OFFSET];
            if(j + a[i] <= MAX_S) dpX[i][j + OFFSET] |= dpX[i-2][j + a[i] + OFFSET];
        }
    }

    dpY[1][a[1] + OFFSET] = true;
    dpY[1][(-1) * a[1] + OFFSET] = true;
    for(int i=3; i<n; i += 2) {
        for(int j=-MAX_S; j<=MAX_S; ++j) {
            if(j - a[i] + OFFSET >= 0) dpY[i][j + OFFSET] |= dpY[i-2][j - a[i] + OFFSET];
            if(j + a[i] <= MAX_S) dpY[i][j + OFFSET] |= dpY[i-2][j + a[i] + OFFSET];
        }
    }

    if(n % 2) {
        if(dpX[n-1][x + OFFSET] && dpY[n - 2][y + OFFSET]) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(dpX[n-2][x + OFFSET] && dpY[n - 1][y + OFFSET]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 249728
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
        int n,m;
        cin>>n>>m;
        int c;
        cin>>c;
        int b[m];
        for(int i=0;i<m;i++){
            cin>>b[i];
        }
        int arr[n][m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>arr[i][j];
            }
        }
        int cnt=0;
        for(int i=0;i<n;i++){
            int sum=c;
            for(int j=0;j<m;j++){
                sum+=arr[i][j]*b[j];
                
            }
            cerr<<sum<<endl;
            if(sum>0)cnt++;
        }
        cout<<cnt;
    }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>        //sort(v.begin(), v.end(), [std::greater()]);  第3引数をなしにすると昇順。
#include <utility>  
#include <vector>           
#include <iterator>         //vector入力で使う istream_iterator(cin)
#include <iomanip>          //doubleやfloatなどの少数の桁数を指定する setprecision(桁数) 

/*----------- 定義 -----------*/
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long int lli;
/*----------------------------*/


/*----------- 入力 -----------*/
lli N;
string S;
string T;
vector<int> data;

/*----------------------------*/

int main(void){

    cin  >> N >> S;
  
    int temp = 0;
    
    rep(i,S.size()){
        //printf("%d ",S[i]);
        temp = S[i] + N;
        //cout <<temp <<endl;
        if(temp >= 91){
            S[i] = temp - 26;
        }else{
            S[i] = temp; 
        }
        
    }
    
    
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char A[4];
    int y=0;
    rep(i,1){
        cin >> A;
    }
    rep(i,3){
        if(A[i]=='o')y++;
    }
    // sort(A,A+3);
    cout << 700+100*y << endl;
}

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

int main(){
    int N;
    char S[100];

    bool yellow = false;

    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> S[i];
        if (S[i] == 'Y'){
            yellow = true;
            break;
        }
    }

    if (yellow) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    INIT;

    int a, b, c;
    cin >> a >> b >> c;

    if(a <= c and c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    int n, ans=0, cnt=0;
    cin>>n;
    for (int i=1; i<=n; i+=2)
    {
        cnt=0;
        for (int j=1; j<=i; j++) if (i%j==0) cnt++;
        if (cnt==8) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    ll t = 0;
    while(t * 0.08 <= a || t * 0.1 <= b){
        t++;
        if(a == (int)(t * 0.08) && (int)(t * 0.1) == b){
            cout << t;
            return 0;
        }
    }

    cout << -1;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long a[n][3],dp[2][3];
    for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
        cin>>a[i][j];
    
    for(int i=0;i<3;i++)
        dp[0][i]=a[0][i];
    for(int i=1;i<n;i++)
    {
        dp[(i&1)][0]=a[i][0]+max(dp[(i-1)&1][1],dp[(i-1)&1][2]);
        dp[(i&1)][1]=a[i][1]+max(dp[(i-1)&1][0],dp[(i-1)&1][2]);
        dp[(i&1)][2]=a[i][2]+max(dp[(i-1)&1][0],dp[(i-1)&1][1]);
       // cout<<dp[(i&1)][0]<<" "<<dp[(i&1)][1]<<" "<<dp[(i&1)][2]<<endl;
    }
    cout<<max(dp[(n-1)&1][0],max(dp[(n-1)&1][1],dp[(n-1)&1][2]))<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define ld      long double
#define F       first
#define S       second
long double PI = 2*acos(0.0);
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
vector<int> edges[200001];
bool bfs(int n,int m,vector<int>& dist)
{
    queue<int> q;
    q.push(1);
    dist[1]=0;
    vector<int> visited(n+1,0);
    visited[1]=1;
    int visits=1;
    while(!q.empty())
    {
        int i=q.front();
        q.pop();
        for(auto j:edges[i])
        {
            if(visited[j]==0)
            {
                ++visits;
                visited[j]=1;
                dist[j]=i;
                q.push(j);
            }
        }
    }
    if(visits==n)
        return true;
    return false;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> dist(n+1,1e10);
    bool flag=bfs(n,m,dist);
    if(flag==false)
        cout<<"No\n";
    else
    {
        cout<<"Yes\n";
        for(int i=2;i<=n;i++)
            cout<<dist[i]<<"\n";
    }
}
int32_t main()
{
    clock_t tStart = clock();
    #ifndef ONLINE_JUDGE
    _READ
    #endif
      _FAST
    
    int t;
    t=1;
    while(t--)
        solve();
    
    #ifndef ONLINE_JUDGE
    cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/


Measured memory_bytes: 16076
import java.util.Scanner;

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

        while(true){
            int i,j;
            int n=sc.nextInt();
            int r=sc.nextInt();

            if(n==0 && r==0){
                break;
            }

            int[] num=new int[n];

            for(i=0;i<n;i++){
                num[i]=n-i;
            }

            int[] swap=new int[n];

            for(i=0;i<r;i++){
                int p=sc.nextInt();
                int c=sc.nextInt();

                for(j=0;j<p+c-1;j++){
                    if(j<p-1){
                        swap[j]=num[j];
                    }else{
                        num[j-p+1]=num[j];
                    }
                }
                for(j=0;j<p-1;j++){
                    num[c+j]=swap[j];
                }
            }
            System.out.println(num[0]);
        }
        sc.close();
    }
}


Measured memory_bytes: 37820
#include<stdio.h>
int main(){
	int n,d,m,t;
	while(~scanf("%d%d",&n,&d))
	{
		t=2*d+1;
		if(n%t==0)
		m=n/t;
		else
		m=n/t+1;
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	while(1) {
		
		int n;
		
		scanf("%d", &n);
		if(n == 0) {
			break;
		}
		
		int i = 0;
		int pay = 0;
		for(i = 0; i < n; i++){
			int x, y, h, w, l;
			scanf("%d%d%d%d", &x, &y, &h, &w);
			l = x + y + h;
			
			if(l <= 60 && w <= 2) {
				pay += 600;
			}else if(l <= 80 && w <= 5) {
				pay += 800;
			}else if(l <= 100 && w <= 10){
				pay += 1000;
			}else if(l <= 120 && w <= 15){
				pay += 1200;
			}else if(l <= 140 && w <= 20){
				pay += 1400;
			}else if(l <= 160 && w <= 25){
				pay += 1600;
			}
		}
		printf("%d\n", pay);
	}
	
	return 0;
}


Measured memory_bytes: 2036
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 1000000007

func Solve() {
  var S int
  NextInt(&S)
  DP := make([][]int, S / 3 + 1)
  for i := range DP { DP[i] = make([]int, S + 1) }
  DP[0][0] = 1
  ans := 0
  for i := range DP[1:] {
    for j := range DP[i][3:] {
      DP[i + 1][j + 3] = (DP[i + 1][j + 2] + DP[i][j]) % p
    }
    ans = (ans + DP[i + 1][S]) % p
  }
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 13012
#include <iostream>
using ll = long long;
using namespace std;

int main(){
    ll K;
    cin >> K;
    ll p[50];
    for(int i = 0; i < 50; ++i){
        p[i] = 49;
    }
    ll rem = K % 50;
    ll div = K / 50;
    for(int i = 0; i < 50; ++i){
        p[i] += div;
    }
    for(int i = 0; i < rem; ++i){
        p[i] += 51 - rem;
    }
    for(int i = rem; i < 50; ++i){
        p[i] -= rem;
    }
    cout << 50 << endl;
    for(int i = 0; i < 49; ++i){
        cout << p[i] << " ";
    }
    cout << p[49] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
	
	int n,r,a,b;
	
	scanf("%d %d",&n,&r);
	
	if(n<=10){
		a=100 * (10-n);
		b=r + a;
		printf("%d\n",b);
	}else{
		printf("%d\n",r);
	}

return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> x(n);
	int ave = 0;
	REP(i,n){
		cin >> x[i];
	}
	int ans = 1e9;
	FOR(k,1,101){
		int tmp = 0;
		REP(i,n) tmp += (k-x[i]) * (k-x[i]);
		ans = min(ans, tmp);
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		if(x < 1200){
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n - 1):
    # if i % 2 == 0:
    #     ans += a[i]
    # else:
    #     ans += a[i - 1]
    ans += a[(i + 1) // 2]
    #print(ans)
print(ans)



Measured memory_bytes: 104880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll cnt[20][214514];
int main(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll x;
		cin>>x;
		for(int j=0;j<20;j++){
			ll num=(1<<j);
			if(x&num)cnt[j][i]++;
		}
	}
	for(int i=2;i<=n;i++){
		for(int j=0;j<20;j++){
			cnt[j][i]+=cnt[j][i-1];
		}
	}
	ll ans=0;
	ll r=1;
	for(int i=1;i<=n;i++){
		while(1){

			bool f=0;
			for(int j=0;j<20;j++)if(cnt[j][r]-cnt[j][i-1]>1)f=1;
			if(f){
				//cout<<i<<' '<<r<<endl;
				ans+=r-i;
				break;
			}
			if(r==n){
			ans+=r-i+1;
			break;
			}
			r++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 34908
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using LL = long long;
#define MAX 1e5
int main() {
	int Q;
	cin >> Q;
	vector<bool> is_prime(MAX, true), like_number(MAX, true);
	is_prime[1] = false;
	for (int i = 2; i * i<= MAX; i++) {
		for (int j = 2; i * j <= MAX; j++) {
			is_prime[i * j] = false;
		}
	}
	vector<int> sum(MAX, 0);
	for (int i = 3; i <= MAX; i++) {
		if (is_prime[i] && is_prime[(i + 1) / 2] && i % 2 == 1) {
			sum[i] = sum[i - 1] + 1;
		}
		else {
			sum[i] = sum[i - 1];
		}
	}
	for (int q = 0; q < Q; q++) {
		int li, ri;
		cin >> li >> ri;
		cout << sum[ri] - sum[li - 1] << endl;
	}


	return 0;


}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max(0, a - 2*b));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3];
 
int main() {
  for(int i =0;i<3;i+=1)
    cin>>a[i];
  
  bool answer = false;
  if(a[0]==5 && a[1]==7 && a[2]==5) 
    answer=true;
  if(a[0]==5 && a[1]==5 && a[2]==7) 
    answer=true;
  if(a[0]==7 && a[1]==5 && a[2]==5) 
    answer=true;
  if(answer)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	string a, b;
	cin >> a >> b;
	string c = a + b;
	for (int i = 0; i < 1000; i++) {
		if (stoi(c) == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main ()
{
	int N ;
	while ( cin >> N )
	{
		int sum = 0 , i = 0 ;
		for ( i = 1 ; i <= N ; i++ ) 
		{
			sum = sum + i ; 
		}
		 cout << sum << endl ;
	}
	return 0 ;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int main() {
	long long H, W, diff = 0x7fffffff;
	scanf("%lld %lld", &H, &W);
	if (H % 3 == 0 || W % 3 == 0)
		diff = std::min(diff, 0ll);
	if (H % 3 == 1 || H % 3 == 2)
		diff = std::min(diff, W);
	if (W % 3 == 1 || W % 3 == 2)
		diff = std::min(diff, H);
	for (int i = 0; i < H / 3 + 2; i++) {
		long long S1 = i * W;
		long long S2 = (H - i) * (W / 2);
		long long S3 = (H - i) * (W - W / 2);
		long long cdiff = std::max(std::max(S1, S2), S3) - std::min(std::min(S1, S2), S3);
		diff = std::min(diff, cdiff);
	}
	for (int i = 0; i < W / 3 + W % 3; i++) {
		long long S1 = H * i;
		long long S2 = (H / 2) * (W - i);
		long long S3 = (H - H / 2) * (W - i);
		long long cdiff = std::max(std::max(S1, S2), S3) - std::min(std::min(S1, S2), S3);
		diff = std::min(diff, cdiff);
	}
	printf("%d\n", diff);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const int inf = 1<<30;
int N, M, R;
vector<int> r;
vector<vector<int>> dist;

void input(){
    cin >> N >> M >> R;
    r.resize(R);
    rep(i, R) cin >> r[i], --r[i];
    dist.resize(N, vector<int>(N, inf));
    rep(i, N) dist[i][i] = 0;
    rep(i, M){
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = dist[b][a] = c;
    }
}

void floyd(){
    rep(k, N){
        rep(i, N){
            if(dist[i][k] == inf) continue;
            rep(j, N){
                if(dist[k][j] == inf) continue;
                chmin(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
}

void solve(){
    floyd();

    int ans = inf;
    sort(r.begin(), r.end());
    do{
        int tmp = 0;
        repr(i, 1, r.size()) tmp += dist[r[i]][r[i-1]];
        chmin(ans, tmp);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}

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

    input();
    solve();

    return 0;
}



Measured memory_bytes: 384
N = int(input())
N = str(N)
num = []
num = [int(x) for x in list(str(N))]
lenN = len(N)
flg = 0


for i in range(lenN):
    if num[i] == 7:
        flg = 1

if flg == 1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9116
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string O, E;
    cin >> O >> E;
    for (int i = 1; i <= (int)O.length() + (int)E.length(); i++)
    {
        if (i % 2 != 0)
        {
            cout << O[(i - 1) / 2]; 
        }else
        {
            cout << E[(i - 2) / 2];
        }
        
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 888
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int value = 700;
    for (int i=0; i<3; i++) {
      if(S.charAt(i) == 'o') value += 100;
    }
    System.out.println(value); 
  }
}

Measured memory_bytes: 22740
N = int(input())
S = input()
K = int(input())
save = S[K-1]
ans = "*"*N
for x in range(N):
    if x == 0 :
        if S[x] == save:
            ans =save + ans[x+1:]
        continue
    if S[x] == save:
        ans = ans[:x] + save + ans[x+1:]
print(ans)

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

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  
  if (a >= k) {
    cout << (a-k) << ' ' << b << endl;
  } else {
	cout << 0 << ' ' << max(b-k+a, ll(0)) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<int> dijkstra(int i,int n, vector<vector<pair<int, int>>> graph) {
  vector<int> d(n, INF);
  d[i] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  q.push(make_pair(0, i));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) {
      continue;
    }
    for (auto x : graph[v]) {
      if (d[x.first] > d[v] + x.second) {
        d[x.first] = d[v] + x.second;
        q.push(pair<int, int>(d[x.first], x.first));
      }
    }
  }
  return d;
}

signed main() {
  int N, M;
  cin >> N >> M;

  vector<vector<pair<int, int>>> graph(N);
  REP(i, M){
    int x, y, d;
    cin >> x >> y >> d;
    x--; y--;
    graph[x].emplace_back(y, d);
  }
  FOR(i, 1, N){
    graph[i].emplace_back(i-1, 0);
  }

  vector<int> dist = dijkstra(0, N, graph);
  if(dist[N-1] == INF) dist[N-1] = -1;
  cout << dist[N-1] << endl;

  return 0;
}

Measured memory_bytes: 15996
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(tmp%2==0) cnt++;
    }
    if(cnt==n) cout<<"second"<<endl;
    else cout<<"first"<<endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce

n  = input()
xs = list(map(int, input().split()))

MAX  = 10 ** 18

if 0 in xs:
  print(0)
  exit(0)

result = 1
  
for x in xs:
  result *= x
  
  if result > MAX:
    print(-1)
    exit(0)
    
print(result)


Measured memory_bytes: 23000
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;

int main(void) {
	long int A,B,C  ;
	long int X, Y;
	long int A_sum ,B_sum= 0;
	long int ans=0;
	cin >> A >> B >> C >> X >> Y;
	if (X > Y) {
		swap(A,B);
		swap(X,Y);
	}
	if (A + B <= C*2)
		ans = X*A + Y*B;
	else {
		ans += X * 2 * C;
		//A買い終わり
		ans += ( Y-X)*min(B, C*2);
		//B end
	}

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

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


/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
*/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)
/*STL library functions

sort(first_iterator, last_iterator) – To sort the given vector.

reverse(first_iterator, last_iterator) – To reverse a vector.

*max_element (first_iterator, last_iterator) – To find the maximum element of a vector.

*min_element (first_iterator, last_iterator) – To find the minimum element of a vector.

accumulate(first_iterator, last_iterator, initial value of sum) – Does the summation of vector elements

count(first_iterator, last_iterator,x) – To count the occurrences of x in vector.

find(first_iterator, last_iterator, x) – Points to last address of vector ((name_of_vector).end())
 if element is not present in vector.

binary_search(first_iterator, last_iterator, x) – Tests whether x exists in sorted vector or not.

lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
which has a value not less than ‘x’.

upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last)
 which has a value greater than ‘x’.

arr.erase(position to be deleted) – This erases selected element in vector and shifts and resizes the vector elements accordingly.

arr.erase(unique(arr.begin(),arr.end()),arr.end()) – This erases the duplicate occurrences in sorted vector in a single line.

distance(first_iterator,desired_position) – It returns the distance of desired position from the first iterator.
This function is very useful while finding the index.

next_permutation(first_iterator, last_iterator) – This modified the vector to its next permutation.

prev_permutation(first_iterator, last_iterator) – This modified the vector to its previous permutation.
*/

using namespace std;

int main()
{

    ll n;
    cin>>n;
    ll a[n+5],i,j=0,ans=INT_MAX,mp[n+5];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        ans=min(ans,a[i]);
        if(a[i]<=ans)
            j++;
    }
    cout<<j<<endl;
    return 0;
}






Measured memory_bytes: 1792
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, cnt[2];

void solve() { 
  cin >> n;
  for (int i = 1;i <= n;i++) {
    int x; cin >> x;
    cnt[x & 1]++;
  }
  if (cnt[1] % 2) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
   // freopen("in", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;


int main(){

    int N,M; cin>>N>>M;
    vector<ll> dp(N+3,0);
    for (int i = 0; i < M; ++i) {
        int tmp; cin>>tmp;
        dp[tmp]=-1;
    }

    if(dp[1]!=-1) dp[1] = 1;
    if(dp[2]!=-1) dp[2] = 1;

    for (int i = 0; i <= N; ++i) {
        if(dp[i]==-1) continue;

        if(dp[i+1]!=-1)
            dp[i+1] += dp[i];

        if(dp[i+2]!=-1)
            dp[i+2] += dp[i];

        dp[i+1] %= MOD;
        dp[i+2] %= MOD;
    }

    cout<<dp[N]<<endl;

    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r(n),g(n),b(n);
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='R')r[i]++;
		if(s[i]=='G')g[i]++;
		if(s[i]=='B')b[i]++;
	}
	for(int i = n-1;i>0;i--)
	{
		r[i-1]+=r[i];
		g[i-1]+=g[i];
		b[i-1]+=b[i];
	}
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n-1;j++)
		{
			if(s[i]=='R'&&s[j]=='G')ans+=b[j+1];
			if(s[i]=='G'&&s[j]=='R')ans+=b[j+1];
			if(s[i]=='R'&&s[j]=='B')ans+=g[j+1];
			if(s[i]=='B'&&s[j]=='R')ans+=g[j+1];
			if(s[i]=='B'&&s[j]=='G')ans+=r[j+1];
			if(s[i]=='G'&&s[j]=='B')ans+=r[j+1];
		}
	}
	ll anss = 0;
	for(int i = 1;i<n;i++)
	{
		for(int j = 0;j<n;j++)
		{
			if(j+i*2>=n)break;
			if(s[j]!=s[j+i]&&s[j+i]!=s[j+i*2]&&s[j+i*2]!=s[j])anss++;
		}
	}
	
	cout<<ans-anss<<endl;
	
	return 0;
}

Measured memory_bytes: 3692
function Main(input) {
    input = input.slice(0,1)
    if(input === "A") {
        console.log("T")
        return 0
    }
    if(input === "T") {
        console.log("A")
        return 0
    }
    if(input === "C") {
        console.log("G")
        return 0
    }
    if(input === "G") {
        console.log("C")
        return 0
    }
    return 0
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 () {
  int n;
  cin >> n;
  
  auto f = [&](int x) {
    int r = x%10;
    int l;
    while (x) {
      l = x;
      x /= 10;
    }
    return P(l,r);
  };


  map<P,int> freq;
  rrep(i,n) {
    freq[f(i)]++;
  }
  ll ans = 0;
  rrep(i,n) {
    P p = f(i);
    ans += freq[P(p.se,p.fi)];
  }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define ll long long
#define maxn 100010
#define inf 0x3f3f3f3f
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct edge{
	int to,nxt;
}e[2*maxn];
int fir[maxn],a[maxn],b[maxn],c[maxn],id[maxn],fa[maxn],mark[maxn];
ll f[maxn],size[maxn];
std::vector<int>son[maxn];
int n,m,tot=0;
bool cmp(int x,int y){return c[x]<c[y];}
inline void add_edge(int x,int y){e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;}
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void dp(int now)
{
	size[now]=b[now];
	for(auto i:son[now]){
		dp(i);
		size[now]+=size[i];
	}
	f[now]=(son[now].size()?1ll<<60:c[now]+b[now]);
	for(auto i:son[now])
		f[now]=std::min(f[now],std::max((ll)c[now],f[i])+size[now]-size[i]);
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),b[i]=read(),c[i]=std::max(a[i]-b[i],0);
	memset(fir,255,sizeof(fir)); tot=0;
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		add_edge(x,y); add_edge(y,x);
	}
	for(int i=1;i<=n;i++)
		fa[i]=i,id[i]=i;
	std::sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		mark[id[i]]=1;
		for(int j=fir[id[i]];~j;j=e[j].nxt)
			if(mark[e[j].to]){
				int fx=find(id[i]),fy=find(e[j].to);
				if(fx!=fy){
					fa[fy]=fx;
					son[id[i]].push_back(fy);
				}
			}
	}
	dp(id[n]);
	writeln(f[id[n]]);
	return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define mod1 998244353 
#define inf 1000000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll dp[2005][2005];


int main()
{
    fastio;
    #ifdef APNA_IO
        start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);    
    #endif

    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++)
        dp[i][0]=1;
    for(ll i=1;i<=m;i++)
        dp[0][i]=1;
    dp[0][0]=1;

    ll a[n+1],b[m+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    for(ll i=1;i<=m;i++)
        cin>>b[i];

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
            if(a[i]==b[j])
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    dp[n][m]=(dp[n][m]+mod)%mod;
    cout<<dp[n][m];

    #ifdef APNA_IO
        end_routine();  
    #endif
}

Measured memory_bytes: 31616
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll nx = N / (A + B);
    ll ny = N % (A + B);
    cout << nx * A + min(ny, A) << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


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

int main(void) {
	int p, q, r;
	cin >> p >> q >> r;

	int r1 = p + q, r2 = q + r, r3 = r + p;
	if (r1 <= r2 && r1 <= r3)
		cout << r1;
	else if (r2 <= r1 && r2 <= r3)
		cout << r2;
	else if (r3 <= r1 && r3 <= r2)
		cout << r3;
}

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

multiset<int> se;

int main()
{
    // freopen("powers.in", "r", stdin);
    // freopen("powers.out", "w", stdout);
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        se.insert(x);
    }
    int answer = 0;
    while (!se.empty())
    {
        multiset<int>::iterator it = se.end();
        it--;
        int back = *it;
        se.erase(it);
        int i = 1;
        for (; i <= back; i <<= 1)
            ;
        if (se.find(i - back) != se.end())
        {
            se.erase(se.find(i - back));
            answer++;
        }
    }
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 9600
import sys
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
if A.count(0)>0:
  print(0)
  sys.exit()
for i in range(1,N):
  ans = ans*A[i]
  if ans>10**18:
    print(-1)
    sys.exit()
print(ans)

Measured memory_bytes: 21648