akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 1e5+50;

int k, p[N];
int c[N];
LL ans;
int n;
bool vis[N];

LL calc(const vector<int> &path, int lim) {
    LL ans = 0, res = 0;
    const int M = sz(path);
    for (int i=0; i<lim; ++i) {
        // dbg(i, path[i]);
        res += c[path[i % M]];
        ans = max(ans, res);
    }
    return ans;
}

void solve() {
    scanf("%d%d", &n, &k);

    int mv = -2e9;
    for (int i=1; i<=n; ++i) {
        scanf("%d", &p[i]);
    }
    for (int i=1; i<=n; ++i) {
        scanf("%d", &c[i]);
    }

    for (int i=1; i<=n; ++i) {
        mv = max(mv, c[p[i]]);
    }
    if (mv < 0) {
        printf("%d\n", mv);
        return;
    }
    LL Ans = 0;
    for (int i=1; i<=n; ++i) {
        int st = i;
        vector<int> path;
        while (!vis[st]) {
            vis[st] = 1;
            path.push_back(p[st]);
            st = p[st];
        }

        LL sum = 0, tim = k / sz(path);
        for (int x : path) {
            sum += c[x];
        }
        LL remain = k % sz(path);
        if (tim > 0) {
            --tim;
            remain += sz(path);
        }
        ans = max(0LL, sum * tim) + calc(path, remain);
        
        // dbg(i, Ans);
        Ans = max(Ans, ans);

        for (int x : path) {
            vis[x] = 0;
        }
    }
    printf("%lld\n", Ans);
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 3892
// AOJ 2769: 28
// 2018.1.6 bal4u@uu

#include <stdio.h>
#include <math.h>

#define HASHSIZ 1500019
typedef struct { long long p; char k; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int lookup(long long n)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->p) {
		if (p->p == n) return p->k;
		if (++p == hashend) p = hash;
	}
	return 0;
}

void insert(long long n, char k)
{
	HASH *p = hash + (int)(n % HASHSIZ);
	while (p->p) {
		if (p->p == n) { p->k = k+1; return; }
		if (++p == hashend) p = hash;
	}
	p->p = n, p->k = k+1;
}

int sz;
long long p[524300];		// 2^19
int ans;

long long special[20] = {
8, 88, 888, 8888, 88888, 888888, 8888888, 88888888, 222888288,
888888888, 8888888888LL, 88888888888LL, 888888888888LL, 8888888888888LL,
88888888888888LL, 888888888888888LL, 8888888888888888LL,
88888888888888888LL, 888888888888888888LL, 0};

//#define getchar_unlocked()  getchar()
long long in()
{
	long long n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(long long n, int i, int s)
{
	int k, a, b;
	long long m;

	if (n & 1) return 0;
	if ((k = lookup(n)) > 0) { if (s+k > ans) ans = s+k; return 1; }
	if (n ==  4) { if (s+2 > ans) ans = s+2; return 1; }
	if (n == 16) { if (s+4 > ans) ans = s+4; return 1; }
	if (n < 21) return 0;

	b = (int)sqrt((double)n);
	for ( ; p[i] <= b; i++) {
		if (!p[i] || (n % p[i])) continue;
		k = (int)p[i];
		m = n / k, a = 1;
		while (!(m % k)) m /= k, a++;
		if (m == 1) { if (s+a > ans) ans = s+a; return 1; }
		if (m < k) m *= k, a--;
		while (a >= 0) {
			if (calc(m, i+1, s+a)) return 1;
			m *= k, a--;
		}
	}
	return 0;
}

void init()
{
	int i, j, k, k2;
	long long t;

	sz = 3;
	p[1] = 2, p[2] = 8, insert(2, 0), insert(8, 0);
	k = 1; for (i = 2; i <= 19; i++) {
		k2 = k << 1;
		for (j = k; j < k2; j++) {
			t = p[j]*10;
			t += 2, p[sz++] = t, insert(t, 0);
			t += 6, p[sz++] = t, insert(t, 0);
		}
		k = k2;
	}
	for (i = 0; special[i]; i++) insert(special[i], 2);
	insert( 1767928088070144LL, 7);
	insert(12751787892400128LL, 4);
	p[2] = p[6] = p[14] = 0;
}

int main()
{
	int k;
	long long n;

	init();
	n = in();
	if (n & 1) { puts("-1"); return 0; }
	if ((k = lookup(n)) > 0) { printf("%d\n", k); return 0; }
	k = 0; while (!(n & 1)) n >>= 1, k++;
	while (k >= 0) {
		n <<= 1, k--;
		calc(n, 2, k);
		if (ans > 0) { printf("%d\n", ans); break; }
	}
	if (ans <= 0) puts("-1");
	return 0;
}



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

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p, ans = 0;
  //cin >> n;
  string A, B;
  cin >> A >> B;
  if(A.size() < B.size()){
    cout << "LESS";
  }else if(A.size() > B.size()){
    cout << "GREATER";
  }else{
    if(A < B){
      cout << "LESS";
    }else if(A > B){
      cout << "GREATER";
    }else{
      cout << "EQUAL";
    }
  }
  return 0;
}


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

