akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,b) for(int i= 0; i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define MOD 1000000007
const int N = 2e5+7 ;
string s ;

int32_t main(){fast ;
	int n,m,k ;
	cin >> n >> m >> k ;
	for(int i = 0 ; i < 10 ; i++){
		k = n*k - m ;
		cout << k << endl ;
	}
	
}





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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = N - 1; i >= 0; i -= 2) cout << A.at(i) << "\n";
  for (int i = (N % 2) ? 1 : 0; i < N; i += 2) cout << A.at(i) << "\n";
}

Measured memory_bytes: 2944
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

ans = 0
prev = 999

A.each do |i|
  current = i-1
  ans += B[i-1]

  if (current - 1) == prev
    ans += C[prev]
  end

  prev = current
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};

signed main() {
int a,b,c;
cin>>a>>b>>c;
int k;cin>>k;
cout<<a+b+c+max({a,b,c})*((1<<k)-1);
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define mod 1000000007
LL sum,mn,mx;
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int flag=0;
    while(a>0&&c>0)
    {
        c-=b;
        if(c<=0)
        {
            flag=1;
            break;
        }
        a-=d;
    }
    if(flag==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1664
'use strict';

function Main(input) {
  const A = Number(input.split(" ")[0])
  const B = Number(input.split(" ")[1])
  const T = Number(input.split(" ")[2])

  const time = T + 0.5
  let ans = 0
  
  for (let i=time; i>=A; i-=A) {
    ans += B
  }

  console.log(ans)

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 11468
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
5 3 11
1
)");
#define cin input
#endif

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

	int mx = max({a, b, c});
	int prod = 1;
	for (int i=0; i<k; i++)
		prod *= 2;

	cout << a+b+c+mx*(prod-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b) // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main()
{
  int D;
  cin >> D;
  string ans;

  if (D == 22)
    ans = "Christmas Eve Eve Eve";
  if (D == 23)
    ans = "Christmas Eve Eve";
  if (D == 24)
    ans = "Christmas Eve";
  if (D == 25)
    ans = "Christmas";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "atcoder/lazysegtree"
#include "atcoder/modint"
#include <cstdio>

using namespace std;
using namespace atcoder;

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return 0; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
	int N, K;
	cin >> N >> K;
	std::vector<S> v(300000 + 1, (long long)0);
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
	for (int i = 0; i < N; ++i) {
		int num;
		cin >> num;
		int r = max(0, num - K);
		int l = min(300000, num + K);
		seg.apply(num, seg.prod(r, l + 1) + 1);
	}
	cout << seg.all_prod() << endl;
}


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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
    optimize();

  ll  a,b,k;

    cin>>a>>b>>k;

   if(k>=a+b)
   {
       a=0;
       b=0;
   }

   else
   {
       a=a-k;
   }

   if(a<0)
   {
       b=b+a;
       a=0;
   }


   cout<<a<<' '<<b;










    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    readLine()
    val h = readLine()!!.split(" ").map { it.toInt() }

    var count = 0
    var max = 0
    h.reduce { a, b ->
        count = if(a>=b) count+1 else 0
        if(count>max) max=count
        b
    }
    max
})

