akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#define mod 1e9+7
#define ll long long
using namespace std;
int T;
int main() {
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if (a <= k)
        ans += 1 * a,k-=a;
    else
        ans += 1 * k,k=0;
    if (b <= k)
        ans += 0 * b,k-=b;
    else
        ans += 0 * k,k=0;
    if (c <= k)
        ans += -1 * c,k-=c;
    else
        ans += -1 * k,k=0;
    printf("%d",ans);

//    for (cin >> T; T; T--) {
//    }
}

Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, m, i, j, k, a, b;
	bool valid = false;

	cin >> n >> m;
	vector<string> sa(n), sb(m);
	for (i = 0; i < n; i++) cin >> sa[i];
	for (i = 0; i < m; i++) cin >> sb[i];

	for (i = 0; i <= n - m; i++) {
		for (j = 0; j <= n - m; j++) {
			bool match = true;
			for (a = 0; a < m; a++) {
				for (b = 0; b < m; b++) {
					if (sa[i + a][j + b] != sb[a][b]) match = false;
				}
			}
			if (match) valid = true;
		}
	}
	if (valid) cout << "Yes";
	else cout << "No";

	return 0;
}



Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

n_list = list(itertools.permutations(range(1, n+1)))

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]

p_n = func1(n_list, p)
q_n = func1(n_list, q)

print(abs(p_n[0] - q_n[0]))

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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}",a*b,(a+b)*2);

        }
    }
}

Measured memory_bytes: 9416
#include <bits/stdc++.h> 
#define Rajpoot ios_base::sync_with_stdio(0);   cin.tie(0);  cout.tie(0);
#define ll long long
#define loo(i,n) for(i=0;i<n;i++)
#define go(i,sp)  for(auto i=sp.begin();i!=sp.end();i++)
#define pb push_back
#define lb lower_bound
#define mo 1000000007
#define pi 3.14159265358979323846264338327950288419716939937510582
#define exp 2.71828182845904523536028747135266249775724709369995957
#define endl "\n"
using namespace std;



int main() 
{
   Rajpoot
      //    freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);

   // int t; cin>>t; 
    int t=1;
    while(t--)
    { 
        ll n; cin>>n;  
        string s; cin>>s;
        ll c=0,ma=0;
        ll i,j=n-1;
    /*    for(i=0;i<n;i++)
        {
            if(s[i]=='W') c++;
           else if(s[i]=='R'){ ma+=c; c=0;}
        }
        c=0; ll k=0;
        for(i=n-1;i>=0;i--)
        {
            if(s[i]=='R') c++;
           else if(s[i]=='W'){ k+=c; c=0;}
        }
        c=0; ma=min(k,ma); // cout<<k; */
        
        for(i=0;i<j;i++)
        {
            if(s[i]=='W')
            {
                
                while(j>i && s[j]!='R') j--;      
                if(j>i && s[j]=='R'){ c++; s[i]='R'; s[j]='W'; }
                j--;
            }
            
        }
        cout<<c;
    }    

	return 0;
}

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

vector<ll> ans;

