akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}

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

    int a[n+1][4];

    for(int i=1; i<=n;i++)
        for(int j=1;j<=3;j++)
            cin >> a[i][j];

    ll dp[n+1][4];

    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];

    for(int i=2;i<=n;i++)
    {
        dp[i][1] = max(dp[i-1][2]+a[i][1], dp[i-1][3]+a[i][1]);
        dp[i][2] = max(dp[i-1][1]+a[i][2], dp[i-1][3]+a[i][2]);
        dp[i][3] = max(dp[i-1][2]+a[i][3], dp[i-1][1]+a[i][3]);
    }

    // for(int i=1; i<=n;i++)
    // {
    //     for(int j=1;j<=3;j++)
    //     {
    //         cout << dp[i][j] << " ";    
    //     }
    //     cout << "\n";
    // }

    cout << max({dp[n][1], dp[n][2], dp[n][3]}) << "\n";
}




Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if (b == 0) return a;
  return gcd(b,a % b);
}
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  bool flg = false;
  for (int i = 0; i < 10000; i++){
    if (A * i % B == C) flg = true;
  }
  if (flg) cout << "YES";
  if (!flg) cout << "NO";
}

Measured memory_bytes: 256
package main

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

func main() {
	sx, sy, tx, ty := ReadInt(), ReadInt(), ReadInt(), ReadInt()

	W, H := tx-sx, ty-sy
	ans := ""

	// 1
	ans += strings.Repeat("U", H)
	ans += strings.Repeat("R", W)

	// 2
	ans += strings.Repeat("D", H)
	ans += strings.Repeat("L", W)

	// 3
	ans += "L"
	ans += strings.Repeat("U", H+1)
	ans += strings.Repeat("R", W+1)
	ans += "D"

	// 4
	ans += "R"
	ans += strings.Repeat("D", H+1)
	ans += strings.Repeat("L", W+1)
	ans += "U"

	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 2004
#include <bits/stdc++.h>
using namespace std;
signed main(){
    string s; cin>>s;
    int sum=0;
    for(int i=0; i<s.size(); i++){
        sum+=s.at(i)-'0';
    }
    cout<<(stoi(s)%sum==0?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string a;
  int cnt=0;
  cin >>a;
  for (int i;i<a.size();i++){
   if(a.at(i)=='1'){
   cnt++;
   }
  }
  cout<<cnt<<endl;
  return 0;
}

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


int main() {
	long long n,k;
	cin>>n>>k;
	long long dp[n+1][k+1];
	memset(dp,-1,sizeof(dp));
	long long a[n+1];
	for(long long i=1;i<=n;i++){
	    cin>>a[i];
	    
	}for(long long i=0;i<=k;i++){
	    if(i<=a[1])
	        dp[1][i]=1;
	    else 
	        dp[1][i]=0;
	}for(long long i=1;i<=n;i++){
	    dp[i][0]=1;
	}
	for(long long i=2;i<=n;i++){
	    for(long long j=1;j<=k;j++){                      
	        if(j<=a[i]){
	            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
	        }else{
	            dp[i][j]=(dp[i][j-1]-dp[i-1][j-a[i]-1]+dp[i-1][j]+1000000007)%1000000007;
	        }
	    }
	}cout<<dp[n][k];
	
    
}




Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i < ll (n); i++)

int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3576
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

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

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (10000001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int l=1, r=1000000000;
	int n;
	int k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	while (l != r) {
		int m = (l + r) / 2;
		int k2 = 0;
		rep(i, n) {
			int b = a[i];
			k2 += (b / m)-1;
			if (b % m != 0)k2++;
		}
		if (k2 <= k) {
			r = m;
		}
		else {
			l = m + 1;
		}
	}
	cout << l << endl;
}

Measured memory_bytes: 4836
N = int(input())
A = list(map(int, input().split()))
A_min = 10000000000
negative_count = 0
ans = 0

for i in range(N):
    if abs(A[i]) < A_min:
        A_min = abs(A[i])
    if A[i] < 0:
        negative_count += 1
    ans += abs(A[i])

if negative_count % 2 == 0:
    print(ans)
else:
    ans -= A_min*2
    print(ans)


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define elif else if
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

ll N, M, S = 2, A[32000];
double P;
cpp_int comb[31];
def nHr() {
    comb[0] = 1;
    inc(i, 1, 30) comb[i] = comb[i - 1] * (N + i - 1) / i;
    inc(i, 1, 30) comb[i] %= MOD;
}

signed main() {
    ll M;
    cin >> N >> M;
    nHr();
    P = sqrt(M);
    while (M != 1) {
        if (M % S == 0) {
            while (M % S == 0) {
                M /= S;
                A[S]++;
            }
        } else if (S > P) {
            A[S]++;
            S++;
            break;
        }
        S++;
    }
    cpp_int ANS = 1;
    rep(i, S) {
        ANS *= comb[A[i]];
        ANS %= MOD;
    }
    cout << ANS << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
#define ld long double

const int mod = 1000000007;
const ld PI = acosl(-1.0);
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    temp = min(x / d, k);
    x -= temp * d;
    k -= temp;
    // cout<<x<<gp<<k<<gp<<d<<endl;
    if(k % 2 == 0)
    cout<<x<<endl;
    else
    cout<<abs(x - d)<<endl;
    return 0;
}

Measured memory_bytes: 3648
import math
A = input()
N = len(A)

ans =[]
for _ in range(N):
  ans.append(0)

Rtmp = 0
for i in range(N):
  if A[i] == "R":
    Rtmp += 1
  else:
    ans[i-1] += math.ceil(Rtmp/2)
    ans[i]   += Rtmp//2
    Rtmp = 0


Ltmp = 0
for i in range(N-1,-1,-1):
  if A[i] == "L":
    Ltmp += 1
  else:
    ans[i+1] += math.ceil(Ltmp/2)
    ans[i]   += Ltmp//2
    Ltmp = 0

L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Measured memory_bytes: 10492
#include <stdio.h>
#include <limits.h>
#define MAX 100
#define FIRST 0
#define SECOUND 1
#define THIRD 2

int n,M[MAX][MAX];

int prim(){
    int u,minv,v,i;
    int d[MAX],p[MAX],color[MAX]; 

    for(i=0;i<n;i++){
        d[i]=INT_MAX;
        p[i]=-1;
        color[i]=FIRST;
    }
    
    d[0]=0;
    
    while(1){
        minv=INT_MAX;
        u=-1;
        for(i=0;i<n;i++){
            if( minv > d[i] && color[i] != THIRD){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=THIRD;
        for(v=0;v<n;v++){ 
            if(color[v]!=THIRD && M[u][v] != INT_MAX){
                if(d[v] > M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                }
            }
        }
    }
    int sum=0;
    
    for(i=0;i<n;i++){
        if(p[i]!=-1) sum += M[i][p[i]];
    }

    return sum;
}

int main(){
    int i,j,l;
    
    scanf("%d",&n);

    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            scanf("%d",&l);
            M[i][j]=(l==-1)?INT_MAX:l;
        }
    }

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

    return 0;
}



Measured memory_bytes: 2112
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var NM = Console.ReadLine().SplittedStringToInt32List();
        var N = NM[0];
        var M = NM[1];
        var basegrid = new bool[N, N];
        var grid = new bool[M, M];
        for (int i = 0; i < N; i++)
        {
            var count = 0;
            Console.ReadLine().Select(x => x == '#').ToList()
                .ForEach(x =>
                {
                    basegrid[i, count++] = x;

                });
        }
        for (int i = 0; i < M; i++)
        {
            var count = 0;
            Console.ReadLine().Select(x => x == '#').ToList()
                .ForEach(x =>
                {
                    grid[i, count++] = x;
                });
        }
        var repeatecount = N - M + 1;
        for (int i = 0; i < repeatecount; i++)
        {
            for (int j = 0; j < repeatecount; j++)
            {
                var isok = true;
                for (int k = 0; k < M; k++)
                {
                    for (int l = 0; l < M; l++)
                    {
                        if (basegrid[i + k, j + l] != grid[k, l])
                        {
                            isok = false;
                            break;
                        }
                    }
                }

                if (isok)
                {
                    Console.WriteLine("Yes");
                    Console.ReadLine();
                    return;
                }
            }
        }
        Console.WriteLine("No");

        Console.ReadLine();
    }



    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }

    sort(p.begin(),p.end());

    long long int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += p[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
l=list(mi())
dp=[sys.maxsize]*a
dp[0]=0
for i in range(1,a):
  for j in range(min(i,b)):
    dp[i]=min(dp[i],abs(l[i]-l[i-j-1])+dp[i-j-1])
print(dp[-1])

Measured memory_bytes: 91308
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll N=1e9+7;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(2*n>=m) printf("%lld\n",m/2);
    else printf("%lld\n",n+(m-2*n)/4);
}

