akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 = 1001001001;

int main() {
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << w*h/2 << " ";
    if(x == w/2 && y == h/2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,K;


int main()
{
  string S;
  cin >> S;
  int k = S.size();
  int a = 0;
  REP(i,0,k){
    if(S[i]=='o'){
      a++;
    }
  }
  if(a>=8||15-k+a>=8){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

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

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<pair<int, int>> CB(M);
    REP(i, M) cin >> CB[i].second >> CB[i].first;

    SORT(A);
    RSORT(CB);
    vector<ll> diff(M);
    diff[0] = CB[0].second;
    FOR(i, 1, M) { diff[i] = diff[i - 1] + CB[i].second; }
    int now = 0;
    REP(i, N) {
        if (A[i] < CB[now].first) {
            A[i] = CB[now].first;
            CB[now].second--;
            if (CB[now].second == 0)
                now++;
            if (now == M && CB[i].second == 0)
                break;
        } else {
            break;
        }
    }

    ll ans = 0;
    REP(i, N) { ans += A[i]; }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout <<"Yes\n";
        exit(0);
    }
    cout <<"No\n";
}


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

long long n, m;
vector<long long> res;
vector<vector<long long>> g;

bool solve();

int main() {
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  if (solve()) {
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) cout << res[i] + 1 << endl;
  } else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  res.resize(n);
  queue<int> qu;
  vector<long long> dist(n, 100000000);
  qu.push(0);
  dist[0] = 0;
  while (qu.size()) {
    int now = qu.front();
    qu.pop();
    for (auto to : g[now])
      if (dist[now] + 1 < dist[to]) {
        dist[to] = dist[now] + 1;
        qu.push(to);
        res[to] = now;
      }
  }
  return 1;
}

Measured memory_bytes: 13472
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	puts((n-1+k)/k - n/k)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i,t,now;
	scanf("%d", &n);
	int ans = n;
	for (i=0; i<=n; i++){
		now=0;
		t=i;
		while(t>0){now+=t%6 , t/=6;}
		t=n-i;
		while(t>0){now+=t%9 , t/=9;}
		if(ans>now) ans=now ;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)



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

  	vector<int> x(m);
	rep(i, m) cin >> x[i];
	sort(x.begin(), x.end());
  
  	vector<int> y(m-1);
	rep(i, m-1){
		y[i] = x[i+1] - x[i];
	}
	sort(y.begin(), y.end());
  	
  	
  	long long j = 0;
	rep(i, m-n){
		j += y[i];
	}
	cout << j << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
using namespace std;
char a[100005];
int b[100005],n,i,sol[100005],nr;
int main()
{
    cin>>a+1;
    n=strlen(a+1);
    b[1]=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]==a[i-1]&&a[i]=='R')
            b[i]=b[i-1]+1;
        if(a[i]!=a[i-1]&&a[i]=='R')
            b[i]=1;
    }
    b[n]=1;
    for(i=n-1;i>=1;i--)
    {
        if(a[i]==a[i+1]&&a[i]=='L')
            b[i]=b[i+1]+1;
        if(a[i]!=a[i+1]&&a[i]=='L')
            b[i]=1;
    }
    for(i=2;i<=n;i++)
    {
        if(a[i]=='L'&&a[i-1]=='R')
        {nr=1+b[i-1]/2+b[i+1]/2;
        sol[i]=nr;
        sol[i-1]=b[i]+b[i-1]-nr;}
    }
    for(i=1;i<=n;i++)
        cout<<sol[i]<<' ';
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    int n,a;
    cin >>n>>a;
  
  cout<<(n+a+1)/2<<endl;
    

   
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005

int main(){
    int n;
    scanf("%d",&n);
    int tot=0;
    for(int i = 0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(x&1)tot++;
    }
    if(tot&1)printf("NO\n");
    else printf("YES\n");
}

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

using namespace std;

