akhauriyash/Code-Regression huggingface dataset:
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll N, W;
ll w[110], v[110];

ll dp[110][100010];

ll dfs(ll i, ll j){
  if(dp[i][j] != -1) return dp[i][j];
  ll res;
  if(i == N) res = 0;
  else if(j < w[i]) res = dfs(i+1, j);
  else res = max(dfs(i+1, j), dfs(i+1, j-w[i])+v[i]);
  return dp[i][j] = res;
}

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

  cin >> N >> W;
  REP(i, N) cin >> w[i] >> v[i];

  /*
  // dp[i][j] := i番目までの重さW以下となる最大価値
  dp[0][0] = 0;
  REP(i, N+1){
    REP(j, W+1){
      if(j-w[i] >= 0){
	dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      }
      else{
	dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
  */

  memset(dp, -1, sizeof(dp));
  cout << dfs(0, W) << endl;
  
  return 0;
}


Measured memory_bytes: 86272
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<cstdlib>
#include<iomanip> //cout<<setiosflags(ios::fixed)<<setprecision(2);
#include<ctime> //double a=(double)clock();   cout<<a<<endl;
#include<vector>
#include<queue>
using namespace std;
inline int read(){
    int x=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return ff*x;
}
bool divid(int x){
	int cnt=0;
	while(x){
		x/=10;
		cnt++;
	}
	return cnt&1;
}
int main(){
	//freopen("in","r",stdin);
	int ans=0;
	int N=read();
	for(int i=1;i<=N;i++)
		if(divid(i))
			ans++;
	cout<<ans<<endl;
	return 0;
}
 


Measured memory_bytes: 256
n_a, n_b, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
xycs = m.times.map{gets.split.map(&:to_i)}

ans = a.min + b.min

xycs.each do |xyc|
    x = xyc[0] - 1
    y = xyc[1] - 1
    t = a[x] + b[y] - xyc[2]
    ans = t if ans > t
end

p ans

Measured memory_bytes: 20732
#include <stdio.h>

int main(void) {

  int num;
  int i = 0;

  while (1) {
    scanf("%d", &num);

    if (num == 0) {
      break;
    } else {
      printf("Case %d: %d\n", ++i, num);
    }
  }

  return 0;
}



Measured memory_bytes: 2048
#include <algorithm>
#include <bitset>
#include <complex>
#include <cassert>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <memory>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>

#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define INF_LL 4000000000000000000LL
#define INF 1000000000
#define EPS 1e-8
#define LL long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))
#define bits(a) __builtin_popcountll(a)

using namespace std;

pair<pair<int, int>, int> arr[100005];
vector<int> in[100005], out[100005];
int cnt[33];

int main() {
  int n, c;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &arr[i].f.f, &arr[i].f.s, &arr[i].s);
    in[arr[i].f.f].pb(arr[i].s);
    out[arr[i].f.s].pb(arr[i].s);
  }
  int ans = 0;
  for (int i = 0; i <= 100000; i++) {
    for (int x : in[i]) {
      cnt[x]++;
    }
    int tmp = 0;
    for (int j = 1; j <= c; j++) {
      tmp += cnt[j] > 0;
    }
    ans = max(ans, tmp);
    for (int x : out[i]) {
      cnt[x]--;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string s;
  cin >> s;
  ll ans=0;
  rep(i, s.size()) if(i+s[i] & 1) ans++;
  cout << min(ans, (ll)(s.size()-ans)) << newl;
  return 0;
}

Measured memory_bytes: 3804
list_stack = [0]
list_input = list((map(str, input().split())))
i = 0
while True:
    try:
        list_stack.append(int(list_input[i]))
    except ValueError:
        b = list_stack.pop()
        a = list_stack.pop()
        if list_input[i] == "+":
            list_stack.append(int(a + b))
        elif list_input[i] == "-":
            list_stack.append(int(a-b))
        else:
            list_stack.append(int(a*b))

    try:
        i += 1
        list_input[i]
    except IndexError:
        print(list_stack.pop())
        break



Measured memory_bytes: 5608
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := (a*3+b)/2
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans=(n+x-1)/x;
    ans*=t;
    cout<<ans<<endl;
}



