akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int N, L; cin >> N >> L;
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += L + i;
  }
  int deg = 1e9, ans = sum;
  for (int i = 0; i < N; i++){
    int now = sum - (L + i);
    if (deg > abs(now - sum)){
      deg = abs(now - sum);
      ans = now;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a,b,c;
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        if(a+b+c<=21) System.out.println("win");
        else System.out.println("bust");
    }
}

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

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

  for (int i = N; i <= 999; i++) {
    string s = to_string(i);
    if (s[0] == s[1] && s[1] == s[2]) {
      cout << i << endl;
      return 0;
    }
  }
}


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

int main(void)
{
    int sum;
    vector<int> d(3);
    vector<char> op(3);
    string s;

    cin >> s;

    rep(i,4){
        d[i] = s[i]-'0';
    }
    
    for(int bit = 0;bit < (1<<3);bit++){
        sum = d[0];
        for(int i = 0;i < 3;i++){
            if(bit & (1<<i)){
                sum += d[i+1];
                op[i] = '+';
            }
            else{
                sum -= d[i+1];
                op[i] = '-';
            }
        }
        if(sum == 7) break;
    }

    rep(i,4){
        cout << d[i];
        if(i < 3) cout << op[i];
    }

    cout << "=7" << endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 10000000000

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int ans=0;
	vector<int>A(N+2);
	A[0]=0;
	A[N+1]=0;
	FOR(i,1,N+1){
		cin>>A[i];
		ans+=abs(A[i-1]-A[i]);
	}
	ans+=abs(0-A[N]);
	FOR(i,1,N+1){
		cout<<ans-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i-1]-A[i+1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,c1,c2,c3,x[110][110];
bool flag;
int main()
{
	int i,s,a,b,j,k;
	while(cin>>n>>m)
	{
		scanf("%d",&k);a=1;b=1;flag=false;
		for(i=1;i<=k;i++)
		{
			scanf("%d",&j);
			while(j)
			{
				x[a][b]=i;j--;
				if(!flag)
				{
					if(b+1<=m)b++;
					else a++,flag=true;
				}
				else
				{
					if(b-1>=1)b--;
					else a++,flag=false;
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			for(s=1;s<=m;s++)printf("%d ",x[i][s]);
			printf("\n"); 
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> B(N-1);
  for(int i=0; i<N-1; i++){
    cin>>B.at(i);
  }
  int a=0,sum=B.at(N-2);
  if(N==2){
    cout<<B.at(0)*2<<endl;
    return 0;
  }
  else{
    for(int i=N-3; i>=0; i--){
      a=min(B.at(i),B.at(i+1));
      sum+=a;
      if(i==0){
        if(B.at(i)>B.at(i+1)){
          sum+=B.at(i);
        }
        else{
          sum+=a;
        }
      }
    }
  }
  cout<<sum<<endl;
}
  

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

int mp[10][10];
int main(){
    int n,ans = 0;
    cin>>n;

    for(int i = 1;i <= n; i++){
        int f = i,e = i%10;
        while(f >= 10)f /= 10;
        mp[f][e]++;
    }
    for(int i = 1;i < 10; i++){
        for(int j = 1;j < 10;j++){
            ans += mp[i][j] * mp[j][i];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

R,C,K = MI()
item = [[0]*(C+1) for _ in range(R+1)]
for i in range(K):
    r,c,v = MI()
    item[r][c] = v

dp = [[[0]*(C+1) for j in range(4)] for i in range(R+1)]  # dp[i][j][k] = (i,k)に至るまでに拾ったアイテムの価値の合計の最大値、但しi列目からアイテムをj個拾う

for i in range(1,R+1):
    for j in range(4):
        for k in range(1,C+1):
            if item[i][k] == 0:
                if j == 0:
                    dp[i][j][k] = max(dp[i][j][k-1],dp[i-1][0][k],dp[i-1][1][k],dp[i-1][2][k],dp[i-1][3][k])
                else:
                    dp[i][j][k] = dp[i][j][k-1]
            else:
                if j == 0:
                    dp[i][j][k] = max(dp[i][j][k-1],dp[i-1][0][k],dp[i-1][1][k],dp[i-1][2][k],dp[i-1][3][k])
                elif j == 1:
                    dp[i][j][k] = max(dp[i][j][k-1]-item[i][k],dp[i][j-1][k-1],dp[i-1][0][k],dp[i-1][1][k],dp[i-1][2][k],dp[i-1][3][k]) + item[i][k]
                else:
                    dp[i][j][k] = max(dp[i][j][k-1],dp[i][j-1][k-1] + item[i][k])

ans = 0
for j in range(4):
    ans = max(ans,dp[R][j][C])

print(ans)


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

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "Yes" : "No");

		static void Main(string[] args)
		{
			var r = In;
			var g = In;
			Console.WriteLine(2 * g - r);
			//Console.ReadLine();
		}
		
	}
}

Measured memory_bytes: 11092
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, X);
    YES(X >= 30);
}

Measured memory_bytes: 3628
jigen, ten = gets.split(' ').map(&:to_i)

ary = []
jigen.times do
  ary << gets.split(' ').map(&:to_i)
end

count = 0
ary.combination(2) do |ca|
  result = 0
  ca[0].each_with_index do |x, idx|
    t = (x - ca[1][idx]).abs
    result += t * t
  end
  sq = Math.sqrt(result)
  count += 1 if sq.to_i == sq
end

puts count


Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
	double r,x,y,pai;
	pai=3.141592653589;
	scanf("%lf",&r);
	printf("%.8lf\n",x=r*r*pai);
	printf("%.8lf\n",y=r*2*pai);
	return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MOD 1000000007
typedef long long int ll;
typedef unsigned long long int llu;

void yes(){printf("Yes\n");}
void no(){printf("No\n");}


int main(void)
{

    int n;

    scanf("%d",&n);
    if(n%2==0)printf("%d\n",n/2);
    else printf("%d\n",n/2+1);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mod 1000000007

int main()
{
	ll n,x;
	cin >> n >> x;
	ll ans = 0;
	ll q = 0;
	if(2*x == n){
		cout << 3*x;
		return 0;
	}
	ans = n;
	ll a,b;
	a = n;
	b = min(x,n-x);
	a -= b;
	while(a%b){
		ans += 2*(a-a%b);
		a = a%b;
		swap(a,b);
	}
	ans += 2*(a-a%b)-b;
	cout << ans;
}

Measured memory_bytes: 256
n, m = list(map(lambda x: int(x), input().split(' ')))
hs = [int(i) for i in input().split(' ')]
is_higher = [1] * len(hs)

for i in range(m):
  a, b = [int(i) for i in input().split(' ')]
  a -= 1
  b -= 1
  if hs[a] > hs[b]:
    is_higher[b] = 0
  elif hs[a] < hs[b]:
    is_higher[a] = 0
  else:
    is_higher[a] = 0
    is_higher[b] = 0

print(sum(is_higher))

Measured memory_bytes: 20148
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;

public class Main {
    private static final int BLACK = 1;
    private static final int WHITE = -1;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final Map<Integer, List<Integer>> tree = new HashMap<>();
        for (int i = 0; i < n - 1; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();

            tree.computeIfAbsent(a, v -> new ArrayList<>()).add(b);
            tree.computeIfAbsent(b, v -> new ArrayList<>()).add(a);
        }

        final boolean[] isVisited = new boolean[n + 1];
        isVisited[1] = true;
        final Deque<Integer> route = search(tree, isVisited, 1, n);

        final List<Integer> fennecRoute = new ArrayList<>();
        final List<Integer> snukeRoute = new ArrayList<>();
        final int[] visitable = new int[n + 1];
        while (!route.isEmpty()) {
            final int fennecNext = route.pollFirst();
            visitable[fennecNext] = BLACK;
            fennecRoute.add(fennecNext);

            if (route.isEmpty()) break;

            final int snukeNext = route.pollLast();
            visitable[snukeNext] = WHITE;
            snukeRoute.add(snukeNext);
        }

        for (final int toVisit : fennecRoute) {
            visitable[toVisit] = BLACK;
            dfs(tree, visitable, toVisit, BLACK);
        }
        for (final int toVisit : snukeRoute) {
            visitable[toVisit] = WHITE;
            dfs(tree, visitable, toVisit, WHITE);
        }

        int fennecCount = 0;
        int snukeCount = 0;
        for (int i = 1; i <= n; i++) {
            if (visitable[i] == BLACK) fennecCount++;
            else snukeCount++;
        }

        System.out.println(fennecCount > snukeCount ? "Fennec" : "Snuke");
    }

    private static void dfs(final Map<Integer, List<Integer>> tree, final int[] visitable, final int current, final int color) {
        for (final int next : tree.get(current)) {
            if (visitable[next] == 0) {
                visitable[next] = color;
                dfs(tree, visitable, next, color);
            }
        }
    }

    private static Deque<Integer> search(final Map<Integer, List<Integer>> tree, final boolean[] isVisited, final int current, final int dest) {
        if (current == dest) {
            final Deque<Integer> route = new ArrayDeque<>();
            route.add(dest);
            return route;
        }

        for (final int next : tree.get(current)) {
            if (!isVisited[next]) {
                isVisited[next] = true;
                final Deque<Integer> route = search(tree, isVisited, next, dest);
                if (!route.isEmpty()) {
                    route.addFirst(current);
                    return route;
                }
            }
        }

        return new ArrayDeque<>();
    }
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n, x, y; cin >> n >> x >> y;
	x--;
	y--;

	vector<int> res(n, 0);
	REP(i, n) for (int j = i + 1; j < n; j++) {
		int mini = min(min(abs(j - i), abs(x - i) + 1 + abs(j - y)), abs(y - i) + 1 + abs(j  - x));
		res[--mini]++;
	}

	REP(i, n - 1) cout << res[i] << '\n';
    return 0;
}


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

using namespace std;

int main(){
    string S;
    int z=0,o=0;

    cin >> S;

    for(int i=0;i<S.size();i++){
        if(S[i] == '0'){
            z++;
        }else{
            o++;
        }
    }

    cout << min(z,o) * 2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c; cin >> c;
  if(c == 'A') cout << 'T';
  if(c == 'T') cout << 'A';
  if(c == 'G') cout << 'C';
  if(c == 'C') cout << 'G';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep0(i,n) for (int i=0; i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL << 60)
#define EPS (1e-10)
using namespace std;
typedef long long Int;
typedef pair<int,int> P;

Int n;
Int w;
Int items[110][2];
Int dp[110][110000];

int main() {
  cin >> n >> w;
  rep1(i, n) {
    cin >> items[i][0] >> items[i][1];
  }

  rep1(i, n) {
    for (int j = 0; j <= w; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - items[i][0] >= 0) {
        dp[i][j] = max(dp[i - 1][j],
                      dp[i - 1][j - items[i][0]] + items[i][1]);
      }
    }
    // cout << dp[i][w] << endl;
  }

  cout << dp[n][w] << endl;

  return 0;
}

Measured memory_bytes: 87424
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 a, b, i;
  cin >> a >> b;
  if(a > b) {
    swap(a, b);
  }
  REP(0, b, i) {
    cout << a;
  }
  cout << endl;

  return 0;
}


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int range=max(a,b);
    vector<int>v;
    for(int i=1;i<=range;i++){
        if(a%i==0 && b%i==0)v.push_back(i);
    }
    reverse(v.begin(),v.end());
    cout<<v[k-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(v,a) for(auto &v:a)
#define fi first
#define se second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(a) a.begin(),a.end()
int re(){int x=0; char c; bool neg=false;while(c!='-'&&(c<'0'||'9'<c)) c=getchar();if (c=='-'){neg=true; c=getchar();}while ('0'<=c && c<='9'){x=x*10+c-'0';c=getchar();}if (neg) x=-x;return x;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ran(int l, int r) {return l+rng()%(r-l+1);}
typedef long long ll;
const int N=1010;
const int mod=1e9+7;
int n,m;
int a[N][N],f[N][N];
int dx[]={1,0};
int cx[]={0,1};
int main()
{
    //freopen("h.inp","r",stdin);
    cin>>n>>m;
    forinc(i,1,n) forinc(j,1,m)
    {
        char ch; cin>>ch;
        a[i][j]=(ch=='#');
    }
    f[1][1]=1;
    forinc(i,1,n) forinc(j,1,m)
    {
        forinc(k,0,1)
        {
            int u=i+dx[k],v=j+cx[k];
            if (u<=n && v<=m && !a[u][v]) f[u][v]=(f[u][v]+f[i][j])%mod;
        }
    }
    cout<<f[n][m];
}


Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007

vector< vector< pair<int, pair<int, int>> > > Graph;
vector<int> used;

int dfs(int v, int t, int f){
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < Graph[v].size(); i++){
    pair<int, pair<int, int> > &now = Graph[v][i];
    if(!used[now.first] && now.second.first > 0){
      int d = dfs(now.first, t, min(f, now.second.first));
      if(d > 0){
        now.second.first -= d;
        Graph[now.first][now.second.second].second.first += d;
        return d;
      }
    }
  }
  return 0;
}

int main(){
  int v,e;  cin >> v >> e;
  Graph = vector< vector< pair<int, pair<int, int>> > >(v);
  for(int i = 0; i < e; i++){
    int s,t,c; cin >> s >> t >> c;
    Graph[s].push_back(pair< int, pair<int, int> >{t, pair<int, int>{c, Graph[t].size()}});
    Graph[t].push_back(pair< int, pair<int, int> >{s, pair<int, int>{0, Graph[s].size()-1}});
  }
  int flow = 0;
  while(true){
    used = vector<int>(100, false);
    int f = dfs(0, v-1, INF);
    if(f==0){
      cout << flow << endl;
      return 0;
    }
    flow += f;
  }
}



Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    string s;
    cin >> s;
    for (int i = s.size() - 2; i >= 2; i -= 2) {
        if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if(S==U){
        A--;
    }else if(T==U){
        B--;
    }
    cout << A <<" "<< B <<"\n";
    return 0;
}


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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= floor(s / 3); x++) {
        for (int z = ceil(s / 3); z <= k; z++) {
            for (int y = x; y <= z; y++) {

                if (x + y + z == s) {
                    if (x == y && y == z) {
                        ans++;
                    } else if (x != y && y != z) {
                        ans += 6;
                    } else {
                        ans += 3;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
    int n; cin >> n;
    vector<int> a;
    for(int i = 1; i < 10; i++) a.push_back(i * 111);

    for(auto x:a){
        if(x >= n){
            put(x);
            return 0;
        }
    }
}

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

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < n.length(); i++) {
        if (n[i] == '1')
            n[i] = '9';
        else
            n[i] = '1';
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int LL
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

const int MXN = 1e5+5;
int cnt[MXN];

int32_t main()
  {
  ios_base::sync_with_stdio(0); 
  int n;
  cin >> n;
  LL res = 0;
  REP(i, n)
    {
    int a;
    cin >> a;
    cnt[a]++;
    res += a;
    }
  int q;
  cin >> q;
  REP(i, q)
    {
    int b, c;
    cin >> b >> c;
    res += cnt[b] * (c - b);
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << res << endl;
    }
  }


Measured memory_bytes: 4324
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(unsigned long long, X, Y);
	auto xy = Y / X, cnt = 0ull;
	while (xy >>= 1)
		++cnt;
	out(cnt + 1);
	return 0;
}


Measured memory_bytes: 256
<?php
  list($y,$m,$d) = explode("/", trim(fgets(STDIN)));
 
  if($y > 2019){
    echo "TBD";
  }else if($y < 2019){
    echo "Heisei";
  }else{
    if($m > 4){
      echo "TBD";
    }else if($m <= 4){
      echo "Heisei";
    }
  }

Measured memory_bytes: 16228
n = int(input())
l = [[] for i in range(n)]


class V:
    def __init__(self, node):
        self.d = -1
        self.f = -1
        self.node = node


for i in range(n):
    _input = [int(j) - 1 for j in input().split(" ")]
    u = _input[0]
    k = _input[1] + 1
    node = sorted(_input[2::])
    if u in node:
        node.remove(u)
    l[u] = V(node)

time = 1


def DFS(i):
    global time
    if l[i].d == -1:
        l[i].d = time
    time += 1
    for n in l[i].node:
        if l[n].d == -1:
            DFS(n)
            time+=1
    if l[i].f == -1:
        l[i].f = time
    return


for i in range(n):
    if l[i].d == -1:
        DFS(i)
        time+=1

for i, v in enumerate(l):
    print(i + 1, v.d, v.f)



Measured memory_bytes: 5664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

const int Ax[]={0,0,1,1};
const int Ay[]={0,1,0,1};
const int Bx[]={0,0,0,0};
const int By[]={0,1,2,3};
const int Cx[]={0,1,2,3};
const int Cy[]={0,0.0,0};
const int Dx[]={0,0,-1,-1};
const int Dy[]={0,1,1,2};
const int Ex[]={0,1,1,2};
const int Ey[]={0,0,1,1};
const int Fx[]={0,0,1,1};
const int Fy[]={0,1,1,2};
const int Gx[]={0,1,-1,0};
const int Gy[]={0,0,1,1};


char field[8][8];

string check(int x,int y){
	if(field[y][x]=='1'){
		bool f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Ax[k];
			int ny=y+Ay[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "A";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Bx[k];
			int ny=y+By[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "B";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Cx[k];
			int ny=y+Cy[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "C";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Dx[k];
			int ny=y+Dy[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "D";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Ex[k];
			int ny=y+Ey[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "E";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Fx[k];
			int ny=y+Fy[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "F";
		}
		f=true;
		// ¡ÌÀW©çTõ
		for(int k = 0; k < 4; k++){
			int nx=x+Gx[k];
			int ny=y+Gy[k];
			if(nx>=0&&ny>=0&&nx<8&&ny<8){
				if(field[ny][nx]!='1'){
					f=false;
					break;
				}
			}
			else{
				f=false;
				break;
			}
		}
		if(f){
			return "G";
		}
	}
	return "";
}

int main(){


	while(1){
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				cin>>field[i][j];
			}
		}
		if(cin.eof())
			break;
		bool f=false;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				string ret=check(j,i);
				string com="";
				if(ret!=com){
					cout<<ret<<endl;
					f=true;
					break;
				}
			}
			if(f)
				break;
		}
	}

	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

struct edge{int to; ll cost;};
int N;
vector<edge> G1[100001], G2[100001];
int dist1[100001], dist2[100001];

void F_Dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(dist1, dist1 + N, INF);
	dist1[0] = 0;
	que.push(P(0, s));

	while(!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if(dist1[v] < p.first) continue;
		for(int i = 0; i < G1[v].size(); ++i) {
			edge e = G1[v][i];
			if(dist1[e.to] > dist1[v] + e.cost) {
				dist1[e.to] = dist1[v] + e.cost;
				que.push(P(dist1[e.to], e.to));
			}
		}
	}
}

void S_Dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(dist2, dist2 + N, INF);
	dist2[0] = 0;
	que.push(P(0, s));

	while(!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if(dist2[v] < p.first) continue;
		for(int i = 0; i < G2[v].size(); ++i) {
			edge e = G2[v][i];
			if(dist2[e.to] > dist2[v] + e.cost) {
				dist2[e.to] = dist2[v] + e.cost;
				que.push(P(dist2[e.to], e.to));
			}
		}
	}
}

int main() {
	scanf("%d", &N);
	rep(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		--a, --b;
		G1[a].push_back((edge){b, 1});
		G1[b].push_back((edge){a, 1});
		a = N - 1 - a; b = N - 1 - b;
		G2[a].push_back((edge){b, 1});
		G2[b].push_back((edge){a, 1});
	}
	F_Dijkstra(0);
	S_Dijkstra(0);
	int fennec = 0, snuke = 0;
	rep(i, N) {
		(dist1[i] <= dist2[N - 1 - i]) ? fennec++ : snuke++;
	}
	(fennec > snuke) ? printf("Fennec\n") : printf("Snuke\n");
	return 0;
}

Measured memory_bytes: 15984
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int h[] = new int[N];
		int max = 0;
		for(int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		
		int h2[] = new int[N];
		int cnt = 0;
		boolean flag = true;
		while(flag) {
		flag = false;
		out : for(int i = 0; i < N; i++) {
			in : for(int j = i; j < N; j++) {
				if(h2[j] < h[j]) {
					flag = true;
					h2[j]++;
					//System.out.println("j" + j + ", h2:" + h2[j]);
				} else {
					if(i == j) {
						if(i == N - 1 && j == N - 1) {
							break out;
						}
						continue out;
					} else {
						//System.out.println(i + "," + j);
						break in;
					}
				}
			}
		//System.out.println(i);
			cnt++;
			i--;
		}
		}
		System.out.println(cnt);
	}
}


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

namespace Competition
{
    public class Program
    {
        
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ok = false;
            for(int i = 1; i <= 9; i++)
            {
                if (N % i == 0 && N / i <= 9) ok = true;
            }
            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    _ = input()
    s = input()

    freq = [0 for _ in range(len(s))]
    for i, c in enumerate(s):
        if i > 0 and s[i-1] == 'A' and c == 'C':
            freq[i] = freq[i-1] + 1
        else:
            freq[i] = freq[i-1]

    for l in sys.stdin:
        x, y = [int(e) for e in l.split()]
        print(freq[y-1]-freq[x-1])


main()


Measured memory_bytes: 6392
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;



int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout<<0<<endl;
	}
	else {
		cout << 10 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	string S; cin >> S; 
	long long ans = 0; 
	int N = S.size(); 
	int sum[200010] = {}; 
	sum[0] = 0; 
	for(int i = 1; i <= N; i++){
		sum[i] = 10 * sum[i-1]; 
		sum[i] += S.at(i-1) - '0'; 
		sum[i] %= 2019; 
	}
	int dig = 1; 
	for(int i = N; i >= 0; i--){
		sum[i] *= dig; sum[i] %= 2019; 
		dig *= 10; dig %= 2019; 
	}
	long long cnt[2020] = {}; 
	for(int i = 0; i <= N; i++) cnt[sum[i]] ++; 
	for(int i = 0; i <= 2018; i++){
		ans += cnt[i] * (cnt[i] - 1) / 2; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 4572
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
vector<ll> a;
int N;
int main()
{
	cin>>N;
	for(int i=0;i<3*N;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=a[2*i+1];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6384
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print(b - (a+b)//2)
else:
  if (a - 1) > (n - b):
    print((n-b) + 1 + (b-a-1)//2)
  else:
    print((a-1) + 1 + (b-a-1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  while(cin >> n && n) {
    int ans=0;
    for(int i=0; i*i*i<=n; i++) {
      int x=n-i*i*i;
      for(int j=0; j<=x; j++) {
        if(j*(j+1)*(j+2)/6>x) break;
        if(x>=j*(j+1)*(j+2)/6) ans=max(ans,i*i*i+j*(j+1)*(j+2)/6);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2972
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]  # 親の値が更新され、更新された親の値が返る, 返るのは正の値

    def size(self, x):
        return -self.parents[self.find(x)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x  # 処理を行う上で、必ずxのグループの要素数の方が多くあってほしい
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
brige = []
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    brige.append((a, b))

uf = UnionFind(N)
ans = [int(N*(N-1)//2)]*M

for i in reversed(range(1, M)):
    if uf.same(brige[i][0], brige[i][1]):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.size(brige[i][0]) * uf.size(brige[i][1])
        uf.union(brige[i][0], brige[i][1])
for i in range(M):
    print(ans[i])


Measured memory_bytes: 22476
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,c,d,y,w;
  cin >> a >> b >> c >> d;
  if (a < b) {
    y = a;
  } else {
    y = b;
  }
  if (c < d) {
    w = c;
  } else {
    w = d;
  }
  cout << y+w << endl;
}


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

struct dice{
    int d[6],tmp[6];
};
struct dice dice1;

void init(int n[6]){
    int i;
    for(i=0;i<6;i++){
        dice1.d[i]=n[i];
        }
    }
void rooldice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}

int main( void )
{

    int n[6];
    int i;
    char ts;
    char t[110];
    
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init(n);
    scanf("%s",t);
    ts=strlen(t);
    for(i=0;i<ts;i++){
        rooldice(t[i]);
    }
    printf("%d\n",dice1.d[0]);
    return 0;
}

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

class Plogram
{
    static void Main()
    {
        var order = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var B = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        int total = 0;
        int ans = 0;
        int count = 0;

        var A = new int[order[0]][];
        for (int i = 0; i < order[0]; i++)
        {
            A[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }

        for (int i = 0; i < order[0]; i++)
        {
            for (int j = 0; j < order[1]; j++)
            {
                total += B[j] * A[i][j];
            }
            ans = total + order[2];
            if (ans > 0)
            {
                count++;
            }
            total = 0;
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11348
(defun count-div (n m)
  (labels ((inner (k rv)
             (cond
               ((not (zerop (mod k m)))
                rv)
               (t
                (inner (floor k m) (1+ rv))))))
    (inner n 0)))

(defun answer (lst)
  (loop for a in lst sum (count-div a 2)))

(princ (answer (loop for a from 1 upto (read) collect (read))))


Measured memory_bytes: 25828
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int s[10]={0};
  s[a]++;s[b]++;s[c]++;
  if(s[5]==2&&s[7]==1) printf("YES");
  else printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define va first
#define vb second
using namespace std;
using pii = pair<int,int>;

int n, k, q;
int a[2005];
set<pii> S;

vector<int> cmp;

void input(){
    cin >> n >> k >> q;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        cmp.push_back(a[i]);
    }
    sort(all(cmp));
    cmp.resize(unique(all(cmp)) - cmp.begin());
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    input();
    S.emplace(1, n);
    vector<int> tmp, ump;
    vector<pii> vmp, wmp;
    int ans = INT_MAX;
    for(int i = 0; i < cmp.size(); i++){
        tmp.clear();
        for(pii p : S){
            ump.clear();
            for(int u = p.va; u <= p.vb; u++){
                ump.push_back(a[u]);
            }
            sort(all(ump));
            for(int i = 0; i < p.vb - p.va - k + 2; i++) tmp.push_back(ump[i]);
        }
        sort(all(tmp));
        if(tmp.size() < q) break;
        ans = min(ans, tmp[q-1] - tmp[0]);
        vmp.clear();
        wmp.clear();
        for(pii p : S){
            int cur = p.va - 1;
            int flag = 0;
            for(int u = p.va; u <= p.vb; u++){
                if(a[u] == cmp[i]){
                    if(!flag){
                        wmp.push_back(p);
                        flag = 1;
                    }
                    vmp.emplace_back(cur + 1, u - 1);
                    cur = u;
                }
            }
            vmp.emplace_back(cur + 1, p.vb);
        }
        for(pii p : wmp) S.erase(p);
        for(pii p : vmp){
            if(p.vb - p.va + 1 >= k) S.insert(p);
        }
    }
    cout << ans << '\n';
}


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

int main(){
  int m, n, diff, n_min, n_max, point[200];
  while(cin >> m >> n_min >> n_max, m){
    n = 0; diff = 0;
    for(int i = 0; i < m; ++i) cin >> point[i];
    for(int i = n_min; i <= n_max; i++){
      if(diff <= point[i - 1] - point[i]){
        diff = point[i - 1] - point[i];
        n = i;
      }
    }
    cout << n << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<deque>
#include<memory.h>

using namespace std;

int H, W, N;
char mapT[1000][1000];
int vis[1000][1000];
int temp_x = 0, temp_y;
char temp;
int final_min_route = 0;
int dir[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };

struct location {
	int x, y, route;
};

location findSmallRouteBFS(int x, int y, char factory) {
	memset(vis, 0, sizeof(vis));
	deque<location> que;
	location temp = { x,y,0 };
	que.push_back(temp);
	vis[x][y] = 1;
	while (!que.empty()) {
		location st = que.front();
		que.pop_front();
		if (mapT[st.x][st.y] == factory) {
			return st;
		}
		for (int i = 0; i < 4; ++i) {
			int t_x = st.x + dir[i][0];
			int t_y = st.y + dir[i][1];
			if (t_x < 0 || t_x >= H || t_y < 0 || t_y >= W || mapT[t_x][t_y] == 'X') {
				continue;
			}
			location temp = { t_x,t_y,st.route + 1 };
			if (!vis[t_x][t_y]) {
				vis[t_x][t_y] = 1;
				que.push_back(temp);
			}
		}
	}

}

int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; ++j) {
			cin >> temp;
			mapT[i][j] = temp;
			if (temp == 'S') {
				mapT[i][j] = '0';
				temp_x = i;
				temp_y = j;
			}
		}
	}

	for (int factory = 1; factory != N + 1; ++factory) {

		location lo = findSmallRouteBFS(temp_x, temp_y, mapT[temp_x][temp_y] + 1);
		temp_x = lo.x;
		temp_y = lo.y;
		final_min_route += lo.route;
	}

	cout << final_min_route << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 6104
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 //#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
//const int INF=4e18+10;
 const int INF=1e9+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

void precomp()
{
}


void solve()
{
    int L, R, d;
    cin>>L>>R>>d;
    int c = 0;
    for(int i= 0;i<=100;i++)
    {
        if(L<=i*d &&i*d<=R) 
            c++;

    } 
    cout<<c<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3636
//
//AtCoder Beginner Contest 162
//C - Sum of gcd of Tuples (Easy)
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

using ll = long long;

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

int main()
{
    int k;

    cin >> k;

    ll ans = 0;

    rep(a,k){
        rep(b,k){
            int tmp = gcd(a+1, b+1);
            rep(c,k){
                ans += gcd(tmp, c+1);
            }
        }
    }

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


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

#define iN(x) int x;cin>>x;
#define iNll(x) ll x;cin>>x;
#define iNl(x) long x;cin>>x;
#define iNv(X,n) reP(ijk,n)cin>>X.at(ijk);
#define reP(i,end) reP(i,0,end)
#define reP2(i,start,end) int i;for(i=start;i<end;i++)
#define ouT(x) cout<<x;


int gcd(int a,int b){
      /* 自然数 a > b を確認・入替 */
  if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
   
  }

return b;

}

long lcm(int a,int b){
    long A = a;
    long B = b;
    return (A*B)/gcd(a,b);
}

int main(){
    iNl(A);iNl(B);iN(C);iN(D);
    ll count=0;
    
    long c;long d;long cd;long L;
    c = B/C - A/C;
    if(A%C==0)c++;
    d = B/D - A/D;
    if(A%D==0)d++;
     
      L= lcm(C,D);
    // ouT(L);ouT(endl);
    cd = B/L- A/L;
    if(A%L==0)cd++;
    
    count = B+1-A-(c+d-cd);
    ouT(count);
    ouT(endl);
    
}

Measured memory_bytes: 256