int main() {
  array<set<int>, 26> letters;
  int n, q, t, x, y;
  cin >> n;
  char c, s[n];
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    letters[s[i] - 'a'].insert(i);
  }
  cin >> q;
  while (q--) {
    cin >> t >> x;
    if (t == 1) {
      // x index, c char
      cin >> c;
      if (s[x-1] == c) continue;
      letters[s[x-1] - 'a'].erase(x-1);
      letters[c - 'a'].insert(x-1);
      s[x-1] = c;
    } else {
      cin >> y; // x:left, y: right
      int ans(0);
      for (int i = 0; i < 26; ++i) {
        auto it = letters[i].lower_bound(x-1);
        if (it != letters[i].end() && *it < y) ans++;
      }
      cout << ans << '\n';
    }
  } 
  
  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

string text;
int pos;

string String();
string Cipher();

string Letter(){
  int coef = 0;
  while( text[pos] == '+' || text[pos] == '-' ) { 
    coef += ((text[pos]=='+')?1:-1);
    ++pos;
  }
  if( 'A' <= text[pos] &&  text[pos] <= 'Z' ) {
    int value = ( text[pos] - 'A' + coef ) % 26;
    while( value < 0 ) value += 26;
    ++pos;
    return string(1,(char)( 'A' + value));
  } else {
    ++pos;
    return "?";
  }
}

string String(){
  string ret = "";
  if( text[pos] == '[' ) {
    ++pos;
    ret = Cipher();
    ++pos;
    reverse(ret.begin(),ret.end());
  } else {
    ret = Letter();
  }
  return ret;
}

string Cipher(){
  string ret = "";
  while( pos < text.size() && ( text[pos] == '[' || text[pos] == '+' || text[pos] == '-' || text[pos] == '?' || isalpha(text[pos]) ) ) ret += String();
  return ret;
}

int main(){
  while( cin >> text, text[0] != '.' ){
    pos = 0;
    string s = Cipher();
    rep(i,s.size()) if( s[i] == '?' ) s[i] = 'A';
    cout << s << endl;
  }
  return 0;
}

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

int main(){
    int A, P;
    cin >> A >> P;

    int pie = 0;
    P = P + 3*A;
    pie = P / 2;

    cout << pie << endl;
}

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