using namespace std;

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int N, K;
	cin >> N >> K;

	long long ans = 0;
	if (K & 1)
	{
		int c = N / K;
		ans += (long long)c * c * c;
	}
	else
	{
		K >>= 1;
		for (int k = 0; k < 2; k++)
		{
			int c = (N + K * k) / K >> 1;
			ans += (long long)c * c * c;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n,m;cin >> n >> m;
    int k = pow(2,m);
    cout << 100*(n-m)*k+1900*m*k << endl;
    return 0;
}

Measured memory_bytes: 4076
#include <iostream>
#include <cmath>
#include <valarray>

using namespace std;

int main() {
    int n;
    cin >> n;
    int mx = 0;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
      int x = i;
      int cnt = 0;
      while (x % 2 == 0) {
        x /= 2;
        cnt++;
      }
      if (cnt > mx) {
        mx = cnt;
        ans = i;
      }
    }
    cout << ans;
    return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,t;
    cin>>n>>t;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    
    set<int> se;
    REP(i,0,n) se.insert(a[i]);
    
    int now=0,ans=0;
    REP(i,0,n){
        if(*se.rbegin()-a[i]>now){
            now=*se.rbegin()-a[i];
            ans=1;
        }else if(*se.rbegin()-a[i]==now) ans++;
        se.erase(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

int solve(const int a, const int b, const int h)
{
    return (a + b) * h / 2;
}
signed main(void)
{
    int a, b, h;
    std::cin >> a >> b >> h;
    std::cout << solve(a, b, h) << std::endl;
    return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const string YES = "Yes";
const string NO = "No";
void solve(std::string S) {

    set<char> s;
    for (auto c : S) s.insert(c);

    if (s.size() > 1) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define INFL (1LL << 62)

typedef long long ll;

using namespace std;

int main() {
    ll n, k;
    scanf("%lld%lld", &n, &k);
    vector<ll> h(n), dp(n, INFL);
    for (ll i = 0; i < n; ++i) scanf("%lld", h.begin() + i);
    dp.front() = 0;
    for (ll i = 1; i < n; ++i) for (ll j = 1; j <= min(k, i); ++j) dp.at(i) = min(dp.at(i), dp.at(i - j) + abs(h.at(i) - h.at(i - j)));
    printf("%lld\n", dp.back());
    return 0;
}


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

int main(void){
  int a,b,c,count1=0,count2=0;
  
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(c*c==a*a+b*b && (a!=b && b!=c))count1++;
    else if((a==b&&b!=c) || (a==b && b==c))count2++;
  }
  cout << count1 <<"\n"<< count2 << endl;
  
  return 0;
}

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

public class Main {
	
	public char[][] code = {{'a', 'f', 'k', 'p', 'u', 'z'}, {'b', 'g', 'l', 'q', 'v', '.'}, {'c', 'h', 'm', 'r', 'w', '?'},
						{'d', 'i', 'n', 's', 'x', '!'}, {'e', 'j', 'o', 't', 'y', ' '}};
	
	public boolean judge(String str){
		if( str.length() %2 != 0 ){
			return false;
		}
		for(int i = 0; i < str.length(); i += 2){
			if( str.charAt(i)-'0' > 6 || str.charAt(i)-'0' < 1 ){
				return false;
			}			
		}
		for(int i = 1; i < str.length(); i += 2){
			if( str.charAt(i)-'0' > 5 || str.charAt(i)-'0' < 1 ){
				return false;
			}
		}
		return true;
	}
	public void solve() throws IOException{
		while( stdIn.hasNext() ){
			String str = stdIn.next();
			if( !judge(str) ){
				writer.println("NA");
			} else {				
				for(int i = 0; i < str.length(); i += 2){
					int x = str.charAt(i)-'1';
					int y = str.charAt(i+1)-'1';
					writer.print(code[y][x]);
				}
				writer.println();
			}				
		}
		writer.flush();
	}
				
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
		
	Scanner stdIn;
	PrintWriter writer;
	
	public void run() throws IOException{
		stdIn = null;
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			writer = new PrintWriter(System.out);
			solve();
			stdIn.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}	
}

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

int main(){
    int A, B ,C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int sum = A*X + B*Y;
    for(int i = 0; i <= max(X, Y); i++){
        int sum1 = C*2*i;
        if((X-i) > 0){
            sum1 += A*(X-i);
        }
        if((Y-i) > 0){
            sum1 += B*(Y-i);
        }
        sum = min(sum, sum1);
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

struct Node{
	int key;
	Node *prev,*next;
};

//?????????????????¨??????????????????list???????£??????????????????????
Node *nil;

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->prev = nil;
	nil->next = nil;
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node *listSearch(int key){
	Node *cur = nil->next;
	while(cur != nil && key != cur->key){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t){
	if( t==nil ) return; //???????????????????????????
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void printList(){
	Node *cur = nil->next;
	while(cur != nil){
		if(cur != nil->next) printf(" ");
		printf("%d",cur->key);
		cur = cur->next;
	}
	printf("\n");
}

int main(){
	init();
	int n;
	scanf("%d",&n);
	
	while(n--){
		char command[10];
		scanf("%s",command);
		
		if(command[0] == 'i'){
			int key;
			scanf("%d",&key);
			insert(key);
		}else if(strlen(command)>6){
			if(command[6] == 'F') deleteFirst();
			else deleteLast();
		}else{
			int key;
			scanf("%d",&key);
			deleteKey(key);
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 32212
<?php
fscanf(STDIN, "%d", $w);
$maxSum = 0;
$nums1 = explode(" ", fgets(STDIN));
$nums2 = explode(" ", fgets(STDIN));
for($i = 0; $i < $w; $i++){
	$sum = 0;
	for($j = 0; $j < $w; $j++){
		if($j <= $i)$sum+=$nums1[$j];
		if($j >= $i)$sum+=$nums2[$j];
	}
	$maxSum = max($sum, $maxSum);
}
echo $maxSum;

Measured memory_bytes: 4728
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
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; }
int main(){
    int n; cin >> n;
    int a[n],b[n],c[n];
    int dp[n][3]={};
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        chmax(dp[i][0],max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]));
        chmax(dp[i][1],max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]));
        chmax(dp[i][2],max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]));
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n,cou=0;
	cin >> n;
	vector<int>vec(n),vec2(n);
	vecin(vec);
	vec2 = vec;
	sort(all(vec));
	rep(i, n) {
		if (vec[i] != vec2[i])cou++;
	}
	if (cou <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}



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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    ll n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll res = 0;
        rep(i,n){
            while(a[i] % 2 == 0){
                a[i]/=2;
                res++;
            }
        } 
    out(res);
}


Measured memory_bytes: 384
//#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 fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#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 = 5e5 + 11, 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;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
bool prime(int n) {
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[N];
int b[N];
int main() {
    ios;
    int n , m , q;
    cin >> n >> m >> q;
    int mna = 1e9 , mnb = 1e9;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        mna = min(mna , a[i]);
    }
    for(int i = 1; i <= m; i ++) {
        cin >> b[i];
        mnb = min(mnb , b[i]);
    }
    int mn = mna + mnb;

    while(q --) {
        int x , y , c;
        cin >> x >> y >> c;
        mn = min(mn , a[x] + b[y] - c);
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

struct P
{
  int to,cap,rev;
  P(int to=-1,int cap=-1,int rev=-1):to(to),cap(cap),rev(rev){}
};
typedef vector<int> VI;
typedef vector<P> VP;
typedef vector<VP> VVP;
typedef pair<int,int> Pes;
int N,M,s,t; 
VVP G;
vector<int> level,iter;
vector<Pes> vec;
vector<int> pvec;
bool sign;

void add_edge(int from,int to,int i)
{
  if(sign)vec.push_back(Pes(from,G[from].size())),
	    pvec.push_back(i);
  G[from].push_back(P(to,1,G[to].size()));
  G[to].push_back(P(from,0,G[from].size()-1));
}

void printVVP()
{
  cout << "printVVP----------" << endl;
  rep(i,G.size())
    {
      rep(j,G[i] .size())
	{
	  cout << "(" << G[i][j].to << "," << G[i][j].cap << "," << G[i][j].rev << ") ";
	}
      cout << endl;
    }
  cout << endl;
}

void bfs()
{
  deque<int> deq;
  deq.push_back(s);
  level[s] = 0;
  while(!deq.empty())
    {
      int p = deq.front(); deq.pop_front();
      rep(i,G[p].size())
	{
	  P pes = G[p][i];
	  int v = pes.to;
	  if(level[v] == -1 && pes.cap > 0)
	    {
	      level[v] = level[p]+1;
	      deq.push_back(v);
	    }
	}
    }
}

void printVI(VI &g)
{
  cout <<"printVI-------------" << endl;
  rep(i,g.size())
    {
      cout << g[i] << " ";
    }
  cout << endl;
}

int dfs(int v,int flow)
{
  if(v == t)return flow;

  for(int &i = iter[v];i < G[v].size();i++)
    {
      P p = G[v][i];

      if(p.cap <= 0)continue;
      if(level[v] < level[p.to])
	{
	  int d = dfs(p.to,min(flow,p.cap));
	  if(d <= 0)continue;
	  G[v][i].cap -= d;
	  G[p.to][p.rev].cap += d;
	  return d;
	    
	}
    }
  return 0;
}

int maximum_flow()
{
  int res = 0;
  iter.resize(N);
  level.resize(N);
  while(1)
    {
      rep(i,N)
	iter[i] = 0,level[i] = -1;
       bfs();
      
       if(level[t] < 0)return res;
       int f;
  
       while((f = dfs(s,(1<<29))) > 0)
	 res += f;
	 
    }
  return res;
}

int main()
{
  cin >> N >> M;
  G.resize(N);
  rep(i,M)
    {
      int from,to;
      cin >> from >> to;
      from--,to--;
      sign = false;
      add_edge(from,to,i);
      sign = true;
      add_edge(to,from,i);
    }
  cin >> s >> t;
  s--,t--;
  
  int mexico = maximum_flow();
  int cnt = 0;
  rep(i,vec.size())
    {
      int p1 = vec[i].first,p2= vec[i].second;
      if(G[p1][p2].cap != 1)cnt++;
    }

  cout << mexico << endl;
  cout << cnt << endl;
  rep(i,vec.size())
    {
      int p1 = vec[i].first,p2= vec[i].second;
      if(G[p1][p2].cap != 1)
	cout << pvec[i]+1 << endl;
    }

  return 0;
}

Measured memory_bytes: 1336
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll x,y,n;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(x=1;x<=3500;x++)
     for(y=1;y<=3500;y++)
      if(4*x*y-n*x-n*y>0 && !((n*x*y)%(4*x*y-n*x-n*y)))return cout<<x<<" "<<y<<" "<<(n*x*y)/(4*x*y-n*x-n*y)<<endl,0;
	  
} 

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[1] % I[0] == 0 ? I[0] + I[1] : I[1] - I[0]);
	}
}


Measured memory_bytes: 11348
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n;(n=s.nextInt())>0;){String x="";for(int t=n,i;t>0;t/=8){i=t%8;x=(i+=(i>4?2:i>3?1:0))+x;}System.out.println(x);}}}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,ans,m,x;
ll f[100005];
ll vis[100005];
ll pre[100005];
int main()
{
    for(int i=0;i<100003;i++) f[i] = -1;
    a = 1;
    ans=-1;
    scanf("%lld%lld%lld",&n,&x,&m);
    for(int i=1;i<=n;i++)
    {
        if(i==1) a = x%m;
        else a = a*a%m;
        if(vis[a]==0)
        {
            f[i] = a;
            vis[a] = i;
            pre[i] = f[i]+pre[i-1];
            //cout<<i<<" "<<f[i]<<endl;
        }
        else
        {
            //从vis[a]到i-1是一个循环节
            ll len = i-vis[a];
            ll yu = (n-i+1)%len;
            ans = pre[i-1]+(n-i+1)/len*(pre[i-1]-pre[vis[a]-1]) + pre[vis[a]+yu-1]-pre[vis[a]-1];
            break;
        }
    }
    if(ans==-1) ans = pre[n];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5624
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力

        //// スペース区切りの整数の入力
        int N = int.Parse(Console.ReadLine());
        int[] ai = new int[N];
        int count = 0;

        for (int i = 0; i < N; i++)
        {
            var read = int.Parse(Console.ReadLine());

            if (Array.IndexOf(ai,read) == -1)
            {
                ai[i] = read;
                count++;
            }
        }
        //出力
        Console.WriteLine(count.ToString());
    }
}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    if( A+B+C == 17 ){
        switch( A ){
        case 5:
            if( B == 5 ^ C == 5 ) ans = 1;
            break;
        case 7:
            if( B == 5 ) ans = 1;
            break;
        }
    }

    if( ans ) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = int.Parse(Console.ReadLine());
            List<int> inputBs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            List<int> comparisons = new List<int>(inputBs);
            inputBs.Add(int.MaxValue);
            comparisons.Insert(0, int.MaxValue);
            int expected = inputBs.Zip(comparisons, (b, c) => Math.Min(b, c)).Sum();

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


