akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N;
int t[110], v[110];
int lim[51000];

int dp[5][210];

int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> t[i], t[i] *= 2;
        int sum = 0;
        for (int i = 0; i < N; ++i) {
            cin >> v[i], v[i] *= 2;
            for (int j = sum; j < sum + t[i]; ++j) {
                lim[j] = v[i];
            }
            sum += t[i];
        }
        
        for (int i = 0; i < 5; ++i) for (int j = 0; j < 210; ++j) dp[i][j] = -(1<<29);
        dp[0][0] = 0;
        for (int i = 0; i < sum; ++i) {
            for (int j = 0; j < 210; ++j) {
                //cout << i << ", " << j << ": " << dp[i%2][j] << " (" << lim[i] << ")" << endl;
                if (j + 1 <= min(lim[i], lim[i+1])) chmax(dp[(i+1)%2][j+1], dp[i%2][j] + j*2+1);
                if (j <= min(lim[i], lim[i+1])) chmax(dp[(i+1)%2][j], dp[i%2][j] + j*2);
                if (j - 1 >= 0 && j - 1 <= min(lim[i], lim[i+1])) chmax(dp[(i+1)%2][j-1], dp[i%2][j] + j*2-1);
            }
            
            for (int j = 0; j < 210; ++j) dp[i%2][j] = -(1<<29);
        }
        
        cout << fixed << setprecision(10) << (double)dp[0][0] / 8 << endl;
    }
}











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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var exStdIn = new System.IO.StreamReader("stdin.txt");
            //System.Console.SetIn(exStdIn);

            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int m = Math.Max(Math.Max(a + b, a - b), a * b);

            Console.WriteLine(m.ToString());
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n;
    cin>>n;
    int dp[n][3];
    for(int i=0;i<n;i++)
    {   for(int j=0;j<3;j++)
        cin>>dp[i][j];
    }
    for(int i=1;i<n;i++)
    {   dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
    }
    int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
}

Measured memory_bytes: 1408
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll a[200010],b[200010],comp[200010];
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll n;cin>>n;
        ll sze=1,sum=0;
        for(ll i=1;i<=n;i++)
        {
            cin>>a[i];
            sze=max(sze,a[i]);
            b[a[i]]++;
        }
        for(ll i=1;i<=sze;i++)
        {
            ll no=b[i];
            if(no<2)
                comp[i]=0;
            else
                comp[i]=(no*(no-1))/2;
            sum+=comp[i];
        }
//        for(ll i=1;i<=sze;i++)cout<<b[i]<<" ";cout<<endl;
//        for(ll i=1;i<=sze;i++)cout<<comp[i]<<" ";cout<<endl;
        for(ll i=1;i<=n;i++)
        {
            ll no=a[i];
            ll temp=sum;
            temp-=comp[no];
            temp+=(b[no]*(b[no]-1))/2-(b[no]-1);
            cout<<temp<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6912
/*
 * FILE: ABC 129 A.cpp
 *
 * @author: Piyush Kanti Das <piyush123kantidas[at]gmail[dot]com>
 *
 * LINK:
 *
 * DATE CREATED: 01.07.2019 14:55:54 +06
 *
 * DESCRIPTION:
 *
 * DEVELOPMENT HISTORY:
 * Date         Version     Description
 * --------------------------------------------------------------
 * 01-07-2019	1.0         File Created
 *
 */


/*
// _______________________________________________________________/\\\_________
//  ______________________________________________________________\/\\\_________
//   ___/\\\\\\\\\___/\\\____/\\\__/\\\____________________________\/\\\_________
//    __/\\\/////\\\_\///____\//\\\/\\\___/\\\____/\\\__/\\\\\\\\\\_\/\\\_________
//     _\/\\\\\\\\\\___/\\\____\//\\\\\___\/\\\___\/\\\_\/\\\//////__\/\\\\\\\\\\__
//      _\/\\\//////___\/\\\_____\//\\\____\/\\\___\/\\\_\/\\\\\\\\\\_\/\\\/////\\\_
//       _\/\\\_________\/\\\__/\\_/\\\_____\/\\\___\/\\\_\////////\\\_\/\\\___\/\\\_
//        _\/\\\_________\/\\\_\//\\\\/______\//\\\\\\\\\___/\\\\\\\\\\_\/\\\___\/\\\_
//         _\///__________\///___\////_________\/////////___\//////////__\///____\///__
//
*/

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

typedef long long           ll;
typedef double              lf;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
typedef vector<pii>         vpii;
typedef vector<int>         vi;
typedef vector<long long>   vll;

#define __FastIO        ios_base::sync_with_stdio(false); cin.tie(0)

#define forr(i, a, b)   for (__typeof (a) i=a; i<=b; i++)
#define rof(i, b, a)    for (__typeof (a) i=b; i>=a; i--)
#define rep(i, n)       for (__typeof (n) i=0; i<n; i++)
#define forit(i, s)     for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar)         ar.begin(), ar.end()

#define fill(ar)   		memset(ar, -1, sizeof(ar))
#define clr(a)          memset(a, 0, sizeof(a))

#define nl              cout << '\n';
#define sp              cout << ' ';
#define ckk             cout << "##########\n"

#define pb              push_back
#define MP 				make_pair

#define debug1(x)       cerr << #x << ": " << x << endl
#define debug2(x, y)    cerr << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define MAX             100005

int Set(int N,int pos){return N=N | (1<<pos);}
int Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}


ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;
    
    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}

