akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<functional>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

#define T1 1000000LL
#define T2 1000LL

long long W, H, X, Y, R;
long long x[1000][1000];
long long d[1000][1000];
long long p1, p2, p3;
long long y_1[1000000], y_2[1000000], cnt, cnt2, v, minx;

priority_queue<long long, vector<long long>, greater<long long>> Q, S;

int main() {
	while (true) {
		cnt = 1; cnt2 = 1; minx = 1145141919810LL;
		memset(x, 51, sizeof(x));
		memset(d, 51, sizeof(d));
		cin >> R;
		if (R == 0) { break; }
		cin >> W >> H >> X >> Y;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		d[Y][X] = 0;
		Q.push(Y*T2 + X);
		while (!Q.empty()) {
			p1 = Q.top() / T1;
			p2 = (Q.top() / T2) % T2;
			p3 = Q.top() % T2;
			if (max(p1, x[p2 - 1][p3]) < d[p2 - 1][p3]) {
				d[p2 - 1][p3] = max(p1, x[p2 - 1][p3]);
				S.push(d[p2 - 1][p3] * T1 + (p2 - 1)*T2 + p3);
			}
			if (max(p1, x[p2 + 1][p3]) < d[p2 + 1][p3]) {
				d[p2 + 1][p3] = max(p1, x[p2 + 1][p3]);
				S.push(d[p2 + 1][p3] * T1 + (p2 + 1)*T2 + p3);
			}
			if (max(p1, x[p2][p3 - 1]) < d[p2][p3 - 1]) {
				d[p2][p3 - 1] = max(p1, x[p2][p3 - 1]);
				S.push(d[p2][p3 - 1] * T1 + p2*T2 + (p3 - 1));
			}
			if (max(p1, x[p2][p3 + 1]) < d[p2][p3 + 1]) {
				d[p2][p3 + 1] = max(p1, x[p2][p3 + 1]);
				S.push(d[p2][p3 + 1] * T1 + p2*T2 + (p3 + 1));
			}
			Q.pop();
			while (!S.empty()) {
				Q.push(S.top());
				S.pop();
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				y_1[cnt] = d[i][j];
				cnt++;
			}
		}
		memset(x, 51, sizeof(x));
		memset(d, 51, sizeof(d));
		cin >> W >> H >> X >> Y;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		d[Y][X] = 0;
		Q.push(Y*T2 + X);
		while (!Q.empty()) {
			p1 = Q.top() / T1;
			p2 = (Q.top() / T2) % T2;
			p3 = Q.top() % T2;
			if (max(p1, x[p2 - 1][p3]) < d[p2 - 1][p3]) {
				d[p2 - 1][p3] = max(p1, x[p2 - 1][p3]);
				S.push(d[p2 - 1][p3] * T1 + (p2 - 1)*T2 + p3);
			}
			if (max(p1, x[p2 + 1][p3]) < d[p2 + 1][p3]) {
				d[p2 + 1][p3] = max(p1, x[p2 + 1][p3]);
				S.push(d[p2 + 1][p3] * T1 + (p2 + 1)*T2 + p3);
			}
			if (max(p1, x[p2][p3 - 1]) < d[p2][p3 - 1]) {
				d[p2][p3 - 1] = max(p1, x[p2][p3 - 1]);
				S.push(d[p2][p3 - 1] * T1 + p2*T2 + (p3 - 1));
			}
			if (max(p1, x[p2][p3 + 1]) < d[p2][p3 + 1]) {
				d[p2][p3 + 1] = max(p1, x[p2][p3 + 1]);
				S.push(d[p2][p3 + 1] * T1 + p2*T2 + (p3 + 1));
			}
			Q.pop();
			while (!S.empty()) {
				Q.push(S.top());
				S.pop();
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				y_2[cnt2] = d[i][j];
				cnt2++;
			}
		}

		sort(y_1, y_1 + cnt);
		sort(y_2, y_2 + cnt2);

		for (int i = 0; i < cnt; i++) {
			v = R - i;
			if (v >= 0 && v < cnt2) {
				minx = min(minx, y_1[i] + y_2[v]);
			}
		}
		cout << minx << endl;
	}
}