Measured memory_bytes: 256
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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 in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

int calc(int n, int i) {
  return n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - (i - 1) * i / 2 + 1;
}

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

  int n, k;
  cin >> n >> k;

  int ans = 0;

  FOR(i, k, n + 2) {
    // debug(i);
    ans += calc(n, i);
    ans %= MOD;
  }
  // debug(ans);

  cout << ans << endl;

  return 0;
};


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

int main() {
	string q, e;
	int i = 0;
	cin >> q;
	cin >> e;
	while (q[i] != '\0') {
		if (e[i] == '\0')cout << q[i];
		else cout << q[i] << e[i];
		i++;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long int A,B;
  scanf("%lld %lld",&A,&B);
  long long int OA=A,OB=B;
  long long int R=A%B;
  while(R>0){
    A=B;
    B=R;
    R=A%B;
  }
  printf("%lld\n",OA*OB/B);
  return 0;
}

Measured memory_bytes: 1708
<?php
list($H, $N) = ints();
$dp = array_fill(0, $H + 1, 10**18);
$dp[0] = 0;
for($i = 1; $i <= $N; $i++){
  list($a, $b) = ints();
  for($j = 1; $j <= $H; $j++){
    if($j - $a >= 0){
      if($dp[$j]>$dp[$j-$a]+$b)$dp[$j] = $dp[$j-$a]+$b;
    }else{
      if($dp[$j]>$b)$dp[$j] = $b;
    }
  }
}
echo $dp[$H];
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}