int main()
{
	ll k;
	cin >> k;
	for(int i = 1;i<=9;i++)
	{
		ans.push_back(i);
	}
	int l = 0;
	while(ans.size()<= 100001)
	{
		for(int i = max(ans[l]%10-1,0LL);i<=min(1LL*9,ans[l]%10+1);i++)
		{
			ans.push_back(ans[l]*10+i);
		}
		l++;
		//cout<<ans.size()<<endl;
	}
	cout<<ans[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 1400
# coding: utf-8
# Here your code !
n=int(input())
cards=input().split()

def bubble_sort(cards_b,n):
    for i in range(n):
        for j in range(-1,-n,-1):
            a=int(cards_b[j][1])
            b=int(cards_b[j-1][1])
            if a<b:
                cards_b[j],cards_b[j-1]=cards_b[j-1],cards_b[j]
    return cards_b

def selection_sort(cards_s,n):
    for i in range(n):
        minv=i
        for j in range(i,n):
            a=int(cards_s[minv][1])
            b=int(cards_s[j][1])
            if a>b:
                minv=j
        cards_s[minv],cards_s[i]=cards_s[i],cards_s[minv]
    return cards_s


dummy=cards.copy()
ans_1=bubble_sort(cards,n)

ans_2=selection_sort(dummy,n)

print(*ans_1)
print("Stable")
print(*ans_2)
if ans_1!=ans_2:
    print("Not stable")
else:
    print("Stable")

Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin>>n;
    if (((n[0]==n[1])&&(n[1]==n[2]))||((n[1]==n[2])&&(n[2]==n[3])))
     cout<<"Yes"<<endl; else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 510


int main() {
	int b[N][N];
	int c[N][N];
	int a[(N*N)];
	int xx[(N*N)];
	int yy[(N*N)];
	int cx[(N*N)];
	int cy[(N*N)];
	int citr;
	int cm;
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	f(i, N) {
		f(j, N)c[i][j] = 0;
	}
	scanf("%d", &n);

	f(i, (n*n)) {
		scanf("%d", &a[i]);
		xx[i] = (a[i] - 1) % n;
		yy[i] = (a[i] - 1) / n;
	}
	f(i, n) {
		f(j, n) {
			x = min(i, n - 1 - i);
			y = min(j, n - j - 1);
			b[i][j] = min(x, y);
			c[i][j] = 1;
		}
	}
	ans = 0;
	f(i, (n*n)) {
		ans += b[xx[i]][yy[i]];
		c[xx[i]][yy[i]] = 0;
		cx[0] = xx[i];
		cy[0] = yy[i];
		citr = 0;
		cm = 1;
		while (citr < cm) {
			x = cx[citr];
			y = cy[citr];
			if (x > 0) {
				if (b[x - 1][y] > (b[x][y] + c[x][y])) {
					b[x - 1][y] = (b[x][y] + c[x][y]);
					cx[cm] = x - 1;
					cy[cm] = y;
					cm++;
				}
			}
			if (x < (n - 1)) {
				if (b[x + 1][y] > (b[x][y] + c[x][y])) {
					b[x + 1][y] = (b[x][y] + c[x][y]);
					cx[cm] = x + 1;
					cy[cm] = y;
					cm++;
				}
			}
			if (y > 0) {
				if (b[x][y - 1] > (b[x][y] + c[x][y])) {
					b[x][y - 1] = (b[x][y] + c[x][y]);
					cx[cm] = x;
					cy[cm] = y - 1;
					cm++;
				}
			}
			if (y < (n - 1)) {
				if (b[x][y + 1] > (b[x][y] + c[x][y])) {
					b[x][y + 1] = (b[x][y] + c[x][y]);
					cx[cm] = x;
					cy[cm] = y + 1;
					cm++;
				}
			}
			citr++;
		}
	}

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


	return 0;
}

Measured memory_bytes: 8644
#include <iostream>
#include <sstream>
#include <bitset>
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a%3==0)
    cout << "Possible" << endl;
  else if (b % 3 == 0)
    cout << "Possible" << endl;
  else if ((a+b) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        P = map(lambda x: int(x), sys.stdin.readline().split(" "))

        counter = 0
        for i in xrange(len(P)):
            index = i + 1
            if P[i] == index:
                if i == 0:
                    P[i], P[i + 1] = P[i + 1], P[i]
                elif i > 0 and i < len(P) - 1:
                    pass
                    if P[i - 1] == index - 1:
                        P[i] = P[i - 1]
                    elif P[i + 1] == index + 1:
                        P[i], P[i + 1] = P[i + 1], P[i]
                    else:
                        P[i] = P[i - 1]
                counter += 1
        print(counter)
        
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 11344
from collections import deque
n,x,y=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(n-1):
    edge[i+1].append(i)
    edge[i].append(i+1)
edge[x-1].append(y-1)
edge[y-1].append(x-1)
ans=[[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dist=[-1]*n
    dist[i]=0
    que=deque([i])
    while que:
        now=que.popleft()
        for j in edge[now]:
            if dist[j]==-1:
                dist[j]=dist[now]+1
                que.append(j)
    for j in range(n):
        ans[i][j]=dist[j]
aa=[0]*n
for i in ans:
    for j in i:
        aa[j]+=1
for i in aa[1:]:
    print(i//2)

Measured memory_bytes: 107928
MOD = 10**9 + 7


def main():
    S = input()
    N = len(S)
    pre_hatena = S[:1].count("?")
    a = S[:1].count("A")
    post_hatena = S[2:].count("?")
    c = S[2:].count("C")

    rev_3 = pow(3, MOD-2, MOD)
    ans = 0
    for i in range(1, N-1):
        if S[i] == "?" or S[i] == "B":
            pre_pow = pow(3, pre_hatena, MOD)
            pre = pre_pow * a + ((pre_pow * rev_3) % MOD) * pre_hatena
            post_pow = pow(3, post_hatena, MOD)
            post = post_pow * c + ((post_pow * rev_3) % MOD) * post_hatena
            ans += pre * post
            ans %= MOD
        if S[i] == "?":
            pre_hatena += 1
        if S[i] == "A":
            a += 1
        if S[i+1] == "?":
            post_hatena -= 1
        if S[i+1] == "C":
            c -= 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int h, w;
    while(cin >> h >> w, h) {
        // w, h <= 100
        int retH = 0, retW = 0;
        int D = w*w + h*h;
        int minD = 1e9;
        for(int H=1; H<=150; ++H) {
            for(int W=H+1; W<=150; ++W) {
                int d = W*W + H*H;
                if(minD <= d) break;
                if(D < d || D == d && h < H) {
                    minD = d;
                    retH = H;
                    retW = W;
                }       
            }
        }
        cout << retH << " " << retW << endl;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
string s;
int vs[200000],a[200000];
ll f(ll n) {
    return n*n*n*n*n;
}
int main()
{
        IO;
        ll i, j=0, n, m, k=1, l=0, r, t,x,y,mx; ll sum=1;
        cin>>n;
        for(i=0; i<=500; i++){
            for(j=0; j<=500; j++){
                if(f(i)-f(j)==n) { k=0; break; }
                if(f(i)-f(-j)==n){
                    l=1; k=0; break;
                }
            }
            if(k==0)break;
        }
        if(l==0) cout<<i<<' '<<j<<endl;
        else cout<<i<<' '<<-j<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int N, T;
    cin >> N >> T;
    ll ans = 0;
    vector<ll> t(N);
    rep(i, N) cin >> t[i];
    rep(i, N-1) {
        if(t[i+1] - t[i] <= T) ans += t[i+1] - t[i];
        else ans += T;
    }

    ans += T;

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

vl f(ll n) {
  vl ret(n+1);
  ret[0] = ret[1] = 1;
  rep(i, n-1) {
    ret[i+2] = (i+2)*ret[i];
  }
  return ret;
}

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

  ll n;
  cin >> n;

  if (n&1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  ll t = 10;
  rep(i, 40) {
    ans += n/t;
    t *= 5;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	map<string, vector<int>> m;
	map<int, int> mi;
	for (int i = 0; i < n; ++i) {
		string s;
		int p;
		cin >> s;
		cin >> p;
		m[s].push_back(p);
		mi[p] = i + 1;
	}
	for (auto it : m)
	{
		sort(it.second.begin(), it.second.end(), greater<int>());
		for (int i = 0; i < it.second.size(); ++i) {
			cout << mi[it.second[i]] << endl;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd
int main()
{
    int n,i;
    double ans=0.0,a[50];
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    for(i=0;i<n-1;i++){
      a[i+1]=(double)(a[i]+a[i+1])/2;
    }
    cout << a[n-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF2 1000000000000000000
#define INF 2000000000
#define int long long int
struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[100010];
int d[100010];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V + 1, INF2);
    d[s] = 0;
    que.push(P(0, s));

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

signed main(void)
{
    cin >> V;
    rep(i ,V-1){
        int s, t, c;
        cin >> s >> t >> c;
        G[s].push_back({t, c});
        G[t].push_back({s, c});
    }
    int Q,K;
    cin >> Q >> K;
    dijkstra(K);
    int x[Q], y[Q];
    rep(i, Q) cin >> x[i] >> y[i];
    rep(i ,Q) cout << d[x[i]] + d[y[i]] << endl;
    return 0;
}

Measured memory_bytes: 11520
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
# alist = list(range(a1, a2))
# blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in range(a1, a2):
    for j in range(b1, b2):
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(0)
print(-1)


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

int main(int argc, char const *argv[]) {
  int n,i,j,k;
  cin >> n;
  long long a[n],b[n+2]={};
  for(i=0;i<n;i++){
    cin >> a[i];
    if(i==0)b[i]=a[i];
    else b[i]+=b[i-1]+a[i];
  }
  int l=0,r=2;
  long long ret=1e16;
  for(int c=1;c<n-1;c++){
    long long P,Q,R,S;
    while(1){
      if(c>l+1 && abs(b[c]-2*b[l+1])<abs(b[c]-2*b[l]))l++;
      else break;
    }
    P=b[l];
    Q=b[c]-b[l];
    while(1){
      if(r<n-1 && abs((b[n-1]-b[r])-(b[r]-b[c]))>abs((b[n-1]-b[r+1])-(b[r+1]-b[c])))r++;
      else break;
    }
    R=b[r]-b[c];
    S=b[n-1]-b[r];
    long long M,m;
    M = max(max(P,Q),max(R,S));
    m = min(min(P,Q),min(R,S));
    ret = min(M-m,ret);
    //cout << P << " " << Q << " " << R << " " << S << endl;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

struct Node {
	int key;
	Node *prev, *next;
};

Node* nil;

void initialize() {
	nil = new Node;
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key) {
	Node* n = new Node;
	n->key = key;

	n->next = nil->next;
	n->prev = nil;
	n->next->prev = n;
	nil->next = n;
}

Node* listSearch(int key) {
	Node* cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t) {
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	delete t;
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void print() {
	Node* cur = nil->next;
	int i = 1;
	while (cur != nil) {
		cout << i++ << "th node's key : " << cur->key << endl;
		cur = cur->next;
	}
}

void printList() {
	Node* cur = nil->next;
	if (cur != nil) {
		cout << cur->key;
		cur = cur->next;
	}
	while (cur != nil) {
		cout << ' ' << cur->key;
		cur = cur->next;
	}
	cout << endl;
}

int main() {
	int n, key;
	char command[20];

	initialize();

	cin >> n;

	for (int i = 0; i < n; i++) {
		scanf("%s%d", command, &key);
		//cout << command << ' ' << key << endl;
		if (command[0] == 'i') insert(key);
		else if (command[0] == 'd') {
			if (strlen(command) > 6) {
				if (command[6] == 'F') deleteFirst();
				else if (command[6] == 'L') deleteLast();
			}
			else deleteKey(key);
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 34380
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
import bisect
import fractions

def gcd(a, b):
    return fractions.gcd(a, b)

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

def calc(n, a, b):
    return int(n//a + n//b - n//lcm(a,b))

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    ans = calc(b, c, d) - calc(a - 1, c, d)
    print(b - a + 1 - ans)


Measured memory_bytes: 5320
n = int(input())
l = list(map(int,input().split()))
dp = []
dp.append(0)
dp.append(abs(l[1]-l[0]))
for i in range(2,n):
    dp.append(0)
for i in range(2,n):
    m = min(dp[i-2]+abs(l[i-2]-l[i]),dp[i-1]+abs(l[i-1]-l[i]))
    dp[i] = m
print(dp[n-1])

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

int main()
{
  int n, k, ans = INT_MAX;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  for (int i = 0; i < n - k + 1; ++i)
  {
    int tmp;
    tmp = a[i + k - 1] - a[i] + min(abs(a[i + k - 1]), abs(a[i]));
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int c = 0;
		boolean[] already = new boolean[n];
		for (int i = 0; i < n; i++)
			if (Integer.parseInt(sc.next()) != i + 1)
				already[i] = true;
		for (int i = 0; i < n - 1; i++) {
			if (!already[i]) {
				c++;
				already[i + 1] = true;
			}
		}
		if (!already[n - 1])
			c++;
		System.out.println(c);
	}
}

Measured memory_bytes: 46344
/**
 * Created by hiramekun at 20:51 on 2019-10-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl d(n);
    cin >> d;
    ll ans = 0;
    rep(i, n - 1) {
        for (ll j = i + 1; j < n; ++j) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct Node
{
    vector<pair<int, int64_t>> edges;
    int64_t cost = 0;
};

using Tree = vector<Node>;

void FindCosts(Tree &t, int node, int father = -1) {
    for (const auto &e : t[node].edges) {
        if (e.first != father) {
            t[e.first].cost = t[node].cost + e.second;
            FindCosts(t, e.first, node);
        }
    }
}

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

    Tree tree(nodes);
    for (auto i = 1; i < nodes; i += 1) {
        int64_t a, b, cost;
        cin >> a >> b >> cost;
        tree[a - 1].edges.push_back({b - 1, cost});
        tree[b - 1].edges.push_back({a - 1, cost});
    }

    int tests, root;
    cin >> tests >> root;

    FindCosts(tree, root - 1);

    for (auto i = 0; i < tests; i += 1) {
        int a, b;
        cin >> a >> b;
        cout << tree[a - 1].cost + tree[b - 1].cost << "\n";
    }

    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(a,n,i) for(i=a;i<n;i++)
#define NL "\n"

int main()
{IOS;int n,x,t;
cin>>n>>x>>t;
if(n%x==0)
cout<<(n/x)*t;
else cout<<(n/x +1)*t;}


Measured memory_bytes: 3644
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    string a,b;     cin >> a >> b;
    int A,B;        cin >> A >> B;
    string w;   cin >> w;
    if(w == a){
        A--;
    }
    else{
        B--;
    }
    cout << A << " " << B;
    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c; cin >> a >> b >> c;
  Yes((a+b)>=c);
  

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll A, B, V, W, T;
    sll(A);
    sll(V);
    sll(B);
    sll(W);
    sll(T);

    if(A==B){
        cout << "YES" <<endl;
    }else if(V<=W){
        cout << "NO"<<endl;
    }else{
        ll diff = abs(A-B);
        ll max_diff = (V - W) * T;
        if(max_diff>= diff){
            cout << "YES" <<endl;
        }else{
            cout << "NO" <<endl;
        }

    }

    


}

int main(){
    Main();
}

Measured memory_bytes: 3176
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String st1 = sc.next();
		String st2 = sc.next();
		
		sc.close();
		
		int count = 0;
		
		char[] ch1 = st1.toCharArray();
		char[] ch2 = st2.toCharArray();
		
		for(int i = 0; i < st1.length(); i++) {
			if (ch1[i] != ch2[i]) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 41992
MOD = int(1e9 + 7)

n = int(input())
can = []
for _ in range(n):
    can.append([int(c) for c in input().split()])

dp = [0] * (2 ** n)
dp[0] = 1

for mask in range(2 ** n - 1):
    a = bin(mask).count('1')
    for b in range(n):
        if can[a][b] and not(mask & (1 << b)):
            m2 = mask ^ (1 << b)
            dp[m2] = dp[m2] + dp[mask]
            if dp[m2] > MOD:
                dp[m2] -= MOD


print(dp[(2**n) - 1])


Measured memory_bytes: 59264
#include <iostream>
#include<algorithm>
//#include<vector>
#define MAX 10000
using namespace std;

int main()
{
    int m=0;
    long int sum=0;
    int x[MAX]={0};
    cin>>m;
   // x.resize(m,0);
    for(int i=0;i<m;i++)
    {
        cin>>x[i];
        sum+=x[i];
    }
    sort(x,x+m);
    cout<<x[0]<<' '<<x[m-1]<<' '<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 3212
n, k = map(int, input().split())
a = [0] * n
cnt = 0
b = []

for i in range(k):
    d = int(input())
    b.append(input().split())
    # print(b)

    for j in range(d):
        b[i][j] = int(b[i][j])
        a[b[i][j] - 1] += 1
for i in range(n):
    if a[i] == 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9028
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string ans = "";
    REP(i,3){
        string s;
        cin >> s;
        ans += toupper(s[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PA pair<int,int>
const int N=310,mod=1000000007;
int n,m,ans;
struct node
{
	int l,r,num;
	friend bool operator < (const node &r1,const node &r2)
	{return r1.r<r2.r;}
}a[N];
int f[N][N][N];
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].num);
	sort(a+1,a+1+m);
	f[1][0][0]=3;
	for(int i=1,now=1;i<=n;i++)
	{
		while(now<=m&&a[now].r==i)
		{
			int l=a[now].l,num=a[now].num;
			for(int j=0;j<i;j++)
				for(int k=0;k<=j;k++)
				{
					int t=1;
					if(j>=l)t++;
					if(k>=l)t++;
					if(t!=num)f[i][j][k]=0;
				}
			now++;
		}
		if(i==n)break;
		for(int j=0;j<i;j++)
			for(int k=0;k<=j;k++)
			{
				(f[i+1][j][k]+=f[i][j][k])%=mod;
				(f[i+1][i][k]+=f[i][j][k])%=mod;
				(f[i+1][i][j]+=f[i][j][k])%=mod;
			}
	}
	for(int j=0;j<n;j++)
		for(int k=0;k<=j;k++)
			(ans+=f[n][j][k])%=mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 112896
k, x = gets.chomp.split.map(&:to_i)

ns = []
d = k - 1
max = d * 2
d.times do |i|
  ns[i] = x - d
  ns[max - i] = x + d
  d -= 1
end
ns[ns.size / 2] = x

puts ns.join(" ")


Measured memory_bytes: 1788
#include <cstdio>

using namespace std;

int main(void){
	int x, y, i, p;
	while(scanf("%d%d",&x,&y) != EOF){
		p = 10;
		for(i = 1;p <= x + y;i++){
			p *= 10;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1028
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

n, m, k = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())

accA = list(accumulate(A))
accB = list(accumulate(B))
ans = 0
for i in range(n):
    if accA[i] > k:
        break
    ans = max(ans, i + 1 + bisect_right(accB, k - accA[i]))
ans = max(ans, 0 + bisect_right(accB, k))
print(ans)

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

int main() {

	int n, m;
	int A[100][100], b[100], c[100];

	cin >> n >> m;

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

	for (int i = 0; i < n; i++) {
		c[i] = 0;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] += A[i][j] * b[j];
		}
	}

	for (int i = 0; i < n; i++) {
		cout << c[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		long long int n=0;
      	cin >> n;
      	n= n%10;
      	if(n==2||n==4||n==5||n==7||n==9){
        cout <<"hon"<<endl;
        }
      else{
      	if(n==3){
         cout <<"bon"<<endl;
        }
        else{cout <<"pon"<<endl;}
      }
	}
}

Measured memory_bytes: 3624
//
// Created by maze on 2019/09/15.
//

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int32_t;
using int64 = int64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

int main(void) {
    int64 N, K, Q;
    cin >> N >> K >> Q;
    vector<int64> A(Q);
    vector<int64> cnt(N, 0);
    REP(i, Q) {
        cin >> A[i];
        cnt[A[i]-1]++;
    }
    int64 res = 0;
    REP(i, N) {
        if (K-(Q-cnt[i]) <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}


Measured memory_bytes: 2176
import java.util.Scanner;

//Revenge of Champernowne Constant
public class Main{

	long DIGIT_LIMIT = 1000000000000000000L;
	long MAX_NUMBER = 59477124183006535L;
	long[] endK;
	long[] ten;
	
	void init(){
		endK = new long[20];
		endK[0] = 0;
		long num = 9;
		for(int k=1;k<=17;k++,num*=10){
			endK[k] = endK[k-1]+k*num;
		}
		endK[18] = DIGIT_LIMIT;
		endK[0] = -1;
		ten = new long[20];
		ten[0] = 0;
		ten[1] = 10;
		for(int k=2;k<=17;k++)ten[k]=ten[k-1]*10;
	}
	
	long findNumber(long x){
		if(x<=0||MAX_NUMBER<x)return DIGIT_LIMIT;
		if(x<10)return x;
		int k = (x+"").length()-1;
		return endK[k]+1+(k+1)*(x-ten[k]);
	}
	
	long findString(String target){
		boolean allzero = true;
		for(char ch:target.toCharArray())allzero&=ch=='0';
		if(allzero)return findNumber(Long.parseLong("1"+target))+1;
		int len = target.length();
		if(len==1){
			return findNumber(Long.parseLong(target));
		}
		long res = DIGIT_LIMIT;
		int lenMax = Math.min(17, len);
		for(int h=0;h<lenMax;h++)for(int k=1;k<=lenMax;k++)res = Math.min(res, findStringSub(target, h, k));
		return res;
	}
	
	long findStringSub(String target, int h, int k){
		if(target.charAt(h)=='0')return DIGIT_LIMIT;
		String sub = target.substring(0, h);
		String s = "";
		for(int i=h;i<h+k;i++){
			if(i<target.length())s+=target.charAt(i);
			else {
				int L = h+k-i;
				String r = (Long.parseLong(sub.substring(sub.length()-L))+1)+"";
				while(r.length()-L<0)r="0"+r;
				s+=r.substring(r.length()-L); break;
			}
		}
		long base = Long.parseLong(s);
		if(MAX_NUMBER<base)return DIGIT_LIMIT;
		String match = base+"";
		int pos = h, addLen = 0;
		long b = base-1;
		while(pos>0){
			if(b<=0)return DIGIT_LIMIT;
			String add = b-- +"";
			pos-=add.length();
			addLen+=add.length();
			match = add+match;
		}
		b = base+1;
		pos = h+k;
		while(pos < target.length()){
			if(MAX_NUMBER<b)return DIGIT_LIMIT;
			String add = b++ +"";
			pos+=add.length();
			match+=add;
		}
		for(int i=0;i<target.length();i++)if(target.charAt(i)!=match.charAt(addLen-h+i))return DIGIT_LIMIT;
		long res = findNumber(base);
		while(h--!=0)res--;
		return res;
	}
	
	void run(){
		init();
		Scanner sc = new Scanner(System.in);
		for(;;){
			String s = sc.next();
			if("#".equals(s))break;
			System.out.println(findString(s));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
const int  N = 1000100;

int t1[200];
int t2[200];
int dp1[N] = {0};
int dp2[N] = {0};

int main(){
	int i,j,k=2,s;
	
	t1[1] = t2[1] = dp1[1] = dp2[1] = 1;
	for(i = 2; i < 200; i++){
		t1[i] = t1[i-1] * (i+2) / (i-1);
		if(t1[i] > 1e+6) break;
		dp1[t1[i]] = 1;
		if(t1[i]%2){ dp2[t1[i]] = 1; t2[k++] = t1[i];}
	}

	for(i = 2; i < N; i++){
		if(dp2[i]) continue;
		for(j = 1; t2[j] < i && j < 200; j++){
			if(!dp2[i] || (1 + dp2[i-t2[j]]) < (dp2[i])){
				dp2[i] = 1 + dp2[i-t2[j]];
			}
		}
		if(dp1[i]) continue;
		for(j = 1; t1[j] < i; j++){
			if(!dp1[i] || (1 + dp1[i-t1[j]]) < (dp1[i])){
				dp1[i] = 1 + dp1[i-t1[j]];
			}
		}
	}

	while(cin >> s, s)
		cout << dp1[s] << ' ' << dp2[s] << endl;

	return 0;
}

Measured memory_bytes: 8516
#include<iostream>

using namespace std;

int main(){
  int n, T;
  int maxi = 1001;
  cin >> n >> T;
  for(int i = 0 ; i < n ; i++){
    int a , b;
    cin >>  a >> b;
    if(b <= T&& maxi >= a) maxi = a;
  }
  if(maxi == 1001) cout << "TLE" << endl;
  else cout << maxi << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll d;
vector<vl> s;
vl c(26);
vector<set<ll>> st(26, {-1});
ll score;

void add(ll i, ll k) {  // i日目(0-index)、テストk（0-index）
  st[k].insert(i);
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score += c[k] * (i - prev) * (next - i) + s[i][k];
}

void rm(ll i, ll k) {
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score -= c[k] * (i - prev) * (next - i) + s[i][k];
  st[k].erase(i);
}

int main() {
  double limit = double(clock()) / double(CLOCKS_PER_SEC) + 1.95;
  // 入力をもらう
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d, vl(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];

  //// 入力を作るデバッグ用
  // d = 365;
  // s.resize(d, vl(26));
  // rep(i, 26) c[i] = rand() % 101;
  // rep(i, d) rep(j, 26) s[i][j] = rand() % 20001;

  // 初期解を作って評価、scoreに反映
  score = -accumulate(all(c), 0LL) * d * (d + 1) / 2;
  vl t(d);
  rep(i, d) {
    ll mx = score, mt = 0;
    rep(j, 26) {
      add(i, j);
      if(mx < score) {
        mx = score;
        mt = j;
      }
      rm(i, j);
    }
    add(i, mt);
    t[i] = mt;
  }

  while(double(clock()) / double(CLOCKS_PER_SEC) < limit) {
    ll xd = rand() % d;
    ll xt = rand() % 26;
    ll old_score = score;
    ll old_test = t[xd];
    if(xt == t[xd]) xt = (xt + 1) % 26;
    rm(xd, t[xd]);
    add(xd, xt);
    if(score < old_score) {
      rm(xd, xt);
      add(xd, old_test);
    } else
      t[xd] = xt;
  }
  rep(i, d) cout << t[i] + 1 << '\n';
}

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 101;

int n, K;
PLL P[N];
vector < LL > v;

int main()
{
    _upgrade
    cin >> n >> K;
    for(int i = 1; i <= n; i++)
        cin >> P[i].first >> P[i].second, v.push_back(P[i].second);
    sort(all(v));
    sort(P + 1, P + n + 1);
    LL ans = 4e18 + 7;
    for(int i = 0; i < sz(v); i++)
    {
        for(int j = i + 1; j < sz(v); j++)
        {
            int y1 = v[i], y2 = v[j];
            vector < LL > good;
            for(int k = 1; k <= n; k++)
                if(y1 <= P[k].second && P[k].second <= y2)
                    good.push_back(P[k].first);
            sort(all(good));
            if(sz(good) < K) continue;
            for(int k = K - 1; k < sz(good); k++)
            {
                ans = min(ans, (y2 - y1) * (good[k] - good[k - K + 1]));
            }
        }
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

bool check(string s)
{
	string r;
	r=s;
	reverse(r.begin(),r.end());
	return r==s;
}
void solve()
{
  string s;
  cin >> s;
  int n=s.length();
  string x=s.substr(0,(n-1)/2);
  string y=s.substr(((n+3)/2)-1,abs(n+1-((n+3)/2)));
  if(check(s) && check(x) && check(y))
  {
	  cout << "Yes\n";
  }
  else
   cout << "No\n";
  return;
}

signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }

int main(){
    ll n, k;
    cin >> n >> k;
    vector<double> p(n);
    for(auto& i : p){
        cin >> i;
        i = (i + 1) / 2; // p 面サイコロの期待値は (p + 1) / 2
    }
    // 最初の k 項の和
    double cnt = 0;
    for(ll i = 0; i < k; i++) cnt += p[i];
    double ans = cnt;
    // 区間をずらしていく これは尺取り法？
    for(ll i = k; i < n; i++){
        cnt += p[i] - p[i - k];
        chmax(ans, cnt);
    }
    // printf のほうが cout << fixed << setprecision(15); より短い
    printf("%.15f", ans);
}


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

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = s[0];
            int B = s[1];

            if (A > 8 || B > 8) {
                Console.WriteLine(":(");
            } else {
                Console.WriteLine("Yay!");
            }

        }

    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
 int n = 3;
  int arr[n];
  for (int i=0;i<n;i++){
  cin>>arr[i];
  }
  sort(arr,arr+3);
  if ((arr[0]==5) && (arr[1]==5) && (arr[2]==7))
    cout<<"YES"<<endl;
  else 
    cout<<"NO"<<endl;
  
  
  return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100, MAXK = 100000;

int a[MAXN + 2];
bool dp[MAXK + 2];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++)
		cin >> a[i];
	for(int i = 1; i <= K; i++)
		for(int j = 0; j < N && i >= a[j]; j++)
			dp[i] |= !dp[i - a[j]];
	if(dp[K])
		cout << "First" << endl;
	else
		cout << "Second" << endl;
}


Measured memory_bytes: 384
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


l, r, d = list(map(int, input().split()))
ans = r//d-(l-1)//d
print(ans)


Measured memory_bytes: 9564
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 150;
int N;
int h[MAX_N];

main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> h[i];
    }

    int ret = 0;
    while (true) {
        bool found = false;
        for (int i = 1; i <= N; i++) {
            if (0 < h[i]) {
                found = true;
                ret++;
                for (int j = i; j <= N; j++) {
                    if (0 < h[j]) {
                        h[j]--;
                    } else {
                        break;
                    }
                }
                break;
            }
        }
        if (!found) {
            break;
        }
    }
    
    std::cout << ret << std::endl;
}

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

MOD = 10 ** 9 + 7

# dp[i][j] i人目までの子供にj個のアメを配る数
dp = [[0] * (ｋ + 1) for _ in range(n + 1)]

for i in range(n + 1):
  dp[i][0] = 1
  
for i in range(1, n + 1):
  for j in range(1, k + 1):
    if j-1-A[i-1] >= 0:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1-A[i-1]]) % MOD
    else:
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD

ans = dp[n][k]
print(ans)


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n, maxn = 0, k, k1 = -1;
   cin >> n >> k;
   for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      if (k1 == -1) k1 = x;
      else k1 = __gcd(k1, x);
      maxn = max(maxn, x);
   }   
   if (k > maxn || k % k1 != 0) {
      cout << "IMPOSSIBLE";
      return 0;
   }
   cout << "POSSIBLE";
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<pii> v(m);
    rep(i, m) cin >> v[i].second >> v[i].first;

    sort(ALL(v));
    int cnt = 1;
    int brige = v[0].first;

    for (int i = 1; i < m; i++)
    {
        if (v[i].second < brige)
            continue;

        cnt++;
        brige = v[i].first;
    }

    OP(cnt);
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  int k;
  int swp;
  int ans=0;

  //長さNの配列を作成.
  vector<int> A(5);
  for(int i = 0; i < 5; i++){
    cin >> A[i];
  }
  //  cout << "---" << endl;

  
  for(int i=1; i<5; i++){
    if(A[i-1]%10 < A[i]%10 &&  A[i]%10 != 0){
      swp=A[i-1];
      A[i-1]=A[i];
      A[i] = swp;
    }else if(A[i]%10 ==0){
      swp=A[i-1];
      A[i-1]=A[i];
      A[i] = swp;
    }

    
  }


  
  for(int i=0; i<4; i++){
    if(A[i]%10 != 0){
      ans=ans+(A[i]/10+1)*10;
    }else{
      ans=ans+A[i];
    }
    //    cout << "+" << A[i] << " "<< ans << endl;
  }

  ans=ans+A[4];

  cout << ans << endl;

}


Measured memory_bytes: 256