//Auto-format --> ctrl+shift+a
/********************* Code starts here ************************/

int main() {
    __FastIO;   //Be aware to use it!
    
    int p;
    vi v;
    
    rep(i,3){
		cin >> p;
		v.pb(p);
	}
	sort(all(v));
	cout << v[0]+v[1] << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int A, B; cin >> A >> B;
  int result = max(A+B, max(A-B, A*B));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

class out {
    public static function println($str = "") {
        echo ($str) . PHP_EOL;
    }
}

while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}

$num = intval($tmp[0]);
$half = intval($tmp[0]/2);
$str = $tmp[1];

$word1 =  substr($str, 0, $half);
$word2 = substr($str, $half, $num);

$ans = judge($word1, $word2);

out::println($ans);


function judge($word1, $word2){
    if($word1===$word2){
        return 'Yes';
    }else{
        return 'No';
    }
}

?>


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

int main()
{
	std::string s, t;
	std::cin >> s >> t;
	int diff_count = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
			diff_count++;
	}
	std::cout << diff_count << std::endl;
	return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int D, last[26];
lint c[26], s[370][26];

lint score_diff(int day){
    lint ret = 0;
    rep(i, 26){
        if(last[i] == day) ret += s[day][i];
        else ret -= c[i] * (day-last[i]);
    }
    return ret;
}

int main(){
    scanf("%d", &D);
    fill(last, last+26, -1);
    rep(i, 26) scanf("%lld", &c[i]);
    rep(i, D)rep(j, 26) scanf("%lld", &s[i][j]);
    lint score = 0;
    rep(i, D){
        int t;
        scanf("%d", &t);
        --t;
        last[t] = i;
        score += score_diff(i);
        printf("%lld\n", score);
    }
}

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

int main(){
    long long a, b, c, k;
    cin >> a >> b >> c;
    cin >> k;

    long long cnt = 0;
    if(b <= a){
        while(b <= a){
            cnt++;
            b = 2 * b;
        }
    }

    if(cnt > k){
        printf("No\n");
        return 0;
    }

    if(c <= b){
        while(c <= b){
            cnt++;
            c = 2 * c;
        }
    }

    if(cnt > k) printf("No\n");
    else printf("Yes\n");
        
    return 0;
}

Measured memory_bytes: 3632
from copy import deepcopy
from collections import deque
N, M = map(int, input().split())
adj_mat = [[-float('inf') for i in range(N)] for j in range(N)]
ls = []
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    ls.append([a, b])
    adj_mat[a][b], adj_mat[b][a] = 1, 1

ans = 0
for i in range(M):
    adj_mat_copy = deepcopy(adj_mat)
    adj_mat_copy[ls[i][0]][ls[i][1]] = -float('inf')
    adj_mat_copy[ls[i][1]][ls[i][0]] = -float('inf')
    st = deque([])
    visited = [-1 for i in range(N)]
    st.append(0)
    visited[0] = 1
    while st:
        l = st.pop()
        for j, node in enumerate(adj_mat_copy[l]):
            if node == 1 and visited[j] != 1:
                st.append(j)
                visited[j] = 1
    if sum(visited) != N:
        ans += 1
print(ans)

Measured memory_bytes: 76936
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]

sum_ws_m = sum(ws_m)