Measured memory_bytes: 4984
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def dfs(start, a, b, visited, n, graph):
    for node in graph[start]:
        if node not in visited:
            if (start, node) == (a, b) or (start, node) == (b, a):
                continue  # (start, node)がなくなっている場合を考えるので，このケースはスルーする
            else:
                visited.append(node)
                dfs(node, a, b, visited, n, graph)
    if len(visited) == n:
        return 0
    else:
        return 1


def main():
    N, M = map(int, input().split())
    graph = [[] for _ in range(N)]
    edge = []
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        graph[a].append(b)
        graph[b].append(a)
        edge.append((a, b))
    cnt = 0
    for a, b in edge:
        cnt += dfs(0, a, b, [], N, graph)
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//c_p_c();
	string s, t;
	cin >> s >> t;
	string res = s + t;
	stringstream geek(res);

	int te = 0;
	geek >> te;
	double fres = sqrt(te);
	if (fres == (int)fres)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B), c(M), x(M), y(M), z(M);
  REP(i, A) {
    cin >> a[i];
  }
  REP(i, B) {
    cin >> b[i];
  }
  REP(i, M) {
    cin >> x[i] >> y[i] >> c[i];
    z[i] = a[x[i]-1] + b[y[i]-1] - c[i];
  }
  sort(ALL(z));
  sort(ALL(a));
  sort(ALL(b));
  if (z[0] < a[0] + b[0]) {
    cout << z[0] << endl;
  } else {
    cout << a[0] + b[0] << endl;
  }
  return 0;
}


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