Measured memory_bytes: 13396
n = int(input())
c = []
ans = "No"
for _ in range(n):
    a, b = map(int, input().split())
    c.append(a==b)
for i in range(n-2):
    if c[i] and c[i+1] and c[i+2]:
        ans = "Yes"

print(ans)


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



int main(){
    int k; cin >> k;
    int sum = 0;
    for(int i  = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int t = 1; t <=k; t++){
                sum += __gcd(__gcd(i,j), t);
            }
        }
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int a[1000][1000];
int ss0[2005][2005];
int ss[2005][2005];

int main(int argc, char* argv[])
{
    int n,D;
    scanf("%d%d", &n, &D);

    int i,j;
    for(i=0; i<n; i++) {
        int x,y;
        scanf("%d%d", &x, &y);
        a[x%D][y%D]++;
    }

    int max=0;
    for(i=0; i<D; i++) {
        for(j=0; j<D; j++) {
            max=MAX(max,a[i][j]);
        }
    }
    double tmp=sqrt((double)max);
    int mm=(int)tmp;
    if(mm*mm<max) {
        mm++;
    }
    assert(mm*mm>=max);
    mm--;
    //printf("%d\n", mm);

    for(i=0; i<D; i++) {
        for(j=0; j<D; j++) {
            if(a[i][j]<=mm*mm) {
                a[i][j]=0;
            }
            else if(a[i][j]<=mm*(mm+1)) {
                a[i][j]=1;
            }
            else {
                assert(a[i][j]<=(mm+1)*(mm+1));
                a[i][j]=2;
            }
        }
    }

    for(i=0; i<D*2; i++) {
        for(j=0; j<D*2; j++) {
            ss0[i][j+1]=ss0[i][j]+a[i%D][j%D];
        }
    }
    for(j=0; j<=D*2; j++) {
        for(i=0; i<D*2; i++) {
            ss[i+1][j]=ss[i][j]+ss0[i][j];
        }
    }

    vector<int> max0(D*2),max1(D*2);
    for(i=0; i<D; i++) {
        for(j=0; j<D; j++) {
            max0[i]=MAX(max0[i],a[i][j]-1);
            max1[j]=MAX(max1[j],a[i][j]-1);
        }
    }
    for(i=0; i<D; i++) {
        max0[i+D]=max0[i];
        max1[i+D]=max1[i];
    }
    vector<int> smax0(D*2+1),smax1(D*2+1);
    for(i=0; i<D*2; i++) {
        smax0[i+1]=smax0[i]+max0[i];
        smax1[i+1]=smax1[i]+max1[i];
    }

    ll ans=LINF;
    for(i=0; i<D; i++) {
        for(j=0; j<D; j++) {
            int l=0, r=D;
            while(r-l>1) {
                int m=(l+r)/2;
                int tmp0=smax0[i+D]-smax0[i+m];
                int tmp1=smax1[j+D]-smax1[j+m];
                int tmp2=ss[i+D][j+D]-ss[i+m][j+D]-ss[i+D][j+m]+ss[i+m][j+m];
                if(tmp0==0 && tmp1==0 && tmp2==0) {
                    r=m;
                }
                else {
                    l=m;
                }
            }
            ans=MIN(ans,D*mm+l);
        }
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,p,q;
    cin>>n;
    if(n%1000==0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        p=n/1000;
        q=1000*(p+1);
        cout<<q-n<<endl;
    }
}


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

int sum(int ame) {
  if(ame==0) {
    return 0;
  }
  int s=sum(ame-1);
    return ame+s;
}
int main() {
  int children;
  cin >> children;
  cout << sum(children) << endl;
}

Measured memory_bytes: 3504
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

void solve() {
    int u,v;
    cin>>u>>v;
    if(u>v){
        cout<<"safe";
    }
    else cout<<"unsafe";
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MAX_LEN = 1000000;

int main()
{
    string s;
    cin >> s;
    int ls = s.length();
    int c[MAX_LEN][2];
    int s0 = s[0] - '0';
    c[0][0] = min(s0, 11 - s0);
    c[0][1] = min(s0 + 1, 10 - s0);
    repSE(i, 1, ls) {
        int si = s[i] - '0';
        c[i][0] = min(c[i-1][0] + si, c[i-1][1] + 10 - si);
        c[i][1] = min(c[i-1][0] + si + 1, c[i-1][1] + 9 - si);
    }
    cout << c[ls-1][0] << endl;
    return 0;
}


Measured memory_bytes: 9220
m=(""+require("fs").readFileSync(0)).split`
`;n=m[a=0];s=m[1];for(b=1<<n;b--;){u=0;for(i=n;i--;)u=b&(1<<i)?s[i]+u:u+s[i];m[u]=-~m[u]}for(b=1<<n;b--;){u=0;for(i=n;i--;)u=b&(1<<i)?s[2*n+~i]+u:u+s[2*n+~i];a+=~~m[u]}console.log(a)

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

int main() {
  int m;
  cin>>m;
  pair<int, int> conv[10];
  for (int i=1; i<10; i++) {
    conv[i].first = 0;
    int j;
    for (j=1; j<=10; j++) {
      if (i * j >= 10) {
        break;
      }
      ++conv[i].first;
    }
    conv[i].second = 1 + (i * j) % 10;
    ++conv[i].first;
  }
  long long ans = 0;
  vector<int> rest;
  for (int i=0; i<m; i++) {
    int d;
    long long c;
    cin>>d>>c;
    if (d == 0) {
      ans += c - 1;
      rest.push_back(0);
      continue;
    }
    while (c > 0) {
      long long cnt = c / conv[d].first;
      long long mod = c % conv[d].first;
      ans += cnt * conv[d].first;
      for (int j=0; j<mod; j++) {
        rest.push_back(d);
      }
      c = cnt;
      d = conv[d].second;
      if (d == 0) {
        ans += c - 1;
        rest.push_back(0);
        break;
      }
    }
  }
  if (rest.size() <= 1) {
    cout<<ans<<endl;
    return 0;
  }
  int i = 1;
  int sum = rest[0];
  for (int i=1; i < rest.size(); i++) {
    sum += rest[i];
    ++ans;
    if (sum >= 10) {
      sum = 1 + sum % 10;
      ++ans;
    }
  }
  cout<<ans<<endl;
}

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

ll n;

inline ll read() {
	ll s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read();
	printf("%lld\n", n * (n - 1) / 2);
	return 0;
}


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


int main(){
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A,B,C;
    vector<ll> total(3001, 0);
    vector<char> moji;
    
    //おいしさを配列に。
    rep(i,X){
        ll x;
        cin >> x;
        A.push_back(x);
    }
    
    rep(i,Y){
        ll x;
        cin >> x;
        B.push_back(x);
    }
    
    rep(i,Z){
        ll x;
        cin >> x;
        C.push_back(x);
    }
    
    //それぞれを大きい順にする
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    sort(B.begin(), B.end());
    reverse(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());
    
    
    //おいしさ合計列を作る
    rep(i,X){
        rep(j,Y){
            if((i+1)*(j+1) > K)break;
            rep(k,Z){
                if((i+1)*(j+1)*(k+1) > K) break;
                total.push_back(A[i]+B[j]+C[k]);
                //必要以上のサイズだったら小さい数を除去
                /*
                if( total.size() >= K+1 ){
                    sort(total.begin(), total.end());
                    reverse(total.begin(), total.end());
                    total.pop_back();
                }
                */
            }
        }
    }
    
    sort(total.begin(), total.end());
    reverse(total.begin(), total.end());
    
    for(int i=0; i<K; i++){
        cout << total[i] << endl;
    }
    
    /*
    for(ll x:C){
        cout << x << " ";
    }
    */
    
    
}


Measured memory_bytes: 1984
from collections import Counter
N = int(input())
S = input()
c = Counter(S)

ans = c["R"] * c["G"] * c["B"]
target = sorted("RGB")
# i間隔
for i in range(1, N):
    for j in range(N):
        s1,s2,s3 = j,j+i,j+i*2
        if s2 >= N or s3 >= N:
            continue
        t = S[s1] + S[s2] + S[s3]
        if sorted(t) == target:
            ans -= 1

print(ans)


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

int main(){
    int count=0, n,m;
    cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    cin >> m;
    vector<int> t(m);
    for(int i=0; i<m; i++) cin >> t[i];
    
    
    sort(s.begin(), s.end());
    int r,l,mid;
    for(int i=0;i<t.size(); i++){
        // r = s.size()-1;
        // l = 0;
        // while(l<=r){
        //     mid=floor((r+l)/2);
        //     if(s[mid] == t[i]){
        //         count++;
        //         break;
        //     }else if(s[mid]<t[i]){
        //         l=++mid;
        //     }else{
        //         r=--mid;
        //     }
            
        // }
        if(binary_search(s.begin(), s.end(), t[i])) count++;
        
    }
    
    cout << count << endl;
    
    return 0;
}


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

using namespace std;
static const int MAX = 200000;
int main() {
	

	int n;
	int R[MAX];
	cin >> n;
	for (int i = 0;i<n;i++) {
		cin >> R[i];
	}
	int maxv = -10000000000;
	int minv = R[0];
	for (int i = 1;i<n;i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;


	return 0;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n), y(m);
  for (auto&& w : x) cin >> w;
  for (auto&& w : y) cin >> w;
  int sx = 0, sy = 0;
  for (int i = 0; i < n; i++) {
    (sx += (((i) - (n - 1 - i)) * x[i] % mod)) %= mod;
    ;
  }
  for (int i = 0; i < m; i++) {
    (sy += (((i) - (m - 1 - i)) * y[i] % mod)) %= mod;
    ;
  }
  int ans = sx * sy % mod;
  cout << ans << endl;
}

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


int main(){
	string num;
	cin >> num;
	long long int sum = 0;
	for(auto i:num){
		sum += ((int)i) - 48;
	}

	if (sum %9 == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a * b) / 2 << endl;
}

Measured memory_bytes: 764
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
    char S[11];
    scanf("%s", S);
    REP(i, 3) cout << S[i];
    cout << 8;
    FOR(i, 4, 10) cout << S[i];
    cout << endl;
    return 0;
}


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin >> s;
    if (sz(s) >= 4 && s.substr(0, 4) == "YAKI")
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    string s;
    cin >> n >> m >> s;
    int _=0;
    n++;
    for(int i=0; i< n; i++){
        if(s[i]=='1') _++;
        else _ = 0;
        if(_==m){
            cout << -1;
            return 0;
        }
    }
    int pre[n+1], dp[n+1];
    for(int i=0; i<n; i++){
        int j= i;
        while(s[j]=='1') j++;
        for(int t=i; t<=j; t++)
            pre[t] = j;
        i=j;
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for(int i=1; i<=n; i++)
        if(s[i]=='0')
            dp[i] = 1+dp[pre[max(0, i-m)]];
    vector<int> res;
    for(int i=n-1; i>0;){
        int p=max(0, i-m);
        while(dp[p]==-1) p++;
        res.push_back(i-p);
        i=p;
    }
    for(int i=dp[n-1]-1; i>=0; i--)
        cout << res[i] << " ";
    return 0;
}


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

int main(){
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	for(int i = 0; i < tx - sx; ++i){
		cout << 'R';
	}
	for(int i = 0; i < ty - sy; ++i){
		cout << 'U';
	}
	for(int i = 0; i < tx - sx; ++i){
		cout << 'L';
	}
	for(int i = 0; i < ty - sy; ++i){
		cout << 'D';
	}
	cout << 'D';
	for(int i = 0; i <= tx - sx; ++i){
		cout << 'R';
	}
	for(int i = 0; i <= ty - sy; ++i){
		cout << 'U';
	}
	cout << 'L' << 'U';
	for(int i = 0; i <= tx - sx; ++i){
		cout << 'L';
	}
	for(int i = 0; i <= ty - sy; ++i){
		cout << 'D';
	}
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef int      ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
#define forr(i, b, e)    for (ll i = (ll)b; i < (ll)e; i++)
ll faster_in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9 + 7);
const lldb PI = acos(-1);
#define tam 320000
const ll MOD=1e9+7;

int main()
{    
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<' '<<y<<endl;
}
// PLUS ULTRA!

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
#define N 100500
#define mod 1000000007
multiset<int> tp;
int n,v[N],l[N],r[N],s[N],m,a;
struct node{int l,r,su;}e[N*4];
void pushup(int x){e[x].su=(e[x<<1].su+e[x<<1|1].su)%mod;}
void build(int x,int l,int r){e[x].l=l;e[x].r=r;if(l==r)return;int mid=(l+r)>>1;build(x<<1,l,mid);build(x<<1|1,mid+1,r);}
void add(int x,int s,int v){if(e[x].l==e[x].r){e[x].su=(e[x].su+v)%mod;return;}int mid=(e[x].l+e[x].r)>>1;if(mid>=s)add(x<<1,s,v);else add(x<<1|1,s,v);pushup(x);}
int que(int x,int l,int r){if(e[x].l==l&&e[x].r==r)return e[x].su;int mid=(e[x].l+e[x].r)>>1;if(mid>=r)return que(x<<1,l,r);else if(mid<l)return que(x<<1|1,l,r);return (que(x<<1,l,mid)+que(x<<1|1,mid+1,r))%mod;}
bool cmp(int i,int j){return l[i]==l[j]?r[i]>r[j]:l[i]<l[j];}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	tp.insert(-1e9-10);tp.insert(2e9+5);
	for(int i=1;i<=m;i++)scanf("%d",&a),tp.insert(a);
	for(int i=1;i<=n;i++)
	{
		multiset<int>::iterator it=tp.lower_bound(v[i]);
		r[i]=*it-v[i];it--;l[i]=v[i]-*it;s[i]=i;v[i]=r[i];
	}
	sort(s+1,s+n+1,cmp);sort(v+1,v+n+2);
	build(1,1,n+1);add(1,1,1);
	for(int i=1;i<=n;i++)
	if(l[s[i]]!=l[s[i-1]]||r[s[i]]!=r[s[i-1]])
	{
		int t=lower_bound(v+1,v+n+2,r[s[i]])-v;
		if(r[s[i]]>1e9||l[s[i]]>1e9)continue;
		add(1,t,que(1,1,t-1));
	}
	printf("%d\n",que(1,1,n+1));
}//

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