Measured memory_bytes: 3656
#include<iostream>
#include<string>
using namespace std;
int main(void) {
  string a;
  string b;
  cin>>a>>b;
  int num=stoi(a+b);
  for(int i=0; i<1001; i++) {
    if(i*i==num) {
      cout<<"Yes";      
      return 0;
    }
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

ans = float("inf")
for k in range(0, max(x, y)*2+1, 2):
    i = 0 if x-k//2 < 0 else x-k//2
    j = 0 if y-k//2 < 0 else y-k//2
    ans = min(ans, a*i+b*j+c*k)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define nMAX 41

int NC = 0,lC = 0,n;

//二分木再起関数で後順
void BtreeRec(int left,int right,int Af[],int Am[],int Al[]){
    int tmp,mid;
    
    //leftとright入れ替わりで終了
    if(left >= right) {
        return;
    }
    
    tmp = Af[NC++];
    mid = Find(tmp,Am);
    //今の場所から左側の処理
    BtreeRec(left, mid,Af,Am,Al);
    //今の場所から右側の処理
    BtreeRec(mid + 1, right,Af,Am,Al);
    Al[lC++] = tmp;
}

//AfとAmで同じ数の物を返す
int Find(int tmp,int Am[]) {
    for(int i = 0 ; i < n ; i++) {
        if(tmp == Am[i]) {
            return i;
        }
    }
    return 0;
}

int main(){
    //枠の作成
    int i;
    scanf("%d",&n);
    int *Af = malloc(sizeof(int)*n);
    int *Am = malloc(sizeof(int)*n);
    int *Al = malloc(sizeof(int)*n);
    
    //読み込み
    for( i = 0 ; i < n ; i++ ){
        scanf("%d",&Af[i]);
    }
    for( i = 0 ; i < n ; i++ ){
        scanf("%d",&Am[i]);
    }
    
    //後行順巡回作成
    BtreeRec(0,n,Af,Am,Al);
    
    //表示
    for(i = 0 ; i < n-1 ; i++) {
        printf("%d ",Al[i]);
    }
    printf("%d\n", Al[n-1]);
    
    return 0;
}


Measured memory_bytes: 2052
#include <stdio.h>
int main(void){
  int a[4],b[4],c1=0,c2=0,c3=0,c4=0;
  for(int i=1;i<=3;i++){
    scanf("%d %d",&a[i],&b[i]);
    if(a[i]==1||b[i]==1) c1++;
    if(a[i]==2||b[i]==2) c2++;
    if(a[i]==3||b[i]==3) c3++;
    if(a[i]==4||b[i]==4) c4++;
  }
  if(c1<=2&&c2<=2&&c3<=2&&c4<=2) printf("YES");
  else printf("NO");
  return 0;
}

Measured memory_bytes: 128
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
MA=max(A)
c=[0]*(MA+1)
for i in range(n):
	c[A[i]]+=1
for i in range(1,MA+1):
	c[i]+=c[i-1]
for j in range(n-1,-1,-1):
	# print(B)
	B[c[A[j]]-1]=A[j]
	c[A[j]]-=1

print(*B)



Measured memory_bytes: 224384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;
vector<vector<ll>> vlist(1e5+1);

void bfs(ll s, vector<ll>& d){
  queue<ll> q;
  q.push(s);
  while(!q.empty()){
    ll t = q.front();
    q.pop();
    REP(i, vlist[t].size()){
      if(vlist[t][i] != s && d[vlist[t][i]] == 0){
        d[vlist[t][i]] = d[t] + 1;
        q.push(vlist[t][i]);
      }
    }
  }
}

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

  ll n;
  cin >> n;
  ll a[n - 1], b[n - 1];
  REP(i, n - 1){
    cin >> a[i] >> b[i];
    vlist[a[i]].pb(b[i]);
    vlist[b[i]].pb(a[i]);
  }

  vector<ll> d1(n + 1, 0), dn(n + 1, 0);
  bfs(1, d1);
  bfs(n, dn);

  ll sum = 0;
  for(int i = 1; i <= n; i++) sum += (d1[i] <= dn[i]) ? 1 : -1;
  if(sum > 0) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 9540
<?php
fscanf(STDIN, "%d", $n);

$cnt = array(
  'AC'  => 0,
  'WA'  => 0,
  'TLE' => 0,
  'RE'  => 0,
);

for ($i=0; $i < $n; $i++) {
  fscanf(STDIN, "%s", $s);

  ++$cnt[$s];
}

foreach ($cnt as $key => $val) {
  echo $key . ' x ' . $val . PHP_EOL;
}


Measured memory_bytes: 16144
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
#define mod 1000000007

signed main()
{
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif
	/************************************/
	
	int n; cin>>n;
	int sum =0;
	int a[n];
	for(int &i :a ) cin>>i;
	for(int i=0; i<n-1; i++)
		for(int j = i+1; j<n; j++)
			sum += a[i]*a[j];
	cout<<sum<<"\n";
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    cin >> s;
    ll ans=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

struct Graph {
    struct Edge { int from; int to; lint cost; };
    struct Node {
        Node() : par(-1), done(false), dist(INF) {}
        int index;
        int par;
        bool done;
        lint dist;
        vector<Edge> edge;
    };

    int n;
    vector<Node> nodes;
    vector<Edge> edges;
    const static lint INF = 1e18;

    Graph(int n) : n(n) {
        nodes.resize(n);
        for(int i=0; i<n; i++)  nodes[i].index = i;
    }

    void add_edge(int from, int to, lint cost) {
        nodes[from].edge.push_back(Edge{from, to, cost});
        edges.push_back(Edge{from, to, cost});
    }

    void bfs(int s) {
        for(auto& e : nodes)  e.dist = INF;
        queue<int> que;
        nodes[s].dist = 0;
        que.push(s);

        while(!que.empty()) {
            int index = que.front(); que.pop();
            for(auto& e : nodes[index].edge) {
                if(nodes[e.to].dist != INF)  continue;
                nodes[e.to].dist = nodes[index].dist + 1;
                nodes[e.to].par = index;
                que.push(e.to);
            }
        }
    }

    lint shortest_dist(int to) { return nodes[to].dist; }

    vector<int> shortest_path(int to) {
        vector<int> path;
        int index = to;
        while(index != -1) {
            path.push_back(index);
            index = nodes[index].par;
        }
        reverse(path.begin(), path.end());
        return path;
    }
};

int main() {
    lint n, x, y;
    cin >> n >> x >> y;

    Graph g(n);
    g.add_edge(x-1, y-1, 1);
    g.add_edge(y-1, x-1, 1);
    for(lint i=0; i+1<n; i++) {
        g.add_edge(i, i+1, 1);
        g.add_edge(i+1, i, 1);
    }

    map<lint, lint> counter;
    for(lint i=0; i<n; i++) {
        g.bfs(i);
        for(lint j=i+1; j<n; j++) {
            counter[g.shortest_dist(j)]++;
        }
    }

    for(lint i=1; i<n; i++) {
        cout << counter[i] << endl;
    }

}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
import re

S = input()
pattern = r"R+L+"
iterator = re.finditer(pattern, S)

i=0
for matched in iterator:
    pattern = r"RL"
    start_id = matched.start()
    end_id = matched.end()
    matched_len = end_id - start_id

    m = re.search(pattern, matched.group())
    R_pos = start_id + m.start()
    R_num = (m.start()+2)//2 + (matched_len - m.start()-1)//2
    L_num = matched_len - R_num
    if i == 1:
        print(" ", end="")
    print("0 "*m.start()+str(R_num)+" "+str(L_num)+" 0"*(matched_len-m.end()), end="")
    i=1


Measured memory_bytes: 56412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    // printf("%d\n", N);
    return 0;
}

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

int main() {
	int n,x;

	scanf("%d", &n);

	x = n / 25;
	x += n % 25 / 10;
	x += n % 25 % 10 / 5;
	x += n % 25 % 10 % 5;

	printf("%d\n", x);


	return 0;
}


Measured memory_bytes: 2108
a=int(input())
b=int(input())
c=int(input())
x=int(input())

sum=0

d=int(x/500)

for i in range(min(a,d)+1):
    #500coin i

    y=x-500*i

    e=int(y/100)
    for j in range(min(b,e)+1):
        #100coin j
        z=y-100*j

        w=int(z/50)

        if w<=c:
            sum+=1
        else:
            pass

print(sum)
        


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vec_rep(itr,v) for(auto itr = v.begin(); itr != v.end(); ++itr)

int main(void){
    string S;
    cin >> S;
    int S_len = (int)S.size();
    string S1,S2,S1_r,S2_r,S_r;
    S1 = S.substr(0,(S_len-1)/2);
    S2 = S.substr((S_len+1)/2);
    S_r = S;
    S1_r = S1;
    reverse(S_r.begin(),S_r.end());
    reverse(S1_r.begin(),S1_r.end());
    S2_r = S2;
    reverse(S2_r.begin(),S2_r.end());
    if(S1 == S1_r && S2 == S2_r && S == S_r)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  var inputs = input.trim().split("\n");
  var N = inputs[0].split(" ")[0];
  var K = inputs[0].split(" ")[1];
  var A = inputs[1].split("");
  var ans = "";
  for(var i=0;i<N;i++){
    if(K==i+1) ans += A[i].toLowerCase();
    else ans += A[i];
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 21064
n = int(input())
if n<105:
    print(0)
    exit()
if n==105:
    print(1)
    exit()
res=1
for i in range(107,n+1):
    if i%2==0:continue
    cnt=0
    for j in range(1, i+1):
        if i%j==0:
            cnt+=1
    if cnt==8:
        res+=1
print(res)

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

int main(){

  int N=0;
  cin>>N;
  int a[N];
	

  int done[N];
  
  rep(i,N){
	cin>>a[i];
    done[i]=0;
  }
  
  int next=a[0]-1;
  done[0]=1;
  if(next==1){cout<<1<<endl; return 0;}
  int count=1;
  while(1){

    if(next==1){cout<<count<<endl; return 0;}
    next=a[next]-1;
    if(done[next]==1){cout<<-1<<endl; return 0;}
    done[next]=1;
	count++;    
  }

}

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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 50 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;
ll a[N];

void solve(int cs){
    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &a[i]);
    }

    ll ans = 0;
    for(int i = 0 ; i < n ; i ++){
            for(int j = i + 1 ; j < n ; j ++){
                    ans += (a[i] * a[j]);
            }
    }
    printf("%lld\n" , ans);
}

main(){

    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}


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

int main() {
  int N;

  cin >> N;

  bool foundP = 0, foundW = 0, foundG = 0, foundY = 0;


  for (int i = 0; i < N; i++) {
    string S;

    cin >> S;

    if (S == "P") {
      foundP = 1;
    } else if (S == "W") {
      foundW = 1;
    } else if (S == "G") {
      foundG = 1;
    } else if (S == "Y") {
      foundY = 1;
    }
  }

  if (foundP + foundW + foundG + foundY == 4) {
    cout << "Four" << endl;
  } else if (foundP + foundW + foundG + foundY == 3) {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 3584
import sys
l,r = map(int,input().split())
if r - l >= 2018:
  print(0)
  sys.exit()
l = l % 2019
r = r % 2019
if r <= l:
  print(0)
  sys.exit()
m = 2019
for i in range(l,r):
  for j in range(i+1,r+1):
    m = min(m,i*j%2019)
print(m)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */
int N, A, B, C;
int l[8];
int dfs(int a, int b, int c, int i){
    int minv = INF;
    if(i == N)return ((a == 0 || b == 0 || c == 0) ? INF : abs(a - A) + abs(b - B) + abs(c - C) - 30);
    minv = min(minv, dfs(a + l[i], b, c, i + 1) + 10);
    minv = min(minv, dfs(a, b + l[i], c, i + 1) + 10);
    minv = min(minv, dfs(a, b, c + l[i], i + 1) + 10);
    minv = min(minv, dfs(a, b, c, i + 1));
    return minv;
}

int main(){
    cin >> N >> A >> B >> C;
    rep(i, N)cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define endl '\n'
#define ll unsigned long long
using namespace std;

string N;

string Solution(string N) {

	for (auto x : N) if (x == '7') return "Yes";
	return "No";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	string s = Solution(N);
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a)
#define abs(x) (x<0?(-x):x) // big bug here if "-x" is not surrounded by "()"
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define TESTS wez(testow)while(testow--) //for multilple cases problems
#define whileZ int T; getI(T); while(T--) // the same as above
#define getS(x) scanf("%s", x) //get a char* string
#define clr(a,x) memset(a,x,sizeof(a)) //set elements of array to some value
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);//to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
// for debug
inline void pisz(int n) { printf("%d\n",n); }
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
#define MAXN 10000
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<long long> vll;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {-1,0}, {0,-1}, {1,0}};
const int fxx[9][2] = {{0,0},{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int N = 500;
const ll mod = 1000000007;



int main() 
{IOS
    int x;
    cin>>x;
    cout<<!x;


}


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



intll factorial(intll x){
  if (x > 1)
   return x * factorial(x-1) %  1000000007 ;    
                            
  if ( x == 1 ) 
    return 1 ;
}

int main() {
  intll n , m ;
  cin >> n >> m ;
  intll  ans = 1 ;
  
  ans = ans * (factorial(n) %  1000000007) ;
  ans = ans * (factorial(m) %  1000000007) ;
  
  if ( (n+m) % 2 == 0)
    ans *=2;
  
  if( max(n,m) - min(n,m) >= 2 ){
    ans = 0;
  }
  
  cout << ans  % 1000000007 ;

  
}


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

#define ARRAY_MAX 114514
#define MAXI 3500

long long int N;

int main(){

    cin >> N;

    for(int i = 1; i <= MAXI;i++){
        for(int j = 1;j <= MAXI; j++){
            long long int tmp1 = i*j*N;
            long long int tmp2 = (4*i*j) - N*(i+j);
            if(tmp2 == 0 || tmp1 / tmp2 < 0 || tmp1 % tmp2 != 0){
                ;
            }else{
                cout << i << " " << j << " " << tmp1 / tmp2 << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int cnt = 0;
    while(A >= B) {
        B *= 2; cnt++;
    }

    while(B >= C) {
        C *= 2; cnt++;
    }

    if (cnt <= K) print("Yes");
    else print("No");
    
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N = 0;
  cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a] = i + 1;
  }
  for (int i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    cout << A[i + 1];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 5504
import sys
from io import StringIO
import unittest
from collections import Counter

def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    counter = Counter(a)

    for i in range(1, n + 1, 1):
        print(counter[i])


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5
1 1 2 2"""
        output = """2
2
0
0
0"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
1 1 1 1 1 1 1 1 1"""
        output = """9
0
0
0
0
0
0
0
0
0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """7
1 2 3 4 5 6"""
        output = """1
1
1
1
1
1
0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 42312
#include<stdio.h>
int main()
{
	long long int n,a[87],i;
	scanf("%d",&n);
	a[0]=2;
	a[1]=1;
	for(i=2;i<=n;i++){
		a[i]=a[i-2]+a[i-1];
	}
	printf("%lld\n",a[n]);
	return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>
int main(){
    int v, h;
    for(scanf("%d %d", &v, &h); v!=0||h!=0; scanf("%d %d", &v, &h)){
        for(int i=0; i<v; i++){
            for(int j=0; j<h; j++){
                if((i+j)%2){
                    putchar('.');
                }else{
                    putchar('#');
                }
            }
            putchar('\n');
        }
        putchar('\n');
    }
}



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

int main(){
    string s;
    int a[1005]={0};
    int s1,t=0;
    getline(cin,s);
    s=s+' '; s1=0;
    for (int i=0; i<s.length(); i++){
    	if (s[i]==' '){
    		if (s[i-1]<='9' && s[i-1]>='0'){
    			t++;
    			int tmp=0;
    			for (int j=s1; j<i; j++){
    				int m=s[j]-'0';
    				tmp+=pow(10,i-j-1)*m;
				}
				a[t]=tmp;
				s1=i+1;
			}
			else{
				s1=i+1;
				switch (s[i-1]){
					case '+':{
						a[t-1]=a[t]+a[t-1];
						t--;
						break;
					}
					case '-':{
						a[t-1]=a[t-1]-a[t];
						t--;
						break;
					}
					case '*':{
						a[t-1]=a[t-1]*a[t];
						t--;
						break;
					}
				}					
			}
		}
	}
	cout<<a[t]<<endl;
    return 0;
} 


Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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 INF = 1e9;
const long long INFL = 1LL<<60;

/*
ll gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}
*/

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i) continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);
  return res;
}

map<ll, int> prime_factor(ll n) {
  map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

  ll g = gcd(a, b);
  map<ll, int> pf = prime_factor(g);

  ll ans = pf.size() + 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
   int w,a,b;
   scanf("%d%d%d",&w,&a,&b);
   if(a<b&&(a+w)<b)
   printf("%d",(b-(a+w)));
   else if(b<a&&(b+w)<a)
   printf("%d",a-(b+w));
   else
   printf("0");
   return 0;
}																												

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	map<string, string> mps;
	mps["Sunny"] = "Cloudy", mps["Cloudy"] = "Rainy", mps["Rainy"] = "Sunny";
	string inp;
	cin >> inp;
	cout << mps[inp];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

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

    vector<int> A(n);
    rep(i, n) cin >> A.at(i);

    vector<int> B(n);
    rep(i, n) cin >> B.at(i);

    vector<int> C(n - 1);
    rep(i, n - 1) cin >> C.at(i);

    int sum = 0, prev = -1;
    for (auto a : A) {
        sum += B.at(a - 1);
        if (prev + 1 == a) {
            sum += C.at(prev - 1);
        }
        prev = a;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int K;
	cin >> K;
	vector<int>d = { a,b,c };
	sort(all(d));
	int ma = d[2];
	ma = ma*pow(2, K);
	cout << ma + d[0] + d[1];

	return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

const int maxn = 1e5 + 20;

int n, m, A[maxn], F[maxn];
std::pair<int,int> M[maxn];
bool used[maxn];

int find(int x)
{
	return F[x] == x ? x : (F[x] = find(F[x]));
}
template<class TAT>void checkmin(TAT &x,const TAT &y)
{
	if(y < x) x = y;
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++) scanf("%d", &A[i]);
	
	for(int i = 0; i < n; i++) F[i] = i;
	
	for(int i = 0, x, y; i < m; i++)
	{
		scanf("%d%d", &x, &y);
		F[find(x)] = find(y);
	}
	
	for(int i = 0; i < n; i++)
		M[i] = std::make_pair(A[i], i);
	
	for(int i = 0; i < n; i++)
		checkmin(M[find(i)], M[i]);
	
	long long ans = 0;
	int cnt = 0;
	
	for(int i = 0; i < n; i++)
		if(find(i) == i)
		{
			ans += M[i].first, cnt++;
			used[M[i].second] = true;
		}

	if(cnt == 1)
	{
		printf("0\n");
	}
	else if(n < (cnt - 1) * 2)
	{
		printf("Impossible\n");
	}
	else
	{
		for(int i = 0; i < n; i++)
			M[i] = std::make_pair(A[i], i);
		std::sort(M, M + n);
		
		int rem = (cnt - 1) * 2 - cnt;
		
		for(int i = 0; i < n && rem; i++)
		{
			if(used[M[i].second]) continue;
			ans += M[i].first, rem--;
		}
		
		printf("%lld\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1792
import sys
from collections import deque


def input(): return sys.stdin.readline().strip()


def insert(x, l):
    l.appendleft(x)


def delete(x, l):
    if len(l) == 0:
        return
    index = l.index(x) if x in l else None
    if index is None:
        return
    else:
        l.remove(x)


def delete_first(l):
    if len(l) == 0:
        return
    l.popleft()


def delete_last(l):
    if len(l) == 0:
        return
    l.pop()


n = int(input())
l = deque()

for _ in range(n):
    command = input().split(' ')

    if command[0] == 'insert':
        insert(command[1], l)

    elif command[0] == 'delete':
        delete(command[1], l)

    elif command[0] == 'deleteFirst':
        delete_first(l)

    elif command[0] == 'deleteLast':
        delete_last(l)

print(' '.join(l))



Measured memory_bytes: 69816
n = int(input())
cardList = list(map(int,input().split()))
a = 0
b = 0
cardList.sort(reverse=True)
while len(cardList) > 0:
    if len(cardList) > 0:
        a += cardList.pop(0)
    if len(cardList) > 0:
        b += cardList.pop(0)
print(a-b)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	string str;
	cin >> str;
	str.insert(4, " ");

	cout << str << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int lmax = 0, rmin = INT_MAX;
    rep(i,M) {
        int l,r;
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }
    int ans = rmin - lmax + 1;
    if (ans < 0)
        ans = 0;
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    set<int> s;
    rep(i, n) s.insert(d[i]);

    cout << s.size() << endl;
    return 0;
}


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

int main(){
  int n, min=1000, max=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
    if(min>v[i])min = v[i];
    if(max<v[i])max = v[i];
  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [[] for i in range(N)]
for i in range(N):
	A = int(input())
	for j in range(A):
		x,y = map(int,input().split())
		a[i].append((x-1,y))

def int2bit(n):
	ret = [0 for i in range(N)]
	i = 0
	while n > 0:
		ret[i] = n % 2
		n = n // 2
		i += 1
	return ret

ans = 0
for i in range(2**N - 1, -1, -1):
	bit = int2bit(i)
	flg = True
	for n in range(N):
		if bit[n] == 0:
			continue
		for x in a[n]:
			if bit[x[0]] != x[1]:
				flg = False
				break
		if not flg:
			break
	if flg:
		ans = max(ans, sum(bit))
print(ans)

Measured memory_bytes: 3064
import math
n = input()
arr = list(map(int, input().split()))
a = sum(arr) // len(arr)
b = a + 1
'''
arr.sort()
if len(arr) % 2 == 0:
    mid = len(arr) // 2
    avg = (arr[mid] + arr[mid-1]) // 2
else:
    mid = len(arr) // 2
    avg = arr[mid]

print(avg)
'''
ans = 0
ans2 = 0
for p in arr:
    ans += (a - p)**2
    ans2  += (b - p)**2
print(min(ans, ans2))


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
ll x[100003], l[100003];
pair<ll,ll> itv[100003];
int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> x[i] >> l[i];
  rep(i,n) itv[i] = make_pair(x[i]+l[i],x[i]-l[i]);
  sort(itv, itv+n);
  int ans = 0;
  ll en = -INF;
  rep(i,n) {
    if (en <= itv[i].second) {
      ans++; en = itv[i].first;
      }
  }
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6732
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, s = 0;
    cin >> n >> k;
    map<ll, ll> m;
    for (ll i = 1; i <= n; i++)
        cin >> a[i], a[i] += a[i - 1];
    m[0] = 1;
    for (ll i = 1, j = 0; i <= n; i++)
    {
        if (i >= k)
            m[(a[j] - j) % k]--, j++;
        s += m[(a[i] - i) % k]++;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

int main()
{
    int N, sum = 0;
    cin >> N;
    vector<string> s(N);
    vector<int> t(N);

    for (int i = 0; i < N; i++)
    {
        cin >> s[i] >> t[i];
    }
    string u;
    cin >> u;
    bool ok = false;

    for (int i = 0; i < N; i++)
    {
        if (ok)
            sum += t[i];
        else if (u == s[i])
            ok = true;
    }
    cout << sum << endl;
}

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


int main() {
  int A, B, K;
  cin >> A >> B >> K;
  int ans = 0;
  int cnt = 0;
  for(int i=A; i>0; i--){
    if (A%(i)==0 && B%(i)==0)
      cnt++;
    if (cnt == K){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
string S;
cin >>S;

if(S[0]!=S[1] && S[0]!=S[2] && S[1]!=S[2]){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}

return 0;

}

Measured memory_bytes: 256
//03/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/vector<ll>v[200005];
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;



int main(){
    _fastio
    ll n,m;
    cin>>n>>m;
    ll h[n+10];
    for(ll i=1;i<=n;i++){
        cin>>h[i];
    }

    for(ll i=1;i<=m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    ll ans=0;
    for(ll i=1;i<=n;i++){
        bool f=true;
        for(ll j=0;j<v[i].size();j++){
            ll adj=v[i][j];
            if(h[adj]>=h[i]) f=false;
        }
        if(f) ans++;
    }

    cout<<ans<<en;




    return 0;
}


Measured memory_bytes: 12628
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n")
  tmp0 = input[0].split(" ")

  N = tmp0[0]
  L = input[1].split(" ")
  for(var i=0; i < N; i++){
    L[i] = Number(L[i])
  }

  L.sort((a,b) => b-a)

  max = L[0]
  L.shift()
  sum = L.reduce((p, c) => Number(p)+Number(c))

  if(max < sum){
    console.log("Yes")
  }else{
    console.log("No")
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;
  string s;

  cin >> n >> s;
  // vi v(n);
  int l = 0, r = 0;
  REP(i, n) {
    if (s[i] == '(') {
      l++;
    } else {
      if (l > 0) l--;
      else r++;
    }
  }
  REP(i, r)cout << '(';
  cout << s;
  REP(i, l)cout << ')';

  cout << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main()
{
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ans=0,i;
    for(i=0;i<k;i++){
        if(i<n)ans+=x;
    }
    For(j,i,n){
        ans+=y;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << '\n';
    else cout << s.substr(0, k) + "..." << '\n';
    return 0;
}

Measured memory_bytes: 3628