Measured memory_bytes: 22760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second
#define ld long double

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<ld>> DP(N+1, vector<ld>(N+1, 0));
    DP[0][0] = 1;
    for(int i = 0; i < N; i++){
        ld p; cin >> p;
        for(int j = 0; j <= i; j++){
            DP[i+1-j][j] += DP[i-j][j] * p;
            DP[i-j][j+1] += DP[i-j][j] * (1-p);
        }
    }
    ld ans = 0;
    for(int i = N; i > N-i; i--) ans += DP[i][N-i];
    cout << fixed << setprecision(12) << ans;
}

Measured memory_bytes: 144384
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int L, R;
    cin >> L >> R;
    if (R - L >= 2019) {
        cout << 0 << endl;
        return;
    }
    int ans = 1LL << 30;
    FOR (i, L, R) FOR (j, i + 1, R + 1) {
        ans = min(ans, i * j % 2019);
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(){
	int a,b;
	int ren;
	string ans="No";

	cin>>a>>b;

	if(b<10)ren=10*a+b;
	else if(b<100)ren=100*a+b;
	else ren=1000*a+b;

	for(int i=0;i<1000;i++){
		if(ren==i*i){
			ans="Yes";
			break;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,cnt,cnt1=0;
	string s;
	char ch;
	cin>>n>>s;
	if(n==1)
	cout<<"No"<<endl;
	else
	{
		for(ch='a';ch<='z';ch++)
	    {
		    cnt=0;
	    	for(i=0;s[i]!='\0';i++)
	    	{
    			if(s[i]==ch)
	    		cnt++;
    		}
	    	if(cnt%2!=0)
	    	{
		    	cnt1++;
		    	break;
		    }
    	}
    	if(cnt1==1)
    	cout<<"No"<<endl;
    	else
    	cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	string S;
	cin >> S;
	int ans = 1000;
	S.pb('a');
	int ssize = S.size();
	int tmpans;
	for(char c = 'a'; c <= 'z'; c ++){
		S[ssize - 1] = c;
		tmpans = 0;
		for(int i = 0; i < ssize - 1; i ++){
			for(int j = i; j < ssize; j ++){
				if(S[j] == c){
					tmpans = max(tmpans, j - i);
					break;
				}
			}
		}
		ans = min(ans, tmpans);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
module subprogram
	implicit none
contains
	subroutine bubblesort(N,array)
    integer,intent(in)::N
    integer,intent(inout)::array(1:N)
    integer::i,j
    integer::t
    do i=1,N-1
       do j=i+1,N
          if(array(i) .gt. array(j))then
             t=array(i)
             array(i)=array(j)
             array(j)=t
          end if
       end do
    end do
    return
	end subroutine bubblesort
end module subprogram

program main
	use subprogram
	implicit none
	integer N, K
	integer, allocatable :: l(:)
	read(*, *) N, K
	allocate(l(1: N))
	read(*, *) l(1: N)
	call bubblesort(N,l)
	l(1:N) = l(N:1:-1)
	write(*, *) sum(l(1:K))
end program main

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int x=n;;x++){
		bool flg=1;
		for(int i=2;i*i<=x;i++) if(x%i==0) {
			flg=0;break;
		}
		if(flg) return printf("%d\n",x),0;
	}
}

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

namespace ProConCWhenIHitMyPocket
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int A = int.Parse(input[1]);
            int B = int.Parse(input[2]);
            // 文字列の入力
            //string s = Console.ReadLine();
            long biscuit = 1;
            int yen = 0;
            if (B <=( A+2))
            {
                biscuit = 1 + K;
            }
            else
            {
                for (var i = 1; i <= K; i++)
                 {
                    if (yen ==1)
                    {
                    yen = 0;
                    biscuit += B;
                        //Console.WriteLine("ビスケットをB個　買い足しました。");
                        continue;
                    }
                    else if ((biscuit >= A ) && (i < K))
                    {
                    biscuit -=A;
                    yen++;
                        //Console.WriteLine("円に換えました。");
                    continue;
                    }
                    else
                    {
                        biscuit++;
                    }
                }
            }
            //出力
                   Console.WriteLine(biscuit);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <set>
#include <memory.h>
using namespace std;

int main(){
    int a, b, i;
    int sum = 0;
    cin >> a >> b;
    for(i = 1; i <= b-a; i++){
        sum += i;
    }
    cout << sum - b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    
    if ( (b - a) % 2 == 0 ) {
        cout << (b - a) / 2 << endl;
    } else {
        long long ans1 = a + (b - a - 1) / 2;
		long long ansN = (n - b + 1) + (b - a - 1) / 2;
		cout << min(ans1, ansN) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int x, i = 1;

	for (;;)
	{
		scanf("%d", &x);

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

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
using namespace std;

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

	int n;
	string s;
	int k;
	cin >> n >> k >> s;
	s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s << endl;


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
h,w = gets.chomp.split(" ").map(&:to_i)
c = gets.chomp.split(" ").map(&:to_i)
d = gets.chomp.split(" ").map(&:to_i)
s = Array.new(h){Array.new}
h.times do |i|
  s[i] = gets.chomp.split("")
end
visited = Array.new(h){Array.new(w,-1)}
visited[c[0]-1][c[1]-1] = 0
queue = [c[0]-1,c[1]-1]
queue2 = []
cnt = 0
map1 = [[-1,0],[1,0],[0,1],[0,-1]]
map2 = [[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],[-1,-2],[-1,-1],[-1,1],[-1,2],[0,-2],[0,2],[1,-2],[1,-1],[1,1],[1,2],[2,-2],[2,-1],[2,0],[2,1],[2,2]]
while !queue.empty? || !queue2.empty?
  while !queue.empty?
    a,b = queue[0],queue[1]
    queue.shift
    queue.shift
    queue2 << a
    queue2 << b
    map1.each do |x|
      v0,v1 = a+x[0],b+x[1]
      if 0 <= v0 && v0 < h && 0 <= v1 && v1 < w
        if visited[v0][v1] == -1 && s[v0][v1] == "."
          visited[v0][v1] = cnt
          queue << v0
          queue << v1
        end
      end
    end
  end
  cnt += 1
  while !queue2.empty?
    a = queue2[0]
    b = queue2[1]
    queue2.shift
    queue2.shift
    map2.each do |x|
      v0,v1 = a+x[0],b+x[1]
      if 0 <= v0 && v0 < h && 0 <= v1 && v1 < w
        if visited[v0][v1] == -1 && s[v0][v1] == "."
          visited[v0][v1] = cnt
          queue << v0
          queue << v1
        end
      end
    end
  end
end
puts visited[d[0]-1][d[1]-1]

Measured memory_bytes: 106272
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	ll n;
	scanf("%lld",&n);
	ll ans=(1+n)*n/2;
	if(n>=3){
		ans-=(3+n/3*3)*(n/3)/2;
	}
	if(n>=5){
		ans-=(5+n/5*5)*(n/5)/2;
	} 
	if(n>=15){
		ans+=(15+n/15*15)*(n/15)/2;
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    from itertools import combinations
    n = int(input())
    ab = [tuple(sorted(list(map(int, input().split())))) for _ in [0]*(n-1)]
    m = int(input())
    uv = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    d = dict()
    for i, (a, b) in enumerate(ab):
        d[(a-1, b-1)] = i

    def tree_path(root, goal):
        d = [-1]*n  # 根からの距離
        d[root] = 0
        q = [root]
        cnt = 0
        while q:  # BFS
            cnt += 1
            qq = []
            while q:
                i = q.pop()
                for j in g[i]:
                    if d[j] == -1:
                        d[j] = cnt
                        qq.append(j)
            q = qq
        now = goal
        path = [goal]
        while True:
            dist = d[now]
            for i in g[now]:
                if d[i] < dist:
                    now = i
                    path.append(i)
                    break
            if dist == 1:
                break
        return path

    seiyaku = [set() for _ in [0]*m]

    for i, (u, v) in enumerate(uv):
        path = tree_path(u-1, v-1)
        for j in range(len(path)-1):
            x, y = min(path[j], path[j+1]), max(path[j], path[j+1])
            seiyaku[i].add(d[(x, y)])

    cnt = 2**(n-1)

    for i in range(1, m+1):
        flag = 1
        if i % 2 == 1:
            flag = -1
        cc = combinations(list(range(m)), i)
        for c in cc:
            s = set()
            for j in c:
                s |= seiyaku[j]
            cnt += (2**(n-1-len(s)))*flag
    print(cnt)


main()


Measured memory_bytes: 3192
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn calc_prime_numbers(max: u64) -> Vec<u64> {
    let limit: u64 = (max as f64).sqrt() as u64;
    let mut prime_numbers: Vec<u64> = Vec::new();
    for i in 2..(limit+1) {
        let mut flag = true;
        for p in &prime_numbers {
            if i % p == 0 {
                flag = false;
            }
        }
        if flag {
            prime_numbers.push(i)
        }
    }
    prime_numbers
}

fn main() {
    let mut n: u64 = input();    
    let prime_numbers= calc_prime_numbers(n);

    // println!("{:?}", prime_numbers);
    print!("{}:", n);
    for p in prime_numbers {
        if n == 1 {
            break;
        }
        while n % p == 0 {
            n /= p;
            print!(" {}", p);
        }
    }
    if n != 1 {
        println!(" {}", n);
    } else {
        println!();
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, k, q, m;
string s;

void solve(){
    ll arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    if(arr[0] == arr[1] && arr[0] != arr[2])
        cout << "Yes" << endl;
    else if(arr[1] == arr[2] && arr[0] != arr[2])
        cout << "Yes" << endl;
    else    
        cout << "No" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

class ITP1
{
    static void Main()
    {
        for (; ; )
        {
        var a = Console.ReadLine();
        int b = int.Parse(a.Split(' ')[0]);
        int c = int.Parse(a.Split(' ')[1]);
            if (b == 0 && c == 0) { break; }
            for (int i = 0; i < b; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    Console.Write('#');
                }
                Console.Write('\n');
            }
            Console.Write('\n');
        }
    }
}

Measured memory_bytes: 5288
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
signed main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    float b[n];
    float sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=(1.0*(1+a[i]))/2;
        if(i<k)
        {
            sum+=b[i];
        }
    }
    float ans=sum;
    for(int i=k;i<n;i++)
    {
         sum = sum + b[i] - b[i-k];
         ans=max(sum,ans);

    }
    printf("%Lf\n",ans);

}

Measured memory_bytes: 4992
n, ma, mb = map(int, input().split())
dp = [[[float('inf') for _ in range(401)] for _ in range(401)] for _ in range(n)]
dp[0][0][0] = 0
a0, b0, c0 = map(int, input().split())
dp[0][a0][b0] = c0

for i in range(1, n):
	dp[i][0][0] = 0
	a, b, c = map(int, input().split())
	for j in range(401):
		for k in range(401):
			if j >= a and k >= b:
				dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a][k-b] + c)
			else:
				dp[i][j][k] = dp[i-1][j][k]

ans = float("inf")
cnt = 400 // max(ma, mb)
for i in range(1, cnt + 1):
	ans = min(ans, dp[-1][ma * i][mb * i])

if ans <= 4000:
	print(ans)
else:
	print(-1)

Measured memory_bytes: 140892
#include<iostream>
#include<vector>
#define ll long long
using namespace std;

vector<int> num(200000);
int main(){
    int N;
    vector<int> A(200000);
    int Q;
    vector<int> B(200000),C(200000);
    cin>>N;
    ll sum=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        num[A[i]]++;
        sum+=A[i];
    }
    cin>>Q;
    for(int i=0;i<Q;i++){
        cin>>B[i]>>C[i];
        num[C[i]]+=num[B[i]];
        sum+=num[B[i]]*(C[i]-B[i]);
        num[B[i]]=0;
        cout<<sum<<endl;
    }

    return 0;

}

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

int main(void){
    int x;
    cin >> x;

    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3616
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        l: i64,
        r: i64,
    }
    let mut rs = Vec::with_capacity(2019);
    for x in (l..=r).take(2019) { rs.push(x % 2019); }
    let n = rs.len();
    let mut ans = i64::MAX;
    for i in 0..(n - 1) {
        for j in (i + 1)..n { ans = min(ans, (rs[i] * rs[j]) % 2019); }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2200
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int A, B;

int main() {
  cin >> A >> B;
  int sum = A + B;
  if (sum >= 10) {
    cout << "error";
  } else {
    cout << sum;
  }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll md=1e9+7;
int main(){
	int n,k;
	ll ans=0;
	scanf("%d%d",&n,&k);
	for(int i=k;i<=n+1;i++){
		ans=(ans-1ll*(i-1)*i/2+1ll*(n+n-i+1)*i/2+1)%md;
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
	string s;
	int n,cnt = 0;
	cin>>s>>n;
	while(n--){
		string ss;
		cin>>ss;
		ss = ss + ss;
		//cout<<ss<<endl;
		int line = 0;
		for(int i = 0 ; i < ss.size() ; i ++){
			//cout<<cnt<<" "<<ss.substr(i,s.size())<<" "<<s<<endl;
			if(s == ss.substr(i,s.size())){
				line=1;
			}
		}
		cnt += line;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define N int(2e5+5)
#define mod 1000000007
using namespace std;
typedef long long ll;
ll ans;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; i++) cin >> arr[i];
    for(int i=0; i<n; i++){
        if(arr[i] == i+1){
            ans++;
            if(arr[i+1] == i+2) i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;

int main() {
    //input
    int n,m; cin >> n >> m;
    vector<int> a(m + 1);
    vector<int> b(m + 1);
    for(int i = 1; i < m + 1; i++) cin >> a[i] >> b[i];

    //compute
    set<int> s1,s2;
    for(int i = 1; i < m + 1; i++) {
        if(a[i] == 1){
            s1.insert(b[i]);
            }
        if(b[i] == n){
            s2.insert(a[i]);
            }
    }
  
    //output
    for(int i = 1; i < n + 1; i++) {
        if((s1.count(i) == 1) && (s2.count(i) == 1)){
          cout << "POSSIBLE" << endl;
          return 0;
        }else{
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13860
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 200005, MAXM = 3003, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(2 * b - 1, 2 * a - 1)) << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  //map<string,int> s;
  //map<string,int> s{};
  //string res;
  vector<int> a;
  
  cin >> n;
  vector<int> s(n,0);
  int tmp,res;
  res = 0;
  
  for(int i = 0;i < n-1; i++){
    cin >> tmp;
    s.at(tmp-1) +=1;
  }
  
  for(int i = 0;i < n; i++){
    cout << s.at(i) << endl;;
  }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n;

struct struk{
		ll cnt, isi;
	};
vector<struk>ganjil(100005), genap(100005);

bool cmp(struk s1, struk s2){
		return s1.cnt>s2.cnt;
	}

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		ll num;
		cin >> num;
		if(i&1){
			ganjil[num].cnt++;
			ganjil[num].isi=num;
		}
		else{
			genap[num].cnt++;
			genap[num].isi=num;
		}
	}
	sort(ganjil.begin(), ganjil.end(), cmp);
	sort(genap.begin(), genap.end(), cmp);
	if(ganjil[0].isi!=genap[0].isi){
		cout << n-(ganjil[0].cnt+genap[0].cnt) << '\n';
		return 0;
	}
	//cout << genap[0].cnt << ' ' << ganjil[0].cnt << '\n';
	ll ans1=n-(ganjil[0].cnt+genap[1].cnt);
	ll ans2=n-(ganjil[1].cnt+genap[0].cnt);
	cout << min(ans1, ans2) << '\n';
}



Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    int neg = 0, zero = 0;
    for(int i=0; i<N; i++){
        if(a[i] < 0) neg++;
        else if(a[i] == 0) zero = 0;
    }

    ll sum = 0;
    ll minv = 10000000000;
    for(int i=0; i<N; i++){
        sum += abs(a[i]);
        minv = min(minv, abs(a[i]));
    }

    if(zero>0 || neg%2==0) cout << sum << endl;
    else cout << sum - 2*minv << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstring>
char s[100];
int main() 
{
	scanf("%s",&s);
    int len =strlen (s);
	if(len==2){
		printf("%s",s);
	}
	else if(len == 3){
		for(int i = 3; i >= 1;i--){
			printf("%c",s[i - 1]);
		}
}

		
        
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int p[2][150],q[300];
    int i, j, k, s, N, max = 0;
    scanf("%d",&N);
    for(i=0;i<2;i++)
        for(j=0;j<N;j++)
           scanf("%d",&p[i][j]);

    for(i=0;i<N;i++)
     {
        s = 0;
        for(j=0;j<2;j++)
           for(k=0;k<N;k++)
              if((j==0&&k<=i)||(j==1&&k>=i))
                   s = s + p[j][k];
        q[i] = s;
     }

    for(i=0;i<N;i++)
        if(q[max]<q[i])
           max = i;
    printf("%d",q[max]);
    return 0;
}

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


using LLI =  long long int;

LLI gcd(LLI a, LLI b) {
	if (a == 0) return b;
	return gcd(b % a, a);
}

int main() {
	LLI a, b, c, d;
	cin >> a >> b >> c >> d;

	LLI cd = c *d / gcd(max(c, d), min(c, d));
	LLI ab_c = b / c - a / c + (a % c == 0 ? 1 : 0);
	LLI ab_d = b / d - a / d + (a % d == 0 ? 1 : 0);
	LLI ab_cd = b / cd - a / cd + (a % cd == 0 ? 1 : 0);

	cout << b - a - (ab_c + ab_d - ab_cd) + 1 << 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++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    vector<char> C( 4 );
    for( auto &x : C )
    {
        cin >> x;
    }
    cout << ( ( C[ 0 ] == C[ 1 ] && C[ 1 ] == C[ 2 ] && C[ 0 ] == C[ 2 ] ) ||
            ( C[ 1 ] == C[ 2 ] && C[ 2 ] == C[ 3 ] && C[ 1 ] == C[ 3 ] ) ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


int main()
{
	int N;
	scanf("%d\n", &N);

	int i,j;
	Card BC[36];
	Card SC[36];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}

	/* Bubble Sort */
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }
	
	/* Selection Sort */
    for (i = 0; i < N - 1; i++) {
        int minj = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[minj].value)
                minj = j;
        }
        swap_Card(&SC[i], &SC[minj]);
    }
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long N, M;
    cin >> N >> M;
    priority_queue<long> A;
    long total = 0;
    long vote;
    for(size_t i=0;i<N; i++)
    {
        cin >> vote;
        A.push(vote);
        total += vote;
    }
    bool ok=true;
    cerr << total * 1.0/(4 * M) << endl;
    for(size_t i=0;i<M; i++)
    {
        vote = A.top();A.pop();
        if(vote < total * 1.0/(4 * M)) ok=false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
n = input()
s = input()
ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j),a+1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k),b+1)
            if c == -1:
                continue
            ans += 1
print(ans)

Measured memory_bytes: 3060
lines = readlines.map(&:strip)

n = lines.shift.to_i

sp = lines.map{|line| [line.split[0].to_s, line.split[1].to_i] }

#puts n
#puts sp.inspect

sp.each_with_index do |_, index|
  sp[index].push(index+1)
end

#puts sp.group_by{|l|l[0]}.sort.inspect

sp.group_by{|l|l[0]}.sort.each do |city, values|
  values.sort{|l,r|l[1] - r[1]}.reverse.each do |line|
    puts line.last
  end
end



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

int main() {

	string s; cin>>s;
	int i,n=s.size();
	for(i=0;i<n;i++) {
		if((i%2==0 && s[i]=='L') || (i%2!=0 && s[i]=='R')) {
			cout<<"No"<<endl; break;
		}
	}
	if(i==n) cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = gets.chomp.split(" ").map(&:to_i)

ret = 0
while true
  break if a.odd? || b.odd? || c.odd?
  if ret > 30 then
    puts -1
    exit
  end
  aa = (b + c) / 2
  bb = (a + c) / 2
  cc = (a + b) / 2
  a, b, c = aa, bb, cc
  ret += 1
end
puts ret


Measured memory_bytes: 1788
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    n,a,b = readInts()
    print(a * (n // (a+b)) + min(a,n%(a+b)))

if __name__ == '__main__':
  main()


Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++)
cin>>L.at(i);
  int Max=L.at(0);
  for(int i=1;i<N;i++){
  if(Max<=L.at(i))
    Max=L.at(i);
   }int sum=0;
  for(int i=0;i<N;i++)
    sum+=L.at(i);
  
  if(sum<=2*Max)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))
check_X = X[0:K]

def calc_distance(check_X):
    if check_X[0] * check_X[-1] < 0:
        result = min(abs(check_X[0]*2)+abs(check_X[-1]), abs(check_X[0])+abs(check_X[-1]*2))
    else:
        result = max(abs(check_X[0]),abs(check_X[-1]))
    return result

ans = calc_distance(check_X)

for i in range(K, len(X)):
    check_X.pop(0)
    check_X.append(X[i])
    ans = min(ans, calc_distance(check_X))

print(ans)


Measured memory_bytes: 14780
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////

int main(){
	int H,W,D;
	SCD3(H,W,D);
	
	static int gridx[90002];
	static int gridy[90002];
	
	vector<int>ans;
	
	REP(i,H){
		REP(j,W){
			int x; SCD(x);
			gridx[x] = i;
			gridy[x] = j;
		}
	}
	
	int Q; SCD(Q);
	
	static int scost [90002] = {};
	
	FORq(i,D+1,H*W){
		scost[i] = scost[i-D] + abs(gridx[i] - gridx[i-D]) + abs(gridy[i] - gridy[i-D]);
	}
	
	REP(i,Q){
		int L,R;
		SCD2(L,R);
		
		ans.PB(scost[R] - scost[L]);
		
	}
	
	
	REP(i,ans.size()){
		PRINTD(ans[i]);
	}
	
	return 0;
}


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


int main(){
    int n;
    double x,ans=0;
    string u;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> u ;
        if(u=="JPY"){
            ans+=x;
        } 
        if(u=="BTC"){
            ans+=x*380000.0;
        }
    }
    cout << fixed << ans << endl;
}

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

int main(void){
  int t,a,b;
  cin >> t >> a >> b;
  int x1 = t*a;
  int x2 = b;
  if(x1 >= x2){
    cout << x2 << '\n';
  }
  else{
    cout << x1 << '\n';
  }
}


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() {
int N ;
cin >> N ;
vector<int> A(N+2) ;
A[0] = 0 ; //スタートの座標
A[N+1] = 0 ;//ゴールの座標
for(int i = 1 ; i < N+1 ; i++ ) cin >> A.at(i) ;  
int ans = 0 ;
rep(i,N+1) ans += abs(A[i+1] - A[i])  ;
rep(i,N){
    int B = ans - abs(A[i+2] - A[i+1]) - abs(A[i+1] -A[i]) + abs(A[i+2] - A[i]) ;
    cout << B << endl;
}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a == 2 || b == 2) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 892
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())

    s = str(n)
    base = 0
    for i in range(len(s)):
        base += int(s[i])

    if n % base == 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;

  int g = a[0];
  for (int x : a) g = __gcd(g, x);

  unordered_set<int> vis;
  bool ok = true;
  for (int x : a) {
    for (int64_t i = 2; i * i <= x; ++i) {
      if (x % i == 0) {
        if (vis.count(i)) {
          ok = false;
          break;
        }
        vis.insert(i);
        while (x % i == 0) {
          x /= i;
        }
      }
    }
    if (x > 1) {
      if (vis.count(x)) {
        ok = false;
        break;
      }
      vis.insert(x);
    }
  }
  if (ok) cout << "pairwise coprime" << endl;
  else if (g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;

  return 0;
}



Measured memory_bytes: 7124
N,M = map(int,input().split())
A = list(map(int,input().split()))

s = sum(A)
A = sorted(A,reverse=True)

for i in range(N):
    if i == M-1:
        if (s/(4*M))>A[i]:
            print('No')
        else:
            print('Yes')

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int rc[][] = new int[r + 1][c + 1];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c + 1; j++) {
				if (j != c) {
					rc[i][j] = sc.nextInt();
					rc[i][c] += rc[i][j];
				}
				rc[r][j] += rc[i][j];
			}
		}
		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c + 1; j++) {
				if(j==c)System.out.print(rc[i][j]);
				else System.out.print(rc[i][j] + " ");
			}
			System.out.println();
		}
	}
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int n = input();
    vector< i64 > as(n + 1), rs(n + 1);
    range(i, 1, n + 1) cin >> as[i];
    range(i, 1, n + 1) rs[i] = (rs[i - 1] + as[i - 1]) % mod;

    i64 ans = 0;
    range(i, 1, n + 1) {
        (ans += as[i] * rs[i]) %= mod;
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

vll cost{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main()
{
    ll N, M; cin >> N >> M;
    vll A(M); rep(i, M) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    vll dp(N+1);
    dp[0] = 0;
    for (ll i = 1; i <= N; i++) {
        ll maxn = -inf;
        for (ll a : A) {
            ll left = i - cost[a];
            if (left >= 0) maxn = max(maxn, dp[left] + 1);
        }
        dp[i] = maxn;
    }

    //for (auto elem : dp) cout << elem << " "; cout << endl;

    ll digit = dp[N];
    string ans = "";
    while (digit > 0) {
        for (ll a : A) {
            if (N - cost[a] < 0) continue;
            if (dp[N - cost[a]] == dp[N] - 1) {
                ans += to_string(a);
                N -= cost[a];
                break;
            }
        }
        digit--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
package main

import (
  "fmt"
  "sort"
)

type runeSlice []rune
func (p runeSlice) Len() int           { return len(p) }
func (p runeSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p runeSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func reverseSortRuneSlice(a []rune) {sort.Sort(sort.Reverse(runeSlice(a)))}

func main() {
  var s, t string 
  fmt.Scan(&s, &t)
  rs := []rune(s)
  rt := []rune(t)
  reverseSortRuneSlice(rt)
  sort.Sort(runeSlice(rs))
  ans := "No"
  if string(rs) < string(rt) {ans = "Yes"}
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
const int maxn=1e5+1e2;
 
int a[maxn];
 
int main()
{
	int n;
	scanf("%d",&n);
	int up=0,down=1e9;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		up=max(up,a[i]);
		down=min(down,a[i]);
	}
	if(up-down>1)
	{
		printf("No\n");
		return 0;
	}
	int num=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==down)num++;
	}
	if(up!=down)
	{
		if(num>=up)printf("No\n");
		else
		{
			if(2*(up-num)+num<=n)printf("Yes\n");
			else printf("No\n");
		}
	}
	else
	{
		if(up==n-1)printf("Yes\n");
		else if(up*2<=n)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	std::int64_t A;
	double B;
	std::cin >> A >> B;
	B *= 100;
	A *= std::int64_t(B + 0.5);
	A /= 100;
	std::cout << A << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3736
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
A = getList()

pair = True
semi = True
# not divisible
# 全部互いに素かどうか
judge = [0] * (10 ** 6 + 1)
num_list = [0] * (10 ** 6 + 1)

for i in A:
    judge[i] += 1

for i in range(2, 10 ** 6 + 1):
    if num_list[i] == 1:
        continue
    cnt = 0
    for j in range(i, 10 ** 6 + 1, i):
        num_list[j] = 1
        cnt += judge[j]
    if cnt > 1:
        if cnt == N:
            semi = False
        pair = False

if pair and semi:
    print('pairwise coprime')
elif semi:
    print('setwise coprime')
else:
    print('not coprime')

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

Measured memory_bytes: 3600