int main(){
    long double a,b,c;
    cin>>a>>b>>c;
    long double eps=1.0E-14;
    if(sqrt(a)+sqrt(b)+eps<sqrt(c)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3708
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun Mar 22 18:28:44 2020

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


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
ll dp[200005];
int solve() {
 	
 	int n=Int;
 	int arr[n+1];
 	For(n){
 		arr[i]=Int;
 		dp[arr[i]]++;
 	}
 	ll sum = 0;
 	for(int i=1;i<=n;i++){
 		sum+=(dp[i]*(dp[i]-1))/2;
 	}
 	// error(sum);
 	For(n){
 		int x=arr[i];
 		cout<<sum-dp[x]+1<<endl;
 		// ll ans1=dp[x]*dp[x-1]
 		// if(i!=n-1) cout<<" ";
 	}
 	// cout<<endl;


 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

ll power(ll n,ll p){
    if(p==0){return 1;}
    if(p%2==1){return n*power(n,(p-1)/2)*power(n,(p-1)/2);}
    else{return power(n,p/2)*power(n,p/2);}
}

int main() {
    ll N;
    cin>>N;
    if(N<357){cout<<0<<endl;return 0;}
    ll ans=0;
    ll X=N;int keta=0;
    while(X>0){keta++;X/=10;}
    for(int i=3;i<=keta;i++){
        for(ll S=0;S<power(3,i);S++){
            ll Y=0;
            ll SC=S;
            vector<bool> a(3,false);
            rep(j,i){
                Y*=10;
                int p=SC%3;
                a.at(p)=true;
                Y+=p*2+3;
                SC/=3;
            }
            if(a.at(0) && a.at(1) && a.at(2))if(Y<=N)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

#define sint(i) scanf("%d",&i)
#define sintt(i,j) scanf("%d%d",&i,&j)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
	int nx[200];
	int ny[200];
	int mx[1000];
	int my[1000];
	
	while(1){
		int n;
		sint(n);
		
		if(n==0){break;}
		
		rep(i,n){
			sintt(nx[i],ny[i]);
		}
		
		int m;
		sint(m);
		rep(i,m){
			sintt(mx[i],my[i]);
		}
		
		
		rep(i,m){
			rep(j,m){
				int temp;
				if(mx[i]<mx[j]){
					temp=mx[i];
					mx[i]=mx[j];
					mx[j]=temp;
					
					temp=my[i];
					my[i]=my[j];
					my[j]=temp;
				}
			}
		}
		
		rep(i,m){
			int dx=mx[i]-nx[0];
			int dy=my[i]-ny[0];
			
			int flgg=1;
			rep(j,n){
				int flg=0;
				rep(k,m){
					if(nx[j]+dx==mx[k] && ny[j]+dy==my[k]){
						flg=1;
						break;
					}
				}
				
				if(flg==0){
					flgg=0;
					break;
				}
			}
			
			if(flgg==1){
				printf("%d %d\n",dx,dy);
				break;
			}
		}
	}
}

/*
5
8 5
6 4
4 3
7 10
0 10
10
10 5
2 7
9 7
8 10
10 2
1 2
8 1
6 7
6 0
0 9

2
1 1
2 2
3
1 2
2 3
1 1

*/

Measured memory_bytes: 0
#include<stdio.h>
#define N 8
#define Free 2
#define Not_Free 3

int A[8][8],row[8],col[8],dpos[15],dneg[15],B[8]={0};

int Queen(int i){

  int k,l,j,m;

  if(i == N){
    for(k = 0;k < N; k++){
      for(l = 0; l < N; l++){
      if(row[k] == l) printf("Q");
      else printf(".");
      }
      printf("\n");
    }
    return 1;
  }

  if(B[i] == 1){
    if(Queen(i+1)) return 1;
    return 0;
  }
  
  for(j = 0; j < N; j++){
    if(col[j] == Not_Free || dpos[i+j] == Not_Free || dneg[i-j+N-1] == Not_Free)
      continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = Not_Free;
  
    if(Queen(i+1)) return 1;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = Free;
  }
  return 0;
}

int main(){
  int i,j,n,r,l;

  scanf("%d",&n);

  for(i = 0; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      A[i][j] = 0;
    }
  }

  for(i = 0; i < N; i++){
    col[i] = dpos[i] = dneg[i] = Free;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d %d",&r,&l);
    row[r] = l ;
    B[r] = 1;
    col[l] = dpos[r+l] = dneg[r-l+N-1] = Not_Free;
  }

  Queen(0);
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main() {
    int64_t h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) cout << "1" << endl;
    else if (h % 2 == 0 || w % 2 == 0) cout << h * w / 2 << endl;
    else cout << h * w / 2 + 1 << endl;
}

Measured memory_bytes: 256
/**
  @file d2.cpp
  @title D - Cake 123
  @url https://atcoder.jp/contests/abc123/tasks/abc123_d
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

template <class T>
void show(vector<T>& v) {
  for (uint i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "\n";
}

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<LL> A(X, 0);
  vector<LL> B(Y, 0);
  vector<LL> C(Z, 0);

  REP(i, X) { cin >> A[i]; }
  REP(i, Y) { cin >> B[i]; }
  REP(i, Z) { cin >> C[i]; }

  sort(ALL(A), std::greater<LL>());
  sort(ALL(B), std::greater<LL>());
  sort(ALL(C), std::greater<LL>());

  vector<LL> ABC;
  REP(i, X) {
    REP(j, Y) {
      REP(k, Z) {
        if (i * j * k <= K) {
          ABC.push_back(A[i] + B[j] + C[k]);
        }
      }
    }
  }
  sort(ALL(ABC), std::greater<LL>());

  REP(i, K) { cout << ABC[i] << "\n"; }

  return 0;
}


Measured memory_bytes: 34920
import numpy as np
a,b,h,m = map(int,input().split())
m = h*60+m
deg_a = m*30/60%360
deg_b = m*6%360
deg = abs(deg_a - deg_b)
if deg>180: deg = 360-deg
S = (a**2+b**2-2*a*b*np.cos(deg/180*np.pi))**0.5

print(S)

Measured memory_bytes: 26676
var
	N,M,X,i:Longint;
	flag:Boolean;
	s,c:Array[1..5]of Longint;
	t:Array[1..3]of Longint;
	sz,xx:Longint;
begin
	read(N,M);
	for i:=1 to M do begin
		read(s[i],c[i]);
		s[i]:=N+1-s[i];
	end;
	for X:=0 to 999 do begin
		xx:=X;
		if xx=0 then begin
			sz:=1;
			t[1]:=0;
		end else begin
			sz:=0;
			while xx>0 do begin
				inc(sz);
				t[sz]:=xx mod 10;
				xx:=xx div 10;
			end;
		end;
		flag:=sz=N;
		for i:=1 to M do if(sz<s[i])or(t[s[i]]<>c[i])then begin
			flag:=False;
			break;
		end;
		if flag then begin
			writeln(X);
			exit;
		end;
	end;
	writeln(-1);
end.


Measured memory_bytes: 128
#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),b(n),c(n);
    rep(i,n)
    { 
        cin>>a[i];
    }
    rep(i,n)
    {
        cin>>b[i];
    }
    rep(i,n)
    {
        cin>>c[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll now_B, num_A, num_C, res = 0;
    ll idx_bound_A, idx_bound_C;

    for (ll i = 0; i < n; ++i) {
        now_B = b[i];
        num_A = 0;
        num_C = 0;

        // 1 段目: now_B 未満の数を求める
        auto iter_A = lower_bound(a.begin(), a.end(), now_B);
        idx_bound_A = distance(a.begin(), iter_A);
        num_A = (iter_A == a.end())? n: (idx_bound_A + 1) - 1;

        // 3 段目: now_B より大きい数
        auto iter_C = upper_bound(c.begin(), c.end(), now_B);
        idx_bound_C = distance(c.begin(), iter_C);
        num_C = (iter_C == c.end())? 0: n - idx_bound_C;

        res += num_A*num_C;
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1408
n,m,q = map(int,input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
A = [0]*n
ans = 0
def dfs(h):
    global ans
    if h == n-1:
        cnt = 0
        for i in range(q):
            if A[b[i]] - A[a[i]] == c[i]:
                cnt += d[i]
        ans = max(ans,cnt)
    else:
        for i in range(A[h],m+1):
            A[h+1] = i
            dfs(h+1)
    return

for i in range(1,m+1):
    A[0] = i
    dfs(0)
print(ans)


Measured memory_bytes: 9228
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n,temp;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int alice=0,bob=0;
	for(int i=n-1; i>=0; i-=2){
		alice+=a[i];
		if(i==0)break;
		bob+=a[i-1];
	}
	cout << alice-bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1050
int lc(string x,string y){
  int c[N+1][N+1];
  int m=x.size();
  int n=y.size();
  int maxl = 0;
  x=' '+x;
  y=' '+y;
  for(int i=0;i<=m;i++)c[i][0]=0;
  for(int j=1;j<=n;j++)c[0][j]=0;
  
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(x[i]==y[j])c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}
int main(){
  int n;cin>>n;
  while(n--){
    string s,v;cin>>s>>v;
    cout<<lc(s,v)<<endl;
  }
  return 0;
}



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

int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k ;
	
	if ( ( e - a ) <= k )
	{
	cout << " Yay! " ;  
	}
	else
	{
	cout << " :( " ;
	}
 return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void self_max(ll  &a, ll b) {
	a = max(a, b);
}
int main() {
	int n, w;
	cin>>n>>w;
	vector<ll> dp(w + 1);
	for(int i = 0; i < n; ++i) {
		int weight, value;
		cin>>weight>> value;
		for(int wt = w - weight;   wt >= 0; wt--) {
			self_max(dp[wt + weight], dp[wt] + value);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= w; i++) 
		self_max(ans, dp[i]);
	cout<<ans<<endl;
}


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

using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	char all[26];
	
	for(int i = 65; i <= 90; ++i){
		all[i - 65] = i;
	}
	
	

    char rijec[s.length()];
    
    for(int i = 0; i < s.length(); ++i){
    	rijec[i] = s[i];
    
	}
    
    for(int i = 0; i < s.length(); ++i){
    	
    	char slovo = rijec[i];
    	
    	int current = slovo - 65;
    	
    	

    	  	
    	current = (current % 26 + n % 26) % 26;
    	
    	
    	
    	
    	rijec[i] = all[current];
    	
    	
	}
	
	for(int i = 0; i < s.length(); ++i){
		cout << rijec[i];
	}
	
	



	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }

int main()
{
	ull sum = 0;
	ull n;
	cin >> n;
	rep(i, n)
	{
		ull an;
		cin >> an;
		sum += an - 1;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nq=arr.shift().split(" ").map(Number);
var player=[];
var maxValue=0;
var maxId=0;
for(var i=0;i<nq[0];i++)player[i]=0;
arr.forEach(function(V){
   var av=V.split(" ").map(Number);
   var a=av[0]-1;
   var v=av[1];
   player[a]+=v;
   if(a==maxId && v>=0)maxValue+=v;
   else if(maxValue==player[a] && maxId>a)maxId=a;
   else if(maxValue<player[a]){maxValue=player[a];maxId=a;}
   else if(a==maxId && v<0){
      var max=(-1*Infinity);
      player.forEach(function(value,index){
         if(max<value){max=value;maxValue=value;maxId=index;}
      });
   }
   console.log((maxId+1)+" "+maxValue);
});

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

using namespace std;
typedef long long ll;
typedef long double ld;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);
//
vector<ll> divisors(ll n) {
    vector<ll> ans;
    for (ll i=1; i<=sqrt(n); i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
                break;
            }
            ans.push_back(i);
            ans.push_back(n / i);
        }
    }
    return ans;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N;
    in(N);
    unordered_set<int> total, duplicates;
    vector<int> A(N);
    int tmp;
    rep(i, N) {
        in(tmp);
        A[i] = tmp;
        if (total.find(tmp) != total.end()) duplicates.insert(tmp);
        total.insert(tmp);
    }
    for (int d: duplicates) {
        total.erase(d);
    }
    int n = total.size();
    A.clear();
    for (int i: total) A.push_back(i);


    sort(A.begin(), A.end());
    int cnt = 0;
    rep(i, n) {
        bool flag = true;
        vector<ll> div = divisors((ll) A[i]);
        for (ll j: div) {
            if (duplicates.find((int) j) != duplicates.end()) {
                flag = false;
                break;
            }
        }
        if (flag) cnt++;
        duplicates.insert(A[i]);
    }
    out(cnt);

    return 0;
}


Measured memory_bytes: 20532
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

struct X{
    int x;
    string s;
};

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

    X v[m];
    REP(i, m){
        cin >> v[i].x >> v[i].s;
    }

    int cntw[n + 1];
    int cnta[n + 1];
    REP(i, n + 1){
        cntw[i] = 0;
        cnta[i] = 0;
    }
    llong wa = 0;
    llong ac = 0;
    REP(i, m){
        if (v[i].s == "AC"){
            cnta[v[i].x] += 1;
            if (cnta[v[i].x] == 1){
                ac++;
                wa += cntw[v[i].x];
            }
        }else{
            cntw[v[i].x] += 1;
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}

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

int gcm(int x,int y){
	if(x<y)swap(x,y);
	int r=x%y;
	while(r!=0){
		x=y;
		y=r;
		r=x%y;
	}
	return y;
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	
	vector<int> g1(N);
	vector<int> g2(N);
	g1[0]=A[0];
	for(int i=1;i<N;i++)g1[i]=gcm(g1[i-1],A[i]);
	
	g2[N-1]=A[N-1];
	for(int i=N-2;i>=0;i--)g2[i]=gcm(g2[i+1],A[i]);
	
	int ans=1;
	
	for(int i=0;i<N;i++){
		int tmp;
		if(i==0)tmp=g2[1];
		else if(i==N-1)tmp=g1[N-2];
		else tmp=gcm(g1[i-1],g2[i+1]);
		ans=max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>

#define reps(i,j,k) for(int i=(j);i<=(k);++i)
#define rep(i,j) reps(i,0,(j)-1)
#define fs first
#define sc second
#define pb push_back

using namespace std;

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

int main(){
	int n;
	while(cin >> n,n){
		vector<string> v(n);
		vector<int> dpt(n);
		rep(i,n){
			cin >> v[i];
			rep(j,v[i].length()){
				if(v[i][j]!='.'){
					dpt[i] = j;
					break;
				}else v[i][j] = ' ';
			}
			if(dpt[i]){
				v[i][dpt[i] - 1]='+';
				for(int j=i-1;j>=0;j--){
					if(dpt[i]<dpt[j]) v[j][dpt[i]-1] = '|';
					else break;
				}
			}
		}
		rep(i,n) cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1856
#include<iostream>
#include<algorithm>

using namespace std;

int a[2][101], dp[2][101];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[0][i];
    }
    for(int i = 0; i < n; i++){
        cin >> a[1][i];
    }
    dp[0][0] = a[0][0];
    for(int i = 1; i < n; i++){
        dp[0][i] = dp[0][i - 1] + a[0][i];
    }
    dp[1][0] = dp[0][0] + a[1][0];
    for(int i = 1; i < n; i++){
        dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[1][i];
    }
    cout << dp[1][n - 1] << endl;
    return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    vector<pair<int,int> > a(N);
    int x,y;
    map< pair<int,int> , bool > m;
    Rep(i,N){
        Scd2(x,y);
        a[i].first = x;
        a[i].second = y;
        m[a[i]] = true;
    }

    sort( a.begin(), a.end() );


    int p,q;
    int tmp = 0;
    int ans = INF;
    Rep(i,N)Rep(j,N){
        if( i == j ) continue;
        p = a[i].first - a[j].first;
        q = a[i].second - a[j].second;

        tmp = 0;
        for( auto i = m.begin(); i != m.end(); i++ ){
            i->second = true;
        }
        for( auto i = m.begin(); i != m.end(); i++ ){
            if( i->second ) tmp++;
            int tx = i->first.first;
            int ty = i->first.second;
            while( m.find({tx + p , ty + q }) != m.end() ){
                m.find({tx + p , ty + q })->second = false;
                tx += p;
                ty += q;
            }
        }

        ans = min( ans, tmp );
    }

  if( ans == INF ) ans = 1;

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


    return 0;
}



Measured memory_bytes: 256
import numpy as np
def main():
    n, t = map(int, input().split())
    dt = [list(map(int, input().split())) for _ in range(n)]
    dt.sort()
    dp = np.zeros(t, dtype=int)
    ans = 0
    for a, b in dt:
        ans = max(ans, dp[-1]+b)
        np.maximum(dp[a:], dp[:-a]+b, out=dp[a:])
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 12776
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll>arr1,arr2;
  if(0LL>=a&&0LL<=b)
    arr1.pb(0);
   if(0LL>=c&&0LL<=d)
    arr2.pb(0);
  arr1.pb(a);
  arr1.pb(b);
  arr2.pb(c);
  arr2.pb(d);
  ll ma=-1e18+5;
    for(auto u1:arr1)
    for(auto u2:arr2){
      ma=max(u1*u2,ma);
    }
  cout<<ma;
}


Measured memory_bytes: 3652
S1 = input()
S2 = input()

ss1 = {}
ss2 = {}
N = len(S1)
for i in range(N):
    if S1[i] not in ss1.keys():
        ss1[S1[i]] = S2[i]
    elif ss1[S1[i]] != S2[i]:
        print('No')
        exit(0)
    if S2[i] not in ss2.keys():
        ss2[S2[i]] = S1[i]
    elif ss2[S2[i]] != S1[i]:
        print('No')
        exit(0)

print('Yes')


Measured memory_bytes: 74124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}




int main() {
  ll n,q;
  cin >> n;
  map <ll,ll> cnt;

  ll a[n+1],sum=0;
  
  rep (i,n){
    cin >> a[i];
    cnt[a[i]]++;
    sum+=a[i];
  }
  cin >> q;
  ll b[q+1],c[q+1];
  rep (i,q){
    cin >> b[i] >> c[i];
  }

  rep (i,q){
    sum -= cnt[b[i]]*b[i];
    sum += cnt[b[i]]*c[i];
    cout << sum << endl;
    cnt[c[i]]+=cnt[b[i]];
    cnt[b[i]]=0;
    //sum += cnt[b[i]]*b[i];
    //sum -= cnt[b[i]]*c[i];
  }


}

Measured memory_bytes: 11836
import scala.annotation.tailrec
import io.StdIn

object Main extends App {
  val n = StdIn.readInt
  val s = StdIn.readLine

  @tailrec
  def rec(acc:Int, x:Int, ch:Iterator[Char]):Int = {
    if(!ch.hasNext || x == 2) acc
    else {
      if(ch.next == 'x') {
        if(x == 0) rec(acc+1, 1, ch)
        else rec(acc, 2, ch)
      }
      else rec(acc+1, 0, ch)
    }
  }

  println( rec(0,0,s.iterator) )
}


Measured memory_bytes: 46100
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    char[] c = sc.next().toCharArray();
    List<Integer> list = new ArrayList<>();
    int cnt = 1;
    if(c[0]=='0')list.add(0);
    for(int i=1;i<n;i++){
      if(c[i]==c[i-1])cnt++;
      else{
        list.add(cnt);
        cnt=1;
      }
    }
    list.add(cnt);
    int max = 0;
    int[] sum = new int[list.size()+1];
    sum[0]=0;
    for(int i=1;i<=list.size();i++)sum[i]=sum[i-1]+list.get(i-1);
    for(int i=0;i<=list.size();i+=2){
      int j=Math.min(i+2*k+1,list.size());
      max=Math.max(max,sum[j]-sum[i]);
    }
    System.out.println(max);
  }
}

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

using namespace std;

#define CHECK(a,b,c) ((line[a]==line[b]) && (line[b]==line[c]) && (line[a] != 's') && (ans=line[a]))

int main() {
    string line;
    while(cin >> line) {
        char ans = 'd';
        CHECK(0,1,2); CHECK(3,4,5); CHECK(6,7,8);
        CHECK(0,3,6); CHECK(1,4,7); CHECK(2,5,8);
        CHECK(0,4,8); CHECK(2,4,6);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[300], res;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n * 2; i++) {
        cin >> a[i];
    }
    sort(a, a + 2 * n);
    for (ll i = 0; i < 2 * n; i += 2) {
        res += a[i];
    }
    cout << res << endl;
}


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

int main() {
    string S; cin >> S;
    if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
import sys
s = input()

answer = True
if s[0] != "A":
  answer = False

if s[2:len(s)-1].count("C") != 1:
  answer = False
  
for i in range(len(s)):
  if s[i] != "A" and s[i] != "C":
    if ord(s[i]) < 97  or  122 < ord(s[i]):
      answer = False

if answer :      
  print("AC")
else :
  print("WA")

Measured memory_bytes: 9120
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]

count = 0
for i in range(n-1):
    for j in range(i+1, n):
        p, q = xy[j][0] - xy[i][0], xy[j][1] - xy[i][1]
        count = max(count, sum((x-p,y-q) in xy for x, y in set(xy)))

print(n-count)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();
        int h = scan.nextInt();
        int x = scan. nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();
        if(x + r > w || x - r < 0|| y + r > h || y - r < 0){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }



    }
}


Measured memory_bytes: 26336
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int m;
    int j,k;
   while(~scanf("%d",&m))
   {
       j=sqrt(m);
      k=pow(j,2);
    if(m>=k)
        printf("%d\n",k);
   }
}

Measured memory_bytes: 128