Measured memory_bytes: 59588
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

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

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


Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[10];
int main(){
	scanf("%s%s", s, s+3);
	int ans = 0;
	REP(i, 3) if(s[i] == s[i+3]) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
def wantnex(a,b):

    if a % b == 0:
        return a

    else:
        return ((a // b) + 1) * b



N = int(input())
AB = []

for i in range(N):

    A,B = map(int,input().split())

    AB.append([A,B])

now = 0
ans = 0
onow = 0

AB.reverse()

for i in range(N):


    now += wantnex( AB[i][0] + now , AB[i][1] ) - (AB[i][0] + now)
    

print (now)


Measured memory_bytes: 19624
#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,x,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		ans^=(x&1);
	}
	if(ans)puts("NO");else puts("YES");
}

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

namespace abc_168a
{
    class Program
    {
        static void Main(string[] args)
        {
            int kazu = int.Parse(Console.ReadLine());

            if(kazu % 10 == 3)
            {
                Console.WriteLine("bon");
            }
            else if(kazu % 10 == 0 || kazu % 10 == 1 || kazu % 10 == 6 || kazu % 10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            Console.Read();

        }
    }
}


Measured memory_bytes: 27504
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << 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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    vi antenna(5); ll k; bool ans = true;
    rep(i, 5) cin >> antenna[i];
    cin >> k;

    for(ll i=0; i<4; i++){
        for(ll j=i+1; j<5; j++){
            if(antenna[j]-antenna[i] > k) ans = false;
        }
    }
    if(ans) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

template<class T>
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(const vector<Edge<T>> &edges, const int V, const int st) {

  const T inf = numeric_limits<T>::max() / 2;
  vector<T> cost(V, inf);
  cost[st] = 0;
  for (int i = 0; i < V - 1; i++) {
    for (const auto &e : edges) {
      if (cost[e.from] == inf) continue;
      cost[e.to] = min(cost[e.to], cost[e.from] + e.cost);
    }
  }

  for (int i = 0; i < V; i++) {
    for (const auto &e : edges) { // finding negative loop
      if (cost[e.from] == inf) continue;
      if (cost[e.from] == -inf) cost[e.to] = -inf; // src is nloop -> dst is nloop
      else if (cost[e.to] > cost[e.from] + e.cost) cost[e.to] = -inf; // chmin is possible -> nloop
    }
  }

  return cost;
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<Edge<ll>> g;
  REP(i,M){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;c=-c;
    g.emplace_back(a,b,c);
  }
  auto ans = Bellman_Ford(g, N, 0);
  if(ans[N-1]==-(numeric_limits<ll>::max()/2)){
    cout<<"inf"<<endl;
  }else{
    cout<<-ans[N-1]<<endl;
  }
}



Measured memory_bytes: 384
G(int a,int b){
	if(a==0||b==0)return(a>b?a:b);
	if(a%b==0)return b;
	return G(b,a%b);
}
main(){
	int i,n,a[100002],l[100002]={0},r[100002]={0},ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){scanf("%d",&a[i]);l[i+1]=G(a[i],l[i]);}
	for(i=n;i>0;i--)r[i]=G(a[i],r[i+1]);
	for(i=1;i<=n;i++)ans=(ans>G(l[i],r[i+1])?ans:G(l[i],r[i+1]));
	printf("%d",ans);
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        auto atemp=lower_bound(a.begin(),a.end(),b[i]);
        auto ctemp=upper_bound(c.begin(),c.end(),b[i]);
        ans+=distance(a.begin(),atemp)*distance(ctemp,c.end());           
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
bool f;



void solve(int x, int y,char op){
	if(x<0||x>=w||y<0||y>=h||op!=fi[y][x])
		return ;
	fi[y][x]='.';
	solve(x+1,y,op);
	solve(x,y+1,op);
	solve(x-1,y,op);
	solve(x,y-1,op);
}
int main(){
	
	while(cin>>h>>w,w!=0&&h!=0){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
		cin>>fi[i][j];
		}
	}
		ans=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fi[i][j]=='@'||fi[i][j]=='#'||fi[i][j]=='*'){
			solve(j,i,fi[i][j]);
				ans++;
				}
		}
		}
		cout<<ans<<endl;
	}

	
}

Measured memory_bytes: 1480
// 数字の桁を入れ替えて出力
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int a = kbd.nextInt();
	while(a>0){
	    String n = kbd.next();
	    int[] num = new int[8];
	    int i;
	    for(i=0; i<num.length; i++){
		num[i] = Integer.parseInt(n.substring(i, i+1));
	    }
	    sortMin(num);
	    String max = "";
	    String min = "";
	    for(i=0; i<num.length; i++){
		max += Integer.toString(num[num.length-1-i]);
		min += Integer.toString(num[i]);
	    }

	    int ans = Integer.parseInt(max) - Integer.parseInt(min);
	    System.out.println(ans);
	    a--;
	}
    }

    static void sortMin(int[] num){
	int i, j;
	for(i=0; i<num.length; i++){
	    for(j=i+1; j<num.length; j++){
		if(num[i] > num[j]){
		    int w = num[i];
		    num[i] = num[j];
		    num[j] = w;
		}
	    }
	}
    }
}
	    