void solve()
{
    int n;
    cin>>n;
    vector<int> height(n);
    for(int i=0;i<n;i++)
        cin>>height[i];
    vector<int> v(n,0);
    v[1]=abs(height[1]-height[0]);
    for(int i=2;i<n;i++)
    {
        v[i]=min(abs(height[i]-height[i-1])+v[i-1],abs(height[i]-height[i-2])+v[i-2]);
    }
    // for(auto x:v)
    //     cout<<x<<" ";
    cout<<v[n-1];
}

int main()
{
//     int t;
//     cin>>t;
//     while(t--)
        solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    string result = "";
    
    int left = a + b;
    int right = c + d;
    if(left == right)
    {
        result = "Balanced";
    }
    else if(left > right)
    {
        result = "Left";
    }
    else
    {
        result = "Right";
    }
    
    cout << result << endl;
}


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

const int MAXN = 2005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int n, K;
int dp[MAXN][MAXN], maxdep[MAXN];
int c[MAXN];

void dfs(int nd, int f)
{
	maxdep[nd] = 1;
	for (register int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		dfs(to, nd);
	}
	memset(dp[nd], -127/3, sizeof dp[nd]);
	dp[nd][0] = 0, dp[nd][1] = 1;
	for (register int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		memcpy(c, dp[nd], sizeof dp[nd]);
		for (register int j = 1; j <= maxdep[nd]; j++)
			for (register int k = 0; k <= maxdep[to]; k++)
				if (j+k-1 <= K)
					c[max(j, k+1)] = max(c[max(j, k+1)], dp[nd][j]+dp[to][k]);
		memcpy(dp[nd], c, sizeof c);
		maxdep[nd] = max(maxdep[nd], maxdep[to]+1);
	}
}

int main()
{
	scanf("%d%d", &n, &K);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		push(u, v), push(v, u);
	}
	dfs(1, 0);
	int ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= maxdep[i]; j++)
			ans = max(ans, dp[i][j]);
	cout << n-ans << endl;
	return 0;
}


Measured memory_bytes: 16128