#include <math.h>
#include <stdlib.h>


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


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    bool ans = true;
    for(int i= 0;i < n-1; i++){
        if(a[i] == a[i+1]) ans=false;
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#k, = map(int,read().split())

def make(k):
    if k==0:
        print(1)
        print(0)
        exit()
    
    k -= 1
    n = 50
    q = k//n
    r = k%n
    
    a = [(2*n-1)+q]*n
    for i in range(r):
        for j in range(n):
            if i==j: a[j] += n
            else: a[j] -= 1
        
    print(n)
    print(*a)


def judge(n,a):
    if max(a) < n:
        return 0
    
    ans = 0
    for i in range(n):
        if a[i] > 3*n:
            d = (a[i]-3*n)//(n+1)
            ans += d
            a[i] -= d*(n+1)
    
    #print(ans)
    if ans >= 2*n:
        ans += n*ans    
    else:
        for i in range(n):
            a[i] += ans

    #print(ans,a)
    #return
    
    while True:
        if max(a) < n:
            return ans
        
        idx = max(range(n),key=lambda i:a[i])
        for j in range(n):
            a[j] += 1
        a[idx] -= n+1
        ans += 1
        #print(idx,a)


n,*a = map(int,read().split())

print(judge(n,a))






Measured memory_bytes: 9188
#include <iostream>

int main() {
    int count = 0, n;
    std::string s;
    std::cin >> s;
    n = s.size();

    for (int i=0; i<n; ++i) {
        int m = n-1-i;
        if (i > m) break;
        if (s[i] != s[m]) ++count;
    }
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#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, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i + 1 < S.length(); i++) if (S[i] != S[i + 1]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 512
count = 0
N,M,X,Y = list(map(int,input().split(' ')))
XL = list(map(int,input().split(' ')))
YL = list(map(int,input().split(' ')))
 
for z in range(X+1,Y+1):
  if z>max(X,max(XL)) and z<=min(Y,min(YL)):
    count += 1 

if count>0:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
 
void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}
 
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    ll c=1+n%2,ans=1;
    for (ll i=n%2;i<n;i+=2){
        if (a[i]==c and a[i+1]==c){
            c+=2;
            ans*=2;
            ans%=1000000007;
            continue;
        }
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long


int32_t main() {
	_ __

#ifdef LOCAL_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, x, m;
	cin >> n >> x >> m;
	int i = 0;
	int sum = 0;
	int init = x;
	int over[m] = {0};
	vector<int> p;
	x %= m;
	while (over[x] == 0 && i < n) {
		p.push_back(x);
		over[x] = 1;
		sum += x;
		x *= x;
		x %= m;
		if (x == 0) {
			cout << sum << "\n";
			return 0;
		}
		i++;
	}
	if (p.size() > 0) {
		reverse(p.begin(), p.end());
		while (p.size() > 0 && p.back() != x) {
			p.pop_back();
		}
		reverse(p.begin(), p.end());
	}
	int temp = 0;
	for (int i = 0; i < (int)p.size(); i++) {
		temp += p[i];
	}
	if (p.size() > 0)
		init = p[0];
	if (i < n) {
		int left = n - i;
		int done = p.size();
		int xx = left / done;
		int rem = left % done;
		sum += xx * temp;
		while (rem--) {
			sum += init;
			init *= init;
			init %= m;
		}
	}
	cout << sum << "\n";




#ifdef LOCAL_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s;
  } else {
    cout << "red";
  }
}

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

vector<ll> divisor(ll n) {
  vector< ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end(), greater<ll>());
  return (ret);
}

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

    vector<ll> div = divisor(M);

    for(ll e : div){
        if(e * N <= M){
            cout << e << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a, b, c, d, q;
	cin >> a >> b;
	cin >> c >> d;
	cin >> q;
	if(a==c){
		cout << "YES\n";
	}
	else if(a<c){
		a+=b*q;
		c+=d*q;
		if(a>=c){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}
	else{
		a-=b*q;
		c-=d*q;
		if(a<=c){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3648
#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; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc159/tasks/abc159_c>
 問題文============================================================
 C - Maximum Volume
 =================================================================
 解説=============================================================
 
 直感的に縦・横・高さに均等に長さを割り振れば最大になることが予想される。
 よって、(L/3)^3が答え
 縦・横・高さの長さをそれぞれ x,y,z
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    double L; cin >> L;
    res = pow(L/3,3);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())

if n % 2 == 0:
    # n//2の階乗の0の個数
    k = n//2
    cnt = 0
    d = 5
    while True:
        
        cnt += k // d
        if k // d  == 0:
            break
        d *= 5
        
    print(cnt)
    sys.exit()

else:
    k = n //2  + 1 
    
    
    t1 = 0
    t2 = k
    d = 2
    while True:
        t1 += 2*k // d
        if 2*k //d == 0:
            break
        #print(d)
        d *= 2
    
    d = 2
    while True:
        t2 += k // d
        if k //d == 0:
            break
        d *= 2
    
    if t1 == t2:
        print(0)
        sys.exit()
    print(t1, t2)

    

    a = 0
    b = 0
    d = 5
    
    while True:
        
        a += k // d
        if k // d  == 0:
            break
        d *= 5

    d = 5
    while True:
        b += 2*k // d
        if 2*k // d == 0:
            break
        d *= 5
    


    print(b-a)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {


            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var a = line[0];
            var b = line[1];

            var ans = new List<int>{ a + b, a - b, a * b }.OrderByDescending(x => x).First();

            Console.WriteLine(ans);

        }

    }


}


Measured memory_bytes: 11348
import java.io.*;
import java.util.Scanner;

class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        int a = ReadInt();
        int b = ReadInt();
        int c = ReadInt();
        if( a < b && b < c ) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
    static int ReadInt() throws IOException {
        return Integer.parseInt(sc.next());
    }
}

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

int main() {
    int N;
    cin >> N;
    int i;
    for (i = 1000; i < N; i += 1000) {
    }
    cout << i - N << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string ans = "YES";
	vector<int> a(n);
	vector<bool> flag(1000000001);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		flag[i] = false;
	}
	for(int i=0; i<n; i++){
		if(flag[a[i]]){
			ans = "NO";
		}else{
			flag[a[i]] = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 123136
#include<stdio.h>
main(){
  int n,a,b,i,aa=0,bb=0;
  while(1){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      if(a<b){
	bb+=(a+b);
      }
      else if(a>b){
	aa+=(a+b);
      }
      else{
	aa+=a;
	bb+=a;
      }
    }
    printf("%d %d\n",aa,bb);
    aa=bb=0;
  }
  return 0;
}

Measured memory_bytes: 600
N,L = map(int, input().split())

L_list = [] * N

for i in range(1,N+1):
    L_list.append(L + i - 1)

tmp = float('inf')
ans = 0
for i in range(N):
    diff = sum(L_list) - L_list[i]
    if tmp > abs(sum(L_list) - diff):
        tmp = abs(sum(L_list) - diff)
        ans = diff

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  string S;
  int K,a;
  cin>>S>>K;
  for(int i=0;i<S.size();i++){
    if(S[i]!='1'){
      a=i;
      break;
    }
  }
  if(a>=K) cout<<"1"<<endl;
  else cout<<S[a]<<endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = list(input())
s.reverse()
for i in range(m):
    s.append("1")
p = 0
ans = []
while p < n:
    p += m
    cnt = m
    while s[p] == "1":
        p -= 1
        cnt -= 1
        if cnt == 0:
            print(-1)
            exit()
    ans.append(cnt)
ans.reverse()
print(*ans)





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

int main(){
    int N,A;
    cin>>N;
    
    vector<vector<pair<int,int>>> data;
    data.resize(N);
    rep(i,N){
        cin>>A;
        data[i].resize(A);
        rep(j,A){
            cin>>data[i][j].first>>data[i][j].second;
            data[i][j].first--;
        }
    }
    
    int ans = 0;
    for (int bit = 1; bit < (1<<N); bit++){
        int cnt = 0;
        bool ok = true;
        rep(i,N){
            if (!((bit >> i) & 1)) continue;
            cnt++;
            for (auto xy:data[i]){
                int x=xy.first;
                int y=xy.second;
                
                
                if (((bit >> x) & 1) != y){
                    ok=false;
                    break;
                }
            }
        }
        if(ok) ans=max(ans,cnt);
    }
    cout<<ans<<endl;   
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	rep(i, N) {
		cin >> x[i];
	}
	ll ans = LLONG_MAX;
	for (int i = 0; i + K - 1 < N; i++) {
		ll a = x[i], b = x[i + K - 1];
		if (a <= 0 && 0 <= b) {
			ans = min({ ans,(-a) * 2 + b,(-a) + b * 2 });
		}
		else {
			ans = min(ans, max(abs(a), abs(b)));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD = 1000000007;


     signed main(){
   int n;
   cin>>n;
   int x[n],y[n],p[n];
   for(int i=0;i<n;i++){
       cin>>x[i]>>y[i]>>p[i];
   }
   int a[1ll<<n][n],b[1ll<<n][n];
   pair<int,int> pax[n],pay[n];
       for(int i=0;i<n;i++){
           pax[i]={x[i],i};
           pay[i]={y[i],i};
       }
       sort(pax,pax+n);sort(pay,pay+n);
       for(int i=0;i<(1ll<<n);i++){
           for(int j=0;j<n;j++)a[i][j]=abs(x[j]);
           for(int j=0;j<n;j++)b[i][j]=abs(y[j]);
           int t=MOD*MOD;
           for(int j=0;j<n;j++){
               if(i&(1ll<<pax[j].second))t=pax[j].first;
               a[i][pax[j].second]=min(a[i][pax[j].second],abs(x[pax[j].second]-t));
 
           }
           t=MOD*MOD;
           for(int j=n-1;j>=0;j--){
               if(i&(1ll<<pax[j].second))t=pax[j].first;
               a[i][pax[j].second]=min(a[i][pax[j].second],abs(x[pax[j].second]-t));

           }
            t=MOD*MOD;
          for(int j=0;j<n;j++){
               if(i&(1ll<<pay[j].second))t=pay[j].first;
               b[i][pay[j].second]=min(b[i][pay[j].second],abs(y[pay[j].second]-t));

           }
            t=MOD*MOD;
           for(int j=n-1;j>=0;j--){
               if(i&(1ll<<pay[j].second))t=pay[j].first;
               b[i][pay[j].second]=min(b[i][pay[j].second],abs(y[pay[j].second]-t));

           }
             for(int j=0;j<n;j++){a[i][j]*=p[j];}
           for(int j=0;j<n;j++)b[i][j]*=p[j];
       }
    int ans[n+1];
    for(int i=0;i<n+1;i++)ans[i]=MOD*MOD;
    for(int i=0;i<(1ll<<n);i++)for(int j=0;j<(1ll<<n);j++){
        if(i&j)continue;
        int m=0,mm=0;
        for(int k=0;k<n;k++){
            m+=min(a[i][k],b[j][k]);
            if((1ll<<k)&(i|j))mm++;
        }
        //cerr<<m<<' '<<mm<<endl;
        ans[mm]=min(ans[mm],m);
      
    }
    
    for(int i=0;i<=n;i++)cout<<ans[i]<<endl;
   
  

     }


 


 






    





      

        


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		int res = 0; ;
		int n = int.Parse(Console.ReadLine());
		string val = Console.ReadLine();



		for ( int i = 1; i < n; i++ ) {
			int[] c = new int[26];
			int[] d = new int[26];

			for ( int k = 0; k < n; k++ ) {
				if ( k < i ) {
					c[val[k] - 'a'] = 1;
				} else {
					d[val[k] - 'a'] = 1;				
				}
			}
			int cnt=0;
			for ( int w = 0; w < 26; w++ ) {
				if ( c[w] == 1 && d[w] == 1 ) {
					cnt++;
				}
			}
			res = Math.Max(res, cnt);
		}

			//deug
			Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

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

    long long r_a = a / x;
    long long r_b = b / x;

    if(a % x == 0){
        cout << r_b - r_a + 1;
    }
    else{
        cout << r_b - r_a;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();

			int min = Integer.MAX_VALUE;
			int max = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				if (a < min) {
					min = a;
				}
				if (max < a) {
					max = a;
				}
			}
			System.out.println(max - min);
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<8;i++)
	{
		int sum=(int)(s[0]-'0');
		for(int j=0;j<3;j++)
		{
			if(i&(1<<j))
			{
				sum+=(int)(s[j+1]-'0');
			}
			else
			{
				sum-=(int)(s[j+1]-'0');
			}
		}
		if(sum==7)
		{
			cout<<s[0];
			for(int j=0;j<3;j++)
			{
				if(i&(1<<j))
				{
					cout<<"+";
				}
				else
				{
					cout<<"-";
				}
				cout<<s[j+1];
			}
			cout<<"=7"<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x,i,c1=0,c2=0,j;
	int s[100];
	cin>>n>>m>>x;
	for(i=0; i<m; i++)
		scanf("%d",&s[i]);
	if(n>=1&&n<=100&&m>=1&&m<=100&&x>=1&&x<=n-1)
	{
		for(j=x-1; j>0; j--)
		{
			for(i=0; i<m; i++)
				if(j==s[i])
				c1++;
		}
		for(j=x+1; j<n; j++)
		{
			for(i=0; i<m; i++)
				if(j==s[i])
				c2++;
		}
		if(c1<c2)
			printf("%d\n",c1);
		else
			printf("%d\n",c2);
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        try(Scanner scan=new Scanner(System.in)){
            while(true){
                int a=scan.nextInt();
                String op=scan.next();
                int b=scan.nextInt();
                int answer;
                switch(op){
                    case "+":
                        answer=a+b;
                        break;
                    case "-":
                        answer=a-b;
                        break;
                    case "*":
                        answer=a*b;
                        break;
                    case "/":
                        answer=a/b;
                        break;
                    default:
                        return;
                }
                System.out.println(answer);
            }
            
        }
    }
}


Measured memory_bytes: 26276
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    if (a == b)
        cout << 2*a << endl;
    else
    {
        if (a > b)
            cout << 2*a-1 << endl;
        else
            cout << 2*b-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pc __builtin_popcountll

using namespace std;
vector<int> l;
int n, k;
    
bool possible(int val){
    if(val == 0)  return false;
    int req = 0;
    for(int i = 0; i < n; ++i){
        if(l[i] <= val) continue;
        req += (l[i] / val) + (l[i] % val != 0) - 1;
    }
    return (req <= k);
}

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    l = vector<int> (n);
    int max_val = 0;

    for(int i = 0; i < n; ++i){
        cin >> l[i];
        max_val = max(max_val, l[i]);
    }   
    int start = 1, end = max_val;
    while(start <= end){
        int mid = (start + end) / 2;
        bool pos_mid = possible(mid);
        if(pos_mid && !possible(mid - 1)){
            cout << mid << "\n";
            return 0;
        }else if(pos_mid){
            end = mid - 1;
        }else{
            start = mid + 1;
        }
    }

    assert(false);
    return 0;
}

Measured memory_bytes: 3952
#include <stdio.h>
#include <string.h>

int main(void){
	char str[1000];
	int i,j,k;

	while (scanf("%s", str) != EOF){
		for (i = 0; i < strlen(str); i++){
			if (str[i] == '@'){
				i++;
				k = str[i] - '0';
				i++;
				for (j = 0; j < k; j++){
					printf("%c", str[i]);
				}
			}
			else printf("%c", str[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift()
A = inp.shift().split(' ').map(x => x - 0)
min = Math.pow(10, 9)
max = 1
for (i=0; i<N; i++) {
    if (A[i] > max) {
        max = A[i]
    }
    if (A[i] < min) {
        min = A[i]
    }
}
console.log(max - min)

Measured memory_bytes: 7372
#include <iostream>
#include <numeric>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using ll = long long;

int main() {
  int n;
  ll min = 1000001, max = -1000001, sum;
  std::vector<ll> a;

  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    min = std::min(min, a[i]);
    max = std::max(max, a[i]);
  }

  sum = std::accumulate(a.begin(), a.end(), 0LL);

  cout << min << " " << max << " " << sum << endl;

  return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      ++cnt;
    } else
      cnt = 0;
    if (cnt == 3) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int x[200000], y[200000];
signed main() {
	int a, b, c, ans = INF, vx = INF, vy = INF;
	cin >> a >> b >> c;
	f(i, a) {
		cin >> x[i];
		vx = min(vx, x[i]);
	}
	f(i, b) {
		cin >> y[i];
		vy = min(vy, y[i]);
	}
	ans = vx + vy;
	f(i, c) {
		int va, vb, vc;
		cin >> va >> vb >> vc;
		ans = min(ans, x[va - 1] + y[vb - 1] - vc);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
    #define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

int a[51] , b[51] , c[51] , d[51];
int A[51];
int n , m , q;

ll mx = 0;

void rec(int v = 1) {
    if(v == n+1) {
        ll cur = 0;
        for(int i = 1; i <= q; i ++) {
            if(A[b[i]] - A[a[i]] == c[i])
                cur += d[i];
        }
        chmax(mx , cur);
        return;
    }
    for(int i = A[v-1]; i <= m; i ++) {
        A[v] = i;
        rec(v+1);
    }
}

void solve() {
    A[0] = 1;
    cin >> n >> m >> q;
    for(int i = 1; i <= q; i ++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    rec();
    cout << mx;
}
/*
4 3
RLRL

*/

main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*
++>
+++>
<[<+>-]<
++++++++++++++++++++++++++++++++++++++++++++++++.

500000000000000000000000000000000000000000000000

1 1 2 3 6


*/


Measured memory_bytes: 3704
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			for (int i = 0; i < str.length(); i++) {
				if (str.charAt(i) == 'L' && i % 2 == 0) {
					System.out.println("No");
					return;
				}
				if (str.charAt(i) == 'R' && i % 2 == 1) {
					System.out.println("No");
					return;
				}
			}
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 23636
"""メモリ足りねぇ..."""

import sys
pin=sys.stdin.readline

INF=10**10
N,W=map(int,pin().split())

dp=[[INF]*100001 for _ in [0]*(N+1)]
dp[0][0]=0
for i in range(1,N+1):
  w,v=pin().split()
  w=int(w)
  v=int(v)
  for j in range(100001):
    if j-v>=0:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v]+w)
    else:
      dp[i][j]=dp[i-1][j]
ans=100000
while dp[N][ans]>W:
  ans-=1
print(ans)
#解説AC

Measured memory_bytes: 147632
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static PrintWriter out = new PrintWriter(System.out);

    void solve() {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (Math.abs(a - b) % 2 == 1) {
            out.println("IMPOSSIBLE");
        } else {
            out.println(Math.abs(a - b) / 2 + Math.min(a, b));
        }
    }

    public static void main(String[]$) {
        new Main().solve();
        out.close();
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

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

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

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

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

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 ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N;
  cin>>N;
  map<ll,ll> m;
  for(ll i = 2LL; i*i<=N; i++){
    while(N%i==0LL){
      N/=i;
      m[i]++;
    }
  }
  if(N!=1LL) m[N]++;
  ll ans = 0LL;
  for(auto x:m){
    ll cnt = 0LL;
    while(cnt*(cnt+1LL)<=2*x.second) cnt++;
    cnt--;
    ans+=cnt;
  }
  cout<<ans<<endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> w(n+1);
    vector<int> sum_w(n+1,0);
    REP(i,n){
        cin>>w[i];
        sum_w[i]=sum_w[i-1]+w[i];
    }
    int ans = 1e9+7;
    REP(i,n-1){
        ans = min(abs(sum_w[n]-2*sum_w[i]),ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int n, x, i=0; 
	cin >> n;

	for (int i = 1; i <= n; i++){
		x = i;
		if (x % 3 == 0){
			cout << " " << i;
			continue;
		}
		while (x){
			if (x % 10 == 3){
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1160
/**
*    created: 06.05.2020 02:03:29
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=1;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    cin >> n;
    int ans = 1;
    int x,z=0;
    rep(i,n+1){
        x = i;
        int y = 0;
        while(x%2==0){
            x /= 2;
            y++;
        }
        if(y>z){
            z = y;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split(' ').map {|i| i.to_i}
w = []

total = a.inject(:+)
half = 0
a.each.with_index(1) do |_a, i|
  if i % 2 == 0
    half += _a * 2
  end
end

w << total - half

0.upto(n-2) do |i|
  w << 2 * a[i] - w[i]
end

puts w.join(' ')

Measured memory_bytes: 14084
def main():
    N = int(input())
    a = list(map(int, input().split()))
    ave_a = sum(a)/len(a)

    best_diff = abs(a[0] - ave_a)
    best_i = 0
    for i, aa in enumerate(a):
        diff = abs(ave_a - aa)
        if diff < best_diff:
            best_i = i
            best_diff = diff

    print(best_i)

main()


Measured memory_bytes: 3060