Measured memory_bytes: 17188
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

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


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}


int main(){

  int k,x;
  cin>>k>>x;

  long long mini = x-(k-1);
  long long maxi = x + (k-1);

  for(int i=mini;i<=maxi;i++){
    cout<<i<<" ";
  }

   cout<<endl;

 return 0;
}

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APassword solver = new APassword();
        solver.solve(1, in, out);
        out.close();
    }

    static class APassword {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            out.println(n * n * n);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

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

    }
}



Measured memory_bytes: 21460
/*---------------------------------------------------------------------*/
/*                   -------------------------------------             */
/*                   -----------MEHEDI HASAN--------------             */
/*                   -----CSE,JAHANGIRNAGAR UNIVERSITY----             */
/*                   -------------------------------------             */
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
#include <cassert>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
/*---------------------------------------------------------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define ccc(x)      cout<<#x<<"="<<"("<<x.ff<<" "<<x.ss<<") ";
#define CC(x)       cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<xx<<" ";
#define CCC(x)      cout<<"["<<#x<<"] = ";for(auto xx: x) cout<<"("<<xx.ff<<" "<<xx.ss<<") ";
#define MARK(x)     cout<<x<<" ";
#define ee          cout<<"\n";
#define OK          cout<<"Ok till line "<<__LINE__<<"\n";
/*---------------------------------------------------------------------*/
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define ps          push
#define psb         push_back
#define psf         push_front
#define pp          pop
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int t;cin>>t;for(int tcase=1;tcase<=t;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
/*---------------------------------------------------------------------*/
#define MAX (ll)(1e6)
#define MOD (ll)(1e9+7)

int main()
{
    FAST
    int n;
    cin>>n;
    ll sum=0ll;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 or i%5==0) continue;
        sum+=i;
    }
    cout<<sum<<endl;






    return 0;

}
/*--------------------------------------------------------------------*/
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
*/
/*--------------------------------------------------------------------*/
/* ---INPUT---
--------(1)------

-------(2)-------


-------(3)-------


-------(4)-------



--------------
*/
/*--------------------------------------------------------------------*/



//https://codeforces.com/contest/466/problem/C try again


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b>>u;
  if(u==s)cout<<a-1<<' '<<b<<'\n';
  else cout<<a<<' '<<b-1<<'\n';
  return 0;
}


Measured memory_bytes: 256
'''
写経
https://youtu.be/cJ-WjtA34GQ?t=1899
https://atcoder.jp/contests/agc011/submissions/1157055
http://noshi91.hatenablog.com/entry/2018/04/17/183132
https://camypaper.bitbucket.io/2016/12/18/adc2016/
'''


class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]  # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)

    def find(self, x):  # xを含む木における根の頂点番号を返す
        if self.v[x] < 0:  # (負)は根
            return x
        else:  # 根の頂点番号
            self.v[x] = self.find(self.v[x])  # uniteでは, 旧根に属する頂点の根が旧根のままなので更新
            return self.v[x]

    def unite(self, x, y):  # 違う根に属していたらrankが低くなるように連結
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:  # size比較, 　(-1) * (連結頂点数 * (-1)), (正)同士の大小比較
            x, y = y, x  # 連結頂点数が少ない方をyにすると, findでの更新回数が減る？
        self.v[x] += self.v[y]  # 連結頂点数の和を取る, 連結頂点数 * (-1)
        self.v[y] = x  # 連結頂点数が少ないy(引数yの根の頂点番号)の根をx(引数xの根の頂点番号)にする

    def root(self, x):
        return self.v[x] < 0  # (負)は根

    def same(self, x, y):
        return self.find(x) == self.find(y)  # 同じ根に属するか

    def size(self, x):
        return -self.v[self.find(x)]  # 連結頂点数を返す