"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""
dp = [[[0]*(3*N+10) for i in range(N+10)] for j in range(N+10)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            # もらうDP
            # j-wなら、新しくwをナップサックに入れて価値が増えるか見る
            if ws[0]*(n+1)+j+w <= W:
                dp[i+1][n+1][j+w] = max(dp[i+1][n+1][j+w], dp[i][n][j]+v)
            # 追加できない場合は以前の情報を更新
                
            dp[i+1][n][j] = max( dp[i+1][n][j], dp[i][n][j] )
            # if dp[i][n][j] == -1: continue
            # # if j + n*ws[0] > W: continue
            # # print("check",i,n,j,v)    )
            # dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
            # dp[i+1][n+1][j+w] = max(dp[i][n+1][j+w], dp[i][n][j] + v)
        # print(dp[i+1][n])
ans= 0
for i,As in enumerate(dp[N]):
    w = min( W - i*ws[0], sum_ws_m )
    if w >= 0:
        ans = max(ans,max(As[:w+1]))
print(ans)   

Measured memory_bytes: 72540
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    string S;
    cin >> S;

    string res;
    for (int i = 0; i < S.length(); ++i) {
        res += 'x';
    }

    cout << res << endl;
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  if (A + B == 3){
    cout << 3 << endl;
  }
  else if (A + B == 4){
    cout << 2 << endl;
  }
  else if (A + B == 5){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N;
  vector<string> w(N);
  for(int i= 0; i<N; i++){
    cin >> w.at(i);
  }
  for(int i = 0; i<N-1; i++){
    for(int j= i+1; j<N; j++){
      if(w.at(i) == w.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for(int i = 0; i< N-1; i++){
    string w_1, w_2;
    w_1 = w.at(i);
    w_2 = w.at(i+1);
    if(w_1.at(w_1.size()-1) != w_2.at(0)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

vector<P> RunLengthCompression(const vector<ll>& a) {
  ll n = SZ(a);
  vector<P> run;
  for (ll i = 0; i < n;) {
    ll j = i;
    while (j < n && a[j] == a[i]) {
      j++;
    }
    run.push_back(make_pair(a[i], j - i));
    i = j;
  }
  return run;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  auto run = RunLengthCompression(a);
  vector<bool> used(1e6 + 1, false);
  ll ans = 0;
  REP(i, SZ(run)) {
    ll x = run[i].first, cnt = run[i].second;
    if (cnt == 1 && !used[x]) {
      ans++;
    }
    for (ll j = x; j <= (ll)1e6; j += x) {
      used[j] = true;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8960
while True:
    (n , x) = [int (i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1 - 2):
        for b in range(a + 1, n + 1 - 1):
            for c in range(b + 1, n + 1 ):
                if (a + b + c) == x:
                    count += 1
    print(count)

Measured memory_bytes: 6724
import math
a, b, x = [float(x) for x in input().split()]
x = x / a
if 2 * x < a * b:
  print(90 - 180.0* math.atan2(2*x/b, b)/math.pi)
else:
  print(180.0* math.atan2(2*(a*b-x)/a, a)/math.pi)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;


int main( )
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a == b || b == c || c == a){
		if(a == b && b == c){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    string n;
    cin>>n;
    rep(i,0,2){
        if(n[i] == '9') cout<<1;
        else cout<<9;
    }
    cout<<endl;
    return 0;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int& x : arr) cin >> x;
	
	vector<int> sum(n+1);
	map<int, int> freq;
	ll ans = 0;
	freq[0] = 1;
	for(int L = 0, R = 1; R <= n; R++) {
		while(R - L + 1 > k) {
			freq[(L - sum[L] + k) % k]--;
			L++;
		}
		
		
		sum[R] = (sum[R-1] + arr[R-1]) % k;
		ans += freq[(R - sum[R] + k) % k];
		freq[(R - sum[R] + k) % k]++;
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int k;
    string s;
    cin >> k >> s;
    
    if(s.length() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) << "..." <<  endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define NIL -1
#define MAX 100005

int D[MAX];

struct node
{
	int parent, left, right;
	node()
	{
		parent = NIL;
		left = NIL;
		right = NIL;
	}
} T[MAX];

int getDegree(int i) 
{
	int cnt = 0;
	for (int c = T[i].left; c != NIL; c = T[c].right)
		cnt++;
	return cnt;
}

void setDepth(int i, int d)
{
	D[i] = d;
	if (T[i].right != NIL)
		setDepth(T[i].right, d);
	if (T[i].left != NIL)
		setDepth(T[i].left, d + 1);
}

void print(int i)
{
	cout << "node " << i << ": parent = " << T[i].parent;
	cout << ", depth = " << D[i] << ", ";
	if (T[i].parent == NIL)
		cout << "root, ";
	else if (T[i].left == NIL)
		cout << "leaf, ";
	else 
		cout << "internal node, ";
	cout << "[";
	for (int j = 0, c = T[i].left; c != NIL; c = T[c].right, j++)
	{
		if (j) cout << ", ";
		cout << c ;
	}
	cout << "]\n";
}

int main(void) 
{
	int n, id, k, c, l, r, i, j;
	cin >> n;
	for (i = 0; i < n; i++) 
	{
		cin >> id >> k;
		for (j = 0; j < k; j++) 
		{
			cin >> c;
			if (j == 0) 
				T[id].left = c;
			else
				T[l].right = c;
			T[c].parent = id;
			l = c;
		}
	}
	for (i = 0; i < n; i++)
	{
		if (T[i].parent == NIL)
			break;
	}
	setDepth(i, 0);
	for (i = 0; i < n; i++)
	{
		print(i);
	}
}


Measured memory_bytes: 7764
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define pi pair<int,int>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ;
     int n ; 
     cin>> n ; 
     string s ;
     cin>> s;
     int a[s.length()+1] ;
     for(int i = 0; i < n; ++i){
		 if(s[i] == 'R')
		     a[i] = 1 ; 
		 else if(s[i] == 'G')
		   a[i] = 2 ;
		   else
		   a[i] = 3 ; 
	   }
	   int co1 = 0 , co2 = 0, co3 = 0;
	   int arr1[n] = {0} , arr2[n] = {0}  , arr3[n] = {0} ; 
	   memset(arr2 , 0 , sizeof arr2) ; 
	   memset(arr3 , 0 , sizeof arr3) ; 
	   memset(arr1 , 0 , sizeof arr1)  ;
	   ll ans =  0 ; 
	   for(int i = 0 ; i < n ; ++i){
		   if(a[i] == 1){
		   co1++;
		   arr1[i] = co1 ;
		   if(i > 0 ){ 
		   arr2[i] = arr2[i-1] ; 
		   arr3[i] = arr3[i-1] ; }
	      }
		  else if(a[i] == 2){
		   co2++ ;
		   arr2[i] = co2 ; 
		   if(i > 0 ){
		   arr1[i] = arr1[i-1] ; 
		   arr3[i] =arr3[i-1] ; }
	   }
		 else  if(a[i] == 3){
		   co3++ ;
		   arr3[i] = co3 ;
		   if(i > 0){
		   arr1[i] = arr1[i-1] ; 
		   arr2[i] = arr2[i-1] ; }
	   }
   }
  /* cout<<arr1[n-1]<<endl;
   cout<<arr2[n-1]<<endl;
   cout<<arr3[n-1]<<endl;
   */
   for(int i = 1; i < n -1; ++i){
	    if(a[i] == 1){
		
		  for(int j = i - 1 , count=1; j >=0 && i + count < n ; --j , count++ ) {
			   if((a[j] == 2 &&a[i+count] == 3) ||
			       (a[j] == 3 && a[i + count ]==2)) ans-- ; 
			   }
		int fno2 = arr2[i] ; 
		int sno2 = arr2[n-1]  - arr2[i] ; 
		int sno3 = arr3[n-1] - arr3[i] ; 
		int fno3 = arr3[i] ;
			ans = ans + fno2*sno3+
			        sno2*fno3 ; 
				}
	   else if(a[i] == 2){
		   
		   
		  for(int j = i - 1 , count=1; j >=0 && i + count < n ; --j , count++ ) {
			   if((a[j] == 1 &&a[i+count] == 3 )||
			       (a[j] == 3 && a[i + count] ==1)) ans-- ; 
			   }
		   int sno3 = arr3[n-1] - arr3[i] ; 
           int fno3 = arr3[i] ;
		   int fno1 = arr1[i] ; 
		   int sno1 = arr1[n-1] - arr1[i] ; 
		   ans = ans + fno1*sno3 + 
		              fno3 * sno1 ; 
				  }
	  else{
		  for(int j = i - 1 , count=1; j >=0 && i + count < n ; --j , count++ ) {
			   if((a[j] == 2 &&a[i+count] == 1) ||
			       (a[j] == 1 && a[i + count] ==2)) ans-- ; 
			   }
		  int fno1 = arr1[i] ; 
		   int sno1 = arr1[n-1] - arr1[i] ; 
		   int fno2 = arr2[i] ; 
		int sno2 = arr2[n-1]  - arr2[i] ; 
		
		   
		  ans = ans + fno1*sno2 +
		              fno2*sno1 ;
			  }
		  }
		   
 
  
  
  
  cout<<ans<<endl;
  
  
  
  
  
  
}


Measured memory_bytes: 3676
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>

using namespace std;

int main(){
    char name[200003];
    int count[26];
    scanf("%s", name);
    size_t len = strlen(name);
    long long rst=0;
    for(size_t i=0; i!=len; i++){
        count[name[i]-'a']+=1;
    }
    for(int i=0; i!=26; i++){
        rst+=count[i]*(len-count[i]);
    }

    printf("%lld\n", rst/2+1);
    return 0;
}

Measured memory_bytes: 384
def main():
    A = []
    for _ in range(3):
        A.extend(map(int, input().split()))
    N = int(input())
    for _ in range(N):
        b = int(input())
        if b in A:
            A[A.index(b)] = 0

    for i in range(3):
        # 縦
        if sum([A[i], A[i+3], A[i+6]]) == 0:
            print("Yes")
            exit()
        # 横
        if sum([A[i*3], A[i*3+1], A[i*3+2]]) == 0:
            print("Yes")
            exit()
    # 斜め
    if sum([A[0], A[4], A[8]]) == 0 or sum([A[2], A[4], A[6]]) == 0:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    main()


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

using namespace std;

int best[100001];
vector<pair<int, int>> A;
int main(){
	best[0] = - (1 << 30);
	for(int i = 1; i <= 100000; i++){
		best[i] = (1 << 30);
	}
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x, h;
		cin >> x >> h;
		A.push_back({x, h});
	}
	sort(A.begin(), A.end(), [](pair<int, int> a, pair<int, int> b){
		return a.first - a.second < b.first - b.second;
	});
	for(int i = 0; i < n; i++){
		int x = A[i].first, h = A[i].second;
		int pos = upper_bound(best, best + n + 1, x - h) - best;
		best[pos] = min(best[pos], x + h);
		ans = max(ans, pos);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 1784
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<utility>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
using namespace std;

const double eps = 1e-8;
const double INF = 1e12;

int main(){
	int n,y=999,m=10,d=20;
	cin>>n;
	int day[1002][11][21];
	day[1000][1][1]=0;
	int cnt=1;
	while(1){
		if(y==0 || m==0 || d==0)break;
		day[y][m][d]=cnt;
		cnt++;
		d--;
		if(y%3!=0){
			if(d==0){
				if(m==1){
					m=10;
					y--;
					if(y%3==0)d=20;
					else d=19;
				}else{
					m--;
					if(m%2==0)d=19;
					else d=20;
				}
			}
		}else{
			if(d==0){
				if(m==1){
					m=10;
					y--;
					d=19;
				}else{
					m--;
					d=20;
				}
			}
		}
	}
	rep(i,n){
		cin>>y>>m>>d;
		cout<<day[y][m][d]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2064
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>s;
    std::stack<char> ss;
    
    for(auto x:s)
    {
        if(x=='S'||ss.empty()||ss.top()=='T')
            ss.push(x);
        else
            ss.pop();
    }
    cout<<sz(ss)<<endl;
}   aryanc403();
    return 0;
}

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

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  
  int x; scanf("%d",&x);
  vector<int> event(n+1);
  for(int i=1;i<m;i++){
    int y; scanf("%d",&y);
    if(x<y){
      event[x]++; event[y]--;
    }else{
      event[x]--; event[y]++;
    }
    x = y;
  }

  ll ans = 0, num = 0;
  for(int i=1;i<n;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    num += event[i];
    ans += min(num*a, num*b+c);
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 1520
import java.math.BigInteger;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	static int Y,N;
	public static void main(String[] args) {
	int ans=0;
	long N=sc.nextLong();
	long K=sc.nextLong();
	//String N=sc.next();
//	String K=sc.next();
//	BigInteger s1 = new BigInteger(N);
	//BigInteger s2 = new BigInteger(K);
	long min;
	long v=N%K;
	min=Math.min(v, Math.abs(v-K));
	
	p(min);
	
	
	}
}


Measured memory_bytes: 22356
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

signed main() {
	int H, W;
	cin >> H >> W;

	vector<string> board(H);
	rep(i, H) cin >> board[i];

	bool ok = true;
	rep(y, H) rep(x, W) {
		if (board[y][x] == '.') continue;
		bool flag = false;
		rep(dir, 4) {
			int nx = x + dx[dir];
			int ny = y + dy[dir];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			flag |= board[ny][nx] == '#';
		}
		ok &= flag;
	}

	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll x[120000];

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

    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    int index0 = N;
    for(int i = 0; i < N; i++){
        if(index0 == N && x[i] >= 0){
            index0 = i;
        }
    }

    ll res = LLONG_MAX;
    for(int i = 0; i < min(index0, N-K+1); i++){
        res = min(-x[i]*2 + max(x[K+i-1], 0LL), res);
    }

    for(int i = max(index0, K-1); i < N; i++){
        res = min(x[i]*2 + max(-x[i-K+1], 0LL), res);
    }

    if(index0 >= K){
        res = min(-x[index0-K], res);
    }

    if(index0 + K - 1 < N){
        res = min(x[index0+K-1], res);
    }

    cout << res << endl;


    return 0;

}



Measured memory_bytes: 1024
num = (int)(input())
ans = [0, 0, 0, 0]
for i in range(num):
  temp = input()
  if temp == "AC":
    ans[0] += 1
  elif temp == "WA":
    ans[1] += 1
  elif temp == "TLE":
    ans[2] += 1
  else:
    ans[3] += 1
print("AC x " + (str)(ans[0]))
print("WA x " + (str)(ans[1]))
print("TLE x " + (str)(ans[2]))
print("RE x " + (str)(ans[3]))

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define INF 100000000
int dp[20001][256];
 main(){
  int n,m;
  while(cin>>n>>m,n){
    int b[m];int a[n+1];
    r(i,m)cin>>b[i];
    r(i,n)cin>>a[i+1];
    r(i,20001)r(j,256)dp[i][j]=INF;
    dp[0][128]=1;
    r(i,n)r(j,256)
        if(dp[i][j]!=INF)r(k,m){
          int p=j+b[k];
          if(p>255)p=255;
          if(p<0)p=0;
          dp[i+1][p]=min(dp[i+1][p],dp[i][j]+(a[i+1]-p)*(a[i+1]-p));
        }
    int p=100000000;
    r(i,256)if(dp[n][i]!=INF)
      p=min(p,dp[n][i]);
    cout<<p-1<<endl;
  }
}

Measured memory_bytes: 23148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

//BufferReader
public class  Main {
//    static long dp[][];
//    static int n;
//    static int a[];
//    static int ans[];

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;


        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader sc=new FastReader();
        int p=sc.nextInt();
         int n=p%10;
        if ( n==2 || n==4 || n==5 || n==7 || n==9 )
            System.out.println("hon");
        else if ( n==0 || n==6 || n==1 || n==8 )
            System.out.println("pon");
        else System.out.println("bon");
    }


}

Measured memory_bytes: 32724
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout), freopen("debug.log", "w", stderr)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

const int MAXN = 500000 + 10;

int N, K;

namespace segmentTree
{
int SegTree[MAXN << 2];
int Query(int QL, int QR, int L = 1, int R = N, int x = 1)
{
	if (QL <= L && R <= QR)
		return SegTree[x];

	int mid = (L + R) >> 1;

	if (QR <= mid)
		return Query(QL, QR, L, mid, x << 1);
	if (QL > mid)
		return Query(QL, QR, mid + 1, R, (x << 1) | 1);
	else
		return max(Query(QL, QR, L, mid, x << 1),
				Query(QL, QR, mid + 1, R, (x << 1) | 1));
}

void Modify(int mpos, int num, int L = 1, int R = N, int x = 1)
{
	if (L == mpos && R == mpos)
	{
		SegTree[x] = num;
		return;
	}

	int mid = (L + R) >> 1;

	if (mpos <= mid)
		Modify(mpos, num, L, mid, x << 1);
	else
		Modify(mpos, num, mid + 1, R, (x << 1) | 1);
	SegTree[x] = max(SegTree[x << 1], SegTree[(x << 1) | 1]);
}

}  // namespace segmentTree

int input[MAXN];
int answer[MAXN], ansCnt;
int inDeg[MAXN];
vector<int> Adj[MAXN];

inline void addEdge(int u, int v)
{
	Adj[u].push_back(v);
	inDeg[v]++;
}

void topologySort()
{
	priority_queue<int, vector<int>, greater<int> > PQ;
	for (int i = 1; i <= N; i++)
		if (inDeg[i] <= 0)
			PQ.push(i);

	while (!PQ.empty())
	{
		int cur;
		cur = PQ.top(), PQ.pop();
		answer[cur] = ++ansCnt;

		for (vector<int>::iterator itr = Adj[cur].begin();
				itr != Adj[cur].end(); ++itr)
			if (!(--inDeg[*itr]))
				PQ.push(*itr);
	}
}

int main()
{
	//REDIRECT("swap");

	int k;
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)
		scanf("%d", &k), input[k] = i;
	for(int i = 1; i <= N; i++)
	{
		int L = max(1, input[i] - K + 1), R = min(N, input[i] + K - 1);

		k = segmentTree::Query(L, input[i]);
		//fprintf(stderr, "Queried in segment [%d, %d] : %d\n", L, input[i], k);
		if(k != 0)
			addEdge(input[k], input[i]);

		k = segmentTree::Query(input[i], R);
		//fprintf(stderr, "Queried in segment [%d, %d] : %d\n",input[i], R, k);
		if(k != 0)
			addEdge(input[k], input[i]);

		segmentTree::Modify(input[i], i);
	}

	topologySort();

	for(int i = 1; i <= N; i++)
		printf("%d\n", answer[i]);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 42240
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    int N; cin >> N;
    vector<ll> A(N),B(N);
    for(int i = 0; i < N;i++) cin >> A[i] >> B[i];
    res = *max_element(A.begin(), A.end());
    res += *min_element(B.begin(), B.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

void Quicksort(int*, int, int); //配列を引数にとる関数のプロトタイプ宣言ってこれでOK？
int totyu(int*, int, int);
void Switch(int*, int*);

int N; //グローバル変数

int main(){
    cin >> N;
    int a[N];
    int Alice=0, Bob=0;
    for(int i=0; i<N; i++) cin >> a[i];
    Quicksort(a,0,N);
    for(int i=N-1; i>-1; i-=2){
        Alice += a[i];
        if(i!=0) Bob += a[i-1];
    }
    cout << Alice - Bob <<endl;;
    return 0;
}

int totyu(int a[], int left, int right){
    int i, j;
    j = left;
    for(i=left; i<right-1; i++){
        if(a[i]<a[right-1]){
            Switch(&a[j], &a[i]);
            j++;
        }
    }
    Switch(&a[j], &a[right-1]);
    return j;
}

void Quicksort(int a[], int left, int right){
    int j;
    if(left>=right) return;
    j = totyu(a, left, right);
    Quicksort(a, left, j);
    Quicksort(a, j+1, right);
}

void Switch(int *a, int *b){
    int c;
    c = *a;
    *a = *b;
    *b = c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>


typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

int gcd(int a, int b) {
	int c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

map<string, int> memo;


int main() {
	//sort(a.begin(),a.end());
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> aa(a), bb(b);
	//vector<vector<int>> c(vector<int>(m), 3);
	rep(i, a) cin >> aa[i];
	rep(i, b) cin >> bb[i];
	int am=*min_element(aa.begin(), aa.end());
	int bm=*min_element(bb.begin(), bb.end());
	int ans = am + bm;
	rep(i, m) {
		int x, y, c; 
		cin >> x >> y >> c;
		x--; y--;
		ans = min(ans, aa[x] + bb[y] - c);
	}
	cout << ans << endl;
	return 0;
}









Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pa first
#define di second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,m,vis[500100],ans,pa[500100],X[500100],Y[500100],Z[500100];
set <int> adj[500100];
int F(int x)
{
    if(pa[x]==x)
        return x;
    return pa[x]=F(pa[x]);
}
int main()
{
    go;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        pa[i]=i;
    for(int i=0; i<m; i++)
    {
        int x,y,z,x1,y1;
        cin>>x>>y>>z;
        z%=2;
        X[i]=x;
        Y[i]=y;
        x=F(x);
        y=F(y);
        if(x!=y)
            pa[x]=y;
    }
    for(int i=1;i<=n;i++)
    {
        ans+=(!vis[F(i)]);
        vis[F(i)]=1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 33536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n][m],dp[n][m];
    char ch;
    
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>ch;
            if(ch=='.')
            {
                a[i][j]=0;
                dp[i][j]=0;
            }
            else
            {
                a[i][j]=-1;
                dp[i][j]=-1;
            }
        }
    }
    
    for(int i=0;i<m;i++)
    {
        if(a[0][i]!=-1)
            dp[0][i]=1;
        else
            break;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i][0]!=-1)
            dp[i][0]=1;
        else 
            break;
    }
    
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(dp[i][j]!=-1)
            {
                if(dp[i-1][j]!=-1)
                    dp[i][j]=(dp[i][j]+dp[i-1][j])%M;
                if(dp[i][j-1]!=-1)
                    dp[i][j]=(dp[i][j]+dp[i][j-1])%M;
            }
                
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}

Measured memory_bytes: 15872
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	std::string s, t;
	getval(s, t);

	int len = s.length();
	bool equal = true;
	for (int i = 0; i < len; i++) {
		if (s[i] != t[i]) equal = false;
	}
	printf("%s\n", (equal ? "Yes" : "No"));
}


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


Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    char a, b;
    cin >>a >>b;
    string x(b - '0', a), y(a - '0', b);
    long long m = stoll(x);
    long long n = stoll(y);
    if(m > n)
        cout <<x;
    else 
        cout <<y;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t dfs(const vector<vector<bool>>& is_white, vector<vector<pair<int64_t, int64_t>>>* visited, int64_t sx, int64_t sy, int64_t x, int64_t y) {
    auto self_is_white = is_white[x][y];

    if ((*visited)[x][y].first >= 0) {
        return 0;
    }
    (*visited)[x][y] = make_pair(sx, sy);

    int64_t ret = 0;
    if (self_is_white) {
        ++ret;
    }

    if (x > 0) {
        if (is_white[x - 1][y] != self_is_white) {
            ret += dfs(is_white, visited, sx, sy, x - 1, y);
        }
    }
    if (x < is_white.size() - 1) {
        if (is_white[x + 1][y] != self_is_white) {
            ret += dfs(is_white, visited, sx, sy, x + 1, y);
        }
    }
    if (y > 0) {
        if (is_white[x][y - 1] != self_is_white) {
            ret += dfs(is_white, visited, sx, sy, x, y - 1);
        }
    }
    if (y < is_white[0].size() - 1) {
        if (is_white[x][y + 1] != self_is_white) {
            ret += dfs(is_white, visited, sx, sy, x, y + 1);
        }
    }

    return ret;
}

main() {
    int64_t h, w;
    cin >> h >> w;

    vector<vector<bool>> is_white(h, vector<bool>(w));
    for (auto i : irange(0L, h)) {
        string s;
        cin >> s;
        for (auto j : irange(0L, w)) {
            is_white[i][j] = (s[j] != '#');
        }
    }

    int64_t ans = 0;
    vector<vector<int64_t>> cache(h, vector<int64_t>(w, 0));
    vector<vector<pair<int64_t, int64_t>>> visited(h, vector<pair<int64_t, int64_t>>(w, make_pair(-1L, -1L)));
    for (auto i : irange(0L, h)) {
        for (auto j : irange(0L, w)) {
            if (is_white[i][j]) {
                continue;
            }

            if (visited[i][j].first >= 0) {
                auto start = visited[i][j];
                ans += cache[start.first][start.second];
                // cerr << "cached: " << i << "," << j << ":" << cache[start.second][start.second] << " " << start.first << "," << start.second << endl;
            } else {
                auto ret = dfs(is_white, &visited, i, j, i, j);
                cache[i][j] = ret;
                ans += ret;
                // cerr << i << "," << j << ":" << ret << endl;
            }

        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 31488
N, c = map(int, input().split())
S = [list(map(int, input().split())) for i in range(N)]

sum_ = 0
r = [0]
for x, v in S:
    sum_ += v
    r.append(sum_-x)

sum_ = 0
l = [0]
for x, v in S[::-1]:
    sum_ += v
    l.append(sum_- (c - x))

def right():
    max_ = r[0]
    for i in r:
        if max_ < i:
            max_ = i
        yield max_

def left():
    max_ = l[0]
    for i in l:
        if max_ < i:
            max_ = i
        yield max_


rm = [[0, 0]] + S
lm = S + [[c, c]]

rpath = list(right())
l_candi = [0]*N
for i in range(N):
    l_candi[i] = l[i] + rpath[-(i + 1)] - (c-lm[-(i + 1)][0])
lmax = max(l_candi)

lpath = list(left())
r_candi = [0]*N
for i in range(N):
    r_candi[i] = r[i] + lpath[-(i + 1)] -rm[i][0]
rmax = max(r_candi)

print(max(rmax, lmax))


Measured memory_bytes: 47180
import sys
input=sys.stdin.readline

def main():
    n=int(input())
    XY=[tuple(map(int,input().split())) for _ in range(n)]
    U,V=[],[]
    for x,y in XY:
        U.append(x+y)
        V.append(x-y)
    print(max(max(U)-min(U),max(V)-min(V)))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 123000