N, M = map(int, input().split())
uf = UnionFind(2 * N)  # 全頂点 * 2(赤, 青の塗り分け)
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    uf.unite(u, N + v)  # u, v: 赤で塗る / N + u, N + v: 青で塗る
    uf.unite(N + u, v)  # 隣り合う頂点を赤, 青または青, 赤で着色したものとして, 集合に加える(二部グラフならば矛盾※が出ない)

    # print(uf.v)

alone = 0
bi = 0
unko = 0

for u in range(N):
    if uf.root(u) or uf.root(N + u): # 根になりうる場合, 単独/二部はどちらもTrue, 二部グラフではない場合は, どちらかの頂点がTrue
        if uf.size(u) == 1: # 単独ならu, N + uのどちらも単独なので, 片方調べればよい
            alone += 1
        elif uf.same(u, N + u):  # ※同じ頂点の赤, 青が同じ集合にあれば塗り分けについて矛盾しており, 二部グラフではない
            unko += 1
        else:
            bi += 1  # 二部グラフ

ans = 0
ans += alone * N
ans += N * alone
ans -= alone * alone
ans += bi * bi * 2
ans += bi * unko
ans += unko * bi
ans += unko * unko

print(ans)


Measured memory_bytes: 8804
#include<iostream>
using namespace std;
int main(){
	int a=0,b=0,i=0;
	cin >> a >> b >> i;
	if(a==1&&b==1){
		cout << "Open" << endl;
	}
	else if(i==1){
		cout << "Open" << endl;
	}
	else{
		cout << "Close" << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0,b[1000000]={0};
        string c;
       long long int o=0,l,d=0,i,j,p=0,s=1,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
   cin>>k;
   cin>>c;
   for(i=0;i<c.length();i++)
   {
       if(i+1<=k)
       cout<<c[i];
       else
       {
           cout<<"...";
           break;
       }
   }

 return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  int x,y;
  cin>>a>>b>>c;
  x=b-a;
  y=c-b;
  
  if(x==y){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
using namespace std;


int main() {
	long long int count=1;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		count = count * i;
		if (count > 1000000007) {
			count = count % 1000000007;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
main = interact $ show . f . lines
f[n, s] = go (foldl (*%) 1 [1..read n]) 0 s
go res open _ | res == 0 || open < 0 = 0
go res open ('W':cs)
  | even open = go (res *% open) (open - 1) cs
  | otherwise = go res (open + 1) cs
go res open ('B':cs)
  | even open = go res (open + 1) cs
  | otherwise = go (res *% open) (open - 1) cs
go res 0 [] = res
go _ _ [] = 0
x *% y = x * y `rem` 1000000007

Measured memory_bytes: 20860
N, H, W = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(N):
    if H <= A[i] and W <= B[i]:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
int main(){
	int n;cin>>n;
	vector<int> w(n);
	for(int i=0;i<n;i++){cin>>w[i];}

	int ans=INF;
	for(int i=1;i<=n;i++){
		int s1=0,s2=0;
		for(int j=0;j<n;j++){
			if(j<=i){s1+=w[j];}
			else{s2+=w[j];}
		}
		ans=min(ans,abs(s1-s2));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        int h,w;
        while(1){
        scanf("%d %d",&h,&w);
        if(!h)break;
        for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                        if(i==0 || i==h-1 || j==0 || j==w-1){
                                printf("#");
                        }else{
                                printf(".");
                        }
                }
                printf("\n");
        }
        printf("\n");
        }
    return 0;
}

Measured memory_bytes: 1152
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
keta = [-1]*(N)
for i in range(M):
    s,c = I()
    if keta[s-1] == -1 or keta[s-1] == c:
        keta[s-1] = c
    else:
        print(-1)
        exit()
if keta[0] == -1 and len(keta) != 1:
    keta[0] = 1
for i in range(N):
    if keta[i] == -1:
        keta[i] = '0'
    else:
        keta[i] = str(keta[i])
if ''.join(keta) != str(int(''.join(keta))):
    print(-1)
else:
    print(''.join(keta))


Measured memory_bytes: 77388
unittest
{
	assert( [ "1 1 2 2" ].solve == 3 );
	assert( [ "2 1 3 4" ].solve == 65 );
	assert( [ "31 41 59 265" ].solve == 387222020 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = 0L;
	auto b = 0L;
	auto c = 0L;
	auto d = 0L;
	input.front.formattedRead!"%s %s %s %s"( a, b, c, d );
	
	// dp[ 縦幅 ][ 横幅 ][ 一番上の行の黒マスの数(0,1,2以上) ] = パターン数
	const M = 998244353L;
	auto dp = new ModWorld!M[][][]( 1 + c, 1 + d, 3 );
	dp[ a ][ b ][ 0 ] = 1;
	foreach( h; a + 1 .. dp.length.signed )
	{
		dp[ h ][ b ][ 1 ] = dp[ h - 1 ][ b ].sum * b;
	}
	foreach( w; b + 1 .. dp[ 0 ].length.signed )
	{
		dp[ a ][ w ][ 0 ] = dp[ a ][ w - 1 ][ 0 ] * ( a - 1 );
		dp[ a ][ w ][ 1 ] = dp[ a ][ w - 1 ][ 1 ] * ( a - 1 ) + dp[ a ][ w - 1 ][ 0 ];
		dp[ a ][ w ][ 2 ] = dp[ a ][ w - 1 ][ 2 ] *   a       + dp[ a ][ w - 1 ][ 1 ];
	}
	foreach( h; a + 1 .. dp.length.signed )
	{
		foreach( w; b + 1 .. dp[ h ].length.signed )
		{
			dp[ h ][ w ][ 0 ] = dp[ h ][ w - 1 ][ 0 ] * ( h - 1 );
			dp[ h ][ w ][ 1 ] = dp[ h - 1 ][ w ].sum * w;
			dp[ h ][ w ][ 2 ] = dp[ h ][ w - 1 ][ 2 ] * h + dp[ h ][ w - 1 ][ 1 ];
			
		}
	}
	return dp[ $ - 1 ][ $ - 1 ].sum;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


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

int main()
{
    long long int i,j,k;
    long long int n,b[500],max=0;

    scanf("%lld",&n);
    for(i=0; i<n-1; i++)
    {
         scanf("%lld",&b[i]);
    }

for(i=0; i<n; i++)
{
    if(i==0)
    {
        max+=b[i];
    }else if(i==n-1)
    {
        max+=b[i-1];
    }
    else
    {
        if(b[i]>b[i-1])
        {
            max+=b[i-1];
        }else
        {
            max+=b[i];
        }
    }
}
    
    printf("%lld",max);
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

void func_A() {

    int n;
    cin >> n;

    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9: 
        cout << "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8: 
        cout << "pon";
        break;
    case 3:
        cout << "bon";
        break;
    }


}

void func_B() {

    int k;
    string s;
    cin >> k >> s;

    if (k < s.size()) s = s.substr(0, k) + "...";

    cout << s;
}

void func_C() {

}

int main() {

    //func_A();
    func_B();
    //func_C();

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

typedef long long ll;

using namespace std;
int main(){
	const int inf = 100000000;
	int dist[100][100];
	int a[1000], b[1000], c[1000];

    int N, M;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
    	cin >> a[i] >> b[i] >> c[i];
    	a[i]--;
    	b[i]--;
    }

    for (int i = 0; i < N; i++) {
    	for (int j = 0; j < N; j++) {
    		if (i == j) dist[i][j] = 0;
    		else dist[i][j] = inf;
    	}
    }

    for (int i = 0; i < M; i++) {
    	dist[a[i]][b[i]] = c[i];
    	dist[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < N; k++) {
    	for (int i = 0; i < N; i++) {
    		for (int j = 0; j < N; j++){
    			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    		}
    	}
    }

    int ans = M;
    for (int i = 0; i < M; i++) {
    	bool shortest = false;
    	for (int s = 0; s < N; s++) {
    		for (int t = 0; t < N; t++) {
    			if (dist[s][a[i]] + c[i] + dist[b[i]][t] == dist[s][t]) {
    				shortest = true;
    			}
    		}
    	}
		if (shortest) ans--;
    }

    cout << ans << endl;

}


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

int main(){
	int N, M, K, A, i, j;
	scanf("%d%d", &N, &M);
	vector<int> count(M, 0);
	for(i = 0; i < N; i++){
		scanf("%d", &K);
		for(j = 0; j < K; j++){
			scanf("%d", &A);
			count[A - 1]++;
		}
	}
	int ans = 0;
	for(i = 0; i < M; i++){
		if(count[i] == N){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

lli dp[200005];
lli ar[200005];
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin >> n >> k;
    vector<pair<int,int > > v;
    for(int i=1;i<=k;i++)
    {
        int a,b;
        cin >> a >> b;
        v.pb(mpr(a,b));
    }
    sort(v.begin(),v.end());
    dp[1] = 1;

    ar[1] = 1;
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<k;j++)
        {
            int l = i-v[j].ss;
            int r = i-v[j].f;
            if(r<=0) continue;
            l = max(1,l);
            dp[i] += ar[r]-ar[l-1];
            dp[i] %= 998244353;
        }

        ar[i] = ar[i-1] + dp[i];
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6712
#include <cstdio>
#define maxn 100005
using namespace std;

int a[maxn], n, m;

inline bool check(int x)
{
	for(int i=0; i<n; i++)
	{
		int t = x / a[i];
		bool flag = false;
		for(double e=-1.5; e<2; e++)
			if((t + e) * a[i] == x)
			{
				flag = true;
				break;
			}
		if(!flag) return false;
	}
	return true;
}

int main(int argc, char** argv)
{
	int maxi = -1;
	scanf("%d%d", &n, &m);
	for(int i=0; i<n; i++)
	{
		scanf("%d", a + i);
		if(a[i] > maxi) maxi = a[i];
	}
	// Find first X
	int first = -1;
	for(int x=maxi>>1; x<=m; x+=maxi)
		if(check(x))
		{
			first = x;
			break;
		}
	if(first == -1) {puts("0"); return 0;}
	int t = m / first;
	printf("%d\n", t & 1? (t >> 1) + 1: t >> 1);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define loop(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,n) loop(i,0,n)
#define all(c) (c).begin(), (c).end()

int main(){
    unsigned long long n;
    while (cin >> n){
        int a[2][10];
        int *next = a[0], *cur = a[1];
        rep(i, 10){
            cur[i] = n % 10;
            n /= 10;
        }
        rep(i, 9){
            rep(j, 9 - i){
                next[j] = (cur[j] + cur[j + 1]) % 10;
            }
            swap(next, cur);
        }
        cout << cur[0] << endl;
    }
}

Measured memory_bytes: 1156
#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 ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

vector<int> Eratosthenes(int n){
  bool dp[n+1];
  REP(i,n+1)dp[i]=false;
  dp[0] = dp[1] = true;
  vector<int> prime;
  FOR(i,2,n+1){
    if(!dp[i]){
      prime.push_back(i);
      for (int j = i*2; j<n+1 ; j+=i)dp[j] = true;
    }
  }
  return prime;
}

bool PrimeNumber(int n){
  vector<int> prime = Eratosthenes(n);
  return n==prime.back();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  while(1){
    if (PrimeNumber(n)==1){
      cout << n << endl;
      return 0;
    }
    n++;
  }
  //cout << PrimeNumber(n) << endl;
}

Measured memory_bytes: 512
fun main(args : Array<String>){
    val (N,A,B) = readLine()?.split(" ")?.map(String::toInt)?: return
    var sum = 0

    for( i in 1..N ){
        var sample = i
        var digitSum = 0
        do{
            digitSum += sample % 10
            sample /= 10
        }while(sample > 0)

        if(digitSum in A..B){
            sum += i
        }
    }

    print(sum)
}

Measured memory_bytes: 38036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	char C[100][100];
	REP(i, H) {
		REP(j, W) {
			cin >> C[i][j];
		}
	}
	REP(i, H) {
		REP(k, 2) {
			REP(j, W) {
				cout << C[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

constexpr int b = 80 * 80 + 3;
constexpr int M = b * 2 + 3;

int main(int argc, const char * argv[]) {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    vector<vector<int>> d(H, vector<int>(W));

    rep (i, H) rep (j, W) cin >> A[i][j];
    rep (i, H) rep (j, W) cin >> B[i][j];

    vector<bitset<M>> dp(W+1);

    dp[1][b] = 1;
    rep (i, H) rep (j, W) { 
        int d = abs(A[i][j] - B[i][j]);
        dp[j + 1] |= dp[j];
        dp[j + 1] = (dp[j + 1] << d) | (dp[j + 1] >> d);
    }
    cout << dp.back()._Find_next(b - 1) - b << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FO(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define ll long long
#define ull unsigned ll
#define db double
#define lb long db
#define pb push_back
#define com complex<db>
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define cle(x) memset(x,0,sizeof(x))
#define DEBUG(x) cout<<#x<<"="<<x<<endl;
#define fo(i,j,k) for(int i=(j),end_i=(k);i<=end_i;i++)
#define fd(i,j,k) for(int i=(j),end_i=(k);i>=end_i;i--)
inline int read()
{
	int x=0; char ch=getchar(); bool f=0;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
#define CASET fo(___,1,read())
const ll mod=998244353;
inline ll Add(ll x,ll y){x+=y; return (x<mod)?x:x-mod;}
inline ll Dec(ll x,ll y){x-=y; return (x<0)?x+mod:x;}
inline ll Mul(ll x,ll y){return x*y%mod;}
inline ll Pow(ll x,ll y)
{
	y%=(mod-1); ll ans=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod;
	return ans;
}
const int N=1e5+5;
int n,m,q,ma,mb,ans;
int x,y,c;
int a[N],b[N];
int main()
{
	n=read(); m=read(); q=read();
	ma=mb=(int)2e9;
	fo(i,1,n) a[i]=read(),ma=min(ma,a[i]);
	fo(i,1,m) b[i]=read(),mb=min(mb,b[i]);
	ans=ma+mb;
	fo(i,1,q)
	{
		x=read(); y=read(); c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
  std::string S; std::cin >> S;
  int p = 0;
  while(p < S.size()) {
    // find last R;
    int iR = p;
    while(S[iR]=='R') ++iR;
    // find last L;
    int iL = iR;
    while(iL < S.size() && S[iL]=='L') ++iL;
    int nR = iR-p, nL = iL-iR;
    int niR = 0;
    for(int i = p; i < iL; ++i) if(i%2 == iR%2) ++niR;
    for(int i = p; i < iR-1; ++i) std::cout << "0 ";
    std::cout << (nR+nL-niR) << " " << niR << " ";
    for(int i = iR+1; i < iL; ++i) std::cout << (i<S.size()-1? "0 ": "0\n");
    p = iL;
  }
  return 0;
}


Measured memory_bytes: 640
// AtCorder_temp.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include<iostream>
#include<string>
using namespace std;

int main(){
	int a,b,c;

	cin >> a >> b >> c;

	if ((a + b + c) <= 21) {
		cout << "win";
	}
	else {
		cout << "bust";
	}


}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound		// first element >= val(itr) 
#define ub              upper_bound		// first element >  val(itr)
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))	//x can be 0 or -1

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }


const ll inf = 1e18;
const int nax = 1e5 + 5;
ll dp[10][20][10][2];
ll k,n;
vector<ll>digits;

void pre(ll x)
{
	digits.clear();
	while(x)
	{
		digits.pb(x%10);
		x /= 10;
	}
	
	reverse(all(digits));
	n = digits.size();
	
	forn(i,0,10)
	{
		forn(j,0,20)
		{
			forn(k,0,10)
			{
				forn(p,0,2)
				{
					dp[i][j][k][p] = -1;
				}
			}
		}
	}
}

ll count(ll idx,ll len,ll prev,bool allow)
{
	if(prev < 0 || prev>=10)
	{
		return 0;
	}
	
	if(idx == len)
	{
		return 1;
	}
	
	if(dp[idx][len][prev][allow] != -1)
	{
		return dp[idx][len][prev][allow];
	}
	
	ll ans = 0;
	if(allow)
	{
		ans += count(idx+1,len,prev-1,1);
		ans += count(idx+1,len,prev,1);
		ans += count(idx+1,len,prev+1,1);
	}
	else
	{
		forn(i,prev-1,prev+2)
		{
			if(i > digits[idx])
			{
				continue;
			}
			if(i == digits[idx])
			{
				ans += count(idx+1,len,i,0);
			}
			else
			{
				ans += count(idx+1,len,i,1);
			}
		}
	}
	
	return dp[idx][len][prev][allow] = ans;
}

bool ok(ll x)
{
	pre(x);
	
	ll cnt = 0;
	forn(i,1,19)	//length of numbers
	{
		forn(j,1,10)	//first number
		{
			if(i<n)
			{
				cnt += count(1,i,j,1);
			}
			else if(i == n)
			{
				if(j == digits[0])
				{
					cnt += count(1,i,j,0);
				}
				else if(j<digits[0])
				{
					cnt += count(1,i,j,1);
				}
			}
		}
	}
	//cout<<cnt<<endl;
	return cnt>=(k);
}

void SolveTestCase()
{
	cin>>k;
	
	ll lo = -1, hi = 1e18;
	ll ans = 0;
	//bool t = ok(3234566667);
	while(hi-lo>1)
	{
		ll mid = (lo+hi)/2;
		//cout<<mid<<endl;
		if(ok(mid))
		{
			ans = mid;
			hi = mid;
		}
		else
		{
			//ans = mid;
			lo = mid;
		}
	}
	cout<<ans;
}

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	forn(i,0,t)
	{
		SolveTestCase();
	}

	return 0;
}


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

vector<bool> seen;
vector<int> counter;
vector<vector<int>> xlist;
int temp;

void dfs(const Graph& G, int v) {
  for (auto& xeach : xlist[v]) {
    temp += xeach;
  }

  seen[v] = true;
  for (auto& next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs(G, next_v);
  }

  counter[v] += temp;
  for (auto& xeach : xlist[v]) {
    temp -= xeach;
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n - 1), b(n - 1), p(q), x(q);
  rep(i, n - 1) { cin >> a[i] >> b[i]; }
  rep(i, q) { cin >> p[i] >> x[i]; }

  Graph G(n);
  rep(i, n - 1) {
    G[a[i] - 1].push_back(b[i] - 1);
    G[b[i] - 1].push_back(a[i] - 1);
  }
  vector<int> vec;
  xlist.assign(n, vec);
  rep(i, q) { xlist[p[i] - 1].push_back(x[i]); }
  counter.assign(n, 0);
  temp = 0;
  seen.assign(n, false);

  dfs(G, 0);

  rep(i, n) { cout << counter[i] << " "; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 40448
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::{Display, Formatter, Error};
use std::hash::{Hash, Hasher};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}

macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
#[derive(Clone)]
struct Hand {
    count: Vec<usize>
}
impl Hand {
    fn new(left: usize, right: usize) -> Hand {
        Hand{count: vec![left, right]}
    }
    fn added(&self, value: usize) -> Vec<Hand> {
        let mut result = Vec::with_capacity(self.count.len());
        for i in 0 .. self.count.len() {
            let mut next = self.count.clone();
            next[i] += value;
            result.push(Hand{count: next.into_iter().filter(|&x| x < 5).collect()});
        }
        result
    }
    fn is_lose(&self) -> bool {
        self.count.is_empty()
    }
    fn touch(&self, other: &Self) -> Vec<Hand> {
        self.count.iter().flat_map(|&x|other.added(x)).collect()
    }
}

fn isono_win(isono: &Hand, nakajima: &Hand) -> bool {
    isono.touch(&nakajima).iter().any(|n| n.is_lose() || n.touch(&isono).iter().all(|i| !i.is_lose() && isono_win(i, n)))
}
fn main() {
    let_all!(il: usize, ir: usize);
    let_all!(nl: usize, nr: usize);
    if isono_win(&Hand::new(il, ir), &Hand::new(nl, nr)) {
        println!("ISONO");
    }else {
        println!("NAKAJIMA");
    }
}


Measured memory_bytes: 5036